University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

CGIReader Class Reference

#include <CGIReader.h>

Inheritance diagram for CGIReader:

Reader FormatStream Stream Object List of all members.

Detailed Description

CGIReader: a reader for URL-encoded data returned by web forms.

The CGIReader class is a kind of Reader that reconstructs a Map object from form data supplied by web browsers. CGIReader expects to receive a URL-encoded String on standard input, and so expects web forms to use the POST-method to submit their data. The length of the String to be read is determined from the environment variable CONTENT_LENGTH, which is defined by web browsers. CGIReader cannot be used in any other context where this variable is not defined. CGIReader decodes the String into a Map relating String keywords to String data values. The keywords are the web form's field names and the corresponding data values are whatever the user supplied, when filling in the form. Any form field may be looked up in the Map. Although each data value is stored as a String, it is possible to convert this to other basic types, using String's conversion methods. The original URL-encoded String is stored in the returned Map under the key "data".


Public Member Functions

 CGIReader ()
 Construct a CGIReader stream.

virtual ~CGIReader ()
 Release an unused CGIReader stream.

virtual ObjectID clone () const
 Clone a copy of this CGIReader.

virtual Void openOn (StringID)
 Disable the redirection of the CGIReader's Input stream.

virtual ReaderID getField (StringID, ObjectID &)
 Read in a Map from its URL-encoded form data representation.


Constructor & Destructor Documentation

CGIReader::CGIReader  ) 
 

Construct a CGIReader stream.

Constructs an CGIReader whose input is the standard TextInput stream, initially closed.

Returns:
a standard CGIReader stream.

CGIReader::~CGIReader  )  [virtual]
 

Release an unused CGIReader stream.

Performs all closing actions to disconnect from the underlying filesystem.


Member Function Documentation

ObjectID CGIReader::clone  )  const [virtual]
 

Clone a copy of this CGIReader.

Creates a shallow copy, which shares the file path name, if any, but does not initialise any filesystem.

Reimplemented from Object.

ReaderID CGIReader::getField StringID  label,
ObjectID variable
[virtual]
 

Read in a Map from its URL-encoded form data representation.

Not intended to be used directly by clients, getField("root", variable) is called by the top-level get() method of Reader. It initialises the argument variable with a Map whose domain and range are Strings, being the web form field-names and user-supplied data values decoded from the URL-encoded data string supplied on standard input. A ReadFailure exception may be raised if reading fails. A general Exception may be raised if the environment variable CONTENT_LENGTH is not defined, or the input String is not correctly URL-encoded.

Parameters:
label - the field label, which is "root".
variable - a variable in which to store the result.

Reimplemented from Reader.

Void CGIReader::openOn StringID  path  )  [virtual]
 

Disable the redirection of the CGIReader's Input stream.

It is illegal for a CGIReader to attempt to read from anything other than the standard input, so this method is disabled, raising an Undefined exception. Likewise, no constructor is provided to create a CGIReader with an initial pathname.

Parameters:
path - a String pathname.

Reimplemented from FormatStream.


The documentation for this class was generated from the following files:
Generated on Fri May 5 17:17:16 2006 for The Simons Component Library by doxygen1.3