RADLib
RADical C++ application framework
RADCore::RADSettings Class Reference

JSON-file-backed key/value settings helper. More...

#include <RADCore.h>

Public Member Functions

 RADSettings (std::string fileName)
 Creates settings bound to fileName. More...
 
const std::string & fileName () const
 Returns backing file path. More...
 
bool load (std::string *error=nullptr)
 Loads settings from disk. More...
 
bool save (std::string *error=nullptr) const
 Saves settings to disk. More...
 
bool contains (const std::string &key) const
 Returns true when key exists. More...
 
RADJsonValue value (const std::string &key, RADJsonValue defaultValue={}) const
 Returns value for key or defaultValue. More...
 
void setValue (const std::string &key, RADJsonValue value)
 Sets value for key. More...
 
void remove (const std::string &key)
 Removes key. More...
 
void clear ()
 Removes all settings. More...
 

Detailed Description

JSON-file-backed key/value settings helper.

Constructor & Destructor Documentation

◆ RADSettings()

RADCore::RADSettings::RADSettings ( std::string  fileName)
explicit

Creates settings bound to fileName.

Member Function Documentation

◆ clear()

void RADCore::RADSettings::clear ( )

Removes all settings.

◆ contains()

bool RADCore::RADSettings::contains ( const std::string &  key) const

Returns true when key exists.

◆ fileName()

const std::string& RADCore::RADSettings::fileName ( ) const

Returns backing file path.

◆ load()

bool RADCore::RADSettings::load ( std::string *  error = nullptr)

Loads settings from disk.

◆ remove()

void RADCore::RADSettings::remove ( const std::string &  key)

Removes key.

◆ save()

bool RADCore::RADSettings::save ( std::string *  error = nullptr) const

Saves settings to disk.

◆ setValue()

void RADCore::RADSettings::setValue ( const std::string &  key,
RADJsonValue  value 
)

Sets value for key.

◆ value()

RADJsonValue RADCore::RADSettings::value ( const std::string &  key,
RADJsonValue  defaultValue = {} 
) const

Returns value for key or defaultValue.


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