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.
 
 
 
 
 
 

94 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_UTIL_H
  9. #define CPPCMS_UTIL_H
  10. #include <cppcms/defs.h>
  11. #include <string>
  12. namespace cppcms {
  13. ///
  14. /// \brief This namespace holds various useful helper functions for we developer
  15. ///
  16. namespace util {
  17. ///
  18. /// Escape string for inclusion in HTML page, i.e.
  19. ///
  20. /// - < - \&lt;
  21. /// - > - \&gt;
  22. /// - \& - \&amp;
  23. /// - &quot; - \&quot;
  24. /// - &#39; - \&#39;
  25. ///
  26. /// Note, this function does not deal with encodings, so it's up to you to
  27. /// provide valid text encoding
  28. ///
  29. std::string CPPCMS_API escape(std::string const &s);
  30. ///
  31. /// Escape string for inclusion in HTML page, i.e.
  32. ///
  33. /// - < - \&lt;
  34. /// - > - \&gt;
  35. /// - \& - \&amp;
  36. /// - &quot; - \&quot;
  37. /// - &#39; - \&#39;
  38. ///
  39. /// Note, this function does not deal with encodings, so it's up to you to
  40. /// provide valid text encoding
  41. ///
  42. void CPPCMS_API escape(char const *begin,char const *end,std::ostream &output);
  43. ///
  44. /// Escape string for inclusion in HTML page, i.e.
  45. ///
  46. /// - < - \&lt;
  47. /// - > - \&gt;
  48. /// - \& - \&amp;
  49. /// - &quot; - \&quot;
  50. /// - &#39; - \&#39;
  51. ///
  52. /// Note, this function does not deal with encodings, so it's up to you to
  53. /// provide valid text encoding
  54. ///
  55. /// if I/O operation on output fails returns -1, otherwise returns 0
  56. int CPPCMS_API escape(char const *begin,char const *end,std::streambuf &output);
  57. ///
  58. /// Encode string for URL (percent encoding)
  59. ///
  60. std::string CPPCMS_API urlencode(std::string const &s);
  61. ///
  62. /// Encode string for URL (percent encoding)
  63. ///
  64. void CPPCMS_API urlencode(char const *begin,char const *end,std::ostream &output);
  65. ///
  66. /// Encode string for URL (percent encoding), returns -1 in case of IO failure, and 0 on success
  67. ///
  68. int CPPCMS_API urlencode(char const *begin,char const *end,std::streambuf &output);
  69. ///
  70. /// Decode string from URL-encoding (percent-encoding)
  71. ///
  72. std::string CPPCMS_API urldecode(std::string const &s);
  73. ///
  74. /// Decode text in range [begin,end) from URL-encoding (percent-encoding)
  75. ///
  76. std::string CPPCMS_API urldecode(char const *begin,char const *end);
  77. ///
  78. /// Make MD5 hash of string \a input converting into binary string of 16 bytes
  79. ///
  80. std::string CPPCMS_API md5(std::string const &input);
  81. ///
  82. /// Make MD5 hash of string \a input converting it into hexadecimal string representing this hash
  83. ///
  84. std::string CPPCMS_API md5hex(std::string const &input);
  85. }
  86. }
  87. #endif