pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Parsnip::SchemaBase Class Referenceabstract

#include <parsnip_schema.h>

Inheritance diagram for Parsnip::SchemaBase:
Inheritance graph
[legend]

Public Member Functions

virtual SchemaBasecreateCopy () const =0
 Create an identical, deep copy of the schema. More...
 
virtual ~SchemaBase ()=default
 
virtual void validate (const Parsnip::Data &entry) const =0
 Verify that Data matches the schema. More...
 
virtual bool operator== (const SchemaBase &other) const
 Check if two schemas perform the same validation. More...
 
bool operator!= (const SchemaBase &other) const
 
virtual void mergeSchemas (const SchemaBase &from)
 Merge elements into the current schema. More...
 
virtual std::ostream & dump (std::ostream &target, int indent, bool suppress_indent=false) const =0
 Render the schema in human-friendly text. More...
 

Protected Types

using StringType = Data::StringType
 
using SchemaRegex = std::basic_regex< StringType::value_type >
 

Protected Member Functions

 SchemaBase ()=default
 
 SchemaBase (const SchemaBase &)=default
 
 SchemaBase (SchemaBase &&)=default
 
SchemaBaseoperator= (const SchemaBase &)=default
 
SchemaBaseoperator= (SchemaBase &&)=default
 
 SchemaBase (const Parsnip::Data &schema_spec)
 Construct a schema from a JSON specification. More...
 
void checkType (Data::Type expected, const Parsnip::Data &entry) const
 Check that Data item is an allowed type. More...
 
bool isValidlyNull (const Parsnip::Data &entry) const
 Determine if the data is Null and if that is allowed. More...
 
bool isType (Data::Type expected, const Parsnip::Data &entry) const
 Check if a data object is a particular type. More...
 

Protected Attributes

bool nullable = false
 If true, element may be null. More...
 

Friends

class ListSchema
 

Member Typedef Documentation

◆ SchemaRegex

using Parsnip::SchemaBase::SchemaRegex = std::basic_regex <StringType::value_type>
protected

◆ StringType

Constructor & Destructor Documentation

◆ SchemaBase() [1/4]

Parsnip::SchemaBase::SchemaBase ( )
protecteddefault

◆ SchemaBase() [2/4]

Parsnip::SchemaBase::SchemaBase ( const SchemaBase )
protecteddefault

◆ SchemaBase() [3/4]

Parsnip::SchemaBase::SchemaBase ( SchemaBase &&  )
protecteddefault

◆ SchemaBase() [4/4]

Parsnip::SchemaBase::SchemaBase ( const Parsnip::Data schema_spec)
protected

Construct a schema from a JSON specification.

Parameters
schema_specThe schema specification.

◆ ~SchemaBase()

virtual Parsnip::SchemaBase::~SchemaBase ( )
virtualdefault

Member Function Documentation

◆ checkType()

void Parsnip::SchemaBase::checkType ( Data::Type  expected,
const Parsnip::Data entry 
) const
inlineprotected

Check that Data item is an allowed type.

If nullable, it must be the expected type or null. If not nullable it must be the expected type.

Parameters
expectedThe expected datatype.
entryThe Data item to check.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCopy()

virtual SchemaBase* Parsnip::SchemaBase::createCopy ( ) const
pure virtual

◆ dump()

virtual std::ostream& Parsnip::SchemaBase::dump ( std::ostream &  target,
int  indent,
bool  suppress_indent = false 
) const
pure virtual

Render the schema in human-friendly text.

Parameters
targetWhere to write the schema.
indentAmount of indent to use.
suppress_indentFlag indicating indent was already performed.

Implemented in Parsnip::ConjunctionSchema, Parsnip::DictionarySchema, Parsnip::ListSchema, Parsnip::OptionSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::KeywordSchema, Parsnip::RegExSchema, Parsnip::StringSchema, Parsnip::TypeSchema, and Parsnip::UncheckedSchema.

Here is the caller graph for this function:

◆ isType()

bool Parsnip::SchemaBase::isType ( Data::Type  expected,
const Parsnip::Data entry 
) const
inlineprotected

Check if a data object is a particular type.

Parameters
expectedThe type to compare to.
entryThe data item to check.
Returns
True if entry's datatype is expected, false otherwise.
Here is the caller graph for this function:

◆ isValidlyNull()

bool Parsnip::SchemaBase::isValidlyNull ( const Parsnip::Data entry) const
inlineprotected

Determine if the data is Null and if that is allowed.

Parameters
entryThe data to validate.
Returns
True if the data is null, and the schema allows it.
Here is the caller graph for this function:

◆ mergeSchemas()

void Parsnip::SchemaBase::mergeSchemas ( const SchemaBase from)
virtual

Merge elements into the current schema.

Merge elements managed by this class.

  • Elements seen every time are mandatory.
  • Elements seen only sometime are optional.
  • Elements always seen together are codependent.
  • Elements must always expect similar types, except they may vary as element and list-of-same-element.
    Parameters
    fromA schema for a valid command command line.
    Exceptions
    Variousexceptions.

Reimplemented in Parsnip::DictionarySchema, Parsnip::ListSchema, Parsnip::OptionSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::KeywordSchema, and Parsnip::TypeSchema.

Here is the caller graph for this function:

◆ operator!=()

bool Parsnip::SchemaBase::operator!= ( const SchemaBase other) const
inline
Here is the call graph for this function:

◆ operator=() [1/2]

SchemaBase& Parsnip::SchemaBase::operator= ( const SchemaBase )
protecteddefault

◆ operator=() [2/2]

SchemaBase& Parsnip::SchemaBase::operator= ( SchemaBase &&  )
protecteddefault

◆ operator==()

bool Parsnip::SchemaBase::operator== ( const SchemaBase other) const
virtual

Check if two schemas perform the same validation.

Compare two schemas to see if they determine validity in the same manner.

Parameters
otherThe schema to compare to.
Returns
True if the schemas match, false otherwise.

Reimplemented in Parsnip::ConjunctionSchema, Parsnip::DictionarySchema, Parsnip::ListSchema, Parsnip::OptionSchema, Parsnip::IntegerSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::KeywordSchema, Parsnip::RegExSchema, Parsnip::StringSchema, and Parsnip::TypeSchema.

Here is the caller graph for this function:

◆ validate()

virtual void Parsnip::SchemaBase::validate ( const Parsnip::Data entry) const
pure virtual

Friends And Related Function Documentation

◆ ListSchema

friend class ListSchema
friend

Member Data Documentation

◆ nullable

bool Parsnip::SchemaBase::nullable = false
protected

If true, element may be null.


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