Skip to content

ConfigSchema::Section

#include <mrx/core/config/ConfigSchema.hpp>
class mrx::core::ConfigSchema::Section
ReturnNameDescription
Section&required inlineDeclares a required property.
Section&optional inlineDeclares an optional property with a normalized default value.
Section&range inlineAdds an inclusive range constraint to the most recently declared property.
Section&validateAdds a custom constraint to the most recently declared property.

inline
template<typename T> inline Section& required(const QString& name)

Declares a required property.

This builder, allowing another property declaration or constraint.

NameTypeDescription
nameconst QString&Property name.

inline
template<typename T> inline Section& optional(const QString& name, const T& defaultValue)

Declares an optional property with a normalized default value.

This builder, allowing another property declaration or constraint.

NameTypeDescription
nameconst QString&Property name.
defaultValueconst T&Value used when the property is absent; constraints also apply to it.

inline
template<typename T> inline Section& range(const T& minimum, const T& maximum)

Adds an inclusive range constraint to the most recently declared property.

This builder.

NameTypeDescription
minimumconst T&Inclusive lower bound.
maximumconst T&Inclusive upper bound.

Section& validate(const std::function<bool(const QVariant &, QString*)>& validator)

Adds a custom constraint to the most recently declared property.

This builder.

NameTypeDescription
validatorconst std::function<bool(const QVariant &, QString*)>&Callback returning false when the value is invalid. The callback should write a descriptive reason to reason before returning false.