46 explicit ConfigStore(
const QString& path, QObject* parent =
nullptr);
87 QSettings& operator()();
93 QString getPath() const;
99 void setKeyPrefix(QAnyStringView prefix);
104 QString getKeyPrefix() const;
113 QString getString(QAnyStringView section, QAnyStringView key, QAnyStringView def = {})
const;
121 void setString(QAnyStringView section, QAnyStringView key, QAnyStringView value);
130 std::string
getStdString(
const std::string& section,
const std::string& key,
const std::string& def)
const;
138 void setStdString(
const std::string& section,
const std::string& key,
const std::string& value);
147 bool getBool(QAnyStringView section, QAnyStringView key,
bool def)
const;
155 void setBool(QAnyStringView section, QAnyStringView key,
bool value);
164 double getFloat(QAnyStringView section, QAnyStringView key,
double def)
const;
172 void setFloat(QAnyStringView section, QAnyStringView key,
double value);
181 int getInt(QAnyStringView section, QAnyStringView key,
int def = 0)
const;
189 void setInt(QAnyStringView section, QAnyStringView key,
int value);
196 void getKeys(QAnyStringView section, QStringList& keys)
const;
203 QStringList
getKeys(QAnyStringView section)
const;
229 void removeKey(QAnyStringView section, QAnyStringView key);
Type to create a string list accessible by keys.
Definition ConfigStore.h:22
ssize_t index_type
Definition ConfigStore.h:25
index_type indexOfKey(QAnyStringView key) const
Gets the index of the given key in the map.
Class to store application configuration. Uses the global application settings or a given ini-file.
Definition ConfigStore.h:16
int getInt(QAnyStringView section, QAnyStringView key, int def=0) const
Gets a section value from the store.
void removeKey(QAnyStringView section, QAnyStringView key)
Removes the given key from the store.
void getSectionValues(QAnyStringView section, Values &values) const
Gets the section content as mapped key-values.
QStringList getKeys(QAnyStringView section) const
Gets all keys from the given section.
void setInt(QAnyStringView section, QAnyStringView key, int value)
Sets a section value in the store.
ConfigStore(const QString &path, QObject *parent=nullptr)
Constructor creating a store from the given filepath.
bool getBool(QAnyStringView section, QAnyStringView key, bool def) const
Gets a section value from the store.
bool isSection(QAnyStringView section) const
Check if a section exists.
ConfigStore(const ConfigStore &cs)
Copy constructor.
void setSectionValues(QAnyStringView section, const Values &values)
Replaces the section content with the given key-values.
bool exists()
Checks if the path exists.
void removeSection(QAnyStringView section)
Deletes all keys including the section.
void setString(QAnyStringView section, QAnyStringView key, QAnyStringView value)
Sets a section value in the store.
ConfigStore(ConfigStore &&) noexcept
Move constructor.
void setStdString(const std::string §ion, const std::string &key, const std::string &value)
Sets a section value in the store.
void getKeys(QAnyStringView section, QStringList &keys) const
Gets all keys from the given section.
double getFloat(QAnyStringView section, QAnyStringView key, double def) const
Gets a section value from 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 setFloat(QAnyStringView section, QAnyStringView key, double value)
Sets a section value in the store.
void setBool(QAnyStringView section, QAnyStringView key, bool value)
Sets a section value in the store.
void removeKeys(QAnyStringView section)
Deletes the keys but keeps the group/section.
void setSectionDefault(QAnyStringView section)
Default section when the section is empty '{}'.
ConfigStore(QObject *parent=nullptr)
Qt constructor initializing the instance using ApplicationSettings::global().
QStringList getSections() const
Gets all sections from the store in a list.
QSettings & getSettings()
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10
Begins and ends a scope of settings for a section. When create it calls beginGroup(....
Definition ConfigStore.h:267
QSettings & settings()
Gets the settings instance with the section/group set.
ConfigStore & _configStore
Holds the reference to the associated ConfigStore instance.
Definition ConfigStore.h:289
Scope(ConfigStore &cs, QAnyStringView section)
Constructor passing a section of the scope.