clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
Classes | Functions
Request

Requests handling library. More...

Classes

class  Request::KeyParserBase
 Base class for key parsers. More...
class  Request::Key< T >
 Scalar key parser. More...
class  Request::Key< std::vector< T > >
 Vector key parser. More...
class  Request::CommandParser
 Base class for command parsers. More...
class  Request::Parser
 Request parser. More...

Functions

template<typename T >
Key< T > * Request::key (std::string name, T &destination)
 Helper function to create key parsers.

Detailed Description

Requests handling library.

This module handles requests composed of:

In the following, we will take "repeat" to be a command taking two keys:

Commands can be formatted in one of two ways:

This module helps parsing such requests and define appropriate C++ functors to handle commands. For example in this case, handling this request would output 5 times the string "foo".

Additionally, a request parser understands (only in plain-text form) an "help" command displaying help messages :

See test_request.cxx for an example showing how to use this module. Here is a example interactive session for an application defining the "repeat" command as above:

Command> help
Example application
Commands:
  help                 Display this help
  help COMMAND         Display help about COMMAND
  repeat               Repeat provided input

Command> help repeat
Repeat provided input

Arguments:
  input STRING
      message to repeat
      required

  times N
      number of times to repeat
      default: 2

Command> repeat
Repeat> times 5
Repeat> input foo
Repeat>
foo
foo
foo
foo
foo
Command> ^D

Function Documentation

template<typename T >
Key<T>* Request::key ( std::string  name,
T &  destination 
)

Helper function to create key parsers.

Create a vector key parser when the provided destination is of type std::vector<T>. Create a scalar key parser otherwise.

Template Parameters
Ttype of key value
Parameters
namename of the key parameter
destinationreference to a variable where key values will be stored
Returns
pointer to a newly allocated key parser