-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseXML.h
51 lines (42 loc) · 1.17 KB
/
parseXML.h
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
#ifndef PARSEXML__H
#define PARSEXML__H
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <deque>
#include <expat.h>
using std::map;
using std::string;
const int BUFSIZE = 512;
class ParseXML {
public:
ParseXML( const string& fn ) :
filename(fn),
parser(NULL),
tagNames(),
xmlData()
{ parseXML(); }
virtual ~ParseXML() { XML_ParserFree(parser); }
const map<string, string> getXmlData() const { return xmlData; }
static void wrapper4Start(void *data, const char *el, const char **attr);
static void wrapper4End(void *data, const char *el);
static void wrapper4Chars(void *data, const char *text, int textlen);
private:
const string filename;
XML_Parser parser;
char buff[BUFSIZE];
std::deque<string> tagNames;
std::map<string, string> xmlData;
void parseXML();
void displayData() const;
void start(const char *el, const char *attr[]);
void end(const char *);
void chars(const char *text, int textlen);
std::string makeTag() const;
std::string makeTag(const std::string&) const;
void stripTrailWhiteSpace(string&) const;
ParseXML& operator=(const ParseXML&);
ParseXML(const ParseXML&);
};
#endif