VS10 solution files, convert from NULL macro to nullptr.
[shibboleth/sp.git] / shibsp / util / CGIParser.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/util/CGIParser.h
19  * 
20  * CGI GET/POST parameter parsing.
21  */
22
23 #ifndef __shibsp_cgi_h__
24 #define __shibsp_cgi_h__
25
26 #include <shibsp/base.h>
27
28 #include <map>
29 #include <string>
30
31 namespace xmltooling {
32     class XMLTOOL_API HTTPRequest;
33 };
34
35 namespace shibsp {
36
37 #if defined (_MSC_VER)
38     #pragma warning( push )
39     #pragma warning( disable : 4251 )
40 #endif
41
42     /**
43      * CGI GET/POST parameter parsing
44      */
45     class SHIBSP_API CGIParser
46     {
47         MAKE_NONCOPYABLE(CGIParser);
48     public:
49         /**
50          * Constructor
51          * 
52          * @param request   HTTP request interface
53          */
54         CGIParser(const xmltooling::HTTPRequest& request);
55
56         ~CGIParser();
57
58         /** Alias for multimap iterator. */
59         typedef std::multimap<std::string,char*>::const_iterator walker;
60         
61         /**
62          * Returns a pair of bounded iterators around the values of a parameter.
63          * 
64          * @param name  name of parameter, or nullptr to return all parameters
65          * @return  a pair of multimap iterators surrounding the matching value(s)
66          */
67         std::pair<walker,walker> getParameters(const char* name) const;
68         
69     private:
70         char* fmakeword(char stop, size_t *cl, const char** ppch);
71         char* makeword(char *line, char stop);
72         void plustospace(char *str);
73
74         std::multimap<std::string,char*> kvp_map;
75     };
76
77 #if defined (_MSC_VER)
78     #pragma warning( pop )
79 #endif
80
81 };
82
83 #endif /* __shibsp_cgi_h__ */