23#include <nlohmann/json.hpp>
30 nlohmann::json js = nlohmann::json::array();
32 for(
const auto& el : *
m_ptr )
35 aSettings->
Set<nlohmann::json>(
m_path, js );
41 if( std::optional<nlohmann::json> js = aSettings.
GetJson(
m_path ) )
45 std::vector<wxString> val;
47 for(
const auto& el : js->items() )
63 if( std::optional<nlohmann::json> js = aSettings.
GetJson(
m_path ) )
69 for(
const auto& el : js->items() )
70 ( *m_ptr )[wxString( el.key().c_str(), wxConvUTF8 )] = el.value().get<wxString>();
73 else if( aResetIfMissing )
82 nlohmann::json js( {} );
84 for(
const auto& el : *
m_ptr )
86 std::string key( el.first.ToUTF8() );
90 aSettings->
Set<nlohmann::json>(
m_path, js );
96 if( std::optional<nlohmann::json> js = aSettings.
GetJson(
m_path ) )
100 if(
m_ptr->size() != js->size() )
103 std::map<wxString, wxString> val;
105 for(
const auto& el : js->items() )
107 wxString key( el.key().c_str(), wxConvUTF8 );
108 val[key] = el.value().get<wxString>();
111 return val == *
m_ptr;
118#if !defined( __MINGW32__ )
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
std::optional< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
bool m_readOnly
Indicates param pointer should never be overwritten.
std::string m_path
Address of the param in the json files.
Like a normal param, but with custom getter and setter functions.
std::vector< wxString > * m_ptr
Represents a map of <std::string, Value>.
wxString toFileFormat(const wxString &aString) const
wxString fromFileFormat(const wxString &aString) const
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
std::map< wxString, wxString > * m_ptr
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
std::map< wxString, wxString > m_default