pianod2
multisource multiuser scriptable networked music player
Classes | Public Types | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
Parsnip::Parser Class Reference

A class for parsing command lines. More...

#include <parsnip_command.h>

Inheritance diagram for Parsnip::Parser:
Inheritance graph
[legend]

Classes

struct  Definition
 
struct  Result
 

Public Types

using CommandId = int
 
using StringType = std::string
 
using Definitions = std::vector< Definition >
 

Public Member Functions

 Parser ()=default
 
 Parser (const Definitions &defs)
 Construct a parser and initialize it with some statements. More...
 
virtual ~Parser ()=default
 
void addOptionParser (const std::string &name, const OptionParserRef &add)
 Register an options parser for use. More...
 
void addStatements (const Definitions &defs)
 Add statements to the parser. More...
 
Result evaluate (const StringType &command) const
 Evaluate a command. More...
 
bool operator== (const Parser &) const
 Check if a parser is identical to another parser. More...
 
bool operator!= (const Parser &other) const
 

Private Types

using OptionParsers = std::unordered_map< std::string, OptionParserRef >
 

Private Attributes

EvaluatorRef evaluator
 
OptionParsers option_parsers
 

Friends

class OptionEvaluator
 
class SchemaSet
 

Detailed Description

A class for parsing command lines.

Member Typedef Documentation

◆ CommandId

◆ Definitions

◆ OptionParsers

using Parsnip::Parser::OptionParsers = std::unordered_map<std::string, OptionParserRef>
private

◆ StringType

using Parsnip::Parser::StringType = std::string

Constructor & Destructor Documentation

◆ Parser() [1/2]

Parsnip::Parser::Parser ( )
default

◆ Parser() [2/2]

Parsnip::Parser::Parser ( const Definitions defs)

Construct a parser and initialize it with some statements.

Parameters
defsThe statement definitions.
Here is the call graph for this function:

◆ ~Parser()

virtual Parsnip::Parser::~Parser ( )
virtualdefault

Member Function Documentation

◆ addOptionParser()

void Parsnip::Parser::addOptionParser ( const std::string &  name,
const OptionParserRef add 
)

Register an options parser for use.

Parameters
nameThe option parser's name.
addThe option parser to register.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addStatements()

void Parsnip::Parser::addStatements ( const Definitions defs)

Add statements to the parser.

Parameters
defsThe statement definitions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluate()

Parser::Result Parsnip::Parser::evaluate ( const StringType command) const

Evaluate a command.

Parameters
commandthe command.
Returns
A result, which contains the command ID and extracted parameters.
Exceptions
Exceptionsrepresenting various command errors.
Here is the call graph for this function:

◆ operator!=()

bool Parsnip::Parser::operator!= ( const Parser other) const
inline

◆ operator==()

bool Parsnip::Parser::operator== ( const Parser other) const

Check if a parser is identical to another parser.

Friends And Related Function Documentation

◆ OptionEvaluator

friend class OptionEvaluator
friend

◆ SchemaSet

friend class SchemaSet
friend

Member Data Documentation

◆ evaluator

EvaluatorRef Parsnip::Parser::evaluator
private

◆ option_parsers

OptionParsers Parsnip::Parser::option_parsers
private

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