A schema built to validate JSON messages based on command line patterns.
More...
#include <parsnip_command.h>
|
| | SchemaSet (const class Parser &from) |
| | Construct schemas from a parser. More...
|
| |
| void | validate (const CommandId, const Data &) const |
| | Validate data against a command's schema. More...
|
| |
| std::ostream & | dump (const std::string &intro, const CommandId command_id, std::ostream &target=std::clog) const |
| | Dump the schema in human-readable format. More...
|
| |
| 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. More...
|
| |
| 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. More...
|
| |
| void | replaceMember (const CommandId, const char *name, const SchemaBase &schema) |
| | Modify a schema by replacing dictionary member. More...
|
| |
| void | removeMember (const CommandId, const char *name) |
| | Modify a schema by removing a dictionary member. More...
|
| |
A schema built to validate JSON messages based on command line patterns.
◆ CommandId
◆ CommandSchemas
◆ Dependencies
◆ OptionSchemas
◆ 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]
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]
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. |
◆ getSchemaForCommand() [1/2]
Get a schema by ID.
- Parameters
-
| command_id | The command ID. |
- Returns
- The schema.
- Exceptions
-
◆ getSchemaForCommand() [2/2]
Constipated variant of this function.
◆ integrateSchema()
| void Parsnip::SchemaSet::integrateSchema |
( |
const int |
command_id, |
|
|
const class DictionarySchema & |
command |
|
) |
| |
|
private |
Callback function, invoked when generating schemas from a Parser.
- Parameters
-
| command_id | The command ID the dataset represents. |
| command | A dataset a valid command would generate. |
◆ 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. |
◆ option_schemas
Schemas for each of the option parsers.
◆ schemas
Schemas for each unique command ID.
The documentation for this class was generated from the following files: