34 #include <boost/mpl/contains.hpp> 62 template<
class t_value>
65 template<
class t_value>
70 template<
class t_value>
72 template<
class t_value>
74 template<
class t_value>
76 template<
class t_value>
96 template<
class trace_policy>
105 template<
class entry_type>
121 template<
class trace_policy>
127 template<
class to_type>
132 template<
class from_type>
136 template<
class t_value>
139 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
141 if(!hparent_section) hparent_section = &
m_root;
147 boost::apply_visitor(gvv, *pentry);
152 template<
class t_value>
159 hparent_section = &
m_root;
168 *pentry = std::forward<t_value>(v);
170 CATCH_ENTRY(
"portable_storage::template<>set_value",
false);
173 template<
class entry_type>
176 static_assert(std::is_rvalue_reference<entry_type&&>(),
"unexpected copy of value");
178 CHECK_AND_ASSERT(psection,
nullptr);
179 CHECK_AND_ASSERT(!pentry_name.empty(),
nullptr);
180 auto ins_res = psection->
m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
181 return &ins_res.first->second;
182 CATCH_ENTRY(
"portable_storage::insert_new_entry_get_storage_entry",
nullptr);
185 template<
class to_type>
190 template<
class from_type>
193 const from_type* pv =
a.get_first_val();
201 template<
class t_value>
204 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
206 if(!hparent_section) hparent_section = &
m_root;
212 array_entry& ar_entry = boost::get<array_entry>(*pentry);
215 if(!boost::apply_visitor(gfv, ar_entry))
221 template<
class to_type>
226 template<
class from_type>
230 const from_type* pv =
a.get_next_val();
238 template<
class t_value>
241 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
243 CHECK_AND_ASSERT(hval_array,
false);
246 if(!boost::apply_visitor(gnv, ar_entry))
252 template<
class t_value>
256 static_assert(std::is_rvalue_reference<t_value&&>(),
"unexpected copy of value");
258 if(!hparent_section) hparent_section = &
m_root;
269 array_entry& arr = boost::get<array_entry>(*pentry);
276 CATCH_ENTRY(
"portable_storage::insert_first_value",
nullptr);
279 template<
class t_value>
283 static_assert(std::is_rvalue_reference<t_value&&>(),
"unexpected copy of value");
285 CHECK_AND_ASSERT(hval_array,
false);
293 CATCH_ENTRY(
"portable_storage::insert_next_value",
false);
Definition: binary_utils.h:36
bool delete_entry(const std::string &pentry_name, hsection hparent_section=nullptr)
t_entry_type & insert_next_value(t_entry_type &&v)
Definition: portable_storage_base.h:128
harray get_first_value(const std::string &value_name, t_value &target, hsection hparent_section)
Definition: portable_storage.h:202
const CharType(& source)[N]
Definition: pointer.h:1147
storage_entry * find_storage_entry(const std::string &pentry_name, hsection psection)
Definition: portable_storage.cpp:154
section m_root
Definition: portable_storage.h:102
array_entry * harray
Definition: portable_storage_base.h:175
hsection open_section(const std::string §ion_name, hsection hparent_section, bool create_if_notexist=false)
Definition: portable_storage.cpp:117
to_type & m_target
Definition: portable_storage.h:224
bool operator()(const array_entry_t< from_type > &a)
Definition: portable_storage.h:227
bool get_value(const std::string &value_name, t_value &val, hsection hparent_section)
Definition: portable_storage.h:137
::std::string string
Definition: gtest-port.h:1097
storage_entry meta_entry
Definition: portable_storage.h:50
A partial drop-in replacement for std::ostream.
Definition: byte_stream.h:57
bool dump_as_xml(std::string &targetObj, const std::string &root_name="")
Definition: portable_storage.h:122
epee::serialization::hsection hsection
Definition: portable_storage.h:48
int type
Definition: superscalar.cpp:50
bool get_next_value(harray hval_array, t_value &target)
Definition: portable_storage.h:239
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
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
void convert_t(const from_type &from, to_type &to)
Definition: portable_storage_val_converters.h:203
Definition: portable_storage.h:45
unsigned char uint8_t
Definition: stdint.h:124
bool operator()(const array_entry_t< from_type > &a)
Definition: portable_storage.h:191
Definition: portable_storage_base.h:82
Definition: portable_storage.h:186
bool dump_as_json(std::string &targetObj, size_t indent=0, bool insert_newlines=true)
Definition: portable_storage.cpp:70
t_entry_type & insert_first_val(t_entry_type &&v)
Definition: portable_storage_base.h:121
bool get_next_section(harray hSecArray, hsection &h_child_section)
Definition: portable_storage.cpp:196
harray insert_first_section(const std::string &pSectionName, hsection &hinserted_childsection, hsection hparent_section)
Definition: portable_storage.cpp:210
bool insert_next_value(harray hval_array, t_value &&target)
Definition: portable_storage.h:280
unsigned int uint32_t
Definition: stdint.h:126
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
hsection insert_new_section(const std::string &pentry_name, hsection psection)
Definition: portable_storage.cpp:166
bool load_from_json(const std::string &source)
Definition: portable_storage.cpp:80
Definition: byte_slice.h:68
to_type & m_target
Definition: portable_storage.h:188
void operator()(const from_type &v)
Definition: portable_storage.h:133
harray insert_first_value(const std::string &value_name, t_value &&target, hsection hparent_section)
Definition: portable_storage.h:253
epee::serialization::harray harray
Definition: portable_storage.h:49
size_t n_strings
Definition: portable_storage.h:56
Definition: portable_storage_base.h:168
bool set_value(const std::string &value_name, t_value &&target, hsection hparent_section)
Definition: portable_storage.h:153
size_t n_objects
Definition: portable_storage.h:54
size_t n_fields
Definition: portable_storage.h:55
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
virtual ~portable_storage()
Definition: portable_storage.h:60
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:39
hsection get_root_section()
Definition: portable_storage.h:103
to_type & m_target
Definition: portable_storage.h:130
get_first_value_visitor(to_type &target)
Definition: portable_storage.h:189
Definition: portable_storage.h:222
Definition: portable_storage.h:52
bool store_to_binary(byte_slice &target, std::size_t initial_buffer_size=8192)
Definition: portable_storage.cpp:46
get_next_value_visitor(to_type &target)
Definition: portable_storage.h:225
bool insert_next_section(harray hSecArray, hsection &hinserted_childsection)
Definition: portable_storage.cpp:234
bool load_from_binary(const std::string &target, const limits_t *limits=nullptr)
Definition: portable_storage.h:91
harray get_first_section(const std::string &pSectionName, hsection &h_child_section, hsection hparent_section)
Definition: portable_storage.cpp:175
portable_storage()
Definition: portable_storage.h:59
bool load_from_binary(const epee::span< const uint8_t > target, const limits_t *limits=nullptr)
Definition: portable_storage.cpp:87
std::map< std::string, storage_entry > m_entries
Definition: portable_storage_base.h:170
get_value_visitor(to_type &target)
Definition: portable_storage.h:131
Definition: portable_storage.h:128
storage_entry * insert_new_entry_get_storage_entry(const std::string &pentry_name, hsection psection, entry_type &&entry)
Definition: portable_storage.h:174
indent
Definition: transfer.py:36