ConfigSchema
Declares and validates a typed application configuration schema.
ConfigSchema separates the schema definition from the parser. The load() convenience method reads a QSettings INI file, while validate() accepts normalized dotted values from another parser. A typical declaration is:
Supported declarations include QString, bool, signed and unsigned integral types, floating point types, and Qt meta-object registered enumerations. Lists are intentionally not part of this initial API.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
ConfigSchema | Constructs an empty configuration schema. | |
Section | section | Declares a required section and returns its fluent builder. |
Section | optionalSection | Declares a section that may be absent and returns its fluent builder. |
ConfigResult | load const | Loads and validates an INI file using QSettings::IniFormat. |
ConfigResult | validate const | Validates normalized dotted values without coupling the schema to a parser. |
bool | hasSection const | Checks whether the schema declares a section. |
bool | hasProperty const | Checks whether the schema declares a property inside a section. |
ConfigResult | validatedValue const | Validates one proposed property value over an existing immutable Config snapshot. |
ConfigSchema
Section titled “ConfigSchema”Constructs an empty configuration schema.
Use section() and optionalSection() to declare the accepted configuration shape before calling load() or validate().
section
Section titled “section”Declares a required section and returns its fluent builder.
Returns
Section titled “Returns”Builder used to declare properties in the section.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name | const QString& | INI section name. |
optionalSection
Section titled “optionalSection”Declares a section that may be absent and returns its fluent builder.
Returns
Section titled “Returns”Builder used to declare properties in the optional section.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name | const QString& | INI section name. |
const
Loads and validates an INI file using QSettings::IniFormat.
Returns
Section titled “Returns”Successful normalized configuration or all parser/validation errors.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
fileName | const QString& | Path to the configuration file. |
const
validate
Section titled “validate”Validates normalized dotted values without coupling the schema to a parser.
Returns
Section titled “Returns”Successful normalized configuration or all validation errors.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
values | const QMap<QString, QVariant>& | Map keyed as section.property. |
const
hasSection
Section titled “hasSection”Checks whether the schema declares a section.
Returns
Section titled “Returns”true when the section exists in the schema, regardless of whether it is required.
This is schema introspection only. It does not inspect a loaded Config and does not imply that the section is present in a candidate value map.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
section | const QString& | Section name to look up exactly as declared through section() or optionalSection(). |
const
hasProperty
Section titled “hasProperty”Checks whether the schema declares a property inside a section.
Returns
Section titled “Returns”true when both the section and property are declared by the schema.
This is schema introspection only. It does not inspect a loaded Config and does not imply that the property is present in a candidate value map.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
section | const QString& | Section name to look up exactly as declared. |
property | const QString& | Property name to look up exactly as declared inside section. |
const
validatedValue
Section titled “validatedValue”Validates one proposed property value over an existing immutable Config snapshot.
Returns
Section titled “Returns”Successful normalized configuration for the overlay, or all schema/validation errors.
validatedValue() is the write-overlay companion to validate(). It first rejects undeclared section/property paths with UnknownSection or UnknownProperty so an application can block unsupported writes before it persists a value. For declared paths, it copies current, overlays section.property with value, and then runs the normal full-schema validation pass. Required siblings, defaults, conversions, range constraints, and custom validators are therefore evaluated in the context of the supplied snapshot without adding persistence or runtime settings-manager policy to ConfigSchema. The returned ConfigResult can be chained into another validatedValue() call by passing its value() after checking the result is successful.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
current | const Config& | Current successful Config snapshot; it is not modified. |
section | const QString& | Declared section that owns the property being changed. |
property | const QString& | Declared property receiving the proposed value. |
value | const QVariant& | Proposed raw value, parsed and validated using the property’s schema declaration. |