clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
Public Types | Public Member Functions | List of all members
Request::Key< std::vector< T > > Class Template Reference

Vector key parser. More...

#include <request.hxx>

Inheritance diagram for Request::Key< std::vector< T > >:
Inheritance graph
[legend]
Collaboration diagram for Request::Key< std::vector< T > >:
Collaboration graph
[legend]

Public Types

typedef std::vector< T > Vector
 Type of container in which values are stored.

Public Member Functions

 Key (std::string name, Vector &destination)
 Constructor.
virtual bool isVector () const
 Tell whether the key takes more than one value.
virtual void parse (std::istream &cin)
 Parse an input stream and handle the key value.
virtual void set (const Json::Value &json)
 Retrieve the key value from a JSON value and handle it.
- Public Member Functions inherited from Request::KeyParserBase
 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.
KeyParserBasemetavar (std::string metavar)
 Set the meta variable name for the key.
KeyParserBasedescription (std::string description)
 Set the description string for the key.
KeyParserBaserequired (bool req=true)
 Sets whether the key is optional or required.

Additional Inherited Members

- Protected Attributes inherited from Request::KeyParserBase
std::string default_
 Description of the default key value.

Detailed Description

template<typename T>
class Request::Key< std::vector< T > >

Vector key parser.

Parses a key and stores multiple values in a destination vector.

Parameters
Ttype of value stored

Constructor & Destructor Documentation

template<typename T >
Request::Key< std::vector< T > >::Key ( std::string  name,
Vector destination 
)
inline

Constructor.

Parameters
namekey name
destinationreference to a vector where key values will be stored

Member Function Documentation

template<typename T >
virtual bool Request::Key< std::vector< T > >::isVector ( ) const
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.

Returns
true if the key takes multiple values, false otherwise

Reimplemented from Request::KeyParserBase.

template<typename T >
virtual void Request::Key< std::vector< T > >::parse ( std::istream &  cin)
inlinevirtual

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.

Parameters
cininput stream

Implements Request::KeyParserBase.

template<typename T >
virtual void Request::Key< std::vector< T > >::set ( const Json::Value &  json)
inlinevirtual

Retrieve the key value from a JSON value and handle it.

This method is used for JSON-formatted requests.

Parameters
jsonJSON request

Implements Request::KeyParserBase.


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