#pragma once #ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #include #include namespace YAML { class Stream; enum REGEX_OP { REGEX_EMPTY, REGEX_MATCH, REGEX_RANGE, REGEX_OR, REGEX_AND, REGEX_NOT, REGEX_SEQ }; // simplified regular expressions // . Only straightforward matches (no repeated characters) // . Only matches from start of string class RegEx { public: RegEx(); RegEx(char ch); RegEx(char a, char z); RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); ~RegEx() {} friend RegEx operator ! (const RegEx& ex); friend RegEx operator || (const RegEx& ex1, const RegEx& ex2); friend RegEx operator && (const RegEx& ex1, const RegEx& ex2); friend RegEx operator + (const RegEx& ex1, const RegEx& ex2); bool Matches(char ch) const; bool Matches(const std::string& str) const; bool Matches(const Stream& in) const; template bool Matches(const Source& source) const; int Match(const std::string& str) const; int Match(const Stream& in) const; template int Match(const Source& source) const; private: RegEx(REGEX_OP op); template bool IsValidSource(const Source& source) const; template int MatchUnchecked(const Source& source) const; template int MatchOpEmpty(const Source& source) const; template int MatchOpMatch(const Source& source) const; template int MatchOpRange(const Source& source) const; template int MatchOpOr(const Source& source) const; template int MatchOpAnd(const Source& source) const; template int MatchOpNot(const Source& source) const; template int MatchOpSeq(const Source& source) const; private: REGEX_OP m_op; char m_a, m_z; std::vector m_params; }; } #include "regeximpl.h" #endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66