41 template<
class pack_value,
class t_stream>
44 pack_value v = pv << 2;
47 strm.write((
const char*)&v,
sizeof(pack_value));
48 return sizeof(pack_value);
51 template<
class t_stream>
62 }
else if(val <= 1073741823)
68 CHECK_AND_ASSERT_THROW_MES(!(val >> 31 >> 31),
"failed to pack varint - too big amount = " << val);
73 template<
class t_stream>
78 strm.write((
const char*)v.data(), v.size());
82 template<
class t_stream>
87 template<
class t_pod_type>
91 m_strm.write((
const char*)&type, 1);
93 for(t_pod_type x: arr_pod.
m_array)
96 m_strm.write((
const char*)&x,
sizeof(t_pod_type));
115 m_strm.write((
const char*)&type, 1);
117 for(
const std::string&
s: arr_str.
m_array)
124 m_strm.write((
const char*)&type, 1);
133 m_strm.write((
const char*)&type, 1);
141 template<
class t_stream>
146 template<
class pod_type>
149 m_strm.write((
const char*)&type, 1);
151 m_strm.write((
const char*)&
v0,
sizeof(pod_type));
168 m_strm.write((
const char*)&type, 1);
175 m_strm.write((
const char*)&type, 1);
187 template<
class t_stream>
191 return boost::apply_visitor(aesv, ae);
194 template<
class t_stream>
198 return boost::apply_visitor(sv, se);
201 template<
class t_stream>
204 typedef std::map<std::string, storage_entry>::value_type section_pair;
206 for(
const section_pair& se: sec.
m_entries)
208 CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(),
"storage_entry_name is too long: " << se.first.size() <<
", val: " << se.first);
209 CHECK_AND_ASSERT_THROW_MES(!se.first.empty(),
"storage_entry_name is empty");
211 strm.write((
const char*)&len,
sizeof(len));
212 strm.write(se.first.data(),
size_t(len));
#define s(x, c)
Definition aesb.c:47
#define v0(p)
Definition aesb.c:116
Definition keyvalue_serialization_overloads.h:49
bool put_string(t_stream &strm, const std::string &v)
Definition portable_storage_to_bin.h:74
boost::variant< uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, section, array_entry > storage_entry
Definition portable_storage_base.h:161
bool pack_entry_to_buff(t_stream &strm, const array_entry &ae)
Definition portable_storage_to_bin.h:188
size_t pack_varint(t_stream &strm, size_t val)
Definition portable_storage_to_bin.h:52
size_t pack_varint_t(t_stream &strm, uint8_t type_or, size_t &pv)
Definition portable_storage_to_bin.h:42
boost::make_recursive_variant< array_entry_t< section >, array_entry_t< uint64_t >, array_entry_t< uint32_t >, array_entry_t< uint16_t >, array_entry_t< uint8_t >, array_entry_t< int64_t >, array_entry_t< int32_t >, array_entry_t< int16_t >, array_entry_t< int8_t >, array_entry_t< double >, array_entry_t< bool >, array_entry_t< std::string >, array_entry_t< section >, array_entry_t< boost::recursive_variant_ > >::type array_entry
Definition portable_storage_base.h:159
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
#define PORTABLE_RAW_SIZE_MARK_WORD
Definition portable_storage_base.h:43
#define SERIALIZE_FLAG_ARRAY
Definition portable_storage_base.h:66
#define PORTABLE_RAW_SIZE_MARK_DWORD
Definition portable_storage_base.h:44
#define SERIALIZE_TYPE_UINT32
Definition portable_storage_base.h:57
#define SERIALIZE_TYPE_INT32
Definition portable_storage_base.h:53
#define SERIALIZE_TYPE_UINT8
Definition portable_storage_base.h:59
#define SERIALIZE_TYPE_UINT16
Definition portable_storage_base.h:58
#define PORTABLE_RAW_SIZE_MARK_BYTE
Definition portable_storage_base.h:42
#define PORTABLE_RAW_SIZE_MARK_INT64
Definition portable_storage_base.h:45
#define SERIALIZE_TYPE_INT64
Definition portable_storage_base.h:52
#define SERIALIZE_TYPE_UINT64
Definition portable_storage_base.h:56
#define SERIALIZE_TYPE_INT8
Definition portable_storage_base.h:55
#define SERIALIZE_TYPE_DOUBLE
Definition portable_storage_base.h:60
#define SERIALIZE_TYPE_STRING
Definition portable_storage_base.h:61
#define SERIALIZE_TYPE_INT16
Definition portable_storage_base.h:54
#define SERIALIZE_TYPE_OBJECT
Definition portable_storage_base.h:63
#define SERIALIZE_TYPE_ARRAY
Definition portable_storage_base.h:64
#define SERIALIZE_TYPE_BOOL
Definition portable_storage_base.h:62
#define CONVERT_POD(x)
Definition portable_storage_bin_utils.h:43
signed short int16_t
Definition stdint.h:122
unsigned short uint16_t
Definition stdint.h:125
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
signed char int8_t
Definition stdint.h:121
Definition portable_storage_to_bin.h:84
bool operator()(const array_entry_t< int64_t > &v)
Definition portable_storage_to_bin.h:106
bool operator()(const array_entry_t< int16_t > &v)
Definition portable_storage_to_bin.h:108
array_entry_store_visitor(t_stream &strm)
Definition portable_storage_to_bin.h:101
bool operator()(const array_entry_t< uint64_t > &v)
Definition portable_storage_to_bin.h:102
bool operator()(const array_entry_t< std::string > &arr_str)
Definition portable_storage_to_bin.h:112
bool operator()(const array_entry_t< section > &arr_sec)
Definition portable_storage_to_bin.h:121
bool operator()(const array_entry_t< uint16_t > &v)
Definition portable_storage_to_bin.h:104
bool operator()(const array_entry_t< array_entry > &arra_ar)
Definition portable_storage_to_bin.h:130
bool operator()(const array_entry_t< bool > &v)
Definition portable_storage_to_bin.h:111
bool operator()(const array_entry_t< int32_t > &v)
Definition portable_storage_to_bin.h:107
t_stream & m_strm
Definition portable_storage_to_bin.h:85
bool operator()(const array_entry_t< uint32_t > &v)
Definition portable_storage_to_bin.h:103
bool pack_pod_array_type(uint8_t contained_type, const array_entry_t< t_pod_type > &arr_pod)
Definition portable_storage_to_bin.h:88
bool operator()(const array_entry_t< double > &v)
Definition portable_storage_to_bin.h:110
bool operator()(const array_entry_t< int8_t > &v)
Definition portable_storage_to_bin.h:109
bool operator()(const array_entry_t< uint8_t > &v)
Definition portable_storage_to_bin.h:105
Definition portable_storage_base.h:83
entry_container< t_entry_type >::type m_array
Definition portable_storage_base.h:139
Definition portable_storage_base.h:169
std::map< std::string, storage_entry > m_entries
Definition portable_storage_base.h:170
Definition portable_storage_to_bin.h:143
bool operator()(const int64_t &v)
Definition portable_storage_to_bin.h:159
t_stream & m_strm
Definition portable_storage_to_bin.h:144
storage_entry_store_visitor(t_stream &strm)
Definition portable_storage_to_bin.h:145
bool operator()(const section &v)
Definition portable_storage_to_bin.h:172
bool operator()(const uint8_t &v)
Definition portable_storage_to_bin.h:158
bool pack_pod_type(uint8_t type, const pod_type &v)
Definition portable_storage_to_bin.h:147
bool operator()(const uint16_t &v)
Definition portable_storage_to_bin.h:157
bool operator()(const int32_t &v)
Definition portable_storage_to_bin.h:160
bool operator()(const int16_t &v)
Definition portable_storage_to_bin.h:161
bool operator()(const double &v)
Definition portable_storage_to_bin.h:163
bool operator()(const uint64_t &v)
Definition portable_storage_to_bin.h:155
bool operator()(const int8_t &v)
Definition portable_storage_to_bin.h:162
bool operator()(const uint32_t &v)
Definition portable_storage_to_bin.h:156
bool operator()(const array_entry &v)
Definition portable_storage_to_bin.h:179
bool operator()(const std::string &v)
Definition portable_storage_to_bin.h:165
bool operator()(const bool &v)
Definition portable_storage_to_bin.h:164