[gxml] Moved NodeList's implementation to its own file



commit 0e94726896a49c5e8c3f3e27ebd1755b637a029f
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Apr 14 17:40:38 2015 -0500

    Moved NodeList's implementation to its own file
    
    * Makes easy to maintain NodeList set of classes

 gxml/Makefile.am                     |    9 +-
 gxml/libxml-AttrChildNodeList.vala   |   55 +++++
 gxml/libxml-BackedNode.vala          |    9 +-
 gxml/libxml-EntityChildNodeList.vala |   55 +++++
 gxml/libxml-LinkedList.vala          |   92 ++++++++
 gxml/libxml-NodeChildNodeList.vala   |   62 ++++++
 gxml/libxml-NodeList.vala            |  401 +---------------------------------
 gxml/libxml-TagNameNodeList.vala     |   32 +++
 8 files changed, 312 insertions(+), 403 deletions(-)
---
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index baacb70..9f5386f 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -19,7 +19,9 @@ sources = \
        Namespace.vala \
        Node.vala \
        libxml-Attr.vala \
+       libxml-AttrChildNodeList.vala \
        libxml-BackedNode.vala \
+       libxml-ChildNodeList.vala \
        libxml-CDATASection.vala \
        libxml-CharacterData.vala \
        libxml-Comment.vala \
@@ -28,17 +30,22 @@ sources = \
        libxml-Document.vala \
        libxml-DomException.vala \
        libxml-Element.vala \
-       libxml-EntityReference.vala \
        libxml-Entity.vala \
+       libxml-EntityChildNodeList.vala\
+       libxml-EntityReference.vala \
        libxml-Error.vala \
        libxml-Implementation.vala \
+       libxml-LinkedList.vala \
        libxml-NamedNodeMap.vala \
        libxml-NamespaceAttr.vala \
+       libxml-NodeChildNodeList.vala \
        libxml-NodeList.vala \
        libxml-NodeType.vala \
        libxml-Node.vala \
        libxml-Notation.vala \
        libxml-ProcessingInstruction.vala \
+       libxml-TagNameNodeList.vala \
+       libxml-NamespaceAttrNodeList.vala \
        libxml-Text.vala \
        Serializable.vala \
        Enumeration.vala \
diff --git a/gxml/libxml-AttrChildNodeList.vala b/gxml/libxml-AttrChildNodeList.vala
new file mode 100644
index 0000000..4f6745c
--- /dev/null
+++ b/gxml/libxml-AttrChildNodeList.vala
@@ -0,0 +1,55 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
+/* NodeList.vala
+ *
+ * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
+ * Copyright (C) 2013-2015  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Authors:
+ *      Richard Schwarting <aquarichy gmail com>
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+internal class GXml.AttrChildNodeList : ChildNodeList {
+       Xml.Attr *parent;
+
+       internal override Xml.Node *head {
+               get {
+                       return parent->children;
+               }
+               set {
+                       parent->children = value;
+               }
+       }
+
+       internal AttrChildNodeList (Xml.Attr* parent, xDocument owner) {
+               this.parent = parent;
+               this.owner = owner;
+       }
+
+       internal override Xml.Node *parent_as_xmlnode {
+               get {
+                       /* This is disgusting, but we do this for the case where
+                          xmlAttr*'s immediate children list the xmlAttr as their
+                          parent, but claim that xmlAttr is an xmlNode* (since
+                          the parent field is of type xmlNode*). We need to get
+                          an Xml.Node*ish parent for when we append new children
+                          here, whether we're the list of children of an Attr
+                          or not. */
+                       return (Xml.Node*)parent;
+               }
+       }
+}
diff --git a/gxml/libxml-BackedNode.vala b/gxml/libxml-BackedNode.vala
index ad26b2c..8e1653b 100644
--- a/gxml/libxml-BackedNode.vala
+++ b/gxml/libxml-BackedNode.vala
@@ -364,14 +364,19 @@ namespace GXml {
                        return str;
                }
                // GXml.Node interface implementations
