Manages loading and saving of a single JSON document using StorageManager. More...
#include <JsonService.h>
Collaboration diagram for JsonService:Public Member Functions | |
| JsonService (StorageManager *storage) | |
| Construct a new JsonService. | |
| bool | load (const std::string &path) |
| Load a JSON file from storage. | |
| bool | save (const std::string &path) const |
| Save the current JSON data to storage. | |
| nlohmann::json & | data () |
| Access the internal JSON object. | |
| const nlohmann::json & | data () const |
| Const access to the internal JSON object. | |
| nlohmann::json & | root () |
| Alias for data(). | |
| const nlohmann::json & | root () const |
| Const alias for data(). | |
| nlohmann::json & | operator* () |
| Operator alias for data(). | |
| const nlohmann::json & | operator* () const |
| Const operator alias for data(). | |
| bool | hasValidData () const |
Private Attributes | |
| StorageManager * | storage |
| nlohmann::json | data_ |
Definition at line 27 of file JsonService.h.
| JsonService::JsonService | ( | StorageManager * | storage | ) |
Construct a new JsonService.
| storage | Pointer to a StorageManager for persistent access. |
| storage | Pointer to a StorageManager for persistent access. |
Definition at line 48 of file JsonService.cpp.
| nlohmann::json & JsonService::data | ( | ) |
Access the internal JSON object.
Definition at line 104 of file JsonService.cpp.
References data_.
Referenced by FrameworkModel::getValue(), FrameworkModel::load(), FrameworkModel::save(), FrameworkModel::saveAll(), and FrameworkModel::setValue().
Here is the caller graph for this function:| const nlohmann::json & JsonService::data | ( | ) | const |
| bool JsonService::hasValidData | ( | ) | const |
Definition at line 139 of file JsonService.cpp.
References data_.
| bool JsonService::load | ( | const std::string & | path | ) |
Load a JSON file from storage.
| path | File path to load from. |
| path | File path to load from. |
Definition at line 52 of file JsonService.cpp.
References data_, StorageManager::isMounted(), StorageManager::mount(), StorageManager::readFile(), storage, and TRACE.
Referenced by FrameworkModel::load().
Here is the call graph for this function:
Here is the caller graph for this function:| nlohmann::json & JsonService::operator* | ( | ) |
| const nlohmann::json & JsonService::operator* | ( | ) | const |
| nlohmann::json & JsonService::root | ( | ) |
| const nlohmann::json & JsonService::root | ( | ) | const |
| bool JsonService::save | ( | const std::string & | path | ) | const |
Save the current JSON data to storage.
| path | File path to save to. |
| path | File path to save to. |
Definition at line 85 of file JsonService.cpp.
References data_, StorageManager::isMounted(), StorageManager::mount(), storage, TRACE, and StorageManager::writeFile().
Referenced by FrameworkModel::save(), and FrameworkModel::saveAll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 84 of file JsonService.h.
Referenced by data(), data(), hasValidData(), load(), operator*(), operator*(), root(), root(), and save().
|
private |
Definition at line 83 of file JsonService.h.