Parsnip
parsing library
Loading...
Searching...
No Matches
Public Types | Public Member Functions
Parsnip::RegExSchema Class Reference

Schema component requiring data be a string of characters matching a regular expression. More...

#include <parsnip_schema.h>

Inheritance diagram for Parsnip::RegExSchema:
Parsnip::StringSchema Parsnip::SchemaBase

Public Types

using size_type = StringType::size_type
 
- Public Types inherited from Parsnip::StringSchema
using size_type = StringType::size_type
 

Public Member Functions

 RegExSchema (const StringType &express, bool case_blind=false, size_type min=0, size_type max=std::numeric_limits< size_type >::max())
 Construct a regular expression validator.
 
 RegExSchema (const RegExSchema &)=default
 
 RegExSchema (RegExSchema &&)=default
 
RegExSchemaoperator= (const RegExSchema &)=default
 
RegExSchemaoperator= (RegExSchema &&)=default
 
 RegExSchema (const Parsnip::Data &schema_spec)
 Construct a string regular expression validator from a schema spec.
 
virtual RegExSchemacreateCopy () const override
 Create an identical, deep copy of the schema.
 
virtual void validate (const Parsnip::Data &entry) const override
 Verify that Data matches the schema.
 
virtual bool operator== (const SchemaBase &other) const override
 Check if two schemas perform the same validation.
 
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::StringSchema
 StringSchema (size_type min=0, size_type max=std::numeric_limits< size_type >::max())
 Validate a type schema: ensure the datatype is as expected.
 
 StringSchema (const StringSchema &)=default
 
 StringSchema (StringSchema &&)=default
 
StringSchemaoperator= (const StringSchema &)=default
 
StringSchemaoperator= (StringSchema &&)=default
 
 StringSchema (const Parsnip::Data &schema_spec)
 Construct a string validator from a schema specification.
 
- Public Member Functions inherited from Parsnip::SchemaBase
bool operator!= (const SchemaBase &other) const
 
virtual void mergeSchemas (const SchemaBase &from)
 Merge elements into the current schema.
 

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::StringSchema
size_type min_length
 
size_type max_length
 
- Protected Attributes inherited from Parsnip::SchemaBase
bool nullable = false
 If true, element may be null.
 

Detailed Description

Schema component requiring data be a string of characters matching a regular expression.

Constructor & Destructor Documentation

◆ RegExSchema()

Parsnip::RegExSchema::RegExSchema ( const StringType &  express,
bool  case_blind = false,
size_type  min = 0,
size_type  max = std::numeric_limits<size_type>::max() 
)

Construct a regular expression validator.

Parameters
expressThe regular expression.
case_blindIf true, the expression is applied case insensitive.
minMinimum length of valid strings.
maxMaximum length of valid strings.

Member Function Documentation

◆ createCopy()

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

Create an identical, deep copy of the schema.

Caller is responsible for deleting it.

Reimplemented from Parsnip::StringSchema.

◆ dump()

std::ostream & Parsnip::RegExSchema::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.

Reimplemented from Parsnip::StringSchema.

◆ operator==()

bool Parsnip::RegExSchema::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::StringSchema.

◆ validate()

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

Verify that Data matches the schema.

Parameters
entryThe data to validate.
Exceptions
Variousexceptions.

Reimplemented from Parsnip::StringSchema.


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