ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

106 lines
2.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_HTTP_CONTENT_TYPE_H
  9. #define CPPCMS_HTTP_CONTENT_TYPE_H
  10. #include <cppcms/defs.h>
  11. #include <booster/shared_ptr.h>
  12. #include <string>
  13. #include <map>
  14. namespace cppcms { namespace http {
  15. ///
  16. /// \brief Class that represents parsed Content-Type header, this is immutable
  17. /// class. Once it is created its values does not change.
  18. ///
  19. class CPPCMS_API content_type {
  20. public:
  21. ///
  22. /// The type part of content type, for example, for "text/html; charset=UTF-8" it would be "text" in lower case
  23. ///
  24. std::string type() const;
  25. ///
  26. /// The subtype part of content type, for example, for "text/html; charset=UTF-8" it would be "html" in lower case
  27. ///
  28. std::string subtype() const;
  29. ///
  30. /// The full media type of content type, for example, for "text/html; charset=UTF-8" it would be "text/html" in lower case
  31. ///
  32. std::string media_type() const;
  33. ///
  34. /// Charset parameter, if given, for example, for "text/html; charset=UTF-8" it would be "UTF-8". If charset is not
  35. /// specified, it would return an empty string
  36. ///
  37. std::string charset() const;
  38. ///
  39. /// All parameters, all parameter keys are in lower case, the values are given as is.
  40. ///
  41. std::map<std::string,std::string> parameters() const;
  42. ///
  43. /// Get parameter's value by key (should be in lowercase), returns empty string if not set
  44. ///
  45. std::string parameter_by_key(std::string const &key) const;
  46. ///
  47. /// Check if the parameter is set using key (should be in lowercase)
  48. ///
  49. bool parameter_is_set(std::string const &key) const;
  50. ///
  51. /// Check if media type application/x-www-form-urlencoded content_type
  52. ///
  53. /// \ver{v1_2}
  54. bool is_form_urlencoded() const;
  55. ///
  56. /// Check if media type is multipart/form-data content_type
  57. ///
  58. /// \ver{v1_2}
  59. bool is_multipart_form_data() const;
  60. ///
  61. /// Parse content type \a ct and create the class
  62. ///
  63. content_type(std::string const &ct);
  64. ///
  65. /// Parse content type \a ct and create the class
  66. ///
  67. content_type(char const *ct);
  68. ///
  69. /// Parse content type in range [begin,end) and create the class
  70. ///
  71. content_type(char const *begin,char const *end);
  72. ///
  73. /// Empty one...
  74. ///
  75. content_type();
  76. ///
  77. /// Copy constructor
  78. ///
  79. content_type(content_type const &);
  80. ///
  81. /// Assignment operator
  82. ///
  83. content_type const &operator=(content_type const &);
  84. ///
  85. /// Destructor
  86. ///
  87. ~content_type();
  88. private:
  89. struct data;
  90. void parse(char const *b,char const *e);
  91. booster::shared_ptr<data> d;
  92. };
  93. } } //::cppcms::http
  94. #endif