blob: 680df1d6887778631b0780dfd95cdbce64162482 (
plain)
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
|
#pragma once
#include <string>
#include <map>
#include <expat.h>
class SAXParser {
public:
SAXParser();
virtual ~SAXParser();
int parse();
int parse(const std::string& buffer);
protected:
using attr_t = std::map<std::string, std::string>;
virtual void characterData(const std::string& data) {}
virtual void startTag(const std::string& name, attr_t& attr) {}
virtual void endTag(const std::string& name) {}
virtual void parseError(const std::string& buf, std::size_t len, const std::string& error, std::size_t lineno);
virtual int readData(std::string& data, std::size_t size) { return 0; }
private:
XML_Parser p;
static void character_hndl(void* p, const XML_Char* s, int len);
static void start_hndl(void* p, const char* el, const char** attr);
static void end_hndl(void* p, const char* el);
};
|