os_form_map


A container for name/value pairs posted from a form.

An os_form_map is a container for name/value pairs transmitted from an os_form . os_form_map is designed for use with an os_form that specifies an HTTP action URL, the post HTTP method, and MIME type application/x-www-form-urlencoded .

An os_form_map is initialized by reading name/value pairs from an input stream specified in the constructor, typically cin . The name and value information is automatically URL-decoded prior to insertion into the os_form_map .

Several member functions are provided to easily query the form data.

Name/value pairs are stored internally in an STL multimap . This underlying container is exposed through the fields() member function to allow application-specific manipulation of the form data.

Although the os_form_map makes note of the CGI environment variables REQUEST_METHOD , CONTENT_TYPE , and CONTENT_LENGTH , it attempts to initialize itself even if one or more of these environment variables are invalid. The member functions invalid_environment() , invalid_request_method() , invalid_content_type() , invalid_content_length() , and malformed_input() report the status of the environment and data at the time the os_form_map was initialized.

Declaration

#include <ospace/web/formmap.h>
class os_form_map

Typedefs

typedef multimap< string, string, less< string > >::iterator iterator;
typedef multimap< string, string, less< string > >::const_iterator const_iterator;

Interface

Constructor
os_form_map( istream& is )
Constructs a form map with name/value pairs from the input stream is .
Constructor
os_form_map( const os_form_map& rhs )
Constructs a form map with a copy of rhs .
Destructor
virtual ~os_form_map()
Destroys the form map.
=
os_form_map& operator=( const os_form_map& rhs )
Replaces the contents of the form map with a copy of rhs .
all_values
vector< string > all_values( const string& name ) const
Returns all values for name in the form map.
fields
multimap< string, string, less< string > >& fields()
Returns a reference to the form map's underlying name/value container.
first_value
string first_value( const string& name ) const
Returns the first value for name in the form map.
invalid_content_length
bool invalid_content_length()
Returns true if the CONTENT_LENGTH environment variable is not set or is equal to 0.
invalid_content_type
bool invalid_content_type()
Returns true if the CONTENT_TYPE environment variable is not set or does not equal application/x-www-form-urlencoded .
invalid_environment
bool invalid_environment()
Returns true if any of the gateway program environment variables REQUEST_METHOD , CONTENT_TYPE , or CONTENT_LENGTH are invalid.
invalid_request_method
bool invalid_request_method()
Returns true if the REQUEST_METHOD environment variable is not set or does not equal POST .
malformed_input
bool malformed_input()
Returns true if the input stream, from which the form map was initialized, did not contain a matched set of name/value pairs.
name_count
int name_count( const string& name ) const
Returns the number of values for name in the form map.
name_exists
bool name_exists( const string& name ) const
Returns true if name has a value in the form map.
size
int size() const
Returns the number of name/value pairs in the form map.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved