cxxtools::QueryParams Class Reference

QueryParams represents parameters from a HTML-Form. More...

#include <cxxtools/query_params.h>

Inheritance diagram for cxxtools::QueryParams:
cxxtools::Cgi tnt::QueryParams

Classes

class  const_iterator
 Iterator for named and unnamed parameters in QueryParams. More...
struct  value_type

Public Types

typedef std::vector< value_typevalues_type
typedef values_type::size_type size_type

Public Member Functions

 QueryParams ()
 default constructor
 QueryParams (const std::string &url)
 QueryParams (const char *url)
void parse_url (const std::string &url)
 read parameters from url
void parse_url (const char *url)
 read parameters from url
void parse_url (std::istream &url_stream)
 read parameters from stream
const std::string & param (size_type n) const
 get unnamed parameter by number (no range-check!)
size_type paramcount () const
 get number of unnamed parameters
const std::string & operator[] (size_type n) const
 get unnamed parameter with operator[] (no range-check!)
QueryParamsadd (const std::string &value)
 add unnamed parameter
const std::string & param (const std::string &name, size_type n=0) const
 get nth named parameter.
std::string param (const std::string &name, size_type n, const std::string &def) const
 get nth named parameter with default value.
std::string param (const std::string &name, const std::string &def) const
 get named parameter or default value.
size_type paramcount (const std::string &name) const
 get number of parameters with the given name
std::string operator[] (const std::string &name) const
 get first named parameter with operator[]
bool has (const std::string &name) const
 checks if the named parameter exists
QueryParamsadd (const std::string &name, const std::string &value)
 add named parameter
QueryParamsadd (const QueryParams &other)
void clear ()
 removes all data
bool empty () const
 returns true, when no parameters exist (named and unnamed)
const_iterator begin () const
 get iterator to unnamed parameters
const_iterator begin (const std::string &name) const
 get iterator to named parameter
const_iterator end () const
 get end-iterator (named and unnamed)
std::string getUrl () const
 get parameters as url

Detailed Description

QueryParams represents parameters from a HTML-Form.

There are 2 types of Query-Parameters from a HTML-Form: named and unnamed. And names are not unique. This results in a combination of a multiset and a set. this class uses a vector instead of a set, because order does matter in unnamed parameters.

The class has a parser to extract parameters from a std::string or from a input-stream.

Member Typedef Documentation

typedef values_type::size_type cxxtools::QueryParams::size_type

Constructor & Destructor Documentation

cxxtools::QueryParams::QueryParams ( )
inline

default constructor

Reimplemented in tnt::QueryParams.

cxxtools::QueryParams::QueryParams ( const std::string &  url)
inlineexplicit
cxxtools::QueryParams::QueryParams ( const char *  url)
inlineexplicit

Member Function Documentation

QueryParams& cxxtools::QueryParams::add ( const std::string &  value)
inline

add unnamed parameter

QueryParams& cxxtools::QueryParams::add ( const std::string &  name,
const std::string &  value 
)
inline

add named parameter

QueryParams& cxxtools::QueryParams::add ( const QueryParams other)
inline
const_iterator cxxtools::QueryParams::begin ( ) const
inline

get iterator to unnamed parameters

const_iterator cxxtools::QueryParams::begin ( const std::string &  name) const
inline

get iterator to named parameter

void cxxtools::QueryParams::clear ( )
inline

removes all data

bool cxxtools::QueryParams::empty ( ) const
inline

returns true, when no parameters exist (named and unnamed)

const_iterator cxxtools::QueryParams::end ( ) const
inline

get end-iterator (named and unnamed)

std::string cxxtools::QueryParams::getUrl ( ) const

get parameters as url

bool cxxtools::QueryParams::has ( const std::string &  name) const

checks if the named parameter exists

const std::string& cxxtools::QueryParams::operator[] ( size_type  n) const
inline

get unnamed parameter with operator[] (no range-check!)

std::string cxxtools::QueryParams::operator[] ( const std::string &  name) const
inline

get first named parameter with operator[]

const std::string& cxxtools::QueryParams::param ( size_type  n) const
inline

get unnamed parameter by number (no range-check!)

const std::string& cxxtools::QueryParams::param ( const std::string &  name,
size_type  n = 0 
) const

get nth named parameter.

std::string cxxtools::QueryParams::param ( const std::string &  name,
size_type  n,
const std::string &  def 
) const

get nth named parameter with default value.

std::string cxxtools::QueryParams::param ( const std::string &  name,
const std::string &  def 
) const
inline

get named parameter or default value.

size_type cxxtools::QueryParams::paramcount ( ) const
inline

get number of unnamed parameters

size_type cxxtools::QueryParams::paramcount ( const std::string &  name) const

get number of parameters with the given name

void cxxtools::QueryParams::parse_url ( const std::string &  url)

read parameters from url

void cxxtools::QueryParams::parse_url ( const char *  url)

read parameters from url

void cxxtools::QueryParams::parse_url ( std::istream &  url_stream)

read parameters from stream


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