regex_yaml.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "regex_yaml.h"
  2. namespace YAML {
  3. // constructors
  4. RegEx::RegEx(REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params{} {}
  5. RegEx::RegEx() : RegEx(REGEX_EMPTY) {}
  6. RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch), m_z(0), m_params{} {}
  7. RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {}
  8. RegEx::RegEx(const std::string& str, REGEX_OP op)
  9. : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {}
  10. // combination constructors
  11. RegEx operator!(const RegEx& ex) {
  12. RegEx ret(REGEX_NOT);
  13. ret.m_params.push_back(ex);
  14. return ret;
  15. }
  16. RegEx operator|(const RegEx& ex1, const RegEx& ex2) {
  17. RegEx ret(REGEX_OR);
  18. ret.m_params.push_back(ex1);
  19. ret.m_params.push_back(ex2);
  20. return ret;
  21. }
  22. RegEx operator&(const RegEx& ex1, const RegEx& ex2) {
  23. RegEx ret(REGEX_AND);
  24. ret.m_params.push_back(ex1);
  25. ret.m_params.push_back(ex2);
  26. return ret;
  27. }
  28. RegEx operator+(const RegEx& ex1, const RegEx& ex2) {
  29. RegEx ret(REGEX_SEQ);
  30. ret.m_params.push_back(ex1);
  31. ret.m_params.push_back(ex2);
  32. return ret;
  33. }
  34. } // namespace YAML