29 const std::string& aPath,
bool aLoadFromFile ) :
31 m_parent( aParent ), m_path( aPath )
65 wxLogTrace(
traceSettings, wxT(
"NESTED_SETTINGS %s: Could not load from "
82 wxLogTrace(
traceSettings, wxT(
"%s: nested settings version could not be read!" ),
89 wxLogTrace(
traceSettings, wxT(
"%s: attempting migration from version %d to %d" ),
92 bool migrated =
false;
112 wxT(
"%s: warning: nested settings version %d is newer than latest (%d)" ),
115 else if( filever >= 0 )
117 wxLogTrace(
traceSettings, wxT(
"%s: schema version %d is current" ),
137 bool modified =
Store();
141 if( !jsonObjectInParent )
143 else if( !nlohmann::json::diff( *
m_internals, jsonObjectInParent.value() ).empty() )
146 if( modified || aForce )
150 wxLogTrace(
traceSettings, wxS(
"Stored NESTED_SETTINGS %s with schema %d" ),
159 wxLogTrace(
traceSettings, wxS(
"NESTED_SETTINGS %s: Could not store to %s at %s" ),
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....
wxString m_filename
The filename (not including path) of this settings file (inicode)
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.
void ReleaseNestedSettings(NESTED_SETTINGS *aSettings)
Saves and frees a nested settings object, if it exists within this one.
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
friend class NESTED_SETTINGS
int m_schemaVersion
Version of this settings schema.
void AddNestedSettings(NESTED_SETTINGS *aSettings)
Transfers ownership of a given NESTED_SETTINGS to this object.
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.
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