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>
93 for(t_pod_type x: arr_pod.
m_array)
96 m_strm.write((
const char*)&x,
sizeof(t_pod_type));
141 template<
class t_stream>
146 template<
class pod_type>
151 m_strm.write((
const char*)&
v0,
sizeof(pod_type));
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));
Definition: binary_utils.h:36
storage_entry_store_visitor(t_stream &strm)
Definition: portable_storage_to_bin.h:145
bool operator()(const int64_t &v)
Definition: portable_storage_to_bin.h:159
bool operator()(const array_entry_t< int8_t > &v)
Definition: portable_storage_to_bin.h:109
#define PORTABLE_RAW_SIZE_MARK_BYTE
Definition: portable_storage_base.h:42
::std::string string
Definition: gtest-port.h:1097
bool operator()(const array_entry_t< section > &arr_sec)
Definition: portable_storage_to_bin.h:121
#define PORTABLE_RAW_SIZE_MARK_WORD
Definition: portable_storage_base.h:43
#define SERIALIZE_TYPE_INT32
Definition: portable_storage_base.h:53
#define SERIALIZE_TYPE_INT16
Definition: portable_storage_base.h:54
bool operator()(const double &v)
Definition: portable_storage_to_bin.h:163
int type
Definition: superscalar.cpp:50
const char * s
Definition: minissdp.c:596
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
unsigned short uint16_t
Definition: stdint.h:125
bool operator()(const array_entry_t< uint64_t > &v)
Definition: portable_storage_to_bin.h:102
Definition: portable_storage_to_bin.h:142
bool operator()(const int32_t &v)
Definition: portable_storage_to_bin.h:160
unsigned char uint8_t
Definition: stdint.h:124
#define SERIALIZE_TYPE_STRING
Definition: portable_storage_base.h:61
#define SERIALIZE_TYPE_INT64
Definition: portable_storage_base.h:52
#define CONVERT_POD(x)
Definition: portable_storage_bin_utils.h:43
bool operator()(const array_entry_t< array_entry > &arra_ar)
Definition: portable_storage_to_bin.h:130
Definition: portable_storage_base.h:82
#define SERIALIZE_TYPE_OBJECT
Definition: portable_storage_base.h:63
#define SERIALIZE_TYPE_UINT32
Definition: portable_storage_base.h:57
#define SERIALIZE_TYPE_UINT64
Definition: portable_storage_base.h:56
#define SERIALIZE_TYPE_BOOL
Definition: portable_storage_base.h:62
bool operator()(const array_entry_t< double > &v)
Definition: portable_storage_to_bin.h:110
bool operator()(const int16_t &v)
Definition: portable_storage_to_bin.h:161
bool operator()(const array_entry_t< int64_t > &v)
Definition: portable_storage_to_bin.h:106
bool operator()(const array_entry_t< std::string > &arr_str)
Definition: portable_storage_to_bin.h:112
unsigned int uint32_t
Definition: stdint.h:126
#define SERIALIZE_TYPE_UINT16
Definition: portable_storage_base.h:58
bool put_string(t_stream &strm, const std::string &v)
Definition: portable_storage_to_bin.h:74
t_stream & m_strm
Definition: portable_storage_to_bin.h:85
signed short int16_t
Definition: stdint.h:122
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
bool operator()(const uint8_t &v)
Definition: portable_storage_to_bin.h:158
bool operator()(const section &v)
Definition: portable_storage_to_bin.h:172
#define SERIALIZE_FLAG_ARRAY
Definition: portable_storage_base.h:66
bool pack_pod_type(uint8_t type, const pod_type &v)
Definition: portable_storage_to_bin.h:147
bool pack_entry_to_buff(t_stream &strm, const array_entry &ae)
Definition: portable_storage_to_bin.h:188
bool operator()(const bool &v)
Definition: portable_storage_to_bin.h:164
bool operator()(const std::string &v)
Definition: portable_storage_to_bin.h:165
unsigned __int64 uint64_t
Definition: stdint.h:136
#define SERIALIZE_TYPE_ARRAY
Definition: portable_storage_base.h:64
size_t pack_varint(t_stream &strm, size_t val)
Definition: portable_storage_to_bin.h:52
signed char int8_t
Definition: stdint.h:121
Definition: portable_storage_base.h:168
bool operator()(const array_entry_t< int16_t > &v)
Definition: portable_storage_to_bin.h:108
#define SERIALIZE_TYPE_INT8
Definition: portable_storage_base.h:55
bool operator()(const array_entry_t< bool > &v)
Definition: portable_storage_to_bin.h:111
entry_container< t_entry_type >::type m_array
Definition: portable_storage_base.h:139
#define SERIALIZE_TYPE_UINT8
Definition: portable_storage_base.h:59
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:39
#define SERIALIZE_TYPE_DOUBLE
Definition: portable_storage_base.h:60
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< uint8_t > &v)
Definition: portable_storage_to_bin.h:105
Definition: portable_storage_to_bin.h:83
#define v0(p)
Definition: aesb.c:116
signed __int64 int64_t
Definition: stdint.h:135
#define PORTABLE_RAW_SIZE_MARK_DWORD
Definition: portable_storage_base.h:44
size_t pack_varint_t(t_stream &strm, uint8_t type_or, size_t &pv)
Definition: portable_storage_to_bin.h:42
t_stream & m_strm
Definition: portable_storage_to_bin.h:144
#define PORTABLE_RAW_SIZE_MARK_INT64
Definition: portable_storage_base.h:45
array_entry_store_visitor(t_stream &strm)
Definition: portable_storage_to_bin.h:101
signed int int32_t
Definition: stdint.h:123
bool operator()(const array_entry &v)
Definition: portable_storage_to_bin.h:179
bool operator()(const array_entry_t< int32_t > &v)
Definition: portable_storage_to_bin.h:107
bool operator()(const uint32_t &v)
Definition: portable_storage_to_bin.h:156
std::map< std::string, storage_entry > m_entries
Definition: portable_storage_base.h:170
bool operator()(const int8_t &v)
Definition: portable_storage_to_bin.h:162
bool operator()(const array_entry_t< uint32_t > &v)
Definition: portable_storage_to_bin.h:103
bool operator()(const uint64_t &v)
Definition: portable_storage_to_bin.h:155
bool operator()(const uint16_t &v)
Definition: portable_storage_to_bin.h:157
bool operator()(const array_entry_t< uint16_t > &v)
Definition: portable_storage_to_bin.h:104