-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXmlParser.h
More file actions
110 lines (88 loc) · 2.59 KB
/
XmlParser.h
File metadata and controls
110 lines (88 loc) · 2.59 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright 2010 www.codereba.com
*
* This file is part of xfreebar.
*
* xfreebar is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* xfreebar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xfreebar. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __XML_PARSER_H__
#define __XML_PARSER_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <atlbase.h>
#include <comdef.h>
#include <string>
#include <vector>
using std::wstring;
using std::vector;
void throwException(HRESULT hr,_bstr_t str,const TCHAR* file,INT32 line);
_bstr_t IntToStr(INT32 nVal, INT32 type);
namespace XML
{
template<class T>
class vectorDel : public vector<T>
{
public:
~vectorDel()
{
clear();
}
void clear()
{
for(iterator i=begin();i!=end();i++)
delete *i;
vector<T>::clear();
}
};
class XmlParser
{
public:
XmlParser();
virtual ~XmlParser() {}
void load(MSXML::IXMLDOMNodeListPtr doc);
MSXML::IXMLDOMDocumentPtr build();
virtual void parse(const _bstr_t& inputStr ,bool isFile = true);
void save ( _bstr_t& outputStr,bool isFile = true);
// operations
void preserveWhiteSpace(bool p);
void validateOnParse(bool p);
void resolveExternals(bool p);
protected:
// load
virtual void startNode(_bstr_t& str) = 0;
virtual void endNode() = 0;
virtual void processAttribute(_bstr_t& bstrName,_bstr_t& strValue) = 0;
VARIANT_BOOL doparseFile(const _bstr_t& fileName);
VARIANT_BOOL doparseStr (const _bstr_t& inputStr);
// save
virtual void do_save() = 0;
// read
virtual void on_parse() = 0;
virtual void on_end_parse() = 0;
//
// XML support code.
//
HRESULT ReportError(MSXML::IXMLDOMParseErrorPtr pXMLError);
bool IterateChildNodes(MSXML::IXMLDOMNodePtr pNode);
bool IterateAttibutes(MSXML::IXMLDOMNodePtr pNode);
HRESULT createDocument();
MSXML::IXMLDOMDocumentPtr m_pIXMLDOMDocument;
VARIANT_BOOL m_preserveWhiteSpace;
VARIANT_BOOL m_resolveExternals;
VARIANT_BOOL m_validateOnParse;
};
} // end namespace XML
#endif // __XML_PARSER_H__