|
clang-tags
C/C++ source code indexing tool based on libclang
|
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. | |
Requests handling library.
This module handles requests composed of:
In the following, we will take "repeat" to be a command taking two keys:
"times" of integer type, and"input" of string type.Commands can be formatted in one of two ways:
repeat times 5 input foo
{
"command": "repeat",
"times": 5,
"input": "foo"
}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 :
help
help COMMAND
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
| 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.
| T | type of key value |
| name | name of the key parameter |
| destination | reference to a variable where key values will be stored |
1.8.1.2