$darkmode
fable::schema::Number< T > Class Template Reference
Inheritance diagram for fable::schema::Number< T >:
[legend]
Collaboration diagram for fable::schema::Number< T >:
[legend]

Public Types

using Type = T
 

Public Member Functions

template<typename X = T, std::enable_if_t< std::is_integral< X >::value &&std::is_unsigned< X >::value, int > = 0>
 Number (Type *ptr, std::string &&desc)
 
template<typename X = T, std::enable_if_t< std::is_integral< X >::value &&std::is_signed< X >::value, int > = 0>
 Number (Type *ptr, std::string &&desc)
 
template<typename X = T, std::enable_if_t< std::is_floating_point< X >::value, int > = 0>
 Number (Type *ptr, std::string &&desc)
 
minimum () const
 
bool exclusive_minimum () const
 
Number< T > minimum (T value) &&
 
Number< T > exclusive_minimum (T value) &&
 
maximum () const
 
bool exclusive_maximum () const
 
Number< T > maximum (T value) &&
 
Number< T > exclusive_maximum (T value) &&
 
std::pair< T, T > bounds () const
 
Number< T > bounds (T min, T max) &&
 
Number< T > bounds_with (T min, T max, std::initializer_list< T > whitelisted) &&
 
const std::set< T > & whitelist () const
 
Number< T > whitelist (T x) &&
 
Number< T > whitelist (std::initializer_list< T > xs) &&
 
void insert_whitelist (T x)
 
const std::set< T > & blacklist () const
 
Number< T > blacklist (T x) &&
 
Number< T > blacklist (std::initializer_list< T > xs) &&
 
void insert_blacklist (T x)
 
Json json_schema () const override
 
void validate (const Conf &c) const override
 
void to_json (Json &j) const override
 
void from_conf (const Conf &c) override
 
Json serialize (const Type &x) const
 
Type deserialize (const Conf &c) const
 
void reset_ptr () override
 
- Public Member Functions inherited from fable::schema::Base< Number< T > >
 Base (JsonType t, std::string &&desc)
 
 Base (JsonType t)
 
 Base (std::string &&desc)
 
Interfaceclone () const override
 
 operator Box () const
 
JsonType type () const override
 
std::string type_string () const override
 
Json usage () const override
 
bool is_required () const override
 
Number< T > require () &&
 
Number< T > required (bool value) &&
 
Number< T > reset_pointer () &&
 
bool has_description () const
 
void set_description (const std::string &s) override
 
void set_description (std::string &&s)
 
const std::string & description () const override
 
Number< T > description (std::string &&desc) &&
 
- Public Member Functions inherited from fable::schema::Interface
virtual bool is_variant () const
 
virtual bool is_valid (const Conf &c) const
 
virtual Json to_json () const
 

Additional Inherited Members

- Protected Member Functions inherited from fable::schema::Base< Number< T > >
void validate_type (const Conf &c) const
 
void throw_error (const Conf &c, const char *format, Args... args) const
 
void throw_error (const ConfError &e) const
 
void throw_wrong_type (const Conf &c) const
 
void augment_schema (Json &j) const
 
- Protected Attributes inherited from fable::schema::Base< Number< T > >
JsonType type_
 
bool required_
 
std::string desc_
 

Member Function Documentation

◆ from_conf()

template<typename T >
void fable::schema::Number< T >::from_conf ( const Conf )
overridevirtual

Apply the input JSON configuration.

This does not validate the input.

Implements fable::schema::Interface.

Here is the call graph for this function:

◆ json_schema()

template<typename T >
Json fable::schema::Number< T >::json_schema ( ) const
overridevirtual

Return the JSON schema.

Example output:

{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "stand-in no-operation simulator", "properties": { "vehicles": { "description": "list of vehicle names to make available", "items": { "type": "string" }, "type": "array" } }, "title": "nop", "additionalProperties": false, "type": "object" }

See the following links for the specification:

Implements fable::schema::Interface.

◆ reset_ptr()

template<typename T >
void fable::schema::Number< T >::reset_ptr ( )
overridevirtual

Reset the internal pointer to nullptr, protecting against invalid access.

This should be used when a schema is used after the backing data has been deleted.

Implements fable::schema::Interface.

Here is the call graph for this function:

◆ to_json()

template<typename T >
void fable::schema::Number< T >::to_json ( Json ) const
overridevirtual

Return the current value of the destination.

Warning: This is NOT an efficient operation, but it can be useful for cases where speed is not important.

Implements fable::schema::Interface.

◆ validate()

template<typename T >
void fable::schema::Number< T >::validate ( const Conf c) const
overridevirtual

Validate the input JSON configuration.

If you don't have a Conf but would like to validate a Json type, then construct a Conf on the fly:

s.validate(Conf{j});

This function is not provided inline to prevent incorrect use.

Implements fable::schema::Interface.


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