-               /*
                public Gee.LinkedList<GXml.Namespace> namespaces
                {
                        get {
                                return _namespace_definitions;
                        }
                }
-               public Gee.LinkedList<GXml.Node> childs { get; }
+               /*
+               public Gee.LinkedList<GXml.Node> childs
+               {
+                       get {
+                               
+                       }
+               }
                public Gee.Map<string,GXml.Node> attrs { get; }
                public string name { get; construct set; }
                public string @value { get; set; }
diff --git a/gxml/libxml-EntityChildNodeList.vala b/gxml/libxml-EntityChildNodeList.vala
new file mode 100644
index 0000000..58eac7e
--- /dev/null
+++ b/gxml/libxml-EntityChildNodeList.vala
@@ -0,0 +1,55 @@
+/* NodeList.vala
+ *
+ * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
+ * Copyright (C) 2013-2015  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Authors:
+ *      Richard Schwarting <aquarichy gmail com>
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+internal class GXml.EntityChildNodeList : ChildNodeList {
+       Xml.Entity *parent;
+
+       internal override Xml.Node *head {
+               get {
+                       return parent->children;
+               }
+               set {
+                       parent->children = value;
+               }
+       }
+
+       internal override Xml.Node *parent_as_xmlnode {
+               get {
+                       /* This is disgusting, but we do this for the case where
+                          xmlAttr*'s immediate children list the xmlAttr as their
+                          parent, but claim that xmlAttr is an xmlNode* (since
+                          the parent field is of type xmlNode*). We need to get
+                          an Xml.Node*ish parent for when we append new children
+                          here, whether we're the list of children of an Attr
+                          or not. */
+                       return (Xml.Node*)parent;
+               }
+       }
+
+       internal EntityChildNodeList (Xml.Entity* parent, xDocument owner) {
+               this.parent = parent;
+               this.owner = owner;
+       }
+}
+
diff --git a/gxml/libxml-LinkedList.vala b/gxml/libxml-LinkedList.vala
new file mode 100644
index 0000000..9163fa3
--- /dev/null
+++ b/gxml/libxml-LinkedList.vala
@@ -0,0 +1,92 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
+/* NodeList.vala
+ *
+ * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
+ * Copyright (C) 2013-2015  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Authors:
+ *      Richard Schwarting <aquarichy gmail com>
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+
+internal class GXml.LinkedList : Gee.LinkedList<GXml.xNode>, NodeList
+{
+       public GXml.xNode root;
+
+       public ulong length {
+         get { return size; }
+         protected set {}
+       }
+
+       public LinkedList (GXml.xNode root)
+       {
+         this.root = root;
+       }
+
+  public unowned xNode? insert_before (xNode new_child, xNode? ref_child)
+  {
+    int i = -1;
+    if (contains (ref_child)) {
+        i = index_of (ref_child);
+        insert (i, new_child);
+        return new_child;
+    }
+    return null;
+  }
+
+       public unowned xNode? replace_child (xNode new_child, xNode old_child)
+       {
+         if (contains (old_child)) {
+           int i = index_of (old_child);
+           remove_at (i);
+           insert (i, new_child);
+           return new_child;
+         }
+         return null;
+       }
+
+       public unowned xNode? remove_child (xNode old_child)
+       {
+         if (contains (old_child)) {
+           unowned xNode n = old_child;
+           remove_at (index_of (old_child));
+           return n;
+         }
+         return null;
+       }
+
+       public unowned xNode? append_child (xNode new_child)
+       {
+         add (new_child);
+         return new_child;
+       }
+
+  public xNode item (ulong idx)
+  {
+    return @get((int) idx);
+  }
+
+  public string to_string (bool in_line) 
+  {
+    string str = "";
+         foreach (xNode node in this) {
+                 str += node.to_string ();
+         }
+         return str;
+  }
+}
diff --git a/gxml/libxml-NodeChildNodeList.vala b/gxml/libxml-NodeChildNodeList.vala
new file mode 100644
index 0000000..f86fc43
--- /dev/null
+++ b/gxml/libxml-NodeChildNodeList.vala
@@ -0,0 +1,62 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
+/* NodeList.vala
+ *
+ * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
+ * Copyright (C) 2013-2015  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Authors:
+ *      Richard Schwarting <aquarichy gmail com>
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+       // /* TODO: warning: this list should NOT be edited :(
+       //    we need a new, better live AttrNodeList :| */
+       // internal class AttrNodeList : GListNodeList {
+       //      internal AttrNodeList (xNode root, xDocument owner) {
+       //              base (root);
+       //              base.nodes = root.attributes.get_values ();
+       //      }
+       // }
+
+internal class GXml.NodeChildNodeList : ChildNodeList {
+       Xml.Node *parent;
+
+       internal override Xml.Node *head {
+               get {
+                       return parent->children;
+               }
+               set {
+                       parent->children = value;
+               }
+       }
+
+       internal NodeChildNodeList (Xml.Node *parent, xDocument owner) {
+               this.parent = parent;
+               this.owner = owner;
+       }
+
+       internal override Xml.Node *parent_as_xmlnode {
+               get {
+                       /* TODO: check whether this is also
+                        * disgusting, like with
+                        * AttrChildNodeList, or necessary
+                        */
+                       return parent;
+               }
+       }
+}
+
diff --git a/gxml/libxml-NodeList.vala b/gxml/libxml-NodeList.vala
index 1fb9f38..0ab6e25 100644
--- a/gxml/libxml-NodeList.vala
+++ b/gxml/libxml-NodeList.vala
@@ -54,7 +54,7 @@ namespace GXml {
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#attribute-length]]
                 */
                public abstract ulong length {
-                       get; private set;
+                       get; protected set;
                }
 
 
@@ -105,402 +105,3 @@ namespace GXml {
                public abstract new xNode @get (int n);
        }
 }
