pianod2
multisource multiuser scriptable networked music player
Public Types | Public Member Functions | Private Attributes | List of all members
PianodSchema Class Reference

#include <interpreter.h>

Inheritance diagram for PianodSchema:
Inheritance graph
[legend]
Collaboration diagram for PianodSchema:
Collaboration graph
[legend]

Public Types

using CommandIds = std::map< std::string, CommandId >
 
using SchemaList = std::vector< std::string >
 
using RequestPair = std::pair< CommandId, const Parsnip::Data * >
 
- Public Types inherited from Parsnip::SchemaSet
using CommandId = int
 
using CommandSchemas = std::unordered_map< CommandId, SchemaBaseRef >
 
using OptionSchemas = Schema::OptionSchemas
 
using Dependencies = Schema::Dependencies
 

Public Member Functions

CommandId getCommandId (const std::string &name) const
 Retrieve a request's ID by name. More...
 
void addRequestNames (const CommandIds &mappings)
 Register additional name/ID mappings for requests. More...
 
void validate (const std::string &command, const Parsnip::Data &request)
 Verify a request complies with its schema. More...
 
std::ostream & dump (const std::string &command, std::ostream &target=std::clog) const
 
std::ostream & dumpAll (std::ostream &target=std::clog) const
 
SchemaList allRequestNames () const
 
- Public Member Functions inherited from Parsnip::SchemaSet
 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...
 

Private Attributes

CommandIds command_ids
 

Additional Inherited Members

- Public Attributes inherited from Parsnip::SchemaSet
OptionSchemas option_schemas
 Schemas for each of the option parsers. More...
 

Member Typedef Documentation

◆ CommandIds

using PianodSchema::CommandIds = std::map <std::string, CommandId>

◆ RequestPair

using PianodSchema::RequestPair = std::pair <CommandId, const Parsnip::Data *>

◆ SchemaList

using PianodSchema::SchemaList = std::vector<std::string>

Member Function Documentation

◆ addRequestNames()

void PianodSchema::addRequestNames ( const CommandIds mappings)

Register additional name/ID mappings for requests.

Parameters
mappingsA map from name to ID.
Here is the caller graph for this function:

◆ allRequestNames()

PianodSchema::SchemaList PianodSchema::allRequestNames ( ) const

◆ dump()

std::ostream & PianodSchema::dump ( const std::string &  command,
std::ostream &  target = std::clog 
) const
Here is the call graph for this function:

◆ dumpAll()

std::ostream & PianodSchema::dumpAll ( std::ostream &  target = std::clog) const

◆ getCommandId()

PianodSchema::CommandId PianodSchema::getCommandId ( const std::string &  request_name) const

Retrieve a request's ID by name.

Parameters
request_nameThe JSON request's name.
Returns
The command ID for the request.
Exceptions
NoSchemaDefineif request_name wasn't found.
Here is the caller graph for this function:

◆ validate()

void PianodSchema::validate ( const std::string &  request_name,
const Parsnip::Data parameters 
)

Verify a request complies with its schema.

Parameters
request_nameThe request name.
parametersThe request parameters to be validated.
Here is the call graph for this function:

Member Data Documentation

◆ command_ids

CommandIds PianodSchema::command_ids
private

The documentation for this class was generated from the following files: