|
| virtual SchemaBase * | createCopy () const =0 |
| | Create an identical, deep copy of the schema.
|
| |
| virtual void | validate (const Parsnip::Data &entry) const =0 |
| | Verify that Data matches the schema.
|
| |
| virtual bool | operator== (const SchemaBase &other) const |
| | Check if two schemas perform the same validation.
|
| |
|
bool | operator!= (const SchemaBase &other) const |
| |
| virtual void | mergeSchemas (const SchemaBase &from) |
| | Merge elements into the current schema.
|
| |
| virtual std::ostream & | dump (std::ostream &target, int indent, bool suppress_indent=false) const =0 |
| | Render the schema in human-friendly text.
|
| |
|
|
using | StringType = Data::StringType |
| |
|
using | SchemaRegex = std::basic_regex< StringType::value_type > |
| |
|
|
bool | nullable = false |
| | If true, element may be null.
|
| |
◆ SchemaBase()
| Parsnip::SchemaBase::SchemaBase |
( |
const Parsnip::Data & |
schema_spec | ) |
|
|
protected |
Construct a schema from a JSON specification.
- Parameters
-
| schema_spec | The schema specification. |
◆ checkType()
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
-
| expected | The expected datatype. |
| entry | The Data item to check. |
◆ createCopy()
| virtual SchemaBase * Parsnip::SchemaBase::createCopy |
( |
| ) |
const |
|
pure virtual |
Create an identical, deep copy of the schema.
Caller is responsible for deleting it.
Implemented in Parsnip::UncheckedSchema, Parsnip::TypeSchema, Parsnip::StringSchema, Parsnip::RegExSchema, Parsnip::KeywordSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::IntegerSchema, Parsnip::OptionSchema, Parsnip::ListSchema, Parsnip::DictionarySchema, and Parsnip::ConjunctionSchema.
◆ 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
-
| target | Where to write the schema. |
| indent | Amount of indent to use. |
| suppress_indent | Flag indicating indent was already performed. |
Implemented in Parsnip::UncheckedSchema, Parsnip::TypeSchema, Parsnip::StringSchema, Parsnip::RegExSchema, Parsnip::KeywordSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::OptionSchema, Parsnip::ListSchema, Parsnip::DictionarySchema, and Parsnip::ConjunctionSchema.
◆ isType()
Check if a data object is a particular type.
- Parameters
-
| expected | The type to compare to. |
| entry | The data item to check. |
- Returns
- True if entry's datatype is expected, false otherwise.
◆ isValidlyNull()
| bool Parsnip::SchemaBase::isValidlyNull |
( |
const Parsnip::Data & |
entry | ) |
const |
|
inlineprotected |
Determine if the data is Null and if that is allowed.
- Parameters
-
| entry | The data to validate. |
- Returns
- True if the data is null, and the schema allows it.
◆ mergeSchemas()
| void Parsnip::SchemaBase::mergeSchemas |
( |
const SchemaBase & |
from | ) |
|
|
virtual |
◆ 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
-
| other | The schema to compare to. |
- Returns
- True if the schemas match, false otherwise.
Reimplemented in Parsnip::TypeSchema, Parsnip::StringSchema, Parsnip::RegExSchema, Parsnip::KeywordSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::IntegerSchema, Parsnip::OptionSchema, Parsnip::ListSchema, Parsnip::DictionarySchema, and Parsnip::ConjunctionSchema.
◆ validate()
| virtual void Parsnip::SchemaBase::validate |
( |
const Parsnip::Data & |
entry | ) |
const |
|
pure virtual |
Verify that Data matches the schema.
- Parameters
-
| entry | The data to validate. |
- Exceptions
-
Implemented in Parsnip::UncheckedSchema, Parsnip::TypeSchema, Parsnip::StringSchema, Parsnip::RegExSchema, Parsnip::KeywordSchema, Parsnip::RangeSchema< NumericType >, Parsnip::RangeSchema< long >, Parsnip::IntegerSchema, Parsnip::OptionSchema, Parsnip::ListSchema, Parsnip::DictionarySchema, and Parsnip::ConjunctionSchema.
The documentation for this class was generated from the following files: