31 #ifndef LEDGER_CORE_PREFERENCESEDITOR_HPP 32 #define LEDGER_CORE_PREFERENCESEDITOR_HPP 34 #include "PreferencesBackend.hpp" 35 #include "Preferences.hpp" 36 #include "../api/PreferencesEditor.hpp" 38 #include <cereal/cereal.hpp> 39 #include <cereal/archives/portable_binary.hpp> 43 struct PreferencesChange;
50 std::shared_ptr<api::PreferencesEditor>
51 putString(
const std::string &key,
const std::string &value)
override;
53 std::shared_ptr<api::PreferencesEditor>
putInt(
const std::string &key, int32_t value)
override;
55 std::shared_ptr<api::PreferencesEditor>
putLong(
const std::string &key, int64_t value)
override;
57 std::shared_ptr<api::PreferencesEditor>
putBoolean(
const std::string &key,
bool value)
override;
59 std::shared_ptr<api::PreferencesEditor>
60 putStringArray(
const std::string &key,
const std::vector<std::string> &value)
override;
62 std::shared_ptr<api::PreferencesEditor>
remove(
const std::string &key)
override;
65 std::shared_ptr<PreferencesEditor> putObject(
const std::string& key, T&
object) {
67 ::cereal::PortableBinaryOutputArchive archive(is);
69 auto savedState = is.str();
70 putData(key, std::vector<uint8_t>((
const uint8_t *)savedState.data(),(
const uint8_t *)savedState.data() + savedState.length()));
71 return shared_from_this();
74 std::shared_ptr<api::PreferencesEditor>
75 putData(
const std::string &key,
const std::vector<uint8_t> &value)
override;
80 void clear()
override;
83 std::vector<PreferencesChange> _changes;
90 #endif //LEDGER_CORE_PREFERENCESEDITOR_HPP std::shared_ptr< api::PreferencesEditor > putString(const std::string &key, const std::string &value) override
Definition: PreferencesEditor.cpp:38
std::shared_ptr< api::PreferencesEditor > putLong(const std::string &key, int64_t value) override
Definition: PreferencesEditor.cpp:60
void commit() override
Definition: PreferencesEditor.cpp:104
Definition: PreferencesEditor.hpp:22
Definition: PreferencesEditor.hpp:46
std::shared_ptr< api::PreferencesEditor > putStringArray(const std::string &key, const std::vector< std::string > &value) override
Definition: PreferencesEditor.cpp:83
std::shared_ptr< api::PreferencesEditor > putData(const std::string &key, const std::vector< uint8_t > &value) override
Definition: PreferencesEditor.cpp:119
Definition: Preferences.hpp:50
void clear() override
Clear all preferences.
Definition: PreferencesEditor.cpp:109
Definition: Account.cpp:8
std::shared_ptr< api::PreferencesEditor > putBoolean(const std::string &key, bool value) override
Definition: PreferencesEditor.cpp:71
std::shared_ptr< api::PreferencesEditor > putInt(const std::string &key, int32_t value) override
Definition: PreferencesEditor.cpp:49