|
| | JsonGroup (QJsonObject &root, QString groupName, JsonBackend *backend, View view=View::Effective) |
| | ~JsonGroup () override |
| QString | readString (const QString &key, const QString &defaultValue={}) const override |
| int | readInt (const QString &key, int defaultValue=0) const override |
| bool | readBool (const QString &key, bool defaultValue=false) const override |
| double | readDouble (const QString &key, double defaultValue=0.0) const override |
| QColor | readColor (const QString &key, const QColor &defaultValue={}) const override |
| void | writeString (const QString &key, const QString &value) override |
| | Write a string.
|
| void | writeInt (const QString &key, int value) override |
| void | writeBool (const QString &key, bool value) override |
| void | writeDouble (const QString &key, double value) override |
| void | writeColor (const QString &key, const QColor &value) override |
| void | writeJson (const QString &key, const QJsonValue &value) override |
| | Write a structured JSON value (array/object/scalar) natively where supported, or as a compact-JSON string for backends without a native representation.
|
| QJsonValue | readJson (const QString &key, const QJsonValue &defaultValue={}) const override |
| | Read a structured JSON value.
|
| bool | hasKey (const QString &key) const override |
| void | deleteKey (const QString &key) override |
| QStringList | keyList () const override |
| | Enumerate scalar leaf keys directly under this group.
|
| virtual | ~IGroup ()=default |
| | IGroup (const IGroup &)=delete |
| IGroup & | operator= (const IGroup &)=delete |
Scoped group view backed by a JsonBackend.
See IGroup for the contract; this class only adds JSON-specific coercion rules documented on its reader methods.
Only one group view is permitted per backend at a time. Debug builds assert; release builds warn. The backend advances its dirty flag on any write-to-storage through this view.
Reads (every read*, readJson, hasKey, keyList) see the backend's overlay laid over the file (see JsonBackend::setOverlay) unless the view was opened as View::Persisted. Writes and deleteKey always act on the file's values alone, so an overlay value is never written back, and deleting a key the overlay supplies leaves it readable.
| QJsonValue PhosphorConfig::JsonGroup::readJson |
( |
const QString & | key, |
|
|
const QJsonValue & | defaultValue = {} ) const |
|
overridevirtual |
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 from PhosphorConfig::IGroup.
| void PhosphorConfig::JsonGroup::writeJson |
( |
const QString & | key, |
|
|
const QJsonValue & | value ) |
|
overridevirtual |
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 from PhosphorConfig::IGroup.