Schema component for validating dictionaries.
More...
#include <parsnip_schema.h>
|
|
using | Dependencies = std::set< std::string > |
| |
|
using | size_type = unsigned int |
| |
|
|
static const Dependencies | NoDependencies |
| |
|
| enum | AdditionalMemberNames { NONE
, ANY
, PATTERN
} |
| |
|
using | StringType = Data::StringType |
| |
|
using | SchemaRegex = std::basic_regex< StringType::value_type > |
| |
|
|
std::map< std::string, DictionaryMember > | members |
| |
|
AdditionalMemberNames | tolerance = AdditionalMemberNames::NONE |
| | Allow unrecognized members in the dictionary?
|
| |
|
SchemaRegex | additional_member_regex |
| |
|
SchemaBaseRef | additional_member_schema |
| |
|
bool | nullable = false |
| | If true, element may be null.
|
| |
|
|
class | ValueEvaluator |
| |
|
class | RemainingValuesEvaluator |
| |
|
class | KeywordEvaluator |
| |
|
class | OptionEvaluator |
| |
Schema component for validating dictionaries.
◆ DictionarySchema()
| Parsnip::DictionarySchema::DictionarySchema |
( |
const Parsnip::Data & |
schema_spec | ) |
|
Construct a dictionary (object) schema from a schema specificiation.
- Parameters
-
| schema_spec | The specification. |
◆ addMember()
| void Parsnip::DictionarySchema::addMember |
( |
const char * |
name, |
|
|
const SchemaBase & |
schema, |
|
|
bool |
mandatory = false, |
|
|
const Dependencies & |
dependencies = NoDependencies |
|
) |
| |
Add a member to a dictionary schema.
- Parameters
-
| name | The name of the member to add. |
| schema | The schema for the new member. |
| mandatory | If true, the member must be present for the dictionary to be valid. |
| dependencies | Any members that must be present when the new member is present. |
◆ createCopy()
Create an identical, deep copy of the schema.
Caller is responsible for deleting it.
Implements Parsnip::SchemaBase.
◆ dump()
| std::ostream & Parsnip::DictionarySchema::dump |
( |
std::ostream & |
target, |
|
|
int |
indent, |
|
|
bool |
suppress_indent = false |
|
) |
| const |
|
overridevirtual |
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. |
Implements Parsnip::SchemaBase.
◆ mergeSchemas()
| void Parsnip::DictionarySchema::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
-
| from | A schema for a valid command command line. |
- Exceptions
-
Reimplemented from Parsnip::SchemaBase.
◆ operator==()
| bool Parsnip::DictionarySchema::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
-
| other | The schema to compare to. |
- Returns
- True if the schemas match, false otherwise.
Reimplemented from Parsnip::SchemaBase.
◆ removeMember()
| void Parsnip::DictionarySchema::removeMember |
( |
const char * |
name | ) |
|
Remove a member from the schema.
- Parameters
-
| name | The member to remove. |
◆ replaceMember()
| void Parsnip::DictionarySchema::replaceMember |
( |
const char * |
name, |
|
|
const SchemaBase & |
schema |
|
) |
| |
Replace a member in the schema, retaining original mandatory status and dependencies.
- Parameters
-
| name | The member to revise. |
| schema | The replacement schema for the member. |
◆ validate()
| void Parsnip::DictionarySchema::validate |
( |
const Parsnip::Data & |
entry | ) |
const |
|
overridevirtual |
Validate a dictionary:
- Check all elements conform to their respected schema.
- Ensure all mandatory elements are present.
- Ensure there are no unknown elements present.
- Make sure any co-dependent keys are present.
Implements Parsnip::SchemaBase.
The documentation for this class was generated from the following files: