$darkmode
#include <interface.hpp>
Public Member Functions | |
| std::unique_ptr< Interface > | clone () const override |
| operator Box () const | |
| JsonType | type () const override |
| std::string | type_string () const override |
| Json | usage () const override |
| bool | is_required () const override |
| CRTP | require () && |
| CRTP | required (bool value) && |
| CRTP | reset_pointer () && |
| bool | has_description () const |
| void | set_description (std::string s) override |
| const std::string & | description () const override |
| CRTP | description (std::string desc) && |
Public Member Functions inherited from fable::schema::Interface | |
| virtual bool | is_variant () const |
| virtual Json | json_schema () const =0 |
| virtual bool | validate (const Conf &c, std::optional< SchemaError > &error) const =0 |
| virtual void | validate_or_throw (const Conf &c) const final |
| virtual std::optional< SchemaError > | fail (const Conf &c) const final |
| virtual bool | is_valid (const Conf &c) const final |
| virtual Json | to_json () const |
| virtual void | to_json (Json &) const =0 |
| virtual void | from_conf (const Conf &)=0 |
| virtual void | reset_ptr ()=0 |
Protected Member Functions | |
| Base (const Base< CRTP > &)=default | |
| Base (Base< CRTP > &&) noexcept=default | |
| Base< CRTP > & | operator= (const Base< CRTP > &)=default |
| Base< CRTP > & | operator= (Base< CRTP > &&) noexcept=default |
| Base (JsonType t, std::string desc) | |
| Base (JsonType t) | |
| Base (std::string desc) | |
| bool | validate_type (const Conf &c, std::optional< SchemaError > &err) const |
| template<typename... Args> | |
| SchemaError | error (const Conf &c, std::string_view format, Args &&... args) const |
| SchemaError | error (const ConfError &e) const |
| SchemaError | wrong_type (const Conf &c) const |
| template<typename... Args> | |
| bool | set_error (std::optional< SchemaError > &err, const Conf &c, std::string_view format, Args &&... args) const |
| bool | set_error (std::optional< SchemaError > &err, const ConfError &e) const |
| bool | set_error (std::optional< SchemaError > &err, SchemaError &&e) const |
| bool | set_wrong_type (std::optional< SchemaError > &err, const Conf &c) const |
| void | augment_schema (Json &j) const |
Protected Member Functions inherited from fable::schema::Interface | |
| Interface (const Interface &)=default | |
| Interface (Interface &&) noexcept=default | |
| Interface & | operator= (const Interface &)=default |
| Interface & | operator= (Interface &&) noexcept=default |
Protected Attributes | |
| JsonType | type_ {JsonType::null} |
| bool | required_ {false} |
| std::string | desc_ {} |
The Base class implements the Interface partially and is meant to cover the most commonly used types.
See most of the other schema types for how it is used.
|
inlineoverridevirtual |
Return a new instance of the object.
This is implemented by Base and allows us to wrap implementors of Interface with Schema.
Implements fable::schema::Interface.
|
inlineoverridevirtual |
Return human-readable description.
Implements fable::schema::Interface.
|
inlineoverridevirtual |
Return whether this interface needs to be set.
Implements fable::schema::Interface.
|
inlineoverridevirtual |
Set human-readable description.
Implements fable::schema::Interface.
|
inlineoverridevirtual |
Return the JSON type.
If this is a variant type of differing types, then null should be returned. Otherwise, the type remains unique and can be returned. A type that is null is almost always a variant type of some sort, if even only an optional type.
Implements fable::schema::Interface.
|
inlineoverridevirtual |
Return the type as a string.
The format of the string is:
"[array of] TYPE"
where TYPE is one of: null, object, boolean, float, integer, unsigned, string, and unknown.
Example output:
"object" "array of boolean" "array of object"
Implements fable::schema::Interface.
Reimplemented in fable::schema::Vector< IncludeConf, IncludeSchema >.
|
inlineoverridevirtual |
Return a compact JSON description of the schema. This is useful for human-readable error output.
Example output:
{ "field1": "boolean! :: lorem ipsum dolor sit amet", "field2": { "field2.1": "integer :: lorem ipsum dolor sit amet" "field2.2": "boolean :: lorem ipsum dolor sit amet" }, "field3": "array of integer :: lorem ipsum dolor sit amet", "field4": [{ "field4.1": "string :: lorem ipsum dolor sit amet" "field4.2": "boolean :: lorem ipsum dolor sit amet" }] }
When describing the schema of a primitive array, we can represent that as a single string. But when the array contains an object, we wrap a single object in an array. This isn't awfully consistent, but it's the best we can do.
Implements fable::schema::Interface.
|
inlineprotected |
Validate whether c is of the correct type.
This method is provided for an implementation to call in its fail() implementation. It is not called automatically.