|
| virtual | ~IGroup ()=default |
| |
| virtual QString | readString (const QString &key, const QString &defaultValue={}) const =0 |
| |
| virtual int | readInt (const QString &key, int defaultValue=0) const =0 |
| |
| virtual bool | readBool (const QString &key, bool defaultValue=false) const =0 |
| |
| virtual double | readDouble (const QString &key, double defaultValue=0.0) const =0 |
| |
| virtual QColor | readColor (const QString &key, const QColor &defaultValue={}) const =0 |
| |
| virtual void | writeString (const QString &key, const QString &value)=0 |
| | Write a string.
|
| |
| virtual void | writeInt (const QString &key, int value)=0 |
| |
| virtual void | writeBool (const QString &key, bool value)=0 |
| |
| virtual void | writeDouble (const QString &key, double value)=0 |
| |
| virtual void | writeColor (const QString &key, const QColor &value)=0 |
| |
| virtual void | writeJson (const QString &key, const QJsonValue &value) |
| | Write a structured JSON value (array/object/scalar) natively where supported, or as a compact-JSON string for backends without a native representation.
|
| |
| virtual QJsonValue | readJson (const QString &key, const QJsonValue &defaultValue={}) const |
| | Read a structured JSON value.
|
| |
| virtual bool | hasKey (const QString &key) const =0 |
| |
| virtual void | deleteKey (const QString &key)=0 |
| |
| virtual QStringList | keyList () const =0 |
| | Enumerate scalar leaf keys directly under this group.
|
| |
| | IGroup (const IGroup &)=delete |
| |
| IGroup & | operator= (const IGroup &)=delete |
| |
Scoped view into a single configuration group.
Obtained from IBackend::group() as a unique_ptr. Implementations may restrict the number of concurrently live groups per backend (the bundled JsonBackend and QSettingsBackend enforce one-at-a-time — destroy the unique_ptr before asking the backend for another group).
Groups support dot-path nesting: "Snapping.Behavior.ZoneSpan" addresses a nested object tree in JsonBackend, and a plain "/"-joined group in QSettingsBackend. Consumers that need other naming semantics (e.g. per-screen overrides keyed by "Prefix:ScreenId") can plug in an IGroupPathResolver on the backend to intercept and rewrite group names before they reach storage.
| virtual QJsonValue PhosphorConfig::IGroup::readJson |
( |
const QString & |
key, |
|
|
const QJsonValue & |
defaultValue = {} |
|
) |
| const |
|
inlinevirtual |
Read a structured JSON value.
Returns defaultValue when the key is absent or unparseable.
The default implementation calls readString and parses the result. Uses hasKey (not string emptiness) to distinguish an absent key from a present empty-string, so empty-string values written through writeJson round-trip correctly. JsonBackend overrides to return the native JSON node directly without a string round-trip.
Reimplemented in PhosphorConfig::JsonGroup.
| virtual void PhosphorConfig::IGroup::writeJson |
( |
const QString & |
key, |
|
|
const QJsonValue & |
value |
|
) |
| |
|
inlinevirtual |
Write a structured JSON value (array/object/scalar) natively where supported, or as a compact-JSON string for backends without a native representation.
The default implementation serializes every value — including strings — to its compact JSON form before storing, so readJson can round-trip it by re-parsing. Strings land on disk quoted ("hello", not hello); consumers that need the raw string should go through writeString / readString directly. JsonBackend overrides this to keep the value as a native JSON node on disk.
Reimplemented in PhosphorConfig::JsonGroup.