39 #ifndef H_IOBUFFER_INCLUDED
40 #define H_IOBUFFER_INCLUDED
72 void OpenBuffer(
const std::vector<uint8_t> & buffer);
77 void Open(
const std::string & file);
87 std::vector<uint8_t>
ReadBytes(uint32_t numBytes);
129 void * readN(
int num);
130 void readN(
void *, uint32_t);
131 uint8_t * immediateBuffer;
165 void Write(
const T &);
166 void WriteBytes(
const std::vector<uint8_t> & data);
167 void WriteString(std::string str);
176 std::vector<uint8_t>
GetData();
190 long operationalSize;
208 template <
typename T>
209 void Dynacoe::OutputBuffer::Write(
const T & obj) {
210 uint8_t * block = (uint8_t *) &obj;
211 std::vector<uint8_t> data(block, block+
sizeof(T));
216 template <
typename T>
219 std::vector<uint8_t> data = ReadBytes(
sizeof(T));
220 if (!data.size())
return T();
221 memcpy(&
object, &data[0],
sizeof(
object));
226 template <
typename T>
228 readN(&o,
sizeof(o));
int Size()
Returns the size of the queued data in bytes.
std::vector< uint8_t > GetData()
Returns a copy of the queued data.
Binary file writing utility.
Definition: Iobuffer.h:148
void Clear()
Resets the queued data buffer.
void GoToByte(int n)
Set the buffer position to the specifified byte.
bool CommitToFile(std::string fileName, bool append)
Stores the written data to the specified file.