#include <portable_storage.h>
|
| | portable_storage () |
| |
| virtual | ~portable_storage () |
| |
| hsection | open_section (const std::string §ion_name, hsection hparent_section, bool create_if_notexist=false) |
| |
| template<class t_value > |
| bool | get_value (const std::string &value_name, t_value &val, hsection hparent_section) |
| |
| bool | get_value (const std::string &value_name, storage_entry &val, hsection hparent_section) |
| |
| template<class t_value > |
| bool | set_value (const std::string &value_name, const t_value &target, hsection hparent_section) |
| |
| template<class t_value > |
| harray | get_first_value (const std::string &value_name, t_value &target, hsection hparent_section) |
| |
| template<class t_value > |
| bool | get_next_value (harray hval_array, t_value &target) |
| |
| template<class t_value > |
| harray | insert_first_value (const std::string &value_name, const t_value &target, hsection hparent_section) |
| |
| template<class t_value > |
| bool | insert_next_value (harray hval_array, const t_value &target) |
| |
| harray | get_first_section (const std::string &pSectionName, hsection &h_child_section, hsection hparent_section) |
| |
| bool | get_next_section (harray hSecArray, hsection &h_child_section) |
| |
| harray | insert_first_section (const std::string &pSectionName, hsection &hinserted_childsection, hsection hparent_section) |
| |
| bool | insert_next_section (harray hSecArray, hsection &hinserted_childsection) |
| |
| bool | delete_entry (const std::string &pentry_name, hsection hparent_section=nullptr) |
| |
| bool | store_to_binary (binarybuffer &target) |
| |
| bool | load_from_binary (const epee::span< const uint8_t > target) |
| |
| bool | load_from_binary (const std::string &target) |
| |
| template<class trace_policy > |
| bool | dump_as_xml (std::string &targetObj, const std::string &root_name="") |
| |
| bool | dump_as_json (std::string &targetObj, size_t indent=0, bool insert_newlines=true) |
| |
| bool | load_from_json (const std::string &source) |
| |
Definition at line 50 of file portable_storage.h.
◆ harray
◆ hsection
◆ meta_entry
◆ portable_storage()
| epee::serialization::portable_storage::portable_storage |
( |
| ) |
|
|
inline |
◆ ~portable_storage()
| virtual epee::serialization::portable_storage::~portable_storage |
( |
| ) |
|
|
inlinevirtual |
◆ delete_entry()
| bool epee::serialization::portable_storage::delete_entry |
( |
const std::string & |
pentry_name, |
|
|
hsection |
hparent_section = nullptr |
|
) |
| |
◆ dump_as_json()
| bool epee::serialization::portable_storage::dump_as_json |
( |
std::string & |
targetObj, |
|
|
size_t |
indent = 0, |
|
|
bool |
insert_newlines = true |
|
) |
| |
|
inline |
Definition at line 114 of file portable_storage.h.
117 std::stringstream ss;
121 CATCH_ENTRY(
"portable_storage::dump_as_json",
false)
#define CATCH_ENTRY(location, return_val)
void dump_as_json(t_stream &strm, const array_entry &ae, size_t indent, bool insert_newlines)
◆ dump_as_xml()
template<class trace_policy >
| bool epee::serialization::portable_storage::dump_as_xml |
( |
std::string & |
targetObj, |
|
|
const std::string & |
root_name = "" |
|
) |
| |
◆ get_first_section()
| harray epee::serialization::portable_storage::get_first_section |
( |
const std::string & |
pSectionName, |
|
|
hsection & |
h_child_section, |
|
|
hsection |
hparent_section |
|
) |
| |
|
inline |
Definition at line 408 of file portable_storage.h.
411 if(!hparent_section) hparent_section = &m_root;
412 storage_entry* pentry = find_storage_entry(sec_name, hparent_section);
417 array_entry& ar_entry = boost::get<array_entry>(*pentry);
418 if(ar_entry.type() !=
typeid(array_entry_t<section>))
420 array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(ar_entry);
421 section* psec = sec_array.get_first_val();
424 h_child_section = psec;
426 CATCH_ENTRY(
"portable_storage::get_first_section",
nullptr);
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
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
◆ get_first_value()
template<class t_value >
| harray epee::serialization::portable_storage::get_first_value |
( |
const std::string & |
value_name, |
|
|
t_value & |
target, |
|
|
hsection |
hparent_section |
|
) |
| |
Definition at line 315 of file portable_storage.h.
317 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
319 if(!hparent_section) hparent_section = &m_root;
320 storage_entry* pentry = find_storage_entry(value_name, hparent_section);
325 array_entry& ar_entry = boost::get<array_entry>(*pentry);
327 get_first_value_visitor<t_value> gfv(target);
328 if(!boost::apply_visitor(gfv, ar_entry))
◆ get_next_section()
| bool epee::serialization::portable_storage::get_next_section |
( |
harray |
hSecArray, |
|
|
hsection & |
h_child_section |
|
) |
| |
|
inline |
Definition at line 430 of file portable_storage.h.
434 if(hsec_array->type() !=
typeid(array_entry_t<section>))
436 array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(*hsec_array);
437 h_child_section = sec_array.get_next_val();
441 CATCH_ENTRY(
"portable_storage::get_next_section",
false);
#define CHECK_AND_ASSERT(expr, fail_ret_val)
◆ get_next_value()
template<class t_value >
| bool epee::serialization::portable_storage::get_next_value |
( |
harray |
hval_array, |
|
|
t_value & |
target |
|
) |
| |
Definition at line 353 of file portable_storage.h.
355 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
359 get_next_value_visitor<t_value> gnv(target);
360 if(!boost::apply_visitor(gnv, ar_entry))
◆ get_value() [1/2]
| bool epee::serialization::portable_storage::get_value |
( |
const std::string & |
value_name, |
|
|
storage_entry & |
val, |
|
|
hsection |
hparent_section |
|
) |
| |
|
inline |
Definition at line 232 of file portable_storage.h.
235 if(!hparent_section) hparent_section = &m_root;
236 storage_entry* pentry = find_storage_entry(value_name, hparent_section);
◆ get_value() [2/2]
template<class t_value >
| bool epee::serialization::portable_storage::get_value |
( |
const std::string & |
value_name, |
|
|
t_value & |
val, |
|
|
hsection |
hparent_section |
|
) |
| |
Definition at line 216 of file portable_storage.h.
218 BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
220 if(!hparent_section) hparent_section = &m_root;
221 storage_entry* pentry = find_storage_entry(value_name, hparent_section);
225 get_value_visitor<t_value> gvv(val);
226 boost::apply_visitor(gvv, *pentry);
◆ insert_first_section()
| harray epee::serialization::portable_storage::insert_first_section |
( |
const std::string & |
pSectionName, |
|
|
hsection & |
hinserted_childsection, |
|
|
hsection |
hparent_section |
|
) |
| |
|
inline |
Definition at line 445 of file portable_storage.h.
448 if(!hparent_section) hparent_section = &m_root;
449 storage_entry* pentry = find_storage_entry(sec_name, hparent_section);
452 pentry = insert_new_entry_get_storage_entry(sec_name, hparent_section,
array_entry(array_entry_t<section>()));
459 array_entry& ar_entry = boost::get<array_entry>(*pentry);
460 if(ar_entry.type() !=
typeid(array_entry_t<section>))
463 array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(ar_entry);
464 hinserted_childsection = &sec_array.insert_first_val(section());
466 CATCH_ENTRY(
"portable_storage::insert_first_section",
nullptr);
◆ insert_first_value()
template<class t_value >
| harray epee::serialization::portable_storage::insert_first_value |
( |
const std::string & |
value_name, |
|
|
const t_value & |
target, |
|
|
hsection |
hparent_section |
|
) |
| |
Definition at line 367 of file portable_storage.h.
370 if(!hparent_section) hparent_section = &m_root;
371 storage_entry* pentry = find_storage_entry(value_name, hparent_section);
374 pentry = insert_new_entry_get_storage_entry(value_name, hparent_section,
array_entry(array_entry_t<t_value>()));
381 array_entry& arr = boost::get<array_entry>(*pentry);
382 if(arr.type() !=
typeid(array_entry_t<t_value>))
385 array_entry_t<t_value>& arr_typed = boost::get<array_entry_t<t_value> >(arr);
386 arr_typed.insert_first_val(target);
388 CATCH_ENTRY(
"portable_storage::insert_first_value",
nullptr);
◆ insert_next_section()
| bool epee::serialization::portable_storage::insert_next_section |
( |
harray |
hSecArray, |
|
|
hsection & |
hinserted_childsection |
|
) |
| |
|
inline |
Definition at line 470 of file portable_storage.h.
475 false,
"unexpected type(not 'section') in insert_next_section, type: " << hsec_array->type().name());
477 array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(*hsec_array);
478 hinserted_childsection = &sec_array.insert_next_value(section());
480 CATCH_ENTRY(
"portable_storage::insert_next_section",
false);
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
◆ insert_next_value()
template<class t_value >
| bool epee::serialization::portable_storage::insert_next_value |
( |
harray |
hval_array, |
|
|
const t_value & |
target |
|
) |
| |
Definition at line 392 of file portable_storage.h.
398 false,
"unexpected type in insert_next_value: " <<
typeid(array_entry_t<t_value>).name());
400 array_entry_t<t_value>& arr_typed = boost::get<array_entry_t<t_value> >(*hval_array);
401 arr_typed.insert_next_value(target);
403 CATCH_ENTRY(
"portable_storage::insert_next_value",
false);
◆ load_from_binary() [1/2]
Definition at line 153 of file portable_storage.h.
156 if(
source.size() <
sizeof(storage_block_header))
158 LOG_ERROR(
"portable_storage: wrong binary format, packet size = " <<
source.size() <<
" less than expected sizeof(storage_block_header)=" <<
sizeof(storage_block_header));
161 storage_block_header* pbuff = (storage_block_header*)
source.data();
166 LOG_ERROR(
"portable_storage: wrong binary format - signature mismatch");
171 LOG_ERROR(
"portable_storage: wrong binary format - unknown format ver = " << pbuff->m_ver);
175 throwable_buffer_reader buf_reader(
source.data()+
sizeof(storage_block_header),
source.size()-
sizeof(storage_block_header));
176 buf_reader.read(m_root);
178 CATCH_ENTRY(
"portable_storage::load_from_binary",
false);
const CharType(& source)[N]
#define PORTABLE_STORAGE_SIGNATUREA
#define PORTABLE_STORAGE_SIGNATUREB
#define PORTABLE_STORAGE_FORMAT_VER
std::map< std::string, storage_entry > m_entries
◆ load_from_binary() [2/2]
| bool epee::serialization::portable_storage::load_from_binary |
( |
const std::string & |
target | ) |
|
|
inline |
Definition at line 88 of file portable_storage.h.
bool load_from_binary(const epee::span< const uint8_t > target)
◆ load_from_json()
| bool epee::serialization::portable_storage::load_from_json |
( |
const std::string & |
source | ) |
|
|
inline |
Definition at line 124 of file portable_storage.h.
128 CATCH_ENTRY(
"portable_storage::load_from_json",
false)
bool load_from_json(const std::string &buff_json, t_storage &stg)
◆ open_section()
| hsection epee::serialization::portable_storage::open_section |
( |
const std::string & |
section_name, |
|
|
hsection |
hparent_section, |
|
|
bool |
create_if_notexist = false |
|
) |
| |
|
inline |
Definition at line 182 of file portable_storage.h.
185 hparent_section = hparent_section ? hparent_section:&m_root;
186 storage_entry* pentry = find_storage_entry(section_name, hparent_section);
189 if(!create_if_notexist)
191 return insert_new_section(section_name, hparent_section);
195 if(pentry->type() !=
typeid(section))
197 if(create_if_notexist)
202 return &boost::get<section>(*pentry);
203 CATCH_ENTRY(
"portable_storage::open_section",
nullptr);
◆ set_value()
template<class t_value >
| bool epee::serialization::portable_storage::set_value |
( |
const std::string & |
value_name, |
|
|
const t_value & |
target, |
|
|
hsection |
hparent_section |
|
) |
| |
Definition at line 246 of file portable_storage.h.
248 BOOST_MPL_ASSERT(( boost::mpl::contains<boost::mpl::push_front<storage_entry::types, storage_entry>::type, t_value> ));
251 hparent_section = &m_root;
252 storage_entry* pentry = find_storage_entry(value_name, hparent_section);
255 pentry = insert_new_entry_get_storage_entry(value_name, hparent_section, v);
262 CATCH_ENTRY(
"portable_storage::template<>set_value",
false);
◆ store_to_binary()
| bool epee::serialization::portable_storage::store_to_binary |
( |
binarybuffer & |
target | ) |
|
|
inline |
Definition at line 138 of file portable_storage.h.
141 std::stringstream ss;
146 ss.write((
const char*)&sbh,
sizeof(storage_block_header));
150 CATCH_ENTRY(
"portable_storage::store_to_binary",
false)
bool pack_entry_to_buff(t_stream &strm, const array_entry &ae)
The documentation for this class was generated from the following file:
- /home/abuild/rpmbuild/BUILD/electroneum-4.0.0.0/contrib/epee/include/storages/portable_storage.h