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.
 
 
 
 
 
 

72 lines
2.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #define CPPCMS_SOURCE
  20. #include "regex.h"
  21. #include "config.h"
  22. #ifdef CPPCMS_USE_EXTERNAL_BOOST
  23. # include <boost/regex.hpp>
  24. #else // Internal Boost
  25. # include <cppcms_boost/regex.hpp>
  26. namespace boost = cppcms_boost;
  27. #endif
  28. namespace cppcms { namespace util {
  29. struct regex_result::data {
  30. std::string str;
  31. boost::cmatch match;
  32. };
  33. regex_result::regex_result() : d(new data)
  34. {
  35. }
  36. regex_result::~regex_result()
  37. {
  38. }
  39. std::string regex_result::operator[](int n)
  40. {
  41. return d->match[n];
  42. }
  43. struct regex::data {
  44. boost::regex r;
  45. data(std::string const &e) : r(e) {}
  46. };
  47. regex::regex(std::string const &e) : d(new data(e))
  48. {
  49. }
  50. regex::~regex()
  51. {
  52. }
  53. bool regex::match(std::string const &str,regex_result &res) const
  54. {
  55. //
  56. // Make sure that cmatch is valid, even if original string already is not
  57. //
  58. res.d->str = str;
  59. return boost::regex_match(res.d->str.c_str(),res.d->match,d->r);
  60. }
  61. bool regex::match(std::string const &str) const
  62. {
  63. return boost::regex_match(str.c_str(),d->r);
  64. }
  65. }} // cppcms::util