libnick 2024.12.0
A cross-platform base for native Nickvision applications.
|
The purpose of DataFileBase
is to act as a base when defining your own data objects that you would like to be saved and retrieved from disk.
Here are some key points when defining your own configuration objects:
const std::string& key
and const std::string& appName
parameters and pass it to DataFileBase
's constructor.key
and appName
in your own implementation, it is required for DataFileBase
's functionality and will be filled-in by the DataFileManager
.DataFileBase
exposes a protected m_json
object which you must use in your implementation of getting and storing variables of your data object.m_json
object is not used, your data object will not be stored to disk correctly.save
method on your configuration object when you want to save the configuration to disk. Writing to the m_json
(of type boost::json::object
) object is not enough to trigger saving the file on disk.Here is an example of a custom configuration object using DataFileBase
: