top | up | prev | next

BinaryReader Class

Definition at line 14 of BinaryReader.hpp

Constructors

BinaryReader(const std::string& fileName_)

Member Functions

void CheckEof()
const std::string& FileName() const
uint32_t Pos() const
bool ReadBool()
uint8_t ReadByte()
char ReadChar()
double ReadDouble()
float ReadFloat()
int32_t ReadInt()
int64_t ReadLong()
int8_t ReadSByte()
int32_t ReadSLEB128Int()
int64_t ReadSLEB128Long()
int16_t ReadShort()
char32_t ReadUChar()
uint32_t ReadUInt()
uint32_t ReadULEB128UInt()
uint64_t ReadULEB128ULong()
uint64_t ReadULong()
uint16_t ReadUShort()
std::u16string ReadUtf16String()
std::u32string ReadUtf32String()
std::string ReadUtf8String()
void ReadUuid(boost::uuids::uuid& uuid)
char16_t ReadWChar()
void Skip(uint32_t size)

Member Variables

const uint8_t* begin
const uint8_t* end
MappedInputFile file
std::string fileName
uint32_t pos

Constructor Details

BinaryReader Constructor

soulng::util::BinaryReader::BinaryReader(const std::string& fileName_)

Definition at line 15 of BinaryReader.cpp :
 15 :
 16 fileName(fileName_)file(fileName)begin(reinterpret_cast<constuint8_t*>(file.Begin()))end(reinterpret_cast<constuint8_t*>(file.End()))pos(0)
 17 {
 18 }


Declaration at line 17 of BinaryReader.hpp


Member Function Details

CheckEof Member Function

void soulng::util::BinaryReader::CheckEof()

Definition at line 226 of BinaryReader.cpp :
227 {
228     if (begin == end)
229     {
230         throw std::runtime_error("unexpected end of file '" + fileName + "'");
231     }
232 }


Declaration at line 50 of BinaryReader.hpp

Called by: soulng::util::BinaryReader::ReadByte


FileName Member Function

const std::string& soulng::util::BinaryReader::FileName() const

Definition at line 18 of BinaryReader.hpp :
18 { return fileName; }


Pos Member Function

uint32_t soulng::util::BinaryReader::Pos() const

Definition at line 42 of BinaryReader.hpp :
42 { return pos; }


ReadBool Member Function

bool soulng::util::BinaryReader::ReadBool()

Definition at line 24 of BinaryReader.cpp :
 25 {
 26     uint8_t x = ReadByte();
 27     return static_cast<bool>(x);
 28 }


Declaration at line 20 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadByte Member Function

uint8_t soulng::util::BinaryReader::ReadByte()

Definition at line 30 of BinaryReader.cpp :
 31 {
 32     CheckEof();
 33     uint8_t x = *begin++;
 34     ++pos;
 35     return x;
 36 }


Declaration at line 21 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::CheckEof

Called by: soulng::util::BinaryReader::ReadBool , soulng::util::BinaryReader::ReadChar , soulng::util::BinaryReader::ReadSByte , soulng::util::BinaryReader::ReadSLEB128Int , soulng::util::BinaryReader::ReadSLEB128Long , soulng::util::BinaryReader::ReadUInt , soulng::util::BinaryReader::ReadULEB128UInt , soulng::util::BinaryReader::ReadULEB128ULong , soulng::util::BinaryReader::ReadULong , soulng::util::BinaryReader::ReadUShort , soulng::util::BinaryReader::ReadUtf8String , soulng::util::BinaryReader::ReadUuid


ReadChar Member Function

char soulng::util::BinaryReader::ReadChar()

Definition at line 104 of BinaryReader.cpp :
105 {
106     uint8_t x = ReadByte();
107     return static_cast<char>(x);
108 }


Declaration at line 31 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadDouble Member Function

double soulng::util::BinaryReader::ReadDouble()

Definition at line 98 of BinaryReader.cpp :
 99 {
100     uint64_t x = ReadULong();
101     return *reinterpret_cast<double*>(&x);
102 }


Declaration at line 30 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadULong


ReadFloat Member Function

float soulng::util::BinaryReader::ReadFloat()

Definition at line 92 of BinaryReader.cpp :
 93 {
 94     uint32_t x = ReadUInt();
 95     return *reinterpret_cast<float*>(&x);
 96 }


Declaration at line 29 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUInt


ReadInt Member Function

int32_t soulng::util::BinaryReader::ReadInt()

Definition at line 66 of BinaryReader.cpp :
 67 {
 68     uint32_t x = ReadUInt();
 69     return static_cast<int32_t>(x);
 70 }


Declaration at line 26 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUInt


ReadLong Member Function

int64_t soulng::util::BinaryReader::ReadLong()

Definition at line 86 of BinaryReader.cpp :
 87 {
 88     uint64_t x = ReadULong();
 89     return static_cast<int64_t>(x);
 90 }


Declaration at line 28 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadULong


ReadSByte Member Function

int8_t soulng::util::BinaryReader::ReadSByte()

Definition at line 38 of BinaryReader.cpp :
 39 {
 40     uint8_t x = ReadByte();
 41     return static_cast<int8_t>(x);
 42 }


Declaration at line 22 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadSLEB128Int Member Function

int32_t soulng::util::BinaryReader::ReadSLEB128Int()

Definition at line 174 of BinaryReader.cpp
Declaration at line 39 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadSLEB128Long Member Function

int64_t soulng::util::BinaryReader::ReadSLEB128Long()

Definition at line 193 of BinaryReader.cpp
Declaration at line 40 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadShort Member Function

int16_t soulng::util::BinaryReader::ReadShort()

Definition at line 51 of BinaryReader.cpp :
 52 {
 53     uint16_t x = ReadUShort();
 54     return static_cast<int16_t>(x);
 55 }


Declaration at line 24 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUShort


ReadUChar Member Function

char32_t soulng::util::BinaryReader::ReadUChar()

Definition at line 116 of BinaryReader.cpp :
117 {
118     uint32_t x = ReadUInt();
119     return static_cast<char32_t>(x);
120 }


Declaration at line 33 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUInt


ReadUInt Member Function

uint32_t soulng::util::BinaryReader::ReadUInt()

Definition at line 57 of BinaryReader.cpp :
 58 {
 59     uint8_t b0 = ReadByte();
 60     uint8_t b1 = ReadByte();
 61     uint8_t b2 = ReadByte();
 62     uint8_t b3 = ReadByte();
 63     return (static_cast<uint32_t>(b0) << 24) | (static_cast<uint32_t>(b1) << 16) | (static_cast<uint32_t>(b2) << 8) | static_cast<uint32_t>(b3);
 64 }


Declaration at line 25 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte

Called by: soulng::util::BinaryReader::ReadFloat , soulng::util::BinaryReader::ReadInt , soulng::util::BinaryReader::ReadUChar


ReadULEB128UInt Member Function

uint32_t soulng::util::BinaryReader::ReadULEB128UInt()

Definition at line 146 of BinaryReader.cpp
Declaration at line 37 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadULEB128ULong Member Function

uint64_t soulng::util::BinaryReader::ReadULEB128ULong()

Definition at line 160 of BinaryReader.cpp
Declaration at line 38 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadULong Member Function

uint64_t soulng::util::BinaryReader::ReadULong()

Definition at line 72 of BinaryReader.cpp
Declaration at line 27 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte

Called by: soulng::util::BinaryReader::ReadDouble , soulng::util::BinaryReader::ReadLong


ReadUShort Member Function

uint16_t soulng::util::BinaryReader::ReadUShort()

Definition at line 44 of BinaryReader.cpp :
 45 {
 46     uint8_t h = ReadByte();
 47     uint8_t l = ReadByte();
 48     return (static_cast<uint16_t>(h) << 8) | static_cast<uint16_t>(l);
 49 }


Declaration at line 23 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte

Called by: soulng::util::BinaryReader::ReadShort , soulng::util::BinaryReader::ReadWChar


ReadUtf16String Member Function

std::u16string soulng::util::BinaryReader::ReadUtf16String()

Definition at line 134 of BinaryReader.cpp :
135 {
136     std::string s = ReadUtf8String();
137     return ToUtf16(s);
138 }


Declaration at line 35 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUtf8String


ReadUtf32String Member Function

std::u32string soulng::util::BinaryReader::ReadUtf32String()

Definition at line 140 of BinaryReader.cpp :
141 {
142     std::string s = ReadUtf8String();
143     return ToUtf32(s);
144 }


Declaration at line 36 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUtf8String


ReadUtf8String Member Function

std::string soulng::util::BinaryReader::ReadUtf8String()

Definition at line 122 of BinaryReader.cpp :
123 {
124     std::string s;
125     uint8_t x = ReadByte();
126     while (x != 0)
127     {
128         s.append(1static_cast<char>(x));
129         x = ReadByte();
130     }
131     return s;
132 }


Declaration at line 34 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte

Called by: soulng::util::BinaryReader::ReadUtf16String , soulng::util::BinaryReader::ReadUtf32String


ReadUuid Member Function

void soulng::util::BinaryReader::ReadUuid(boost::uuids::uuid& uuid)

Definition at line 212 of BinaryReader.cpp :
213 {
214     for (boost::uuids::uuid::value_type& x : uuid)
215     {
216         x = ReadByte();
217     }
218 }


Declaration at line 41 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadByte


ReadWChar Member Function

char16_t soulng::util::BinaryReader::ReadWChar()

Definition at line 110 of BinaryReader.cpp :
111 {
112     uint16_t x = ReadUShort();
113     return static_cast<char16_t>(x);
114 }


Declaration at line 32 of BinaryReader.hpp

Calls: soulng::util::BinaryReader::ReadUShort


Skip Member Function

void soulng::util::BinaryReader::Skip(uint32_t size)

Definition at line 220 of BinaryReader.cpp :
221 {
222     begin += size;
223     pos += size;
224 }


Declaration at line 43 of BinaryReader.hpp


top | up | prev | next