2 * Amiga Generic Set - set of libraries and includes to ease sw development for all Amiga platforms
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "LibrarySpool.h"
27 #include <libdata/expat.h>
30 * this class relies on expat2.library (both binary and include files) that i have created...
44 virtual void Initialize(const char* sN
, const char* sV
);
45 virtual void Initialize(const char* sN
, int64 lV
);
49 XMLAttribute(const char* sName
, const char* sValue
);
50 XMLAttribute(const char* sName
, int64 sValue
);
51 virtual ~XMLAttribute();
53 virtual String
&GetName();
54 virtual String
&GetValue();
55 virtual void SetName(const char* sName
);
56 virtual void SetValue(const char* sValue
);
57 virtual void SetValue(uint64 sValue
);
60 class XMLElement
: public XMLAttribute
63 VectorT
<XMLElement
*> hChildren
;
64 VectorT
<XMLAttribute
*> hAttributes
;
67 virtual void Initialize(const char* sN
, const char* sV
);
68 static bool freeAttr(XMLAttribute
* const& attr
);
69 static bool freeNode(XMLElement
* const& node
);
72 XMLElement(const char* sName
, const char* sValue
);
73 virtual ~XMLElement();
75 virtual long GetChildrenCount();
76 virtual XMLElement
*GetChild(long i
);
77 virtual long GetAttributesCount();
78 virtual XMLAttribute
*GetAttribute(long i
);
79 virtual String
*GetChildValue(const char *sName
);
80 virtual String
*GetAttributeValue(const char *sName
);
81 virtual XMLElement
*FindChild(const char* sName
);
82 virtual XMLAttribute
*FindAttribute(const char* sName
);
84 virtual XMLElement
*AddChild(const char* sName
, const char* sValue
);
85 virtual XMLAttribute
*AddAttribute(const char* sName
, const char* sValue
);
86 virtual XMLAttribute
*AddAttribute(const char* sName
, int64 lValue
);
87 virtual XMLElement
*AddChild(XMLElement
* pElem
);
88 virtual XMLAttribute
*AddAttribute(XMLAttribute
*pAttr
);
89 virtual void RemChild(XMLElement
* pElem
);
90 virtual void RemAttribute(XMLAttribute
* pAttr
);
93 class XMLDocument
: public XMLElement
98 XErr_OK
= 0, // all ok
99 XErr_NoExpat
, // unable to open expat2.library
100 XErr_NoFile
, // unable to open file
101 XErr_NoMemory
, // not enough memory
102 XErr_CorruptedXML
, // corrupted xml file
103 XErr_NoParser
// unable to create parser
113 VectorT
<XMLElement
*> hParse
;
115 static void fXMLStartHandler(void* userData
, const XML_Char
*name
, const XML_Char
**atts
);
116 static void fXMLEndHandler(void* userData
, const XML_Char
*name
);
117 static void fXMLContentHandler(void* userData
, const XML_Char
*begin
, int length
);
118 void XMLStartHandler(const XML_Char
*name
, const XML_Char
**atts
);
119 void XMLEndHandler(const XML_Char
*name
);
120 void XMLContentHandler(const XML_Char
*begin
, int length
);
121 void XMLWriteElement(BPTR fh
, XMLElement
* pElem
);
124 XMLDocument(const char* sName
);
125 virtual ~XMLDocument();
127 bool ReadXML(const char *sName
);
128 bool WriteXML(const char *sName
);
129 bool ReadXML(BPTR file
);
130 bool WriteXML(BPTR file
);
135 #endif /*XMLDATA_H_*/