1
2
3
4
5
6 #ifndef SOULNG_UTIL_BINARY_READER_INCLUDED
7 #define SOULNG_UTIL_BINARY_READER_INCLUDED
8 #include <soulng/util/UtilApi.hpp>
9 #include <soulng/util/MappedInputFile.hpp>
10 #include <boost/uuid/uuid.hpp>
11
12 namespace soulng { namespace util {
13
14 class BinaryReader
15 {
16 public:
17 BinaryReader(const std::string& fileName_);
18 const std::string& FileName() const { return fileName; }
19 virtual ~BinaryReader();
20 bool ReadBool();
21 uint8_t ReadByte();
22 int8_t ReadSByte();
23 uint16_t ReadUShort();
24 int16_t ReadShort();
25 uint32_t ReadUInt();
26 int32_t ReadInt();
27 uint64_t ReadULong();
28 int64_t ReadLong();
29 float ReadFloat();
30 double ReadDouble();
31 char ReadChar();
32 char16_t ReadWChar();
33 char32_t ReadUChar();
34 std::string ReadUtf8String();
35 std::u16string ReadUtf16String();
36 std::u32string ReadUtf32String();
37 uint32_t ReadULEB128UInt();
38 uint64_t ReadULEB128ULong();
39 int32_t ReadSLEB128Int();
40 int64_t ReadSLEB128Long();
41 void ReadUuid(boost::uuids::uuid& uuid);
42 uint32_t Pos() const { return pos; }
43 void Skip(uint32_t size);
44 private:
45 std::string fileName;
46 MappedInputFile file;
47 const uint8_t* begin;
48 const uint8_t* end;
49 uint32_t pos;
50 void CheckEof();
51 };
52
53 } }
54
55 #endif // SOULNG_UTIL_BINARY_READER_INCLUDED