1 #ifndef DYSCO_SERIALIZABLE_H
2 #define DYSCO_SERIALIZABLE_H
12 virtual void Serialize(std::ostream &stream)
const = 0;
17 uint64_t val64t =
value;
18 stream.write(reinterpret_cast<char *>(&val64t),
sizeof(val64t));
23 uint32_t val32t =
value;
24 stream.write(reinterpret_cast<char *>(&val32t),
sizeof(val32t));
29 uint16_t val16t =
value;
30 stream.write(reinterpret_cast<char *>(&val16t),
sizeof(val16t));
35 uint8_t val8t =
value;
36 stream.write(reinterpret_cast<char *>(&val8t),
sizeof(val8t));
40 uint8_t val8t =
value;
41 stream.write(reinterpret_cast<char *>(&val8t),
sizeof(val8t));
45 stream.write(reinterpret_cast<char *>(&value),
sizeof(value));
49 stream.write(reinterpret_cast<char *>(&value),
sizeof(value));
53 stream.write(reinterpret_cast<char *>(&value),
sizeof(value));
57 std::complex<long double>
value) {
58 stream.write(reinterpret_cast<char *>(&value),
sizeof(value));
63 stream.write(str.c_str(), str.size());
67 const std::string &str) {
69 stream.write(str.c_str(), str.size());
73 return Unserialize<uint64_t>(stream);
77 return Unserialize<uint32_t>(stream);
81 return Unserialize<uint16_t>(stream);
85 return Unserialize<uint8_t>(stream);
89 return (
bool)Unserialize<uint8_t>(stream);
93 return Unserialize<float>(stream);
97 return Unserialize<double>(stream);
101 return Unserialize<long double>(stream);
105 return Unserialize<std::complex<long double>>(stream);
110 char *str =
new char[size];
111 stream.read(str, size);
112 destStr = std::string(str, size);
118 char *str =
new char[size];
119 stream.read(str, size);
120 destStr = std::string(str, size);
125 template <
typename T>
128 stream.read(reinterpret_cast<char *>(&val),
sizeof(val));
static uint64_t UnserializeUInt64(std::istream &stream)
static void SerializeToLDoubleC(std::ostream &stream, std::complex< long double > value)
static void SerializeToUInt64(std::ostream &stream, T value)
static void SerializeToFloat(std::ostream &stream, float value)
static uint16_t UnserializeUInt16(std::istream &stream)
static double UnserializeFloat(std::istream &stream)
static void SerializeToBool8(std::ostream &stream, bool value)
static void SerializeToString(std::ostream &stream, const std::string &str)
static uint32_t UnserializeUInt32(std::istream &stream)
static T Unserialize(std::istream &stream)
static void SerializeTo32bString(std::ostream &stream, const std::string &str)
static void SerializeToLDouble(std::ostream &stream, long double value)
static void SerializeToUInt32(std::ostream &stream, T value)
static void SerializeToDouble(std::ostream &stream, double value)
static void SerializeToUInt8(std::ostream &stream, T value)
static bool UnserializeBool8(std::istream &stream)
static void Unserialize32bString(std::istream &stream, std::string &destStr)
static void SerializeToUInt16(std::ostream &stream, T value)
virtual void Serialize(std::ostream &stream) const =0
static long double UnserializeLDouble(std::istream &stream)
static double UnserializeDouble(std::istream &stream)
static void UnserializeString(std::istream &stream, std::string &destStr)
static std::complex< long double > UnserializeLDoubleC(std::istream &stream)
static uint8_t UnserializeUInt8(std::istream &stream)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual void Unserialize(std::istream &stream)=0