/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. * This namespace CGI will contain all CGI-related functions and classes.
  6. * All according to RFCs.
  7. */
  8. namespace CGI {
  9. /*
  10. * Query String Parser, according to RFC 1738
  11. */
  12. class Parser {
  13. private:
  14. /*
  15. * The raw query string as obtained from getenv('QUERY_STRING')
  16. */
  17. std::string source;
  18. /*
  19. * Query string sanitizer
  20. * There are some string combinations, that can produce errors, major ones!
  21. * Some of them are described here- https://bitbucket.org/nileshgr/cppcms/wiki/Plan
  22. */
  23. void _sanitize(std::string&, size_t);
  24. public:
  25. /*
  26. * Constructor accepting std::string
  27. * Calls setQstr()
  28. */
  29. Parser(std::string s) {
  30. setQstr(s);
  31. }
  32. Parser() {
  33. }
  34. /*
  35. * Property setter accepting std::string
  36. */
  37. const Parser& setQstr(std::string);
  38. /*
  39. * Property retriever in type const char*
  40. */
  41. const char* getQstr() const;
  42. /*
  43. * The parser, returns reference to auto_ptr'd Dict.
  44. */
  45. Dict_ptr_t parse();
  46. /*
  47. * Clear function. Calls the destructor to clear up everything allocated so far
  48. * and the object is like a new instance.
  49. */
  50. void clear() {
  51. this->~Parser();
  52. }
  53. };
  54. }
  55. #endif