|
clang-tags
C/C++ source code indexing tool based on libclang
|
Base class for key parsers. More...
#include <request.hxx>

Public Member Functions | |
| KeyParserBase (std::string name) | |
| Constructor. | |
| const std::string & | name () const |
| Get the key name. | |
| void | display (std::ostream &cout) const |
| Display help about the key. | |
| KeyParserBase * | metavar (std::string metavar) |
| Set the meta variable name for the key. | |
| KeyParserBase * | description (std::string description) |
| Set the description string for the key. | |
| KeyParserBase * | required (bool req=true) |
| Sets whether the key is optional or required. | |
| virtual bool | isVector () const |
| Tell whether the key takes more than one value. | |
| virtual void | parse (std::istream &cin)=0 |
| Parse an input stream and handle the key value. | |
| virtual void | set (const Json::Value &json)=0 |
| Retrieve the key value from a JSON value and handle it. | |
Protected Attributes | |
| std::string | default_ |
| Description of the default key value. | |
Base class for key parsers.
A key is a named parameter taking a typed value.
|
inline |
Constructor.
| name | key name |
|
inline |
Set the description string for the key.
The description string is included in the help message output by the display() method.
Returns the key itself to allow chaining mutator calls.
| description | new value for the key description |
|
inline |
Display help about the key.
Display the key name, along with indications about its usage. Such indications include, when available:
| cout | I/O stream where help will be printed |
|
inlinevirtual |
Tell whether the key takes more than one value.
A scalar key can take only one argument. If it is present multiple times in the request, only the last value will be used. A vector key takes multiple values : each occurence of the key in the request adds the correponding value to a list. In JSON-formatted requests, vector keys are associated to an array of values.
true if the key takes multiple values, false otherwise Reimplemented in Request::Key< std::vector< T > >.
|
inline |
Set the meta variable name for the key.
The meta variable name is a generic name used as a placeholder for the value taken by the key in the documentation. For example, the meta variable name for a "fileName" key could be "PATH", indicating that the value provided to the key should be a filesystem path. The meta variable name is included in the help message printed by the display() method.
Returns the key itself to allow chaining mutator calls.
| metavar | new value for the meta variable name |
|
inline |
Get the key name.
|
pure virtual |
Parse an input stream and handle the key value.
Parse the key value in an input text stream and store it. This method is used for plain-text requests. Values associated to vector keys are appended to the list of previously read values.
| cin | input stream |
Implemented in Request::Key< std::vector< T > >, and Request::Key< T >.
|
inline |
Sets whether the key is optional or required.
If a required key is missing in a request, an error message will be output. Optional keys can take default values when missing in the request.
Returns the key itself to allow chaining mutator calls.
| req | true if the key should be required |
|
pure virtual |
Retrieve the key value from a JSON value and handle it.
This method is used for JSON-formatted requests.
| json | JSON request |
Implemented in Request::Key< std::vector< T > >, and Request::Key< T >.
|
protected |
Description of the default key value.
Used for the help message
1.8.1.2