Reader for binary files.
More...
#include <BinaryReader.h>
|
| BinaryReader (std::vector< unsigned char > &&data) |
| Constructor. More...
|
|
size_t | GetSize () const |
| Retrieves the size of the data in the reader. More...
|
|
void | Seek (unsigned int position) |
| Moves the stream cursor. More...
|
|
unsigned int | GetPosition () |
| Retrieves the current stream cursor position. More...
|
|
unsigned int | ReadU32 () |
| Reads 32 bits of data as an unsigned integer. More...
|
|
signed int | ReadS32 () |
| Reads 32 bits of data as a signed integer. More...
|
|
signed short int | ReadS16 () |
| Reads 16 bits of data as an unsigned integer. More...
|
|
unsigned short int | ReadU16 () |
| Reads 16 bits of data as a signed integer. More...
|
|
unsigned char | ReadU8 () |
| Reads 8 bits of data as an unsigned integer. More...
|
|
signed char | ReadS8 () |
| Reads 8 bits of data as a signed integer. More...
|
|
|
static std::vector< unsigned char > | ReadAll (std::string file_name) |
| Reads a file, from start to end. More...
|
|
◆ BinaryReader()
BinaryReader::BinaryReader |
( |
std::vector< unsigned char > && |
data | ) |
|
|
inline |
Constructor.
- Parameters
-
[in] | data | Bytes for the reader |
◆ GetPosition()
unsigned int BinaryReader::GetPosition |
( |
| ) |
|
|
inline |
Retrieves the current stream cursor position.
- Returns
- position[in] Position (offset) of the cursor.
◆ GetSize()
size_t BinaryReader::GetSize |
( |
| ) |
const |
|
inline |
Retrieves the size of the data in the reader.
- Returns
- The size of the data in bytes.
◆ InternalRead()
template<class T >
T BinaryReader::InternalRead |
( |
| ) |
|
|
inlineprivate |
Reads T bits of data as a signed integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadAll()
static std::vector< unsigned char > BinaryReader::ReadAll |
( |
std::string |
file_name | ) |
|
|
inlinestatic |
Reads a file, from start to end.
- Parameters
-
[in] | file_name | Path and name of the file to read. |
- Returns
- Read bytes.
- Exceptions
-
std::runtime_error | if the file can't be opened for reading. |
◆ ReadS16()
signed short int BinaryReader::ReadS16 |
( |
| ) |
|
|
inline |
Reads 16 bits of data as an unsigned integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadS32()
signed int BinaryReader::ReadS32 |
( |
| ) |
|
|
inline |
Reads 32 bits of data as a signed integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadS8()
signed char BinaryReader::ReadS8 |
( |
| ) |
|
|
inline |
Reads 8 bits of data as a signed integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadU16()
unsigned short int BinaryReader::ReadU16 |
( |
| ) |
|
|
inline |
Reads 16 bits of data as a signed integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadU32()
unsigned int BinaryReader::ReadU32 |
( |
| ) |
|
|
inline |
Reads 32 bits of data as an unsigned integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ ReadU8()
unsigned char BinaryReader::ReadU8 |
( |
| ) |
|
|
inline |
Reads 8 bits of data as an unsigned integer.
It advances the stream cursor.
- Returns
- Read bits.
- Exceptions
-
◆ Seek()
void BinaryReader::Seek |
( |
unsigned int |
position | ) |
|
|
inline |
Moves the stream cursor.
- Parameters
-
[in] | position | Position (offset) of the cursor. |
- Exceptions
-
◆ size_
size_t BinaryReader::size_ = 0 |
|
private |
The size of the data, in bytes.
◆ stream_
std::stringstream BinaryReader::stream_ |
|
private |
The documentation for this class was generated from the following file: