Electroneum
epee::serialization Namespace Reference

Namespaces

 json
 

Classes

struct  array_entry_store_to_json_visitor
 
struct  array_entry_store_visitor
 
struct  array_entry_t
 
struct  base_serializable_types
 
struct  convert_to_integral
 
struct  convert_to_integral< from_type, to_type, false >
 
struct  convert_to_integral< from_type, to_type, true >
 
struct  convert_to_integral< std::string, uint64_t, false >
 
struct  convert_to_same
 
struct  convert_to_same< from_type, to_type, false >
 
struct  convert_to_same< from_type, to_type, true >
 
struct  convert_to_signed_unsigned
 
struct  convert_to_signed_unsigned< from_type, to_type, false, false >
 
struct  convert_to_signed_unsigned< from_type, to_type, false, true >
 
struct  convert_to_signed_unsigned< from_type, to_type, true, false >
 
struct  convert_to_signed_unsigned< from_type, to_type, true, true >
 
struct  entry_container
 
struct  entry_container< bool >
 
struct  get_first_value_visitor
 
struct  get_next_value_visitor
 
struct  get_value_visitor
 
struct  is_convertable
 
struct  kv_serialization_overloads_impl_is_base_serializable_types
 
struct  kv_serialization_overloads_impl_is_base_serializable_types< false >
 
struct  kv_serialization_overloads_impl_is_base_serializable_types< true >
 
class  portable_storage
 
struct  section
 
struct  selector
 
struct  selector< false >
 
struct  selector< true >
 
struct  storage_entry_store_to_json_visitor
 
struct  storage_entry_store_visitor
 
struct  throwable_buffer_reader
 

Typedefs

typedef 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
 
typedef boost::variant< uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, section, array_entrystorage_entry
 
typedef std::string binarybuffer
 
typedef sectionhsection
 
typedef array_entryharray
 

Functions

