clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
Public Member Functions | List of all members
Request::Parser Class Reference

Request parser. More...

#include <request.hxx>

Public Member Functions

 Parser (std::string description="")
 Constructor.
Parserprompt (std::string p)
 Set a global prompt.
Parserecho (bool activate=true)
 Set echo.
Parseradd (CommandParser *command)
 Add a command parser.
void help (std::ostream &cout)
 Display help about the command parser.
void parse (std::istream &cin, std::ostream &cout)
 Parse a stream of plain-text requests and run the associated commands.
void parseJson (std::istream &cin, std::ostream &cout, bool verbose=false)
 Parse a stream of JSON requests and run the associated commands.

Detailed Description

Request parser.

Parses a request to identify the command, and run it.

Constructor & Destructor Documentation

Request::Parser::Parser ( std::string  description = "")
inline

Constructor.

Parameters
descriptionglobal description for the request parser

Member Function Documentation

Parser& Request::Parser::add ( CommandParser command)
inline

Add a command parser.

Parameters
commandpointer to a command parser
Returns
the parser itself
Parser& Request::Parser::echo ( bool  activate = true)
inline

Set echo.

When reading an plain-text request and echo is activated, read lines are echoed after the prompt. This is moslty useful when reading a plain-text request non-interactively (for exemple for testing purposes).

Parameters
activatetrue to activate echo
Returns
the parser itself
void Request::Parser::help ( std::ostream &  cout)
inline

Display help about the command parser.

Displays the command parser description, along with a list of all recognised commands.

Parameters
coutoutput stream where help will be displayed
void Request::Parser::parse ( std::istream &  cin,
std::ostream &  cout 
)
inline

Parse a stream of plain-text requests and run the associated commands.

Parameters
cininput stream where the request is read
coutoutput stream where results are printed
void Request::Parser::parseJson ( std::istream &  cin,
std::ostream &  cout,
bool  verbose = false 
)
inline

Parse a stream of JSON requests and run the associated commands.

JSON requests must be separated by blank lines.

Parameters
cininput stream where requests are read
coutoutput stream where results are printed
verboseif true, output progress information
Parser& Request::Parser::prompt ( std::string  p)
inline

Set a global prompt.

This prompt will be used at the top level for interactive plain-text requests.

Parameters
pprompt string
Returns
the parser itself

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