PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/Thirdparty/yaml-cpp/src/regex.cpp

https://bitbucket.org/Tomasen/splayer/
C++ | 60 lines | 48 code | 10 blank | 2 comment | 3 complexity | 10c9634abb027d520ca3b7b19bd74dcc MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0, LGPL-2.0, LGPL-2.1, BSD-3-Clause, LGPL-3.0, AGPL-1.0
  1. #include "regex.h"
  2. namespace YAML
  3. {
  4. // constructors
  5. RegEx::RegEx(): m_op(REGEX_EMPTY)
  6. {
  7. }
  8. RegEx::RegEx(REGEX_OP op): m_op(op)
  9. {
  10. }
  11. RegEx::RegEx(char ch): m_op(REGEX_MATCH), m_a(ch)
  12. {
  13. }
  14. RegEx::RegEx(char a, char z): m_op(REGEX_RANGE), m_a(a), m_z(z)
  15. {
  16. }
  17. RegEx::RegEx(const std::string& str, REGEX_OP op): m_op(op)
  18. {
  19. for(std::size_t i=0;i<str.size();i++)
  20. m_params.push_back(RegEx(str[i]));
  21. }
  22. // combination constructors
  23. RegEx operator ! (const RegEx& ex)
  24. {
  25. RegEx ret(REGEX_NOT);
  26. ret.m_params.push_back(ex);
  27. return ret;
  28. }
  29. RegEx operator || (const RegEx& ex1, const RegEx& ex2)
  30. {
  31. RegEx ret(REGEX_OR);
  32. ret.m_params.push_back(ex1);
  33. ret.m_params.push_back(ex2);
  34. return ret;
  35. }
  36. RegEx operator && (const RegEx& ex1, const RegEx& ex2)
  37. {
  38. RegEx ret(REGEX_AND);
  39. ret.m_params.push_back(ex1);
  40. ret.m_params.push_back(ex2);
  41. return ret;
  42. }
  43. RegEx operator + (const RegEx& ex1, const RegEx& ex2)
  44. {
  45. RegEx ret(REGEX_SEQ);
  46. ret.m_params.push_back(ex1);
  47. ret.m_params.push_back(ex2);
  48. return ret;
  49. }
  50. }