Go to the documentation of this file.
39 #ifndef BLOCXX_BinarySerialization_HPP_
40 #define BLOCXX_BinarySerialization_HPP_
41 #include "blocxx/BLOCXX_config.h"
57 namespace BinarySerialization
99 template <
typename Handler,
typename ReaderFunc>
101 std::streambuf & istrm, Handler & result,
102 const ReaderFunc &
read,
const UInt8 beginsig,
const UInt8 endsig)
110 result.handle(
read(istrm));
112 catch (
const BadSignatureException& e)
121 BLOCXX_COMMON_API
void write(
122 std::streambuf & ostrm,
const void * dataOut,
size_t dataOutLen
125 inline void write(std::streambuf & ostrm, Int32 val)
131 inline void write(std::streambuf & ostrm, UInt32 val)
137 BLOCXX_COMMON_API
void writeLen(std::streambuf & ostrm, UInt32 len);
144 inline void write(std::streambuf & ostrm, UInt16 val)
150 inline void write(std::streambuf & ostrm, Int16 val)
156 inline void write(std::streambuf & ostrm, UInt64 val)
162 inline void write(std::streambuf & ostrm, Int64 val)
168 inline void write(std::streambuf & ostrm,
const String & str)
170 str.writeObject(ostrm);
173 inline void writeBool(std::streambuf & ostrm, Bool arg)
176 arg.writeObject(ostrm);
179 inline void writeString(std::streambuf & ostrm,
const String & str)
182 str.writeObject(ostrm);
185 BLOCXX_COMMON_API
void readLen(std::streambuf & istrm, UInt32 & len);
188 template <
typename T>
197 for (UInt32
i = 0;
i < len;
i++)
199 typename T::value_type x;
206 template <
typename T>
208 writeArray(std::streambuf & ostrm,
const T & a)
210 UInt32 len =
static_cast<UInt32
>(a.size());
212 for (UInt32
i = 0;
i < len;
i++)
214 a.operator[](
i).writeObject(ostrm);
227 std::streambuf & ostrm,
const StringArray * propertyList
231 BLOCXX_COMMON_API
void read(
232 std::streambuf & istrm,
void * dataIn,
size_t dataInLen
235 inline void read(std::streambuf & istrm,
String & arg)
240 inline void read(std::streambuf & istrm, UInt64 & val)
246 inline void read(std::streambuf & istrm, Int64 & val)
252 inline void read(std::streambuf & istrm, Int32 & val)
258 inline void read(std::streambuf & istrm, UInt32 & val)
264 inline void read(std::streambuf & istrm, UInt16 & val)
270 inline void read(std::streambuf & istrm, Int16 & val)
276 inline void read(std::streambuf & istrm,
UInt8 & val)
289 inline String
readString(std::streambuf & istrm)
293 rv.readObject(istrm);
309 #endif // BLOCXX_BinarySerialization_HPP_
void readArray(std::streambuf &istr, T &a)
void writeArray(std::streambuf &ostrm, const T &a)
void verifySignature(std::streambuf &istrm, UInt8 validSig)
The Bool class is an abstraction for the boolean data type.
const UInt8 BIN_EXCEPTION
This String class is an abstract data type that represents as NULL terminated string of characters.
void write(std::streambuf &ostrm, void const *dataOut, size_t dataOutLen)
Bool readBool(std::streambuf &istrm)
void readLen(std::streambuf &istrm, UInt32 &len)
const UInt8 BINSIG_STRINGENUM
void read(std::streambuf &istrm, void *dataIn, size_t dataInLen)
void readEnum(std::streambuf &istrm, Handler &result, const ReaderFunc &read, const UInt8 beginsig, const UInt8 endsig)
void writeString(std::streambuf &ostrm, const String &str)
void writeBool(std::streambuf &ostrm, Bool arg)
void readObject(std::streambuf &istrm)
Read this object from an input stream.
String readString(std::streambuf &istrm)
void writeLen(std::streambuf &ostrm, UInt32 len)
const UInt32 BinaryProtocolVersion
const UInt8 BINSIG_STRARRAY
void writeStringArray(std::streambuf &ostrm, const StringArray *propertyList)
void readObject(std::streambuf &istrm)
Read this String object from the given istream.
const UInt8 END_STRINGENUM
const UInt32 MinBinaryProtocolVersion
StringArray readStringArray(std::streambuf &istrm)
Array<> wraps std::vector<> in COWReference<> adding ref counting and copy on write capability.
const UInt8 BIN_LOG_MESSAGE