Code

fix include
[inkscape.git] / src / pedro / pedrodom.h
index b9fb98b92faaee8fad161b80b3a118947e654214..91ad21da20c717f45a2eb538b5c07b714460eb7e 100644 (file)
@@ -6,7 +6,7 @@
  * Authors:
  *   Bob Jamison
  *
- * Copyright (C) 2005-2006 Bob Jamison
+ * Copyright (C) 2005-2008 Bob Jamison
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,8 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <glib.h>
+
 #include <string>
 #include <vector>
 
@@ -125,6 +127,12 @@ protected:
 };
 
 
+//#Define a list of elements. (Children, search results, etc)
+class Element;
+typedef std::vector<Element *> ElementList;
+
+
+
 class Element
 {
 friend class Parser;
@@ -176,10 +184,13 @@ public:
     Element *getParent()
         { return parent; }
 
-    std::vector<Element *> getChildren()
+    Element *getFirstChild()
+        { return (children.size() == 0) ? NULL : children[0]; }
+
+    ElementList getChildren()
         { return children; }
 
-    std::vector<Element *> findElements(const DOMString &name);
+    ElementList findElements(const DOMString &name);
 
     DOMString getAttribute(const DOMString &name);
 
@@ -196,6 +207,8 @@ public:
 
     void addNamespace(const DOMString &prefix, const DOMString &namespaceURI);
 
+    bool exists(const DOMString &name)
+        { return (findElements(name).size() > 0); }
 
     /**
      * Prettyprint an XML tree to an output stream.  Elements are indented
@@ -230,7 +243,7 @@ protected:
 
     Element *parent;
 
-    std::vector<Element *>children;
+    ElementList children;
 
     std::vector<Attribute> attributes;
     std::vector<Namespace> namespaces;
@@ -307,7 +320,7 @@ private:
 
     void getLineAndColumn(long pos, long *lineNr, long *colNr);
 
-    void error(char *fmt, ...);
+    void error(char const *fmt, ...) G_GNUC_PRINTF(2,3);
 
     int peek(long pos);