regex.cpp 1.03 KB
Newer Older
1
2
3
4
#include "regex.h"

namespace YAML
{
5
6
	// constructors
	RegEx::RegEx(): m_op(REGEX_EMPTY)
7
8
	{
	}
9
10
	
	RegEx::RegEx(REGEX_OP op): m_op(op)
11
12
	{
	}
13
14
	
	RegEx::RegEx(char ch): m_op(REGEX_MATCH), m_a(ch)
15
16
	{
	}
17
18
	
	RegEx::RegEx(char a, char z): m_op(REGEX_RANGE), m_a(a), m_z(z)
19
20
	{
	}
21
22
	
	RegEx::RegEx(const std::string& str, REGEX_OP op): m_op(op)
23
	{
24
		for(std::size_t i=0;i<str.size();i++)
25
26
27
			m_params.push_back(RegEx(str[i]));
	}
	
28
	// combination constructors
29
30
31
32
33
34
	RegEx operator ! (const RegEx& ex)
	{
		RegEx ret(REGEX_NOT);
		ret.m_params.push_back(ex);
		return ret;
	}
35
	
36
37
38
39
40
41
42
	RegEx operator || (const RegEx& ex1, const RegEx& ex2)
	{
		RegEx ret(REGEX_OR);
		ret.m_params.push_back(ex1);
		ret.m_params.push_back(ex2);
		return ret;
	}
43
	
44
45
46
47
48
49
50
	RegEx operator && (const RegEx& ex1, const RegEx& ex2)
	{
		RegEx ret(REGEX_AND);
		ret.m_params.push_back(ex1);
		ret.m_params.push_back(ex2);
		return ret;
	}
51
	
52
53
54
55
56
57
	RegEx operator + (const RegEx& ex1, const RegEx& ex2)
	{
		RegEx ret(REGEX_SEQ);
		ret.m_params.push_back(ex1);
		ret.m_params.push_back(ex2);
		return ret;
58
	}	
59
60
}