-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRule.cpp
51 lines (43 loc) · 1.03 KB
/
Rule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Rule.cpp: implementation of the CRule class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Rule.h"
#include "Handler.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRule::CRule()
{
}
CRule::~CRule()
{
}
bool CRule::action(const string &block, CHandler *handler)
{
if(handler){
handler->start(m_type);
handler->feed(block);
handler->end(m_type);
return true;
}
return false;
}
bool CListItemRule::action(const string& block, CHandler* handler)
{
handler->start(m_type);
handler->feed(block.substr(1, block.size() - 1));
handler->end(m_type);
return true;
}
bool CListRule::action(const string& block, CHandler* handler)
{
if(!m_bInside && CListItemRule::condition(block)){
handler->start(m_type);
m_bInside = true;
}else if(m_bInside && !CListItemRule::condition(block)){
handler->end(m_type);
m_bInside = false;
}
return false;
}