-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandler.cpp
62 lines (49 loc) · 1.31 KB
/
Handler.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
52
53
54
55
56
57
58
59
60
61
62
// Handler.cpp: implementation of the CHandler class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Handler.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
map<string, CHandler::pFunc> CHandler::m_funcmap;
map<string, CHandler::pFuncSub> CHandler::m_funcsubmap;
CHandler::CHandler()
{
}
CHandler::~CHandler()
{
}
void CHandler::callback(const string &str)
{
funcmap_iter iter = m_funcmap.find(str);
if(iter != m_funcmap.end())
(this->*(iter->second))();
else
cout << "invalid function name : " << str << endl;
}
void CHandler::start(const string &func_name)
{
callback(string("CHTMLRenderer::start_") + func_name);
}
void CHandler::end(const string &func_name)
{
callback(string("CHTMLRenderer::end_") + func_name);
}
void CHandler::feed(const string &block)
{
cout << block << endl;
}
string CHandler::sub(const string &sub_name)
{
return callback_sub(string("CHTMLRenderer::sub_") + sub_name);
}
string CHandler::callback_sub(const string &str)
{
funcsubmap_iter iter = m_funcsubmap.find(str);
if(iter != m_funcsubmap.end())
return (this->*(iter->second))();
else
cout << "invalid sub name : " << str << endl;
return "$001";
}