libiqxmlrpc
0.12.4
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Typedefs
Enumerations
libiqxmlrpc
parser2.h
1
// Libiqxmlrpc - an object-oriented XML-RPC solution.
2
// Copyright (C) 2011 Anton Dedov
3
4
#ifndef _iqxmlrpc_parser2_h_
5
#define _iqxmlrpc_parser2_h_
6
7
#include <map>
8
#include <string>
9
#include <vector>
10
#include <boost/shared_ptr.hpp>
11
12
namespace
iqxmlrpc {
13
14
class
Parser;
15
16
class
BuilderBase
{
17
public
:
18
BuilderBase
(
Parser
&,
bool
expect_text =
false
);
19
20
void
21
visit_element(
const
std::string& tag);
22
23
void
24
visit_element_end(
const
std::string& tag);
25
26
void
27
visit_text(
const
std::string&);
28
29
bool
30
expects_text()
const
31
{
32
return
expect_text_;
33
}
34
35
int
36
depth()
const
37
{
38
return
depth_;
39
}
40
41
bool
42
wants_exit()
const
43
{
44
return
want_exit_;
45
}
46
47
void
48
build(
bool
flat =
false
);
49
50
protected
:
51
template
<
class
R,
class
BUILDER>
52
R
53
sub_build(
bool
flat =
false
)
54
{
55
BUILDER b(parser_);
56
b.build(flat);
57
return
b.result();
58
}
59
60
void
61
want_exit()
62
{
63
want_exit_ =
true
;
64
}
65
66
virtual
void
67
do_visit_element(
const
std::string&) = 0;
68
69
virtual
void
70
do_visit_element_end(
const
std::string&);
71
72
virtual
void
73
do_visit_text(
const
std::string&);
74
75
Parser
& parser_;
76
int
depth_;
77
bool
expect_text_;
78
bool
want_exit_;
79
};
80
81
class
Parser
{
82
public
:
83
Parser
(
const
std::string& buf);
84
85
void
86
parse(
BuilderBase
& builder);
87
88
std::string
89
get_data();
90
91
std::string
92
context()
const
;
93
94
private
:
95
class
Impl;
96
boost::shared_ptr<Impl> impl_;
97
};
98
99
class
StateMachine
{
100
public
:
101
struct
StateTransition
{
102
int
prev_state;
103
int
new_state;
104
const
char
* tag;
105
};
106
107
StateMachine
(
const
Parser
&,
int
start_state);
108
109
void
110
set_transitions(
const
StateTransition
*);
111
112
int
113
get_state()
const
{
return
curr_; }
114
115
int
116
change(
const
std::string& tag);
117
118
void
119
set_state(
int
new_state);
120
121
private
:
122
typedef
const
StateTransition* TransitionMap;
123
124
const
Parser
& parser_;
125
int
curr_;
126
TransitionMap trans_;
127
};
128
129
}
// namespace iqxmlrpc
130
131
#endif
132
// vim:sw=2:ts=2:et:
Generated on Mon Aug 5 2013 18:53:37 for libiqxmlrpc by
1.8.3.1