30 const std::string& aPath,
bool aLoadFromFile ) :
41 m_parent->ReleaseNestedSettings(
this );
54 if(
m_parent->m_internals->contains( ptr ) )
66 wxLogTrace(
traceSettings, wxT(
"NESTED_SETTINGS %s: Could not load from "
83 wxLogTrace(
traceSettings, wxT(
"%s: nested settings version could not be read!" ),
90 wxLogTrace(
traceSettings, wxT(
"%s: attempting migration from version %d to %d" ),
93 bool migrated =
false;
113 wxT(
"%s: warning: nested settings version %d is newer than latest (%d)" ),
116 else if( filever >= 0 )
118 wxLogTrace(
traceSettings, wxT(
"%s: schema version %d is current" ),
127 settings->LoadFromFile();
147 bool modified = !jsonObjectInParent
148 || !nlohmann::json::diff( *
m_internals, jsonObjectInParent.value() ).empty();
157 if( !param->ClearUnknownKeys() )
160 nlohmann::json::json_pointer ptr =
163 if(
m_parent->m_internals->m_original.contains( ptr ) )
164 m_parent->m_internals->m_original[ptr] = nlohmann::json::object();
167 if( modified || aForce )
171 wxLogTrace(
traceSettings, wxS(
"Stored NESTED_SETTINGS %s with schema %d" ),
180 wxLogTrace(
traceSettings, wxS(
"NESTED_SETTINGS %s: Could not store to %s at %s" ),
196 m_parent->AddNestedSettings(
this );
static nlohmann::json::json_pointer PointerFromString(std::string aPath)
Builds a JSON pointer based on a given string.
wxString m_filename
The filename (not including path) of this settings file (inicode)
std::vector< NESTED_SETTINGS * > m_nested_settings
Nested settings files that live inside this one, if any.
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
wxString GetFullFilename() const
bool Migrate()
Migrates the schema of this settings from the version in the file to the latest version.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
friend class NESTED_SETTINGS
int m_schemaVersion
Version of this settings schema.
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
wxString GetFilename() const
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)
std::string m_path
The path (in pointer format) of where to store this document in the parent.
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
virtual ~NESTED_SETTINGS()
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then saves the JSON document contents into the parent JSON_SETTINGS.
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath, bool aLoadFromFile=true)
bool LoadFromFile(const wxString &aDirectory="") override
Loads the JSON document from the parent and then calls Load()
@ NESTED
Not stored in a file, but inside another JSON_SETTINGS.
std::vector< FAB_LAYER_COLOR > dummy