libDwm-0.9.45
DwmCgi.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 1999-2001, 2016
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
32// PURPOSE, OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _CGI_HH_
42#define _CGI_HH_
43
44#include <string>
45#include <map>
46
47namespace Dwm {
48
49 //--------------------------------------------------------------------------
50 // class Cgi
51 //--------------------------------------------------------------------------
63 //--------------------------------------------------------------------------
64 class Cgi
65 {
66 public:
67 typedef std::map<std::string,std::string> valueMap_t;
68 typedef valueMap_t::iterator iterator;
69 typedef valueMap_t::const_iterator const_iterator;
70
71 //------------------------------------------------------------------------
76 //------------------------------------------------------------------------
77 Cgi();
78
79 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
83
84 //------------------------------------------------------------------------
86 //------------------------------------------------------------------------
87 const std::string & RequestMethod() const;
88
89 //------------------------------------------------------------------------
91 //------------------------------------------------------------------------
92 const std::string & RequestMethod(const std::string & requestMethod);
93
94 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 valueMap_t & QueryValues();
99
100 valueMap_t & EnvValues();
101
102 //------------------------------------------------------------------------
105 //------------------------------------------------------------------------
106 static void UrlEncode(const std::string & src, std::string & dst);
107
108 //------------------------------------------------------------------------
110 //------------------------------------------------------------------------
111 static std::string UrlEncode(const std::string & src);
112
113 //------------------------------------------------------------------------
116 //------------------------------------------------------------------------
117 static void HtmlEncode(const std::string & src, std::string & dst);
118
119 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
122 static std::string HtmlEncode(const std::string & src);
123
124 private:
125 std::string _requestMethod;
126 valueMap_t _queryValues;
127 valueMap_t _envValues;
128
129 static std::map<char,std::string> _urlEncodingMap;
130 static void LoadUrlEncodingMap();
131 static std::map<char,std::string> _htmlEncodingMap;
132 static void LoadHtmlEncodingMap();
133 };
134
135
136} // namespace Dwm
137
138#endif // _CGI_HH_
139
140//---------------------------- emacs settings -----------------------------
141// Local Variables:
142// mode: C++
143// tab-width: 2
144// indent-tabs-mode: nil
145// c-basic-offset: 2
146// End:
147//-------------------------------------------------------------------------
This class encapsulates CGI input.
Definition DwmCgi.hh:65
~Cgi()
destructor
valueMap_t & QueryValues()
Returns a reference to the query values sent by the client.
static void HtmlEncode(const std::string &src, std::string &dst)
Encodes a string src into an HTML string dst, with special characters escaped.
Cgi()
Constructor.
static std::string HtmlEncode(const std::string &src)
Returns an HTML-escaped version of src.
static void UrlEncode(const std::string &src, std::string &dst)
Encodes a URL string src into a string dst, with special characters escaped.
const std::string & RequestMethod() const
Returns the HTTP request method.
const std::string & RequestMethod(const std::string &requestMethod)
Sets and returns the HTTP request method.
static std::string UrlEncode(const std::string &src)
Returns a URL-escaped version of src.