template<class t_type , class t_storage >
bool kv_serialize (const t_type &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_unserialize (t_type &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_serialize (const std::vector< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_unserialize (std::vector< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_serialize (const std::deque< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_unserialize (std::deque< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_serialize (const std::list< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_unserialize (std::list< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_serialize (const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<class t_type , class t_storage >
bool kv_unserialize (std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
 
template<>
storage_entry throwable_buffer_reader::read_se< std::string > ()
 
template<class t_struct >
bool load_t_from_json (t_struct &out, const std::string &json_buff)
 
template<class t_struct >
bool load_t_from_json_file (t_struct &out, const std::string &json_file)
 
template<class t_struct >
bool store_t_to_json (t_struct &str_in, std::string &json_buff, size_t indent=0, bool insert_newlines=true)
 
template<class t_struct >
std::string store_t_to_json (t_struct &str_in, size_t indent=0, bool insert_newlines=true)
 
template<class t_struct >
bool store_t_to_json_file (t_struct &str_in, const std::string &fpath)
 
template<class t_struct >
bool load_t_from_binary (t_struct &out, const epee::span< const uint8_t > binary_buff)
 
template<class t_struct >
bool load_t_from_binary (t_struct &out, const std::string &binary_buff)
 
template<class t_struct >
bool load_t_from_binary_file (t_struct &out, const std::string &binary_file)
 
template<class t_struct >
bool store_t_to_binary (t_struct &str_in, std::string &binary_buff, size_t indent=0)
 
template<class t_struct >
std::string store_t_to_binary (t_struct &str_in, size_t indent=0)
 
template<class pack_value , class t_stream >
size_t pack_varint_t (t_stream &strm, uint8_t type_or, size_t &pv)
 
template<class t_stream >
PRAGMA_WARNING_PUSH size_t pack_varint (t_stream &strm, size_t val)
 
template<class t_stream >
PRAGMA_WARNING_POP bool put_string (t_stream &strm, const std::string &v)
 
template<class t_stream >
bool pack_entry_to_buff (t_stream &strm, const array_entry &ae)
 
template<class t_stream >
bool pack_entry_to_buff (t_stream &strm, const storage_entry &se)
 
template<class t_stream >
bool pack_entry_to_buff (t_stream &strm, const section &sec)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const array_entry &ae, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const storage_entry &se, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const std::string &v, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const int8_t &v, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const uint8_t &v, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const bool &v, size_t indent, bool insert_newlines)
 
template<class t_stream , class t_type >
void dump_as_json (t_stream &strm, const t_type &v, size_t indent, bool insert_newlines)
 
template<class t_stream >
void dump_as_json (t_stream &strm, const section &sec, size_t indent, bool insert_newlines)
 
std::string make_indent (size_t indent)
 
template<typename from_type , typename to_type >
void convert_int_to_uint (const from_type &from, to_type &to)
 
template<typename from_type , typename to_type >
void convert_int_to_int (const from_type &from, to_type &to)
 
template<typename from_type , typename to_type >
void convert_uint_to_any_int (const from_type &from, to_type &to)
 
template<class from_type , class to_type >
void convert_t (const from_type &from, to_type &to)
 

Typedef Documentation

◆ array_entry

◆ binarybuffer

typedef std::string epee::serialization::binarybuffer

Definition at line 156 of file portable_storage_base.h.

◆ harray

◆ hsection

Definition at line 167 of file portable_storage_base.h.

◆ storage_entry

Definition at line 154 of file portable_storage_base.h.

Function Documentation

◆ convert_int_to_int()

template<typename from_type , typename to_type >
void epee::serialization::convert_int_to_int ( const from_type &  from,
to_type &  to 
)

Definition at line 56 of file portable_storage_val_converters.h.

57  {
58  CHECK_AND_ASSERT_THROW_MES(from >= boost::numeric::bounds<to_type>::lowest(), "int value overhead: try to set value " << from << " to type " << typeid(to_type).name() << " with lowest possible value = " << boost::numeric::bounds<to_type>::lowest());
60 DISABLE_CLANG_WARNING(tautological-constant-out-of-range-compare)
61  CHECK_AND_ASSERT_THROW_MES(from <= std::numeric_limits<to_type>::max(), "int value overhead: try to set value " << from << " to type " << typeid(to_type).name() << " with max possible value = " << std::numeric_limits<to_type>::max());
63  to = static_cast<to_type>(from);
64  }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
PUSH_WARNINGS
Definition: hash-ops.h:54
#define DISABLE_CLANG_WARNING(w)
Definition: warnings.h:25
int compare(MDB_val const *left, MDB_val const *right) noexcept
Definition: util.h:135
const char * name
#define POP_WARNINGS
Definition: warnings.h:17
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_int_to_uint()

template<typename from_type , typename to_type >
void epee::serialization::convert_int_to_uint ( const from_type &  from,
to_type &  to 
)

Definition at line 45 of file portable_storage_val_converters.h.

46  {
49  CHECK_AND_ASSERT_THROW_MES(from >=0, "unexpected int value with signed storage value less than 0, and unsigned receiver value");
51  CHECK_AND_ASSERT_THROW_MES(from <= std::numeric_limits<to_type>::max(), "int value overhead: try to set value " << from << " to type " << typeid(to_type).name() << " with max possible value = " << std::numeric_limits<to_type>::max());
52  to = static_cast<to_type>(from);
54  }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
#define DISABLE_GCC_AND_CLANG_WARNING(w)
Definition: warnings.h:28
PUSH_WARNINGS
Definition: hash-ops.h:54
STL namespace.
int compare(MDB_val const *left, MDB_val const *right) noexcept
Definition: util.h:135
const char * name
#define POP_WARNINGS
Definition: warnings.h:17
int less(MDB_val const *left, MDB_val const *right) noexcept
Definition: util.h:111
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_t()

template<class from_type , class to_type >
void epee::serialization::convert_t ( const from_type &  from,
to_type &  to 
)

Definition at line 197 of file portable_storage_val_converters.h.

198  {
200  }
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the caller graph for this function:

◆ convert_uint_to_any_int()

template<typename from_type , typename to_type >
void epee::serialization::convert_uint_to_any_int ( const from_type &  from,
to_type &  to 
)

Definition at line 66 of file portable_storage_val_converters.h.

67  {
70 DISABLE_CLANG_WARNING(tautological-constant-out-of-range-compare)
71  CHECK_AND_ASSERT_THROW_MES(from <= std::numeric_limits<to_type>::max(), "uint value overhead: try to set value " << from << " to type " << typeid(to_type).name() << " with max possible value = " << std::numeric_limits<to_type>::max());
72  to = static_cast<to_type>(from);
74  }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
PUSH_WARNINGS
Definition: hash-ops.h:54
#define DISABLE_CLANG_WARNING(w)
Definition: warnings.h:25
STL namespace.
int compare(MDB_val const *left, MDB_val const *right) noexcept
Definition: util.h:135
const char * name
#define POP_WARNINGS
Definition: warnings.h:17
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_as_json() [1/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const array_entry ae,
size_t  indent,
bool  insert_newlines 
)

Definition at line 111 of file portable_storage_to_json.h.

112  {
113  array_entry_store_to_json_visitor<t_stream> aesv(strm, indent, insert_newlines);
114  boost::apply_visitor(aesv, ae);
115  }
Here is the caller graph for this function:

◆ dump_as_json() [2/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const storage_entry se,
size_t  indent,
bool  insert_newlines 
)

Definition at line 118 of file portable_storage_to_json.h.

119  {
120  storage_entry_store_to_json_visitor<t_stream> sv(strm, indent, insert_newlines);
121  boost::apply_visitor(sv, se);
122  }

◆ dump_as_json() [3/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const std::string &  v,
size_t  indent,
bool  insert_newlines 
)

Definition at line 125 of file portable_storage_to_json.h.

126  {
127  strm << "\"" << misc_utils::parse::transform_to_escape_sequence(v) << "\"";
128  }
std::string transform_to_escape_sequence(const std::string &src)
Here is the call graph for this function:

◆ dump_as_json() [4/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const int8_t v,
size_t  indent,
bool  insert_newlines 
)

Definition at line 131 of file portable_storage_to_json.h.

132  {
133  strm << static_cast<int32_t>(v);
134  }

◆ dump_as_json() [5/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const uint8_t v,
size_t  indent,
bool  insert_newlines 
)

Definition at line 137 of file portable_storage_to_json.h.

138  {
139  strm << static_cast<int32_t>(v);
140  }

◆ dump_as_json() [6/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const bool v,
size_t  indent,
bool  insert_newlines 
)

Definition at line 143 of file portable_storage_to_json.h.

144  {
145  if(v)
146  strm << "true";
147  else
148  strm << "false";
149  }

◆ dump_as_json() [7/8]

template<class t_stream , class t_type >
void epee::serialization::dump_as_json ( t_stream &  strm,
const t_type &  v,
size_t  indent,
bool  insert_newlines 
)

Definition at line 154 of file portable_storage_to_json.h.

155  {
156  strm << v;
157  }

◆ dump_as_json() [8/8]

template<class t_stream >
void epee::serialization::dump_as_json ( t_stream &  strm,
const section sec,
size_t  indent,
bool  insert_newlines 
)

Definition at line 160 of file portable_storage_to_json.h.

161  {
162  size_t local_indent = indent + 1;
163  std::string newline = insert_newlines ? "\r\n" : "";
164  strm << "{" << newline;
165  std::string indent_str = make_indent(local_indent);
166  if(sec.m_entries.size())
167  {
168  auto it_last = --sec.m_entries.end();
169  for(auto it = sec.m_entries.begin(); it!= sec.m_entries.end();it++)
170  {
171  strm << indent_str << "\"" << misc_utils::parse::transform_to_escape_sequence(it->first) << "\"" << ": ";
172  dump_as_json(strm, it->second, local_indent, insert_newlines);
173  if(it_last != it)
174  strm << ",";
175  strm << newline;
176  }
177  }
178  strm << make_indent(indent) << "}";
179  }
::std::string string
Definition: gtest-port.h:1097
std::string transform_to_escape_sequence(const std::string &src)
std::string make_indent(size_t indent)
void dump_as_json(t_stream &strm, const section &sec, size_t indent, bool insert_newlines)
Here is the call graph for this function:

◆ kv_serialize() [1/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_serialize ( const t_type &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 396 of file keyvalue_serialization_overloads.h.

397  {
398  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
399  }
bool kv_serialize(const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the caller graph for this function:

◆ kv_serialize() [2/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_serialize ( const std::vector< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 408 of file keyvalue_serialization_overloads.h.

409  {
410  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
411  }
bool kv_serialize(const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_serialize() [3/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_serialize ( const std::deque< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 420 of file keyvalue_serialization_overloads.h.

421  {
422  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
423  }
bool kv_serialize(const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_serialize() [4/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_serialize ( const std::list< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 432 of file keyvalue_serialization_overloads.h.

433  {
434  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
435  }
bool kv_serialize(const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_serialize() [5/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_serialize ( const std::set< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 444 of file keyvalue_serialization_overloads.h.

445  {
446  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
447  }
bool kv_serialize(const std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_unserialize() [1/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_unserialize ( t_type &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 402 of file keyvalue_serialization_overloads.h.

403  {
404  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
405  }
bool kv_unserialize(std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the caller graph for this function:

◆ kv_unserialize() [2/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_unserialize ( std::vector< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 414 of file keyvalue_serialization_overloads.h.

415  {
416  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
417  }
bool kv_unserialize(std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_unserialize() [3/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_unserialize ( std::deque< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 426 of file keyvalue_serialization_overloads.h.

427  {
428  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
429  }
bool kv_unserialize(std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_unserialize() [4/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_unserialize ( std::list< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 438 of file keyvalue_serialization_overloads.h.

439  {
440  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
441  }
bool kv_unserialize(std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ kv_unserialize() [5/5]

template<class t_type , class t_storage >
bool epee::serialization::kv_unserialize ( std::set< t_type > &  d,
t_storage &  stg,
typename t_storage::hsection  hparent_section,
const char *  pname 
)

Definition at line 450 of file keyvalue_serialization_overloads.h.

451  {
452  return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
453  }
bool kv_unserialize(std::set< t_type > &d, t_storage &stg, typename t_storage::hsection hparent_section, const char *pname)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Here is the call graph for this function:

◆ load_t_from_binary() [1/2]

template<class t_struct >
bool epee::serialization::load_t_from_binary ( t_struct &  out,
const epee::span< const uint8_t binary_buff 
)

Definition at line 87 of file portable_storage_template_helper.h.

88  {
89  portable_storage ps;
90  bool rs = ps.load_from_binary(binary_buff);
91  if(!rs)
92  return false;
93 
94  return out.load(ps);
95  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_t_from_binary() [2/2]

template<class t_struct >
bool epee::serialization::load_t_from_binary ( t_struct &  out,
const std::string &  binary_buff 
)

Definition at line 98 of file portable_storage_template_helper.h.

99  {
100  return load_t_from_binary(out, epee::strspan<uint8_t>(binary_buff));
101  }
bool load_t_from_binary(t_struct &out, const std::string &binary_buff)
Here is the call graph for this function:

◆ load_t_from_binary_file()

template<class t_struct >
bool epee::serialization::load_t_from_binary_file ( t_struct &  out,
const std::string &  binary_file 
)

Definition at line 104 of file portable_storage_template_helper.h.

105  {
106  std::string f_buff;
107  if(!file_io_utils::load_file_to_string(binary_file, f_buff))
108  return false;
109 
110  return load_t_from_binary(out, f_buff);
111  }
::std::string string
Definition: gtest-port.h:1097
bool load_file_to_string(const std::string &path_to_file, std::string &target_str, size_t max_size=1000000000)
bool load_t_from_binary(t_struct &out, const std::string &binary_buff)
Here is the call graph for this function:

◆ load_t_from_json()

template<class t_struct >
bool epee::serialization::load_t_from_json ( t_struct &  out,
const std::string &  json_buff 
)

Definition at line 41 of file portable_storage_template_helper.h.

42  {
43  portable_storage ps;
44  bool rs = ps.load_from_json(json_buff);
45  if(!rs)
46  return false;
47 
48  return out.load(ps);
49  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_t_from_json_file()

template<class t_struct >
bool epee::serialization::load_t_from_json_file ( t_struct &  out,
const std::string &  json_file 
)

Definition at line 52 of file portable_storage_template_helper.h.

53  {
54  std::string f_buff;
55  if(!file_io_utils::load_file_to_string(json_file, f_buff))
56  return false;
57 
58  return load_t_from_json(out, f_buff);
59  }
::std::string string
Definition: gtest-port.h:1097
bool load_file_to_string(const std::string &path_to_file, std::string &target_str, size_t max_size=1000000000)
bool load_t_from_json(t_struct &out, const std::string &json_buff)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_indent()

std::string epee::serialization::make_indent ( size_t  indent)
inline

Definition at line 58 of file portable_storage_to_json.h.

59  {
60  return std::string(indent*2, ' ');
61  }
::std::string string
Definition: gtest-port.h:1097
Here is the caller graph for this function:

◆ pack_entry_to_buff() [1/3]

template<class t_stream >
bool epee::serialization::pack_entry_to_buff ( t_stream &  strm,
const array_entry ae 
)

Definition at line 187 of file portable_storage_to_bin.h.

188  {
189  array_entry_store_visitor<t_stream> aesv(strm);
190  return boost::apply_visitor(aesv, ae);
191  }
Here is the caller graph for this function:

◆ pack_entry_to_buff() [2/3]

template<class t_stream >
bool epee::serialization::pack_entry_to_buff ( t_stream &  strm,
const storage_entry se 
)

Definition at line 194 of file portable_storage_to_bin.h.

195  {
196  storage_entry_store_visitor<t_stream> sv(strm);
197  return boost::apply_visitor(sv, se);
198  }

◆ pack_entry_to_buff() [3/3]

template<class t_stream >
bool epee::serialization::pack_entry_to_buff ( t_stream &  strm,
const section sec 
)

Definition at line 201 of file portable_storage_to_bin.h.

202  {
203  typedef std::map<std::string, storage_entry>::value_type section_pair;
204  pack_varint(strm, sec.m_entries.size());
205  for(const section_pair& se: sec.m_entries)
206  {
207  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);
208  uint8_t len = static_cast<uint8_t>(se.first.size());
209  strm.write((const char*)&len, sizeof(len));
210  strm.write(se.first.data(), size_t(len));
211  pack_entry_to_buff(strm, se.second);
212  }
213  return true;
214  }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
PRAGMA_WARNING_PUSH size_t pack_varint(t_stream &strm, size_t val)
unsigned char uint8_t
Definition: stdint.h:124
bool pack_entry_to_buff(t_stream &strm, const section &sec)
Here is the call graph for this function:

◆ pack_varint()

template<class t_stream >
PRAGMA_WARNING_PUSH size_t epee::serialization::pack_varint ( t_stream &  strm,
size_t  val 
)

Definition at line 55 of file portable_storage_to_bin.h.

56  { //the first two bits always reserved for size information
57 
58  if(val <= 63)
59  {//mean enough one byte
60  return pack_varint_t<uint8_t>(strm, PORTABLE_RAW_SIZE_MARK_BYTE, val);
61  }
62  else if(val <= 16383)
63  {//mean need word
64  return pack_varint_t<uint16_t>(strm, PORTABLE_RAW_SIZE_MARK_WORD, val);
65  }else if(val <= 1073741823)
66  {//mean need dword
67  return pack_varint_t<uint32_t>(strm, PORTABLE_RAW_SIZE_MARK_DWORD, val);
68  }else
69  {
70  CHECK_AND_ASSERT_THROW_MES(val <= 4611686018427387903, "failed to pack varint - too big amount = " << val);
71  return pack_varint_t<uint64_t>(strm, PORTABLE_RAW_SIZE_MARK_INT64, val);
72  }
73  }
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
Definition: misc_log_ex.h:173
#define PORTABLE_RAW_SIZE_MARK_BYTE
#define PORTABLE_RAW_SIZE_MARK_WORD
#define PORTABLE_RAW_SIZE_MARK_DWORD
#define PORTABLE_RAW_SIZE_MARK_INT64
Here is the caller graph for this function:

◆ pack_varint_t()

template<class pack_value , class t_stream >
size_t epee::serialization::pack_varint_t ( t_stream &  strm,
uint8_t  type_or,
size_t &  pv 
)

Definition at line 41 of file portable_storage_to_bin.h.

42  {
43  pack_value v = (*((pack_value*)&pv)) << 2;
44  v |= type_or;
45  strm.write((const char*)&v, sizeof(pack_value));
46  return sizeof(pack_value);
47  }

◆ put_string()

template<class t_stream >
PRAGMA_WARNING_POP bool epee::serialization::put_string ( t_stream &  strm,
const std::string &  v 
)

Definition at line 77 of file portable_storage_to_bin.h.

78  {
79  pack_varint(strm, v.size());
80  if(v.size())
81  strm.write((const char*)v.data(), v.size());
82  return true;
83  }
PRAGMA_WARNING_PUSH size_t pack_varint(t_stream &strm, size_t val)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_t_to_binary() [1/2]

template<class t_struct >
bool epee::serialization::store_t_to_binary ( t_struct &  str_in,
std::string &  binary_buff,
size_t  indent = 0 
)

Definition at line 114 of file portable_storage_template_helper.h.

115  {
116  portable_storage ps;
117  str_in.store(ps);
118  return ps.store_to_binary(binary_buff);
119  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_t_to_binary() [2/2]

template<class t_struct >
std::string epee::serialization::store_t_to_binary ( t_struct &  str_in,
size_t  indent = 0 
)

Definition at line 122 of file portable_storage_template_helper.h.

123  {
124  std::string binary_buff;
125  store_t_to_binary(str_in, binary_buff, indent);
126  return binary_buff;
127  }
::std::string string
Definition: gtest-port.h:1097
std::string store_t_to_binary(t_struct &str_in, size_t indent=0)
Here is the call graph for this function:

◆ store_t_to_json() [1/2]

template<class t_struct >
bool epee::serialization::store_t_to_json ( t_struct &  str_in,
std::string &  json_buff,
size_t  indent = 0,
bool  insert_newlines = true 
)

Definition at line 62 of file portable_storage_template_helper.h.

63  {
64  portable_storage ps;
65  str_in.store(ps);
66  ps.dump_as_json(json_buff, indent, insert_newlines);
67  return true;
68  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_t_to_json() [2/2]

template<class t_struct >
std::string epee::serialization::store_t_to_json ( t_struct &  str_in,
size_t  indent = 0,
bool  insert_newlines = true 
)

Definition at line 71 of file portable_storage_template_helper.h.

72  {
73  std::string json_buff;
74  store_t_to_json(str_in, json_buff, indent, insert_newlines);
75  return json_buff;
76  }
std::string store_t_to_json(t_struct &str_in, size_t indent=0, bool insert_newlines=true)
::std::string string
Definition: gtest-port.h:1097
Here is the call graph for this function:

◆ store_t_to_json_file()

template<class t_struct >
bool epee::serialization::store_t_to_json_file ( t_struct &  str_in,
const std::string &  fpath 
)

Definition at line 79 of file portable_storage_template_helper.h.

80  {
81  std::string json_buff;
82  store_t_to_json(str_in, json_buff);
83  return file_io_utils::save_string_to_file(fpath, json_buff);
84  }
std::string store_t_to_json(t_struct &str_in, size_t indent=0, bool insert_newlines=true)
::std::string string
Definition: gtest-port.h:1097
bool save_string_to_file(const std::string &path_to_file, const std::string &str)
Definition: file_io_utils.h:73
Here is the call graph for this function:

◆ throwable_buffer_reader::read_se< std::string >()

Definition at line 202 of file portable_storage_from_bin.h.

203  {
205  return storage_entry(read<std::string>());
206  }
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
#define RECURSION_LIMITATION()