-
-namespace GXml {
-       /* TODO: this will somehow need to watch the document and find
-        * out as new elements are added, and get reconstructed each
-        * time, or get reconstructed-on-the-go?
-        */
-  internal class TagNameNodeList : GXml.LinkedList { internal string tag_name;
-               internal TagNameNodeList (string tag_name, xNode root, xDocument owner) {
-                       base (root);
-                       this.tag_name = tag_name;
-               }
-       }
-
-       // /* TODO: warning: this list should NOT be edited :(
-       //    we need a new, better live AttrNodeList :| */
-       // internal class AttrNodeList : GListNodeList {
-       //      internal AttrNodeList (xNode root, xDocument owner) {
-       //              base (root);
-       //              base.nodes = root.attributes.get_values ();
-       //      }
-       // }
-
-       internal class NamespaceAttrNodeList : GXml.LinkedList {
-               internal NamespaceAttrNodeList (BackedNode root, xDocument owner) {
-                       base (root);
-                       for (Xml.Ns *cur = root.node->ns_def; cur != null; cur = cur->next) {
-                               this.append_child (new NamespaceAttr (cur, owner));
-                       }
-               }
-       }
-
-       internal class NodeChildNodeList : ChildNodeList {
-               Xml.Node *parent;
-
-               internal override Xml.Node *head {
-                       get {
-                               return parent->children;
-                       }
-                       set {
-                               parent->children = value;
-                       }
-               }
-
-               internal NodeChildNodeList (Xml.Node *parent, xDocument owner) {
-                       this.parent = parent;
-                       this.owner = owner;
-               }
-
-               internal override Xml.Node *parent_as_xmlnode {
-                       get {
-                               /* TODO: check whether this is also
-                                * disgusting, like with
-                                * AttrChildNodeList, or necessary
-                                */
-                               return parent;
-                       }
-               }
-       }
-
-       internal class AttrChildNodeList : ChildNodeList {
-               Xml.Attr *parent;
-
-               internal override Xml.Node *head {
-                       get {
-                               return parent->children;
-                       }
-                       set {
-                               parent->children = value;
-                       }
-               }
-
-               internal AttrChildNodeList (Xml.Attr* parent, xDocument owner) {
-                       this.parent = parent;
-                       this.owner = owner;
-               }
-
-               internal override Xml.Node *parent_as_xmlnode {
-                       get {
-                               /* This is disgusting, but we do this for the case where
-                                  xmlAttr*'s immediate children list the xmlAttr as their
-                                  parent, but claim that xmlAttr is an xmlNode* (since
-                                  the parent field is of type xmlNode*). We need to get
-                                  an Xml.Node*ish parent for when we append new children
-                                  here, whether we're the list of children of an Attr
-                                  or not. */
-                               return (Xml.Node*)parent;
-                       }
-               }
-       }
-       internal class EntityChildNodeList : ChildNodeList {
-               Xml.Entity *parent;
-
-               internal override Xml.Node *head {
-                       get {
-                               return parent->children;
-                       }
-                       set {
-                               parent->children = value;
-                       }
-               }
-
-               internal override Xml.Node *parent_as_xmlnode {
-                       get {
-                               /* This is disgusting, but we do this for the case where
-                                  xmlAttr*'s immediate children list the xmlAttr as their
-                                  parent, but claim that xmlAttr is an xmlNode* (since
-                                  the parent field is of type xmlNode*). We need to get
-                                  an Xml.Node*ish parent for when we append new children
-                                  here, whether we're the list of children of an Attr
-                                  or not. */
-                               return (Xml.Node*)parent;
-                       }
-               }
-
-               internal EntityChildNodeList (Xml.Entity* parent, xDocument owner) {
-                       this.parent = parent;
-                       this.owner = owner;
-               }
-       }
-
-       // TODO: Desperately want to extend List or implement relevant interfaces to make iterable
-       // TODO: remember that the order of interfaces that you're listing as implemented matters
-       internal abstract class ChildNodeList :  Gee.AbstractCollection<xNode>, NodeList
-{
-               /* TODO: must be live
-                  if this reflects children of a node, then must always be current
-                  same with nodes from GetElementByTagName, made need separate impls for each */
-               // TODO: if necessary, create two versions that use parent instead of head
-
-               internal weak xDocument owner;
-               internal abstract Xml.Node *head { get; set; }
-
-               internal abstract Xml.Node *parent_as_xmlnode { get; }
-
-               /**
-                * { inheritDoc}
-                */
-               public ulong length {
-                       get {
-                               return size;
-                       }
-                       private set { }
-               }
-
-        public override bool add (xNode item)
-        {
-                append_child (item);
-                return true;
-        }
-               public override void clear () {}
-               public override bool contains (xNode item) { return false; }
-               public override bool remove (xNode item)  { return false; }
-               public override bool read_only { get { return true; } }
-               public override int size {
-            get {
-                if (head != null) {
-                    //GLib.warning ("At NodeChildNodeList: get_size");
-                    int len = 1;
-                    var cur = head;
-                    while (cur->next != null) {
-                        cur = cur->next;
-                        len++;
-                    }
-                    return len;
-                }
-                return 0;
-            }
-        }
-               public override Gee.Iterator<xNode> iterator () {
-                       return new NodeListIterator (this);
-               }
-               public override bool @foreach (ForallFunc<xNode> func) {
-                       return iterator ().foreach (func);
-               }
-
-               /** GNOME List conventions */
-               public xNode first () {
-                       return this.owner.lookup_node (head);
-               }
-               public xNode last () {
-                       Xml.Node *cur = head;
-                       while (cur != null && cur->next != null) {
-                               cur = cur->next;
-                       }
-                       return this.owner.lookup_node (cur); // TODO :check for nulls?
-               }
-               public new xNode @get (int n)
-            requires (head != null)
-        {
-            Xml.Node *cur = head;
-            int i = 0;
-            while (cur->next != null && i != n) {
-                cur = cur->next;
-                i++;
-            }
-                       return this.owner.lookup_node (cur);
-               }
-        public xNode item (ulong idx) { return get ((int) idx); }
-
-               /** Node's child methods, implemented here **/
-               internal new unowned xNode? insert_before (xNode new_child, xNode? ref_child) {
-                       Xml.Node *child = head;
-
-                       if (ref_child == null) {
-                               this.append_child (ref_child);
-                       }
-
-                       while (child != ((BackedNode)ref_child).node && child != null) {
-                               child = child->next;
-                       }
-                       if (child == null) {
-                               GXml.warning (DomException.NOT_FOUND, "ref_child '%s' not found, was supposed 
to have '%s' inserted before it.".printf (ref_child.node_name, new_child.node_name));
-                               return null;
-                               // TODO: provide a more useful description of ref_child, but there are so 
many different types
-                       } else {
-                               if (new_child.node_type == NodeType.DOCUMENT_FRAGMENT) {
-                                       foreach (xNode new_grand_child in new_child.child_nodes) {
-                                               child->add_prev_sibling (((BackedNode)new_grand_child).node);
-                                       }
-                               } else {
-                                       child->add_prev_sibling (((BackedNode)new_child).node);
-                               }
-                       }
-                       return new_child;
-               }
-
-               internal new unowned xNode? replace_child (xNode new_child, xNode old_child) {
-                       // TODO: verify that libxml2 already removes
-                       // new_child first if it is found elsewhere in
-                       // the tree.
-
-                       // TODO: nuts, if Node as an iface can't have properties,
-                       //       then I have to cast these to Nodes, ugh.
-                       // TODO: need to handle errors?
-
-                       // TODO: want to do a 'find_child' function
-                       if (new_child.node_type == NodeType.DOCUMENT_FRAGMENT) {
-                               this.insert_before (new_child, old_child);
-                               this.remove_child (old_child);
-                       } else {
-                               Xml.Node *child = head;
-
-                               while (child != null && child != ((BackedNode)old_child).node) {
-                                       child = child->next;
-                               }
-
-                               if (child != null) {
-                                       // it is a valid child
-                                       child->replace (((BackedNode)new_child).node);
-                               } else {
-                                       GXml.warning (DomException.NOT_FOUND, "old_child '%s' not found, 
tried to replace with '%s'".printf (old_child.node_name, new_child.node_name));
-                               }
-                       }
-
-                       return old_child;
-               }
-               internal new unowned xNode? remove_child (xNode old_child) /* throws DomError */ {
-                       // TODO: verify that old_child is a valid child here and then unlink
-
-                       ((BackedNode)old_child).node->unlink (); // TODO: do we need to free libxml2 stuff 
manually?
-                       return old_child;
-               }
-
-               internal virtual unowned xNode? append_child (xNode new_child) /* throws DomError */ {
-                       // TODO: verify that libxml2 will first remove
-                       // new_child if it already exists elsewhere in
-                       // the tree.
-
-                       if (new_child.node_type == NodeType.DOCUMENT_FRAGMENT) {
-                               foreach (xNode grand_child in new_child.child_nodes) {
-                                       parent_as_xmlnode->add_child (((BackedNode)grand_child).node);
-                               }
-                       } else {
-                               if (new_child.node_type == NodeType.ENTITY_REFERENCE) {
-                                       GLib.warning ("Appending EntityReferences to Nodes is not yet 
supported");
-                               } else {
-                                       parent_as_xmlnode->add_child (((BackedNode)new_child).node);
-                               }
-                       }
-
-                       return new_child;
-               }
-
-               public string to_string (bool in_line = true) {
-                       string str = "";
-                       foreach (xNode node in this) {
-                               str += node.to_string ();
-                       }
-                       return str;
-               }
-
-               /* ** NodeListIterator ***/
-
-               private class NodeListIterator : GLib.Object, Gee.Traversable<xNode>, Gee.Iterator<xNode>
-               {
-                       private weak xDocument doc;
-                       private Xml.Node *cur;
-                       private Xml.Node *head;
-
-                       /* TODO: consider rewriting this to work on NodeList instead of the Xml.Node*
-                          list, then perhaps we could reuse it for get_elements_by_tag_name () */
-                       public NodeListIterator (ChildNodeList list) {
-                               this.head = list.head;
-                               this.cur = null;
-                               this.doc = list.owner;
-                       }
-                       /* Gee.Iterator interface */
-                       public new xNode @get () { return this.doc.lookup_node (this.cur); }
-                       public bool has_next () { return head == null ? false : true; }
-                       public bool next () {
-                               if (has_next ()) {
-                                       cur = head;
-                                       head = head->next;
-                                       return true;
-                               }
-                               return false;
-                       }
-                       public void remove () {}
-                       public bool read_only { get { return true; } }
-                       public bool valid { get { return cur != null ? true : false; } }
-
-                       /* Traversable interface */
-                       public new bool @foreach (Gee.ForallFunc<xNode> f)
-                       {
-                               if (next ())
-                                       return f (get ());
-                               return false;
-                       }
-               }
-       }
-}
-
-internal class GXml.LinkedList : Gee.LinkedList<GXml.xNode>, NodeList
-{
-  public GXml.xNode root;
-
-  public ulong length {
-    get { return size; }
-    private set {}
-  }
-
-  public LinkedList (GXml.xNode root)
-  {
-    this.root = root;
-  }
-
-        public unowned xNode? insert_before (xNode new_child, xNode? ref_child)
-    {
-        int i = -1;
-        if (contains (ref_child)) {
-            i = index_of (ref_child);
-            insert (i, new_child);
-            return new_child;
-        }
-        return null;
-    }
-
-  public unowned xNode? replace_child (xNode new_child, xNode old_child)
-  {
-    if (contains (old_child)) {
-      int i = index_of (old_child);
-      remove_at (i);
-      insert (i, new_child);
-      return new_child;
-    }
-    return null;
-  }
-
-  public unowned xNode? remove_child (xNode old_child)
-  {
-    if (contains (old_child)) {
-      unowned xNode n = old_child;
-      remove_at (index_of (old_child));
-      return n;
-    }
-    return null;
-  }
-
-  public unowned xNode? append_child (xNode new_child)
-  {
-    add (new_child);
-    return new_child;
-  }
-
-    public xNode item (ulong idx)
-    {
-        return @get((int) idx);
-    }
-
-    public string to_string (bool in_line) 
-    {
-        string str = "";
-               foreach (xNode node in this) {
-                       str += node.to_string ();
-               }
-
-               return str;
-    }
-}
diff --git a/gxml/libxml-TagNameNodeList.vala b/gxml/libxml-TagNameNodeList.vala
new file mode 100644
index 0000000..cb6e6f3
--- /dev/null
+++ b/gxml/libxml-TagNameNodeList.vala
@@ -0,0 +1,32 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 0; tab-width: 2 -*- */
+/* ObjectModel.vala
+ *
+ * Copyright (C) 2015  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+/* TODO: this will somehow need to watch the document and find
+ * out as new elements are added, and get reconstructed each
+ * time, or get reconstructed-on-the-go?
+ */
+internal class GXml.TagNameNodeList : GXml.LinkedList { internal string tag_name;
+       internal TagNameNodeList (string tag_name, xNode root, xDocument owner) {
+               base (root);
+               this.tag_name = tag_name;
+       }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]