top | up | prev | next

BinaryWriter Class

Definition at line 14 of BinaryWriter.hpp

Constructors

BinaryWriter(const std::string& fileName_)

Member Functions

bool BufferFull() const
void BufferReset()
void FlushBuffer()
uint32_t Pos() const
void Seek(uint32_t pos_)
void Write(bool x)
void Write(char x)
void Write(char16_t x)
void Write(char32_t x)
void Write(const boost::uuids::uuid& uuid)
void Write(const std::string& s)
void Write(const std::string& s, bool writeNull)
void Write(const std::u16string& s)
void Write(const std::u32string& s)
void Write(double x)
void Write(float x)
void Write(int16_t x)
void Write(int32_t x)
void Write(int64_t x)
void Write(int8_t x)
void Write(uint16_t x)
void Write(uint32_t x)
void Write(uint64_t x)
void Write(uint8_t x)
void WriteSLEB128Int(int32_t x)
void WriteSLEB128Long(int64_t x)
void WriteULEB128UInt(uint32_t x)
void WriteULEB128ULong(uint64_t x)

Member Variables

const int N static
uint8_t* bufend
uint8_t* bufp
FilePtr file
std::string fileName
uint32_t pos

Constructor Details

BinaryWriter Constructor

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

Definition at line 14 of BinaryWriter.cpp :
 14 : fileName(fileName_)file(OpenWrite(fileName.c_str())fileNameLockKind::write)buffer()bufp(buffer)bufend(buffer + N)pos(0)
 15 {
 16     if (!file)
 17     {
 18         throw std::runtime_error("could not open '" + fileName + "' for writing: " + soulng::util::PlatformStringToUtf8(std::strerror(errno)));
 19     }
 20 }


Declaration at line 17 of BinaryWriter.hpp


Member Function Details

BufferFull Member Function

bool soulng::util::BinaryWriter::BufferFull() const

Definition at line 53 of BinaryWriter.hpp :
53 { return bufp == bufend; }

Called by: soulng::util::BinaryWriter::Write


BufferReset Member Function

void soulng::util::BinaryWriter::BufferReset()

Definition at line 52 of BinaryWriter.hpp :
52 { bufp = buffer; bufend = buffer + N; }

Called by: soulng::util::BinaryWriter::FlushBuffer


FlushBuffer Member Function

void soulng::util::BinaryWriter::FlushBuffer()

Definition at line 256 of BinaryWriter.cpp
Declaration at line 54 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::BufferReset

Called by: soulng::util::BinaryWriter::Seek , soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::destructor


Pos Member Function

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

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


Seek Member Function

void soulng::util::BinaryWriter::Seek(uint32_t pos_)

Definition at line 245 of BinaryWriter.cpp :
246 {
247     FlushBuffer();
248     pos = pos_;
249     int result = fseek(fileposSEEK_SET);
250     if (result != 0)
251     {
252         throw std::runtime_error("seek failed: " + soulng::util::PlatformStringToUtf8(std::strerror(errno)));
253     }
254 }


Declaration at line 43 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::FlushBuffer


Write Member Function

void soulng::util::BinaryWriter::Write(bool x)

Definition at line 27 of BinaryWriter.cpp :
 28 {
 29     Write(uint8_t(x));
 30 }


Declaration at line 19 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(char x)

Definition at line 114 of BinaryWriter.cpp :
115 {
116     Write(static_cast<uint8_t>(x));
117 }


Declaration at line 30 of BinaryWriter.hpp

Called by: soulng::util::Trace::Write


Write Member Function

void soulng::util::BinaryWriter::Write(char16_t x)

Definition at line 119 of BinaryWriter.cpp :
120 {
121     Write(static_cast<uint16_t>(x));
122 }


Declaration at line 31 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(char32_t x)

Definition at line 124 of BinaryWriter.cpp :
125 {
126     Write(static_cast<uint32_t>(x));
127 }


Declaration at line 32 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(const boost::uuids::uuid& uuid)

Definition at line 237 of BinaryWriter.cpp :
238 {
239     for (boost::uuids::uuid::value_type x : uuid)
240     {
241         Write(x);
242     }
243 }


Declaration at line 41 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(const std::string& s)

Definition at line 129 of BinaryWriter.cpp :
130 {
131     Write(strue);
132 }


Declaration at line 33 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write

Called by: soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(const std::string& s, bool writeNull)

Definition at line 134 of BinaryWriter.cpp
Declaration at line 34 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write

Called by: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(const std::u16string& s)

Definition at line 147 of BinaryWriter.cpp :
148 {
149     std::string utf8_str = ToUtf8(s);
150     Write(utf8_str);
151 }


Declaration at line 35 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(const std::u32string& s)

Definition at line 153 of BinaryWriter.cpp :
154 {
155     std::string utf8_str = ToUtf8(s);
156     Write(utf8_str);
157 }


Declaration at line 36 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(double x)

Definition at line 108 of BinaryWriter.cpp :
109 {
110     uint64_t* u = reinterpret_cast<uint64_t*>(&x);
111     Write(*u);
112 }


Declaration at line 29 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(float x)

Definition at line 102 of BinaryWriter.cpp :
103 {
104     uint32_t* u = reinterpret_cast<uint32_t*>(&x);
105     Write(*u);
106 }


Declaration at line 28 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(int16_t x)

Definition at line 55 of BinaryWriter.cpp :
 56 {
 57     Write(static_cast<uint16_t>(x));
 58 }


Declaration at line 23 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(int32_t x)

Definition at line 72 of BinaryWriter.cpp :
 73 {
 74     Write(static_cast<uint32_t>(x));
 75 }


Declaration at line 25 of BinaryWriter.hpp

Called by: soulng::util::Trace::Write


Write Member Function

void soulng::util::BinaryWriter::Write(int64_t x)

Definition at line 97 of BinaryWriter.cpp :
 98 {
 99     Write(static_cast<uint64_t>(x));
100 }


Declaration at line 27 of BinaryWriter.hpp

Called by: soulng::util::Trace::Write


Write Member Function

void soulng::util::BinaryWriter::Write(int8_t x)

Definition at line 42 of BinaryWriter.cpp :
 43 {
 44     Write(static_cast<uint8_t>(x));
 45 }


Declaration at line 21 of BinaryWriter.hpp


Write Member Function

void soulng::util::BinaryWriter::Write(uint16_t x)

Definition at line 47 of BinaryWriter.cpp :
 48 {
 49     uint8_t b0 = static_cast<uint8_t>(x >> 8);
 50     uint8_t b1 = static_cast<uint8_t>(x);
 51     Write(b0);
 52     Write(b1);
 53 }


Declaration at line 22 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(uint32_t x)

Definition at line 60 of BinaryWriter.cpp :
 61 {
 62     uint8_t b0 = static_cast<uint8_t>(x >> 24);
 63     uint8_t b1 = static_cast<uint8_t>(x >> 16);
 64     uint8_t b2 = static_cast<uint8_t>(x >> 8);
 65     uint8_t b3 = static_cast<uint8_t>(x);
 66     Write(b0);
 67     Write(b1);
 68     Write(b2);
 69     Write(b3);
 70 }


Declaration at line 24 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(uint64_t x)

Definition at line 77 of BinaryWriter.cpp
Declaration at line 26 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


Write Member Function

void soulng::util::BinaryWriter::Write(uint8_t x)

Definition at line 32 of BinaryWriter.cpp :
 33 {
 34     if (BufferFull())
 35     {
 36         FlushBuffer();
 37     }
 38     *bufp++ = x;
 39     ++pos;
 40 }


Declaration at line 20 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::BufferFull , soulng::util::BinaryWriter::FlushBuffer

Called by: soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::Write , soulng::util::BinaryWriter::WriteSLEB128Int , soulng::util::BinaryWriter::WriteSLEB128Long , soulng::util::BinaryWriter::WriteULEB128UInt , soulng::util::BinaryWriter::WriteULEB128ULong


WriteSLEB128Int Member Function

void soulng::util::BinaryWriter::WriteSLEB128Int(int32_t x)

Definition at line 189 of BinaryWriter.cpp
Declaration at line 39 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


WriteSLEB128Long Member Function

void soulng::util::BinaryWriter::WriteSLEB128Long(int64_t x)

Definition at line 213 of BinaryWriter.cpp
Declaration at line 40 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


WriteULEB128UInt Member Function

void soulng::util::BinaryWriter::WriteULEB128UInt(uint32_t x)

Definition at line 159 of BinaryWriter.cpp
Declaration at line 37 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


WriteULEB128ULong Member Function

void soulng::util::BinaryWriter::WriteULEB128ULong(uint64_t x)

Definition at line 174 of BinaryWriter.cpp
Declaration at line 38 of BinaryWriter.hpp

Calls: soulng::util::BinaryWriter::Write


top | up | prev | next