Webmaster  |  Imprint 
Platinum
Platinum C++ Framework
Main  |  License  |  Documentation  |  Download  |  Support 

QueryParams Class Reference

#include <Pt/Net/QueryParams.h>

List of all members.

Public Types

typedef std::string string
typedef std::vector< string > names_type
typedef std::vector< string > unnamed_params_type
typedef std::multiset< string > values_set
typedef std::map< string,
unnamed_params_type > 
named_params_type
typedef names_type::size_type size_type

Public Member Functions

 QueryParams ()
 default constructor
 QueryParams (QueryParams *_parent, bool _use_parent_values=true)
 initializes class with parent
 QueryParams (QueryParams &_parent, bool _use_parent_values)
 initializes class with parent
 QueryParams (const QueryParams &src)
QueryParamsgetParent () const
 returns the parent-object
void setParent (QueryParams *p, bool _use_parent_values=true)
 changes parent-object
void setParent (QueryParams &p, bool _use_parent_values=true)
 changes parent-object
bool useParentValues () const
 returns true, when parent-object delivers values
bool hasParent () const
 returns true, if parent exists
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 string & param (size_type n) const
 get unnamed parameter by number (no range-check!)
size_type paramcount () const
 get number of unnamed parameters
const string & operator[] (size_type n) const
 get unnamed parameter with operator[] (no range-check!)
template<typename output_iterator>
void get (output_iterator &o) const
 get all unnamed parameters
QueryParamsret (const string &value)
void eraseUnnamed (const string &value)
 remove unnamed parameter by value
QueryParamsadd (const string &value)
 add unnamed parameter to this class.
const string & param (const string &name, size_type n=0, const string &def=std::string()) const
 get named parameter.
const string & param (const string &name, const string &def) const
 shortcut for first named parameter
size_type paramcount (const string &name) const
 get number of parameters with the given name
string operator[] (const string &name) const
 get first named parameter with operator[]
template<typename output_iterator>
void getNames (output_iterator o) const
 get all names
template<typename output_iterator>
void getValues (const string &name, output_iterator o) const
 get all values with a given name
bool has (const string &name) const
 checks if the named parameter exists
QueryParamsret (const string &name, const string &value)
 replace named parameter in parent or this class if no parent exists
QueryParamsaddret (const string &name, const string &value)
 add named parameter to parent or this class if no parent exists
void erase (const string &name)
 remove named parameter
QueryParamsadd (const string &name, const string &value)
 add named parameter to this class
void replace (const string &name, const string &value, bool to_parent=true)
 replace named parameter
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)
string getUrl () const
 get parameters in url-syntax
string dump () const
 get readable parameters for debugging

Classes

class  const_iterator


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.

QueryParams can reference a parent-object. Parent-objects might return values or just store them. This is for passing QueryParams as parameter to functions. You can pass the object itself or a new object, which has additional parameters, without changing the original object. For the called function it looks like the object contains all parameter. The function can still modify the parent-object by using the method QueryParams::ret.

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


Member Function Documentation

QueryParams& ret ( const string &  value  ) 

add unnamed parameter to parent or this class if no parent exists.

Copyright © 2003-2007 The Pt Development Team
Pt 1.0