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