Parsnip
parsing library
Data Structures | Public Types | Public Member Functions | Friends
Parsnip::Parser Class Reference

A class for parsing command lines. More...

#include <parsnip_command.h>

Data Structures

struct  Definition
 
struct  Result
 

Public Types

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

Public Member Functions

 Parser (const Definitions &defs)
 Construct a parser and initialize it with some statements. More...
 
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.
 
bool operator!= (const Parser &other) const
 

Friends

class OptionEvaluator
 
class SchemaSet
 

Detailed Description

A class for parsing command lines.

Constructor & Destructor Documentation

◆ Parser()

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

Construct a parser and initialize it with some statements.

Parameters
defsThe statement definitions.

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.

◆ addStatements()

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

Add statements to the parser.

Parameters
defsThe statement definitions.

◆ 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.

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