Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorConfig::IGroup Class Referenceabstract

Scoped view into a single configuration group. More...

#include <phosphor-config/include/PhosphorConfig/IBackend.h>

Inheritance diagram for PhosphorConfig::IGroup:
[legend]

Public Member Functions

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
 
IGroupoperator= (const IGroup &)=delete
 

Protected Member Functions

 IGroup ()=default
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~IGroup()

virtual PhosphorConfig::IGroup::~IGroup ( )
virtualdefault

◆ IGroup() [1/2]

PhosphorConfig::IGroup::IGroup ( const IGroup )
delete

◆ IGroup() [2/2]

PhosphorConfig::IGroup::IGroup ( )
protecteddefault

Member Function Documentation

◆ deleteKey()

virtual void PhosphorConfig::IGroup::deleteKey ( const QString &  key)
pure virtual

◆ hasKey()

virtual bool PhosphorConfig::IGroup::hasKey ( const QString &  key) const
pure virtual

◆ keyList()

virtual QStringList PhosphorConfig::IGroup::keyList ( ) const
pure virtual

Enumerate scalar leaf keys directly under this group.

Nested sub-groups (dot-path children in JsonBackend) are NOT included — consumers that want to purge stale keys without touching declared descendants can iterate this list against the schema. Order is implementation-defined.

Implemented in PhosphorConfig::JsonGroup, and PhosphorConfig::QSettingsGroup.

◆ operator=()

IGroup & PhosphorConfig::IGroup::operator= ( const IGroup )
delete

◆ readBool()

virtual bool PhosphorConfig::IGroup::readBool ( const QString &  key,
bool  defaultValue = false 
) const
pure virtual

◆ readColor()

virtual QColor PhosphorConfig::IGroup::readColor ( const QString &  key,
const QColor &  defaultValue = {} 
) const
pure virtual

◆ readDouble()

virtual double PhosphorConfig::IGroup::readDouble ( const QString &  key,
double  defaultValue = 0.0 
) const
pure virtual

◆ readInt()

virtual int PhosphorConfig::IGroup::readInt ( const QString &  key,
int  defaultValue = 0 
) const
pure virtual

◆ readJson()

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.

◆ readString()

virtual QString PhosphorConfig::IGroup::readString ( const QString &  key,
const QString &  defaultValue = {} 
) const
pure virtual

◆ writeBool()

virtual void PhosphorConfig::IGroup::writeBool ( const QString &  key,
bool  value 
)
pure virtual

◆ writeColor()

virtual void PhosphorConfig::IGroup::writeColor ( const QString &  key,
const QColor &  value 
)
pure virtual

◆ writeDouble()

virtual void PhosphorConfig::IGroup::writeDouble ( const QString &  key,
double  value 
)
pure virtual

◆ writeInt()

virtual void PhosphorConfig::IGroup::writeInt ( const QString &  key,
int  value 
)
pure virtual

◆ writeJson()

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.

◆ writeString()

virtual void PhosphorConfig::IGroup::writeString ( const QString &  key,
const QString &  value 
)
pure virtual

Write a string.

Stored verbatim — no content-dependent reinterpretation.

Callers that need to persist structured data (array/object) should go through writeJson, which preserves the native JSON type where the backend supports it (JsonBackend stores as a native array/object; QSettingsBackend stringifies).

Implemented in PhosphorConfig::JsonGroup, and PhosphorConfig::QSettingsGroup.


The documentation for this class was generated from the following file: