Main Page | Namespace List | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

NWWWCodec.h File Reference

Methods designed to encode and decode information coming from CGI requests. More...

#include <MonsterworksCopyright.h>
#include <string>
#include <exception>
#include <map>
#include <set>

Include dependency graph for NWWWCodec.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  monsterworks
namespace  monsterworks::cgi
namespace  monsterworks::cgi::NWWWCodec

Data Structures

class  monsterworks::cgi::NWWWCodec::XInvalidString
 thrown if an improperly www-url-encoded string is attempt to be decoded More...

Typedefs

typedef std::multimap< std::string,
std::string > 
FormPairs
 how we handle key/value pairs from form data
typedef std::set< std::string > QueryWords
 how we handle query words

Functions

std::string ToWWW (const std::string &inPlainText)
 converts a string to WWW URL encoded string
std::string FromWWW (const std::string &inCypherText)
 converts a string from WWW URL encoded string
std::string EscapeHTML (const std::string &inPlainText)
 escapes all HTML in a string so that it can be displayed as text
monsterworks::cgi::FormPairs StringToPairs (const std::string &inEncodedString)
 converts the string into a series of key/value pairs appropriate for form processing
monsterworks::cgi::QueryWords StringToWords (const std::string &inEncodedString)
 converts the string into a series of keywords appropriate for form processiong


Detailed Description

Methods designed to encode and decode information coming from CGI requests.

Author
eeyore
Date
2004/03/04 02:51:26

Copyright (c) 2004 eeyore@monsterworks.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2.

This program is distributed in the hope that it wil be found useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Gnu Public License in the documentation or read the source of MonsterworksCopyright.h.

You should have received a copy of the GNU General Public Licence along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307 USA.

Definition in file NWWWCodec.h.


Typedef Documentation

typedef std::multimap<std::string,std::string> monsterworks::cgi::FormPairs
 

how we handle key/value pairs from form data

Definition at line 37 of file NWWWCodec.h.

Referenced by monsterworks::cgi::NForm::GetInt(), monsterworks::cgi::NForm::GetString(), and monsterworks::cgi::NWWWCodec::StringToPairs().

typedef std::set<std::string> monsterworks::cgi::QueryWords
 

how we handle query words

Definition at line 39 of file NWWWCodec.h.

Referenced by monsterworks::cgi::NWWWCodec::StringToWords().


Function Documentation

std::string monsterworks::cgi::NWWWCodec::EscapeHTML const std::string &  inPlainText  ) 
 

escapes all HTML in a string so that it can be displayed as text

encodes a string so that it will display appropriately as HTML

characterencoded as
<&lt
>&gt
&&amp
"&quot
any other characteritself

Returns:
the result of the encoding
Parameters:
inPlainText  the text to be encoded
Definition at line 173 of file NWWWCodec.cp.

std::string monsterworks::cgi::NWWWCodec::FromWWW const std::string &  inCypherText  ) 
 

converts a string from WWW URL encoded string

decodes an www-url-encoded string

encoded characterdecoded to
+space
%[hex][hex]ASCII character [hex][hex]
sequences of 0x0D & 0x0Aa single newline (\n)
other control charactersstripped
everything elseitself

Returns:
the unecoded string
Exceptions:
XInvalidString if string has improper encoding
Parameters:
inCypherText  the string to decode
Definition at line 94 of file NWWWCodec.cp.

Referenced by monsterworks::cgi::NWWWCodec::StringToPairs(), and monsterworks::cgi::NWWWCodec::StringToWords().

monsterworks::cgi::FormPairs monsterworks::cgi::NWWWCodec::StringToPairs const std::string &  inEncodedString  ) 
 

converts the string into a series of key/value pairs appropriate for form processing

decodes a string as a sequence of key/value pairs

Returns:
the pairs in a FormPairs structure
Exceptions:
XInvalidString if string has incorrect encoding, see FromWWW()
Parameters:
inEncodedString  the string to be decoded
Definition at line 247 of file NWWWCodec.cp.

References monsterworks::cgi::FormPairs, and monsterworks::cgi::NWWWCodec::FromWWW().

Referenced by NFormInitialize().

monsterworks::cgi::QueryWords monsterworks::cgi::NWWWCodec::StringToWords const std::string &  inEncodedString  ) 
 

converts the string into a series of keywords appropriate for form processiong

decodes a www-url-encoded string as a sequence of words appropriate for use as query string from a form

Returns:
the words in a QueryWords structure
Exceptions:
XInvalidString if string has invalid encoding, see FromWWW()
Parameters:
inEncodedString  the string to be decoded
Definition at line 213 of file NWWWCodec.cp.

References monsterworks::cgi::NWWWCodec::FromWWW(), and monsterworks::cgi::QueryWords.

Referenced by NFormInitialize().

std::string monsterworks::cgi::NWWWCodec::ToWWW const std::string &  inPlainText  ) 
 

converts a string to WWW URL encoded string

encodes as string in to ww-url-encoded form:
plaintext characterencoded as
space+
alphanumericitself
nonalphanumeric%[hex][hex]

Returns:
the result of the encoding
Parameters:
inPlainText  the string to be encoded
Definition at line 51 of file NWWWCodec.cp.


monsterworks Code by Monsterworks. Made available under the GNU Public License.
Documentation by doxygen.