31 enum OverflowHandlingMode
37 OverflowHandlingMode on_overflow = TerminateOnOverflow;
39 const offset_t start_offset;
40 const offset_t maximum_size;
47 Reader(offset_t start_offset, offset_t maximum_size, EndianType
endiantype, std::istream *
in =
nullptr)
52 Reader CreateWindow(offset_t new_start_offset, offset_t new_maximum_size = offset_t(-1));
57 void ReadData(
size_t count,
void * data);
62 void ReadData(
size_t count, std::vector<uint8_t>& data,
size_t offset = 0);
67 void ReadData(std::vector<uint8_t>& data,
size_t offset = 0);
72 std::string
ReadData(
size_t count,
bool terminate_at_null =
false);
77 std::string
ReadUTF16Data(
size_t count,
bool terminate_at_null =
false);
82 template <
class T, std::
size_t N>
83 void ReadData(std::array<T, N>& data,
size_t offset = 0)
87 ReadData(N - offset,
reinterpret_cast<char *
>(data.data()) + offset);
93 std::string
ReadASCII(
char terminator,
size_t maximum =
size_t(-1));
98 std::string
ReadASCIIZ(
size_t maximum =
size_t(-1));
103 std::string
ReadUTF16Data(
const char terminator[2],
size_t maximum =
size_t(-1));
113 std::string
ReadUTF16Data(
char16_t terminator,
size_t maximum =
size_t(-1));
148 void Seek(offset_t offset);
153 void Skip(offset_t offset);
158 void SeekEnd(relative_offset_t offset = 0);
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:20
void Skip(offset_t offset)
Jump to a distance in the input stream.
Definition reader.cc:189
std::string ReadASCIIZ(size_t maximum=size_t(-1))
Read a zero terminated ASCII string.
Definition reader.cc:93
std::string ReadASCII(char terminator, size_t maximum=size_t(-1))
Read an ASCII string up to a terminator.
Definition reader.cc:78
void Seek(offset_t offset)
Jump to a specific location in the input stream.
Definition reader.cc:179
offset_t GetImageEnd()
Returns the last location that can be read.
Definition reader.cc:262
std::string ReadUTF16Data(size_t count, bool terminate_at_null=false)
Read in a sequence of 16-bit words.
Definition reader.cc:98
uint64_t ReadSigned(size_t bytes, EndianType endiantype)
Read a signed word.
Definition reader.cc:167
void SeekEnd(relative_offset_t offset=0)
Jump to end of the input stream.
Definition reader.cc:211
EndianType endiantype
The default endianness of the binary format, used for reading multibyte numeric data.
Definition reader.h:25
std::string ReadUTF16ZData(size_t maximum=size_t(-1))
Read a zero terminated string of 16-bit words.
Definition reader.cc:149
std::istream * in
The input stream.
Definition reader.h:29
void ReadData(size_t count, void *data)
Read in a sequence of bytes.
Definition reader.cc:30
offset_t GetRemainingCount()
Returns the byte count until the last location that can be read.
Definition reader.cc:278
void ReadData(std::array< T, N > &data, size_t offset=0)
Read in a sequence of bytes.
Definition reader.h:83
offset_t Tell()
Retrieve the current location.
Definition reader.cc:233
uint64_t ReadUnsigned(size_t bytes, EndianType endiantype)
Read an unsigned word.
Definition reader.cc:155