6#include "phosphorconfig_export.h"
51class PHOSPHORCONFIG_EXPORT
Store :
public QObject
87 T
read(
const QString& group,
const QString& key)
const
89 static_assert(
sizeof(T) == 0,
90 "PhosphorConfig::Store::read<T> is only implemented for QString, int, bool, double, "
91 "QColor, QVariantMap, QVariantList — extend store.cpp with a new specialization to add "
102 QVariant
readVariant(
const QString& group,
const QString& key)
const;
138 void write(
const QString& group,
const QString& key,
const QVariant& value);
149 void reset(
const QString& group,
const QString& key);
210 void changed(
const QString& group,
const QString& key);
214 std::unique_ptr<Private> d;
Pluggable configuration backend.
Definition IBackend.h:151
QJsonObject defaultsToJson() const
Produce a JSON snapshot of every declared key's SCHEMA DEFAULT, independent of current values.
IBackend * backend() const
Direct access for callers that still need the backend (e.g.
QJsonObject exportToJson() const
Produce a JSON snapshot of every declared key's current value.
Store(IBackend *backend, Schema schema, QObject *parent=nullptr)
Construct a store that borrows backend and applies schema.
const Schema & schema() const
The schema the store was constructed with.
void resetGroup(const QString &group)
Reset every key declared in group.
bool hasExplicitValue(const QString &group, const QString &key) const
Whether key is physically stored, as opposed to being served from the schema default.
bool commit()
Durable flush: the backend's commit(), which never defers.
T read(const QString &group, const QString &key) const
Read a declared key.
Definition Store.h:87
void reset(const QString &group, const QString &key)
Reset one key to its schema default.
void changed(const QString &group, const QString &key)
Emitted after any successful write() or reset() operation.
void resetAll()
Reset every declared key in every declared group. Extras are untouched.
bool sync()
Flush the underlying backend.
bool importFromJson(const QJsonObject &snapshot)
Overwrite declared keys from snapshot.
void write(const QString &group, const QString &key, const QVariant &value)
Write a value.
QVariant readVariant(const QString &group, const QString &key) const
Read as QVariant.
Definition HostDirectory.h:19
Declarative description of a configuration store.
Definition Schema.h:127