Schema for one JSON object.
More...
#include <parsnip.h>
|
|
using | OptionSchemas = std::unordered_map< class OptionParser *, SchemaRef > |
| |
|
using | Dependencies = std::set< std::string > |
| |
|
|
| Schema (const class OptionParser &from, const OptionSchemas &option_schemas) |
| |
|
| Schema (Schema &&)=default |
| |
|
Schema & | operator= (Schema &&)=default |
| |
| | Schema (const Parsnip::Data &schema_spec) |
| | Construct a schema that has been defined in JSON.
|
| |
| void | addMember (const char *name, const SchemaBase &new_schema, bool mandatory=false, const Dependencies &dependencies=NoDependencies) |
| | Modify a schema by adding a new dictionary member.
|
| |
| void | replaceMember (const char *name, const SchemaBase &new_schema) |
| | Modify a schema by replacing dictionary member.
|
| |
| void | removeMember (const char *name) |
| | Modify a schema by removing a dictionary member.
|
| |
| void | validate (const Data &) const |
| | Validate data against the schema.
|
| |
| std::ostream & | dump (const std::string &intro, std::ostream &target=std::clog) const |
| | Dump the schema in human-readable format.
|
| |
|
|
static const Dependencies | NoDependencies |
| |
Schema for one JSON object.
◆ Schema()
Construct a schema that has been defined in JSON.
- See also
- : http://json-schema.org
- Parameters
-
| schema_spec | The schema specification. |
◆ addMember()
| void Parsnip::Schema::addMember |
( |
const char * |
name, |
|
|
const SchemaBase & |
new_schema, |
|
|
bool |
mandatory = false, |
|
|
const Dependencies & |
dependencies = NoDependencies |
|
) |
| |
Modify a schema by adding a new dictionary member.
- Parameters
-
| name | The dictionary member to add. |
| new_schema | The schema for the new member. |
| mandatory | If true, the member must be present for dictionaries to be valid. |
| dependencies | The names of other properties that must also be present when this one is. |
◆ dump()
| std::ostream & Parsnip::Schema::dump |
( |
const std::string & |
intro, |
|
|
std::ostream & |
target = std::clog |
|
) |
| const |
Dump the schema in human-readable format.
- Parameters
-
| intro | A label for the schema. |
| target | A stream to which to render. |
◆ removeMember()
| void Parsnip::Schema::removeMember |
( |
const char * |
name | ) |
|
Modify a schema by removing a dictionary member.
- Parameters
-
| name | The dictionary member to remove. |
◆ replaceMember()
| void Parsnip::Schema::replaceMember |
( |
const char * |
name, |
|
|
const SchemaBase & |
new_schema |
|
) |
| |
Modify a schema by replacing dictionary member.
Mandatory status and dependencies are unchanged.
- Parameters
-
| name | The dictionary member to replace. |
| new_schema | The replacement schema. |
◆ validate()
| void Parsnip::Schema::validate |
( |
const Data & |
data | ) |
const |
Validate data against the schema.
- Parameters
-
| data | The data to be validated. ` |
- Exceptions
-
| Exceptions | representing the manner of data non-conformance. |
The documentation for this class was generated from the following files: