Top100
Your Personal Movie List (C++17 CLI + library)
Loading...
Searching...
No Matches
Configuration (persistent settings)

Classes

struct  AppConfig
 Persistent application configuration stored in a single JSON file. More...
 

Functions

std::string getConfigPath ()
 Resolve the configuration file path for this run.
 
std::string getDefaultDataPath ()
 Compute the default data file path for movies JSON.
 
AppConfig loadConfig ()
 Load configuration from disk, creating defaults if missing.
 
void saveConfig (const AppConfig &cfg)
 Persist configuration to disk.
 
bool configureOmdb (AppConfig &cfg, const std::string &key, const std::function< bool(const std::string &)> &verify)
 Configure OMDb credentials in the active config.
 

Detailed Description

Function Documentation

◆ configureOmdb()

bool configureOmdb ( AppConfig cfg,
const std::string &  key,
const std::function< bool(const std::string &)> &  verify 
)

Configure OMDb credentials in the active config.

Parameters
cfgActive configuration (modified in-place and persisted on success)
keyCandidate OMDb API key
verifyFunction that returns true if the key is valid
Returns
true if configuration succeeded (key accepted and saved)
Postcondition
On success: cfg.omdbApiKey is set, cfg.omdbEnabled=true, and the config file is updated.
Here is the call graph for this function:

◆ getConfigPath()

std::string getConfigPath ( )

Resolve the configuration file path for this run.

Returns
Absolute path to the active config file.
Note
If TOP100_CONFIG_PATH is set, it takes precedence; otherwise ~/.top100_config.json is used.
Here is the caller graph for this function:

◆ getDefaultDataPath()

std::string getDefaultDataPath ( )

Compute the default data file path for movies JSON.

Returns
Absolute path "$HOME/top100/top100.json".
Here is the caller graph for this function:

◆ loadConfig()

AppConfig loadConfig ( )

Load configuration from disk, creating defaults if missing.

Returns
Loaded configuration; if the file did not exist, a new one is created and returned.
Exceptions
std::runtime_erroron unrecoverable I/O errors (e.g., permission issues).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveConfig()

void saveConfig ( const AppConfig cfg)

Persist configuration to disk.

Parameters
cfgConfiguration to save.
Note
Creates parent directories for the config file if needed.
Here is the call graph for this function:
Here is the caller graph for this function: