From 919790e8080cffb1b7ff1e54bfddf74a572e4713 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 21 Mar 2024 14:31:40 +0100 Subject: [PATCH] some temporary commits --- .../keyvalue_serialization_overloads.h | 2 +- .../epee/include/storages/portable_storage.h | 16 ++-- .../portable_storage_extended_for_doc.h | 96 +++++++++++++++++++ src/gui/qt-daemon/layout | 2 +- utils/Directory.Build.props.in | 1 + 5 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 contrib/epee/include/storages/portable_storage_extended_for_doc.h diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index c79c56b2..42397206 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -315,7 +315,7 @@ namespace epee struct selector { template - static bool serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname, bool doc_mode = false, const t_type& doc_substitute = t_type()) + static bool serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname, bool doc_mode = false, const t_type& doc_substitute = t_type(), const std::string& description = std::string()) { return kv_serialize( (doc_mode ? doc_substitute:d), stg, hparent_section, pname); } diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h index 0a8b8127..2b41cdfc 100644 --- a/contrib/epee/include/storages/portable_storage.h +++ b/contrib/epee/include/storages/portable_storage.h @@ -44,15 +44,19 @@ namespace epee /************************************************************************/ /* */ /************************************************************************/ - class portable_storage + template + class portable_storage_base { public: - typedef epee::serialization::hsection hsection; + //typedef epee::serialization::hsection hsection; + typedef t_section hasection; typedef epee::serialization::harray harray; typedef storage_entry meta_entry; - portable_storage(){} - virtual ~portable_storage(){} + portable_storage_base + (){} + virtual ~portable_storage_base + (){} hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false); template bool get_value(const std::string& value_name, t_value& val, hsection hparent_section); @@ -107,8 +111,8 @@ namespace epee }; #pragma pack(pop) }; - inline - bool portable_storage::dump_as_json(std::string& buff, size_t indent /* = 0 */, end_of_line_t eol /* = eol_crlf */) + template + bool portable_storage_base::dump_as_json(std::string& buff, size_t indent /* = 0 */, end_of_line_t eol /* = eol_crlf */) { TRY_ENTRY(); std::stringstream ss; diff --git a/contrib/epee/include/storages/portable_storage_extended_for_doc.h b/contrib/epee/include/storages/portable_storage_extended_for_doc.h new file mode 100644 index 00000000..35de4c65 --- /dev/null +++ b/contrib/epee/include/storages/portable_storage_extended_for_doc.h @@ -0,0 +1,96 @@ +// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Andrey N. Sabelnikov nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + + + +#pragma once + +#include "portable_storage.h" + +namespace epee +{ + namespace serialization + { + /************************************************************************/ + /* */ + /************************************************************************/ + class portable_storage_extended: public portable_storage + { + public: + typedef epee::serialization::hsection hsection; + typedef epee::serialization::harray harray; + typedef storage_entry meta_entry; + + portable_storage_extended(){} + virtual ~portable_storage_extended(){} + hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false); + template + 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 + bool set_value(const std::string& value_name, const t_value& target, hsection hparent_section); + + //serial access for arrays of values -------------------------------------- + //values + template + harray get_first_value(const std::string& value_name, t_value& target, hsection hparent_section); + template + bool get_next_value(harray hval_array, t_value& target); + template + harray insert_first_value(const std::string& value_name, const t_value& target, hsection hparent_section); + template + bool insert_next_value(harray hval_array, const t_value& target); + //sections + 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); + //------------------------------------------------------------------------ + //delete entry (section, value or array) + bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr); + //------------------------------------------------------------------------------- + bool store_to_binary(binarybuffer& target); + bool load_from_binary(const binarybuffer& target); + template + bool dump_as_xml(std::string& targetObj, const std::string& root_name = ""); + bool dump_as_json(std::string& targetObj, size_t indent = 0, end_of_line_t eol = eol_crlf); + bool load_from_json(const std::string& source); + + template + bool enum_entries(hsection hparent_section, cb_t cb); + private: + section m_root; + hsection get_root_section() {return &m_root;} + storage_entry* find_storage_entry(const std::string& pentry_name, hsection psection); + template + storage_entry* insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, const entry_type& entry); + + hsection insert_new_section(const std::string& pentry_name, hsection psection); + }; + + //--------------------------------------------------------------------------------------------------------------- + } +} diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index d593aa34..f8e9556f 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit d593aa3485395d7cc0415519dc1fc079de82e0ea +Subproject commit f8e9556fbaccd49841ce91afc3c90c8e3142ac95 diff --git a/utils/Directory.Build.props.in b/utils/Directory.Build.props.in index 168abb6a..5f263a21 100644 --- a/utils/Directory.Build.props.in +++ b/utils/Directory.Build.props.in @@ -3,5 +3,6 @@ true true + 11