PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/cgi/parser.hpp

https://bitbucket.org/nileshgr/cxxcms/
C++ Header | 76 lines | 23 code | 21 blank | 32 comment | 0 complexity | 251ef5c5192a6ba89df9030778b11670 MD5 | raw file
 1#ifndef CGI_PARSER_HPP
 2#define CGI_PARSER_HPP
 3#include <cgi/cgi.hpp>
 4
 5/*
 6 * This namespace CGI will contain all CGI-related functions and classes.
 7 * All according to RFCs.
 8 */
 9
10namespace CGI {
11
12
13  /*
14   * Query String Parser, according to RFC 1738
15   */
16
17  class Parser {
18  private:
19
20    /*
21     * The raw query string as obtained from getenv('QUERY_STRING')
22     */
23    
24    std::string source;
25
26    /*
27     * Query string sanitizer
28     * There are some string combinations, that can produce errors, major ones!
29     * Some of them are described here- https://bitbucket.org/nileshgr/cppcms/wiki/Plan
30     */
31
32    void _sanitize(std::string&, size_t);
33    
34  public:
35
36    /*
37     * Constructor accepting std::string
38     * Calls setQstr()
39     */
40
41    Parser(std::string s) {
42      setQstr(s);
43    }
44
45    Parser() {
46    }
47
48    /*
49     * Property setter accepting std::string
50     */
51
52    const Parser& setQstr(std::string);
53
54    /*
55     * Property retriever in type const char*
56     */
57
58    const char* getQstr() const;
59
60    /*
61     * The parser, returns reference to auto_ptr'd Dict.
62     */
63
64    Dict_ptr_t parse();
65
66    /*
67     * Clear function. Calls the destructor to clear up everything allocated so far
68     * and the object is like a new instance.
69     */
70
71    void clear() {
72      this->~Parser();
73    }
74  };
75}
76#endif