![]() |
Scanframe Modular Application 0.1.0
|
Class to store application configuration. Uses the global application settings or a given ini-file. More...
#include <ConfigStore.h>
Classes | |
struct | Scope |
Begins and ends a scope of settings for a section. When create it calls beginGroup(...) and when out of scop it calls endGroup(). More... | |
class | Values |
Type to create a string list accessible by keys. More... | |
Public Member Functions | |
ConfigStore (QObject *parent=nullptr) | |
Qt constructor initializing the instance using ApplicationSettings::global(). | |
ConfigStore (const QString &path, QObject *parent=nullptr) | |
Constructor creating a store from the given filepath. | |
ConfigStore (const ConfigStore &cs) | |
Copy constructor. | |
ConfigStore (ConfigStore &&) noexcept | |
Move constructor. | |
ConfigStore & | operator= (ConfigStore &) noexcept |
Copy operator. | |
ConfigStore & | operator= (ConfigStore &&) noexcept |
Move operator. | |
~ConfigStore () override | |
Overridden destructor. | |
ConfigStore & | assign (const ConfigStore &cfg_store) |
Initializes this store with the passed instance. | |
ConfigStore & | assign (const QString &filepath) |
Initializes this store with the passed ini-filepath. | |
QSettings & | operator() () |
Operator to get access to underlying QSettings object of this instance. | |
QString | getPath () const |
Gets the path of the current instance. | |
void | setKeyPrefix (QAnyStringView prefix) |
Sets the prefix for key names. | |
QString | getKeyPrefix () const |
Gets the prefix for key names. | |
QString | getString (QAnyStringView section, QAnyStringView key, QAnyStringView def={}) const |
Gets a section value from the store. | |
void | setString (QAnyStringView section, QAnyStringView key, QAnyStringView value) |
Sets a section value in the store. | |
std::string | getStdString (const std::string §ion, const std::string &key, const std::string &def) const |
Gets a section value from the store. | |
void | setStdString (const std::string §ion, const std::string &key, const std::string &value) |
Sets a section value in the store. | |
bool | getBool (QAnyStringView section, QAnyStringView key, bool def) const |
Gets a section value from the store. | |
void | setBool (QAnyStringView section, QAnyStringView key, bool value) |
Sets a section value in the store. | |
double | getFloat (QAnyStringView section, QAnyStringView key, double def) const |
Gets a section value from the store. | |
void | setFloat (QAnyStringView section, QAnyStringView key, double value) |
Sets a section value in the store. | |
int | getInt (QAnyStringView section, QAnyStringView key, int def=0) const |
Gets a section value from the store. | |
void | setInt (QAnyStringView section, QAnyStringView key, int value) |
Sets a section value in the store. | |
void | getKeys (QAnyStringView section, QStringList &keys) const |
Gets all keys from the given section. | |
QStringList | getKeys (QAnyStringView section) const |
Gets all keys from the given section. | |
void | removeKeys (QAnyStringView section) |
Deletes the keys but keeps the group/section. | |
void | removeSection (QAnyStringView section) |
Deletes all keys including the section. | |
bool | isSection (QAnyStringView section) const |
Check if a section exists. | |
void | removeKey (QAnyStringView section, QAnyStringView key) |
Removes the given key from the store. | |
void | setSectionValues (QAnyStringView section, const Values &values) |
Replaces the section content with the given key-values. | |
void | getSectionValues (QAnyStringView section, Values &values) const |
Gets the section content as mapped key-values. | |
QStringList | getSections () const |
Gets all sections from the store in a list. | |
bool | exists () |
Checks if the path exists. | |
void | setSectionDefault (QAnyStringView section) |
Default section when the section is empty '{}'. | |
QSettings & | getSettings () |
Class to store application configuration. Uses the global application settings or a given ini-file.
|
explicit |
Qt constructor initializing the instance using ApplicationSettings::global().
parent | Owner of the object. |
|
explicit |
Constructor creating a store from the given filepath.
path | File to use as ini format. |
parent | Owner of the object. |
|
explicit |
Copy constructor.
|
explicitnoexcept |
Move constructor.
|
override |
Overridden destructor.
ConfigStore & sf::ConfigStore::assign | ( | const ConfigStore & | cfg_store | ) |
Initializes this store with the passed instance.
ConfigStore & sf::ConfigStore::assign | ( | const QString & | filepath | ) |
Initializes this store with the passed ini-filepath.
bool sf::ConfigStore::exists | ( | ) |
Checks if the path exists.
bool sf::ConfigStore::getBool | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
bool | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
double sf::ConfigStore::getFloat | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
double | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
int sf::ConfigStore::getInt | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
int | def = 0 |
||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QString sf::ConfigStore::getKeyPrefix | ( | ) | const |
Gets the prefix for key names.
QStringList sf::ConfigStore::getKeys | ( | QAnyStringView | section | ) | const |
Gets all keys from the given section.
section | Section containing the keys. |
void sf::ConfigStore::getKeys | ( | QAnyStringView | section, |
QStringList & | keys | ||
) | const |
Gets all keys from the given section.
section | Section containing the keys. |
keys | Return value. |
QString sf::ConfigStore::getPath | ( | ) | const |
Gets the path of the current instance.
QStringList sf::ConfigStore::getSections | ( | ) | const |
Gets all sections from the store in a list.
void sf::ConfigStore::getSectionValues | ( | QAnyStringView | section, |
Values & | values | ||
) | const |
Gets the section content as mapped key-values.
section | Name of the section. |
values | Key and value map. |
QSettings & sf::ConfigStore::getSettings | ( | ) |
std::string sf::ConfigStore::getStdString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | def | ||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
QString sf::ConfigStore::getString | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QAnyStringView | def = {} |
||
) | const |
Gets a section value from the store.
section | When empty '{}' the default section is used. |
key | Name of the key to get. |
def | Default value when the key is not found in the store. |
bool sf::ConfigStore::isSection | ( | QAnyStringView | section | ) | const |
Check if a section exists.
section | Name of the section. |
QSettings & sf::ConfigStore::operator() | ( | ) |
Operator to get access to underlying QSettings object of this instance.
|
noexcept |
Move operator.
|
noexcept |
Copy operator.
void sf::ConfigStore::removeKey | ( | QAnyStringView | section, |
QAnyStringView | key | ||
) |
Removes the given key from the store.
section | |
key |
void sf::ConfigStore::removeKeys | ( | QAnyStringView | section | ) |
Deletes the keys but keeps the group/section.
section |
void sf::ConfigStore::removeSection | ( | QAnyStringView | section | ) |
Deletes all keys including the section.
section |
void sf::ConfigStore::setBool | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
bool | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setFloat | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
double | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setInt | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
int | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setKeyPrefix | ( | QAnyStringView | prefix | ) |
Sets the prefix for key names.
prefix | Names used as prefix. |
void sf::ConfigStore::setSectionDefault | ( | QAnyStringView | section | ) |
Default section when the section is empty '{}'.
section |
void sf::ConfigStore::setSectionValues | ( | QAnyStringView | section, |
const Values & | values | ||
) |
Replaces the section content with the given key-values.
section | Name of the section. |
values | Key and value map. |
void sf::ConfigStore::setStdString | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |
void sf::ConfigStore::setString | ( | QAnyStringView | section, |
QAnyStringView | key, | ||
QAnyStringView | value | ||
) |
Sets a section value in the store.
section | When empty '{}' the default section is used. |
key | Name of the key to set. |
value | Value to set. |