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