Parsnip
parsing library
Loading...
Searching...
No Matches
Public Member Functions
Parsnip::OptionSchema Class Reference

Schema adapter component that allows use of schemas from option parsers. More...

#include <parsnip_schema.h>

Inheritance diagram for Parsnip::OptionSchema:
Parsnip::SchemaBase

Public Member Functions

 OptionSchema ()=default
 Validate a type schema: ensure the datatype is as expected.
 
 OptionSchema (const OptionSchema &)=default
 
 OptionSchema (OptionSchema &&)=default
 
OptionSchemaoperator= (const OptionSchema &)=default
 
OptionSchemaoperator= (OptionSchema &&)=default
 
 OptionSchema (const SchemaRef &option_schema)
 Construct a new option schema.
 
virtual OptionSchemacreateCopy () const override
 Create an identical, deep copy of the schema.
 
virtual void validate (const Parsnip::Data &entry) const override
 Validate the option's schema by calling that scheme's validator.
 
virtual bool operator== (const SchemaBase &other) const override
 Check if two schemas perform the same validation.
 
virtual void mergeSchemas (const SchemaBase &from) override
 Merge elements into the current schema.
 
virtual std::ostream & dump (std::ostream &target, int indent, bool suppress_ident=false) const override
 Render the schema in human-friendly text.
 
- 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.
 
void checkType (Data::Type expected, const Parsnip::Data &entry) const
 Check that Data item is an allowed type.
 
bool isValidlyNull (const Parsnip::Data &entry) const
 Determine if the data is Null and if that is allowed.
 
bool isType (Data::Type expected, const Parsnip::Data &entry) const
 Check if a data object is a particular type.
 
- Protected Attributes inherited from Parsnip::SchemaBase
bool nullable = false
 If true, element may be null.
 

Detailed Description

Schema adapter component that allows use of schemas from option parsers.

Member Function Documentation

◆ createCopy()

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

Create an identical, deep copy of the schema.

Caller is responsible for deleting it.

Implements Parsnip::SchemaBase.

◆ dump()

std::ostream & Parsnip::OptionSchema::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::OptionSchema::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::OptionSchema::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::OptionSchema::validate ( const Parsnip::Data entry) const
overridevirtual

Validate the option's schema by calling that scheme's validator.

Implements Parsnip::SchemaBase.


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