diff --git a/src/dom/minidom.h b/src/dom/minidom.h
index df8cca88182f51662899fa7e46e179611ed7d6e7..41af805fbeed8460b1d8f77844a7f829d011897a 100644 (file)
--- a/src/dom/minidom.h
+++ b/src/dom/minidom.h
-#include <string>\r
-#include <vector>\r
-\r
-\r
-namespace MiniDom\r
-{\r
-typedef std::string DOMString;\r
-typedef unsigned int XMLCh;\r
-\r
-\r
-class Namespace\r
-{\r
-public:\r
- Namespace()\r
- {}\r
-\r
- Namespace(const DOMString &prefixArg, const DOMString &namespaceURIArg)\r
- {\r
- prefix = prefixArg;\r
- namespaceURI = namespaceURIArg;\r
- }\r
-\r
- Namespace(const Namespace &other)\r
- {\r
- prefix = other.prefix;\r
- namespaceURI = other.namespaceURI;\r
- }\r
-\r
- virtual ~Namespace()\r
- {}\r
-\r
- virtual DOMString getPrefix()\r
- { return prefix; }\r
-\r
- virtual DOMString getNamespaceURI()\r
- { return namespaceURI; }\r
-\r
-protected:\r
-\r
- DOMString prefix;\r
- DOMString namespaceURI;\r
-\r
-};\r
-\r
-class Attribute\r
-{\r
-public:\r
- Attribute()\r
- {}\r
-\r
- Attribute(const DOMString &nameArg, const DOMString &valueArg)\r
- {\r
- name = nameArg;\r
- value = valueArg;\r
- }\r
-\r
- Attribute(const Attribute &other)\r
- {\r
- name = other.name;\r
- value = other.value;\r
- }\r
-\r
- virtual ~Attribute()\r
- {}\r
-\r
- virtual DOMString getName()\r
- { return name; }\r
-\r
- virtual DOMString getValue()\r
- { return value; }\r
-\r
-protected:\r
-\r
- DOMString name;\r
- DOMString value;\r
-\r
-};\r
-\r
-\r
-class Element\r
-{\r
-friend class Parser;\r
-\r
-public:\r
- Element()\r
- {\r
- parent = NULL;\r
- }\r
-\r
- Element(const DOMString &nameArg)\r
- {\r
- parent = NULL;\r
- name = nameArg;\r
- }\r
-\r
- Element(const DOMString &nameArg, const DOMString &valueArg)\r
- {\r
- parent = NULL;\r
- name = nameArg;\r
- value = valueArg;\r
- }\r
-\r
- Element(const Element &other)\r
- {\r
- parent = other.parent;\r
- children = other.children;\r
- attributes = other.attributes;\r
- namespaces = other.namespaces;\r
- name = other.name;\r
- value = other.value;\r
- }\r
-\r
- virtual ~Element()\r
- {\r
- for (unsigned int i=0 ; i<children.size() ; i++)\r
- delete children[i];\r
- }\r
-\r
- virtual DOMString getName()\r
- { return name; }\r
-\r
- virtual DOMString getValue()\r
- { return value; }\r
-\r
- Element *getParent()\r
- { return parent; }\r
-\r
- std::vector<Element *> getChildren()\r
- { return children; }\r
-\r
- std::vector<Element *> findElements(const DOMString &name);\r
-\r
- DOMString getAttribute(const DOMString &name);\r
-\r
- void addChild(Element *child);\r
-\r
- void addAttribute(const DOMString &name, const DOMString &value);\r
-\r
- void addNamespace(const DOMString &prefix, const DOMString &namespaceURI);\r
-\r
-\r
- /**\r
- * Prettyprint an XML tree to an output stream. Elements are indented\r
- * according to element hierarchy.\r
- * @param f a stream to receive the output\r
- * @param elem the element to output\r
- */\r
- void writeIndented(FILE *f);\r
-\r
- /**\r
- * Prettyprint an XML tree to standard output. This is the equivalent of\r
- * writeIndented(stdout).\r
- * @param elem the element to output\r
- */\r
- void print();\r
-\r
-protected:\r
-\r
-\r
- void findElementsRecursive(std::vector<Element *>&res, const DOMString &name);\r
-\r
- void writeIndentedRecursive(FILE *f, int indent);\r
-\r
- Element *parent;\r
-\r
- std::vector<Element *>children;\r
-\r
- std::vector<Attribute> attributes;\r
- std::vector<Namespace> namespaces;\r
-\r
- DOMString name;\r
- DOMString value;\r
-\r
-};\r
-\r
-\r
-\r
-\r
-\r
-class Parser\r
-{\r
-public:\r
- Parser()\r
- { init(); }\r
-\r
- virtual ~Parser()\r
- {}\r
-\r
- /**\r
- * Parse XML in a char buffer.\r
- * @param buf a character buffer to parse\r
- * @param pos position to start parsing\r
- * @param len number of chars, from pos, to parse.\r
- * @return a pointer to the root of the XML document;\r
- */\r
- Element *parse(const char *buf,int pos,int len);\r
-\r
- /**\r
- * Parse XML in a char buffer.\r
- * @param buf a character buffer to parse\r
- * @param pos position to start parsing\r
- * @param len number of chars, from pos, to parse.\r
- * @return a pointer to the root of the XML document;\r
- */\r
- Element *parse(const DOMString &buf);\r
-\r
- /**\r
- * Parse a named XML file. The file is loaded like a data file;\r
- * the original format is not preserved.\r
- * @param fileName the name of the file to read\r
- * @return a pointer to the root of the XML document;\r
- */\r
- Element *parseFile(const char *fileName);\r
-\r
-\r
-\r
-\r
-private:\r
-\r
- void init()\r
- {\r
- keepGoing = true;\r
- currentNode = NULL;\r
- parselen = 0;\r
- parsebuf = NULL;\r
- currentPosition = 0;\r
- }\r
-\r
- void getLineAndColumn(long pos, long *lineNr, long *colNr);\r
-\r
- void error(char *fmt, ...);\r
-\r
- int peek(long pos);\r
-\r
- int match(long pos, const char *text);\r
-\r
- int skipwhite(long p);\r
-\r
- int getWord(int p0, DOMString &buf);\r
-\r
- int getQuoted(int p0, DOMString &buf, int do_i_parse);\r
-\r
- int parseVersion(int p0);\r
-\r
- int parseDoctype(int p0);\r
-\r
- int parseElement(int p0, Element *par,int depth);\r
-\r
- Element *parse(XMLCh *buf,int pos,int len);\r
-\r
- bool keepGoing;\r
- Element *currentNode;\r
- long parselen;\r
- XMLCh *parsebuf;\r
- DOMString cdatabuf;\r
- long currentPosition;\r
- int colNr;\r
-\r
-\r
-};\r
-\r
-\r
-\r
-}//namespace MiniDom\r
-\r
-\r
-//########################################################################\r
-//# E N D O F F I L E\r
-//########################################################################\r
-\r
+#include <glib.h>
+
+#include <string>
+#include <vector>
+
+
+namespace MiniDom
+{
+typedef std::string DOMString;
+typedef unsigned int XMLCh;
+
+
+class Namespace
+{
+public:
+ Namespace()
+ {}
+
+ Namespace(const DOMString &prefixArg, const DOMString &namespaceURIArg)
+ {
+ prefix = prefixArg;
+ namespaceURI = namespaceURIArg;
+ }
+
+ Namespace(const Namespace &other)
+ {
+ prefix = other.prefix;
+ namespaceURI = other.namespaceURI;
+ }
+
+ virtual ~Namespace()
+ {}
+
+ virtual DOMString getPrefix()
+ { return prefix; }
+
+ virtual DOMString getNamespaceURI()
+ { return namespaceURI; }
+
+protected:
+
+ DOMString prefix;
+ DOMString namespaceURI;
+
+};
+
+class Attribute
+{
+public:
+ Attribute()
+ {}
+
+ Attribute(const DOMString &nameArg, const DOMString &valueArg)
+ {
+ name = nameArg;
+ value = valueArg;
+ }
+
+ Attribute(const Attribute &other)
+ {
+ name = other.name;
+ value = other.value;
+ }
+
+ virtual ~Attribute()
+ {}
+
+ virtual DOMString getName()
+ { return name; }
+
+ virtual DOMString getValue()
+ { return value; }
+
+protected:
+
+ DOMString name;
+ DOMString value;
+
+};
+
+
+class Element
+{
+friend class Parser;
+
+public:
+
+ Element()
+ {
+ parent = NULL;
+ }
+
+ Element(const DOMString &nameArg)
+ {
+ parent = NULL;
+ name = nameArg;
+ }
+
+ Element(const DOMString &nameArg, const DOMString &valueArg)
+ {
+ parent = NULL;
+ name = nameArg;
+ value = valueArg;
+ }
+
+ Element(const Element &other)
+ {
+ parent = other.parent;
+ children = other.children;
+ attributes = other.attributes;
+ namespaces = other.namespaces;
+ name = other.name;
+ value = other.value;
+ }
+
+ virtual ~Element()
+ {
+ for (unsigned int i=0 ; i<children.size() ; i++)
+ delete children[i];
+ }
+
+ virtual DOMString getName()
+ { return name; }
+
+ virtual DOMString getValue()
+ { return value; }
+
+ Element *getParent()
+ { return parent; }
+
+ std::vector<Element *> getChildren()
+ { return children; }
+
+ int getLine()
+ { return line; }
+
+ std::vector<Element *> findElements(const DOMString &name);
+
+ DOMString getAttribute(const DOMString &name);
+
+ void addChild(Element *child);
+
+ void addAttribute(const DOMString &name, const DOMString &value);
+
+ void addNamespace(const DOMString &prefix, const DOMString &namespaceURI);
+
+
+ /**
+ * Prettyprint an XML tree to an output stream. Elements are indented
+ * according to element hierarchy.
+ * @param f a stream to receive the output
+ * @param elem the element to output
+ */
+ void writeIndented(FILE *f);
+
+ /**
+ * Prettyprint an XML tree to standard output. This is the equivalent of
+ * writeIndented(stdout).
+ * @param elem the element to output
+ */
+ void print();
+
+protected:
+
+
+ void findElementsRecursive(std::vector<Element *>&res, const DOMString &name);
+
+ void writeIndentedRecursive(FILE *f, int indent);
+
+ Element *parent;
+
+ std::vector<Element *>children;
+
+ std::vector<Attribute> attributes;
+ std::vector<Namespace> namespaces;
+
+ DOMString name;
+ DOMString value;
+
+ int line;
+
+};
+
+
+
+
+
+class Parser
+{
+public:
+
+ Parser()
+ { init(); }
+
+ virtual ~Parser()
+ {}
+
+ /**
+ * Parse XML in a char buffer.
+ * @param buf a character buffer to parse
+ * @param pos position to start parsing
+ * @param len number of chars, from pos, to parse.
+ * @return a pointer to the root of the XML document;
+ */
+ Element *parse(const char *buf,int pos,int len);
+
+ /**
+ * Parse XML in a char buffer.
+ * @param buf a character buffer to parse
+ * @param pos position to start parsing
+ * @param len number of chars, from pos, to parse.
+ * @return a pointer to the root of the XML document;
+ */
+ Element *parse(const DOMString &buf);
+
+ /**
+ * Parse a named XML file. The file is loaded like a data file;
+ * the original format is not preserved.
+ * @param fileName the name of the file to read
+ * @return a pointer to the root of the XML document;
+ */
+ Element *parseFile(const char *fileName);
+
+
+
+
+private:
+
+ void init()
+ {
+ keepGoing = true;
+ currentNode = NULL;
+ parselen = 0;
+ parsebuf = NULL;
+ currentPosition = 0;
+ }
+
+ int countLines(int begin, int end);
+
+ void getLineAndColumn(int pos, int *lineNr, int *colNr);
+
+ void error(char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+ int peek(int pos);
+
+ int match(int pos, const char *text);
+
+ int skipwhite(int p);
+
+ int getWord(int p0, DOMString &buf);
+
+ int getQuoted(int p0, DOMString &buf, int do_i_parse);
+
+ int parseVersion(int p0);
+
+ int parseDoctype(int p0);
+
+ int parseElement(int p0, Element *par,int depth);
+
+ Element *parse(XMLCh *buf,int pos,int len);
+
+ bool keepGoing;
+ Element *currentNode;
+ int parselen;
+ XMLCh *parsebuf;
+ DOMString cdatabuf;
+ int currentPosition;
+ int colNr;
+
+
+};
+
+
+
+}//namespace MiniDom
+
+
+//########################################################################
+//# E N D O F F I L E
+//########################################################################
+