Loads the VPS database file in ASAPCabinetFE. More...
#include <vps_database_loader.h>
Public Member Functions | |
VpsDatabaseLoader (const std::string &vpsDbPath) | |
Constructs a VpsDatabaseLoader instance. | |
bool | load (LoadingProgress *progress=nullptr) |
Loads the VPS database from the specified file path. | |
const nlohmann::json & | getVpsDb () const |
Retrieves the loaded VPS database JSON. | |
Loads the VPS database file in ASAPCabinetFE.
This class handles the loading of the VPS database (vpsdb.json) from a specified file path into a nlohmann::json object. It validates the JSON structure (array or object with a 'tables' array), tracks progress with LoadingProgress, and provides access to the loaded data. The path is configurable via the constructor, with potential for configUI enhancements (e.g., custom validation rules).
VpsDatabaseLoader::VpsDatabaseLoader | ( | const std::string & | vpsDbPath | ) |
Constructs a VpsDatabaseLoader instance.
Initializes the loader with the path to the VPS database file, which will be used during the loading process.
vpsDbPath | The file path to the VPS database (vpsdb.json). |
const nlohmann::json & VpsDatabaseLoader::getVpsDb | ( | ) | const |
Retrieves the loaded VPS database JSON.
Returns a constant reference to the loaded JSON data, which is either an array of table entries or adjusted to be so from an object with a 'tables' array.
bool VpsDatabaseLoader::load | ( | LoadingProgress * | progress = nullptr | ) |
Loads the VPS database from the specified file path.
Parses the vpsdb.json file at vpsDbPath_ into a nlohmann::json object. Validates that the JSON is either an array or an object with a 'tables' array, adjusting the internal storage accordingly. Progress is tracked via LoadingProgress if provided, updating currentTablesLoaded with the number of entries loaded.
progress | Optional pointer to LoadingProgress for real-time updates. |