top | up | prev | next

MemoryReader Class

Definition at line 14 of MemoryReader.hpp

Constructors

MemoryReader(uint8_t* ptr_, int64_t count_)

Member Functions

uint8_t ReadByte()
DateTime ReadDateTime()
int32_t ReadInt()
int64_t ReadLong()
int8_t ReadSByte()
int16_t ReadShort()
uint32_t ReadUInt()
uint64_t ReadULong()
uint16_t ReadUShort()

Member Variables

int64_t count
uint8_t* pos
uint8_t* ptr

Constructor Details

MemoryReader Constructor

soulng::util::MemoryReader::MemoryReader(uint8_t* ptr_, int64_t count_)

Definition at line 11 of MemoryReader.cpp :
11 : ptr(ptr_)pos(ptr)count(count_)
12 {
13 }


Declaration at line 17 of MemoryReader.hpp


Member Function Details

ReadByte Member Function

uint8_t soulng::util::MemoryReader::ReadByte()

Definition at line 15 of MemoryReader.cpp :
16 {
17     if (pos - ptr >= count)
18     {
19         throw std::runtime_error("memory reader: unexpected end of data");
20     }
21     return *pos++;
22 }


Declaration at line 18 of MemoryReader.hpp

Called by: soulng::util::MemoryReader::ReadSByte , soulng::util::MemoryReader::ReadUInt , soulng::util::MemoryReader::ReadULong , soulng::util::MemoryReader::ReadUShort


ReadDateTime Member Function

DateTime soulng::util::MemoryReader::ReadDateTime()

Definition at line 74 of MemoryReader.cpp :
75 {
76     int16_t year = ReadShort();
77     Month month = static_cast<Month>(ReadSByte());
78     int8_t day = ReadSByte();
79     Date date(yearmonthday);
80     int32_t secs = ReadInt();
81     DateTime dt(datesecs);
82     return dt;
83 }


Declaration at line 26 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadInt , soulng::util::MemoryReader::ReadSByte , soulng::util::MemoryReader::ReadShort


ReadInt Member Function

int32_t soulng::util::MemoryReader::ReadInt()

Definition at line 50 of MemoryReader.cpp :
51 {
52     return static_cast<int32_t>(ReadUInt());
53 }


Declaration at line 23 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadUInt

Called by: soulng::util::MemoryReader::ReadDateTime


ReadLong Member Function

int64_t soulng::util::MemoryReader::ReadLong()

Definition at line 69 of MemoryReader.cpp :
70 {
71     return static_cast<int64_t>(ReadULong());
72 }


Declaration at line 25 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadULong


ReadSByte Member Function

int8_t soulng::util::MemoryReader::ReadSByte()

Definition at line 24 of MemoryReader.cpp :
25 {
26     return static_cast<int8_t>(ReadByte());
27 }


Declaration at line 19 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadByte

Called by: soulng::util::MemoryReader::ReadDateTime


ReadShort Member Function

int16_t soulng::util::MemoryReader::ReadShort()

Definition at line 36 of MemoryReader.cpp :
37 {
38     return static_cast<int16_t>(ReadUShort());
39 }


Declaration at line 21 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadUShort

Called by: soulng::util::MemoryReader::ReadDateTime


ReadUInt Member Function

uint32_t soulng::util::MemoryReader::ReadUInt()

Definition at line 41 of MemoryReader.cpp :
42 {
43     uint8_t b0 = ReadByte();
44     uint8_t b1 = ReadByte();
45     uint8_t b2 = ReadByte();
46     uint8_t b3 = ReadByte();
47     return (static_cast<uint32_t>(b0) << 24u) | (static_cast<uint32_t>(b1) << 16u) | (static_cast<uint32_t>(b2) << 8u) | static_cast<uint32_t>(b3);
48 }


Declaration at line 22 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadByte

Called by: soulng::util::MemoryReader::ReadInt


ReadULong Member Function

uint64_t soulng::util::MemoryReader::ReadULong()

Definition at line 55 of MemoryReader.cpp
Declaration at line 24 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadByte

Called by: soulng::util::MemoryReader::ReadLong


ReadUShort Member Function

uint16_t soulng::util::MemoryReader::ReadUShort()

Definition at line 29 of MemoryReader.cpp :
30 {
31     uint8_t b0 = ReadByte();
32     uint8_t b1 = ReadByte();
33     return (static_cast<uint16_t>(b0) << 8u) | static_cast<uint16_t>(b1);
34 }


Declaration at line 20 of MemoryReader.hpp

Calls: soulng::util::MemoryReader::ReadByte

Called by: soulng::util::MemoryReader::ReadShort


top | up | prev | next