PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/raytracer/yaml/regex.cpp

https://github.com/catrope/cg
C++ | 61 lines | 49 code | 10 blank | 2 comment | 3 complexity | 7201d58b4f7e59e156a68ff4ab78331a MD5 | raw file
  1. #include "crt.h"
  2. #include "regex.h"
  3. namespace YAML
  4. {
  5. // constructors
  6. RegEx::RegEx(): m_op(REGEX_EMPTY)
  7. {
  8. }
  9. RegEx::RegEx(REGEX_OP op): m_op(op)
  10. {
  11. }
  12. RegEx::RegEx(char ch): m_op(REGEX_MATCH), m_a(ch)
  13. {
  14. }
  15. RegEx::RegEx(char a, char z): m_op(REGEX_RANGE), m_a(a), m_z(z)
  16. {
  17. }
  18. RegEx::RegEx(const std::string& str, REGEX_OP op): m_op(op)
  19. {
  20. for(std::size_t i=0;i<str.size();i++)
  21. m_params.push_back(RegEx(str[i]));
  22. }
  23. // combination constructors
  24. RegEx operator ! (const RegEx& ex)
  25. {
  26. RegEx ret(REGEX_NOT);
  27. ret.m_params.push_back(ex);
  28. return ret;
  29. }
  30. RegEx operator || (const RegEx& ex1, const RegEx& ex2)
  31. {
  32. RegEx ret(REGEX_OR);
  33. ret.m_params.push_back(ex1);
  34. ret.m_params.push_back(ex2);
  35. return ret;
  36. }
  37. RegEx operator && (const RegEx& ex1, const RegEx& ex2)
  38. {
  39. RegEx ret(REGEX_AND);
  40. ret.m_params.push_back(ex1);
  41. ret.m_params.push_back(ex2);
  42. return ret;
  43. }
  44. RegEx operator + (const RegEx& ex1, const RegEx& ex2)
  45. {
  46. RegEx ret(REGEX_SEQ);
  47. ret.m_params.push_back(ex1);
  48. ret.m_params.push_back(ex2);
  49. return ret;
  50. }
  51. }