class Cgi

Cgi class

public members:

Cgi()
Ctor, decode the data and initialize the instance variables.
Cgi(const Cgi &)
Copy ctor

Accessors

string dump(void) const
Return a string with all variable names and values.
bool exist(const string&) const
Check existence
string operator[](const string)
Read variable

Mutator

Cgi & operator<<(pair<string,string>)
Add variable
class CgiException
Class for exceptions
etype type
Exception type
string s
Name of variable (for nosuva only)
CgiException(etype,string ="")
Ctor for exception objects

private members:

static char x2c(const string&)
Convert from hexadecimal
static void unescape_hex(string&)
Unescape hexadecimal sequences (encoded as ``%xx'')
static void unescape_space(string&)
Unescape spaces (encoded as ``+'')
void split(string)
Does the decoding
static pair<string,string> lrhs(const string&)
Takes a string ``A=B'' and returns the pair of strings ``<A,B>''

Documentation

This class handles everything related to data encoded according to the CGI specs.
Cgi ()
If compiled with support for exceptions, decoding could throw the following exceptions:
norqme
if the request method can not be determined;
nocole
if the content's length can not be determined;
noqust
if the query string can not be determined;
ivrqme
if the request method is invalid.
Without exception support, assertions are made (with the assert() macro) and the error messages are written with perror().

string dump (void) const
The string is in the form ``name1=val1\nname2=val2\n''.

bool exist (const string&) const
Checks if a variable named as the argument exists. This operation is useful mainly for checkboxes, but can be also used to prevent errors (requesting an non-existent variable) in case exceptions are not supported.

string operator[] (const string)
Returns a string corresponding to the value of the variable supplied as an argument. If the variable does not exist, then:
  • if expections are supported it throws nosuva, or
  • if exceptions are not supported, it returns an empty string.

Cgi & operator<< (pair<string,string>)
Add the argument (a (name,value) pair) to the receiver. If the variable name already exists, the value is overwritten.

class CgiException
Exceptions are simple in this case so there's nothing really spiffy here.

CgiException (etype,string ="")
Takes the exception type and an optional string. The exception type is one of the following: norqme, nocole, noqust, ivrqme or nosuva. For nosuva, the string holds the name of the non-existent variable.


this class has no child classes.

alphabetic index hierarchy of classes


Dragos Manolescu ([email protected])

generated by doc++