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
|
/***************************************************************************
* XMLReader.h
*
* Tue Jan 2 14:18:08 2007
* Copyright 2007 Fernando TarĂn Morales
* icemanf@gmail.com
****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
#ifndef _XMLREADER_H
#define _XMLREADER_H
#include <glibmm/ustring.h>
#include <libxml/xmlreader.h>
#define MAXVALUE 20
class XMLReader{
public:
XMLReader();
XMLReader(const Glib::ustring&);
~XMLReader();
void setFileName(const Glib::ustring & fname) { filename = fname; };
const Glib::ustring & getFileName(void) const { return filename; };
int goToNextElement(void);
int getDepth(void) const { return xmlTextReaderDepth(reader); }
bool goToRootElement(void);
bool goToNextAttribute(void);
bool findChild(const Glib::ustring &);
bool findChildFromBeginning(const Glib::ustring &);
bool isEmpty(void) { return xmlTextReaderIsEmptyElement(reader); };
bool hasAttributes(void) { return (numattrs > 0); };
const Glib::ustring & getNodeName(void) const { return presentnode; };
const Glib::ustring & getFather(void) const { return father_node[getDepth() - 1]; };
Glib::ustring getChildData(void);
const Glib::ustring & getAttributeData(void) const { return attributedata; };
const Glib::ustring & getAttributeName(void) const { return attributename; };
private:
bool initializeReader(void);
bool isReaderInitilizated(void) const { return !(reader == NULL); };
void freeReader(void) { xmlFreeTextReader(reader); reader = NULL; };
Glib::ustring filename;
int numattrs, currentattr;
xmlTextReaderPtr reader;
Glib::ustring childdata;
Glib::ustring attributename;
Glib::ustring attributedata;
Glib::ustring presentnode;
Glib::ustring father_node[MAXVALUE], attributedatatmp[MAXVALUE];
};
#endif /* _XMLREADER_H */
|