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 ::std::vector<uint8_t> m_vect;
30 CDeserialiser(::std::vector<uint8_t>())
32 CDeserialiser(const ::std::vector<uint8_t>& vect);
33 CDeserialiser(::std::vector<uint8_t>&& vect);
34 CDeserialiser(const CDeserialiser& x) { *this = x; };
35 CDeserialiser& operator=(const CDeserialiser& x);
36 bool IsConsumed() const;
40 const ::std::vector<uint8_t> ReadBuffer();
41 const ::std::string ReadString();
43 void RangeCheck(const char *Method, size_t bytes) throw(::std::out_of_range);
48 ::std::vector<uint8_t> m_data;
51 void WriteU8(::uint8_t val);
52 void WriteU16(::uint16_t val);
53 void WriteS16(::int16_t val);
54 void WriteBuffer(size_t n, const void* val);
55 void WriteString(const char* val, size_t n);
56 void WriteString(const char* val) {
57 WriteString(val, ::std::char_traits<char>::length(val));
59 void WriteString(const ::std::string& val) {
60 WriteString(val.data(), val.size());
62 void WriteSub(const CSerialiser& val);
64 const ::std::vector<uint8_t>& Compact();