The CGILib C++ Library |
This is the README / FAQ / HOWTO file of the CGILib C++ library. It is a set of programming utilities which simplify the complexities of CGI programming using the C++ language. Don't worry if you aren't a C++ guru!: Everything here is explained and made easy for you.
Please, send feedback.
You can download the whole package compressed.
The current distribution (1.0) has been tested and compiled in the following systems:
The package is compound of six files:
Name | Content |
---|---|
CGIlib.h
|
Header to be included in your files. Contains the classes definitions for the library. |
CGILib.cpp
|
The methods' bodies. |
test.cpp
|
An example CGI program which uses the CGILib library. |
Makefile
|
Auto-compilation for gcc users. |
test.html
|
HTML page with forms to test the library. |
CGILib.html
|
This file. |
[Index]
The simplest program you can write uses only one
instance of the class CGIParser
. Its methods provide you of an
useful way of reading the CGI data form the server and manage it.
The
parse()
method must be called first and only once to retrieve
the data. Then you can fetch it by using:
Function | Description |
---|---|
getType()
|
Returns one string of "GET", "POST" or "ISINDEX" indicating the type of transaction. |
getText()
|
Returns the whole decoded text transmited by the server. |
getData()
|
Returns a CGIData object (a STL map) which can be accesed using the subscript operator []. The keys are the NAME fields of the HTML FORM inputs and the values are the data typed by the user. All of them are standard strings. |
It is recommended to enclose all the calls to these methods in an try/catch block in order to capture the CGIException that can be thrown if something goes wrong.
This is a simple example:
HTML code |
|
---|---|
myprog C++ code |
|
[Index]
Q: How could I enumetate the keys
received?
A: Renember that the CGIData is a
STL map, so, if you want to enumetate the keys and values, you must use
an iterator:
|
Q: In my Linux box I can't check
somethig like
A: Some string distributions
can't handle the operator== correctly. Use:
For further information, please check the comentaries in the source code.
[Index]
Last revised on Nov 29 1996 | © Mack |