Parsnip
parsing library
Public Member Functions
Parsnip::TypeSchema Class Reference

Schema component requiring data be a particular type. More...

#include <parsnip_schema.h>

Inheritance diagram for Parsnip::TypeSchema:
Parsnip::SchemaBase

Public Member Functions

 TypeSchema (const TypeSchema &)=default
 
 TypeSchema (TypeSchema &&)=default
 
TypeSchemaoperator= (const TypeSchema &)=default
 
TypeSchemaoperator= (TypeSchema &&)=default
 
 TypeSchema (const Data::Type require)
 Construct a type schema, specifying required type.
 
 TypeSchema (const Data::Type require, const Parsnip::Data &schema_spec)
 Construct a type schema. More...
 
virtual TypeSchemacreateCopy () const override
 Create an identical, deep copy of the schema. More...
 
virtual void validate (const Parsnip::Data &entry) const override
 Verify that Data matches the schema. More...
 
virtual bool operator== (const SchemaBase &other) const override
 Check if two schemas perform the same validation. More...
 
virtual void mergeSchemas (const SchemaBase &from) override
 Merge elements into the current schema. More...
 
virtual std::ostream & dump (std::ostream &target, int indent, bool suppress_ident=false) const override
 Render the schema in human-friendly text. More...
 
- Public Member Functions inherited from Parsnip::SchemaBase
bool operator!= (const SchemaBase &other) const
 

Additional Inherited Members

- Protected Types inherited from Parsnip::SchemaBase
using StringType = Data::StringType
 
using SchemaRegex = std::basic_regex< StringType::value_type >
 
- Protected Member Functions inherited from Parsnip::SchemaBase
 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 inherited from Parsnip::SchemaBase
bool nullable = false
 If true, element may be null.
 

Detailed Description

Schema component requiring data be a particular type.

Constructor & Destructor Documentation

◆ TypeSchema()

Parsnip::TypeSchema::TypeSchema ( const Data::Type  require,
const Parsnip::Data schema_spec 
)

Construct a type schema.

Parameters
requireThe required type.
schema_specThe schema specification.

Member Function Documentation

◆ createCopy()

TypeSchema * Parsnip::TypeSchema::createCopy ( ) const
overridevirtual

Create an identical, deep copy of the schema.

Caller is responsible for deleting it.

Implements Parsnip::SchemaBase.

◆ dump()

std::ostream & Parsnip::TypeSchema::dump ( std::ostream &  target,
int  indent,
bool  suppress_indent = false 
) const
overridevirtual

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.

Implements Parsnip::SchemaBase.

◆ mergeSchemas()

void Parsnip::TypeSchema::mergeSchemas ( const SchemaBase from)
overridevirtual

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 from Parsnip::SchemaBase.

◆ operator==()

bool Parsnip::TypeSchema::operator== ( const SchemaBase other) const
overridevirtual

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 from Parsnip::SchemaBase.

◆ validate()

void Parsnip::TypeSchema::validate ( const Parsnip::Data entry) const
overridevirtual

Verify that Data matches the schema.

Parameters
entryThe data to validate.
Exceptions
Variousexceptions.

Implements Parsnip::SchemaBase.


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