ASAPCabinetFE
 
Loading...
Searching...
No Matches
VpsDatabaseLoader Class Reference

Loads the VPS database file in ASAPCabinetFE. More...

#include <vps_database_loader.h>

+ Collaboration diagram for VpsDatabaseLoader:

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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ VpsDatabaseLoader()

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.

Parameters
vpsDbPathThe file path to the VPS database (vpsdb.json).

Member Function Documentation

◆ getVpsDb()

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.

Returns
A constant reference to the loaded VPS database JSON.

◆ load()

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.

Parameters
progressOptional pointer to LoadingProgress for real-time updates.
Returns
True if loading succeeds, false on failure (e.g., file not found, invalid JSON).
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: