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

Typed application settings store. More...

#include <RADSettings.h>

Public Member Functions

 Settings (std::string fileName, Format format=Format::Json)
 Creates settings at fileName using format. More...
 
 Settings (AppIdentity identity, Format format=Format::Json)
 Creates settings under the platform config path from identity. More...
 
const std::string & fileName () const
 Returns backing file path. More...
 
Format format () const
 Returns file format. More...
 
bool load (std::string *error=nullptr)
 Loads settings; missing files are treated as empty settings. More...
 
bool save (std::string *error=nullptr) const
 Saves settings, creating parent directories when needed. More...
 
bool contains (const std::string &key) const
 Returns true when key exists. More...
 
void remove (const std::string &key)
 Removes a key. More...
 
void clear ()
 Clears all keys. More...
 
RADCore::RADJsonValue value (const std::string &key, RADCore::RADJsonValue defaultValue={}) const
 Returns a JSON value. More...
 
void setValue (const std::string &key, RADCore::RADJsonValue value)
 Sets a JSON value. More...
 
bool boolValue (const std::string &key, bool defaultValue=false) const
 Returns a bool. More...
 
int64_t intValue (const std::string &key, int64_t defaultValue=0) const
 Returns an integer. More...
 
double doubleValue (const std::string &key, double defaultValue=0.0) const
 Returns a double. More...
 
std::string stringValue (const std::string &key, const std::string &defaultValue={}) const
 Returns a string. More...
 
void setBool (const std::string &key, bool value)
 Sets a bool. More...
 
void setInt (const std::string &key, int64_t value)
 Sets an integer. More...
 
void setDouble (const std::string &key, double value)
 Sets a double. More...
 
void setString (const std::string &key, std::string value)
 Sets a string. More...
 

Static Public Member Functions

static std::string defaultFileName (const AppIdentity &identity, Format format=Format::Json)
 Returns a config file path for identity. More...
 

Detailed Description

Typed application settings store.

Constructor & Destructor Documentation

◆ Settings() [1/2]

RADSettings::Settings::Settings ( std::string  fileName,
Format  format = Format::Json 
)

Creates settings at fileName using format.

◆ Settings() [2/2]

RADSettings::Settings::Settings ( AppIdentity  identity,
Format  format = Format::Json 
)

Creates settings under the platform config path from identity.

Member Function Documentation

◆ boolValue()

bool RADSettings::Settings::boolValue ( const std::string &  key,
bool  defaultValue = false 
) const

Returns a bool.

◆ clear()

void RADSettings::Settings::clear ( )

Clears all keys.

◆ contains()

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

Returns true when key exists.

◆ defaultFileName()

static std::string RADSettings::Settings::defaultFileName ( const AppIdentity identity,
Format  format = Format::Json 
)
static

Returns a config file path for identity.

◆ doubleValue()

double RADSettings::Settings::doubleValue ( const std::string &  key,
double  defaultValue = 0.0 
) const

Returns a double.

◆ fileName()

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

Returns backing file path.

◆ format()

Format RADSettings::Settings::format ( ) const

Returns file format.

◆ intValue()

int64_t RADSettings::Settings::intValue ( const std::string &  key,
int64_t  defaultValue = 0 
) const

Returns an integer.

◆ load()

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

Loads settings; missing files are treated as empty settings.

◆ remove()

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

Removes a key.

◆ save()

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

Saves settings, creating parent directories when needed.

◆ setBool()

void RADSettings::Settings::setBool ( const std::string &  key,
bool  value 
)

Sets a bool.

◆ setDouble()

void RADSettings::Settings::setDouble ( const std::string &  key,
double  value 
)

Sets a double.

◆ setInt()

void RADSettings::Settings::setInt ( const std::string &  key,
int64_t  value 
)

Sets an integer.

◆ setString()

void RADSettings::Settings::setString ( const std::string &  key,
std::string  value 
)

Sets a string.

◆ setValue()

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

Sets a JSON value.

◆ stringValue()

std::string RADSettings::Settings::stringValue ( const std::string &  key,
const std::string &  defaultValue = {} 
) const

Returns a string.

◆ value()

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

Returns a JSON value.


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