A schema built to validate JSON messages based on command line patterns.
More...
#include <parsnip_command.h>
|
|
using | CommandId = int |
| |
|
using | CommandSchemas = std::unordered_map< CommandId, SchemaBaseRef > |
| |
|
using | OptionSchemas = Schema::OptionSchemas |
| |
|
using | Dependencies = Schema::Dependencies |
| |
|
| | SchemaSet (const class Parser &from) |
| | Construct schemas from a parser.
|
| |
| void | validate (const CommandId, const Data &) const |
| | Validate data against a command's schema.
|
| |
| std::ostream & | dump (const std::string &intro, const CommandId command_id, std::ostream &target=std::clog) const |
| | Dump the schema in human-readable format.
|
| |
| void | addMember (const CommandId, const char *name, const SchemaBase &schema, bool mandatory=false, const Dependencies &dependencies=Schema::NoDependencies) |
| | Modify a schema by adding a new dictionary member.
|
| |
| void | addMember (const char *name, const SchemaBase &schema, bool mandatory=false, const Dependencies &dependencies=Schema::NoDependencies) |
| | Add member to every schema in the schema set.
|
| |
| void | replaceMember (const CommandId, const char *name, const SchemaBase &schema) |
| | Modify a schema by replacing dictionary member.
|
| |
| void | removeMember (const CommandId, const char *name) |
| | Modify a schema by removing a dictionary member.
|
| |
|
|
OptionSchemas | option_schemas |
| | Schemas for each of the option parsers.
|
| |
A schema built to validate JSON messages based on command line patterns.
◆ SchemaSet()
| Parsnip::SchemaSet::SchemaSet |
( |
const class Parser & |
from | ) |
|
Construct schemas from a parser.
This first constructs schemas for all its option parsers, then generates the schema for the parser itself.
- Parameters
-
| from | The parser for which schemas are being generated. |
◆ addMember() [1/2]
| void Parsnip::SchemaSet::addMember |
( |
const char * |
name, |
|
|
const SchemaBase & |
schema, |
|
|
bool |
mandatory = false, |
|
|
const Dependencies & |
dependencies = Schema::NoDependencies |
|
) |
| |
Add member to every schema in the schema set.
- Parameters
-
| name | The dictionary member to add. |
| 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. |
◆ addMember() [2/2]
| void Parsnip::SchemaSet::addMember |
( |
const CommandId |
command_id, |
|
|
const char * |
name, |
|
|
const SchemaBase & |
schema, |
|
|
bool |
mandatory = false, |
|
|
const Dependencies & |
dependencies = Schema::NoDependencies |
|
) |
| |
Modify a schema by adding a new dictionary member.
- Parameters
-
| command_id | The command number to modify. |
| name | The dictionary member to add. |
| 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::SchemaSet::dump |
( |
const std::string & |
intro, |
|
|
const CommandId |
command_id, |
|
|
std::ostream & |
target = std::clog |
|
) |
| const |
Dump the schema in human-readable format.
- Parameters
-
| intro | A label for the schema. |
| command_id | The ID of the command to render. |
| target | A stream to which to render. |
◆ removeMember()
| void Parsnip::SchemaSet::removeMember |
( |
const CommandId |
command_id, |
|
|
const char * |
name |
|
) |
| |
Modify a schema by removing a dictionary member.
- Parameters
-
| command_id | The command number to modify. |
| name | The dictionary member to remove. |
◆ replaceMember()
| void Parsnip::SchemaSet::replaceMember |
( |
const CommandId |
command_id, |
|
|
const char * |
name, |
|
|
const SchemaBase & |
schema |
|
) |
| |
Modify a schema by replacing dictionary member.
Mandatory status and dependencies are unchanged.
- Parameters
-
| command_id | The command number to modify. |
| name | The dictionary member to replace. |
| schema | The replacement schema. |
◆ validate()
| void Parsnip::SchemaSet::validate |
( |
const CommandId |
command_id, |
|
|
const Data & |
data |
|
) |
| const |
Validate data against a command's schema.
- Parameters
-
| command_id | The command the data represents. |
| 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: