3 * - By John Hodge (thePowersGang)
6 * - Generic (de)serialisation code
8 #ifndef _SERIALISATION_H_
9 #define _SERIALISATION_H_
19 class CDeserialiseException:
20 public ::std::exception
26 const size_t m_length;
27 const uint8_t* m_data;
30 CDeserialiser(size_t Length, const uint8_t *Buffer);
31 bool IsConsumed() const;
35 const ::std::string ReadString();
40 ::std::vector<uint8_t> m_data;
43 void WriteU8(::uint8_t val);
44 void WriteU16(::uint16_t val);
45 void WriteS16(::int16_t val);
46 void WriteBuffer(size_t n, const void* val);
47 void WriteString(const char* val, size_t n);
48 void WriteString(const char* val) {
49 WriteString(val, ::std::char_traits<char>::length(val));
51 void WriteString(const ::std::string& val) {
52 WriteString(val.data(), val.size());
54 void WriteSub(const CSerialiser& val);
56 const ::std::vector<uint8_t>& Compact();