[libxml++] Branches merged



I have reverted the child_iterator changes - the patch is attached if
anyone wants to continue working on it/discussing it. I need to read
those emails again myself.

So BRANCH_1_0 is no longer needed. Please just use HEAD again.

-- 
Murray Cumming
murray usa net
www.murrayc.com
? temp.patch
Index: libxml++/nodes/node.cc
===================================================================
RCS file: /cvsroot/libxmlplusplus/libxml++/libxml++/nodes/node.cc,v
retrieving revision 1.15
diff -u -p -r1.15 node.cc
--- libxml++/nodes/node.cc	7 Feb 2003 10:41:25 -0000	1.15
+++ libxml++/nodes/node.cc	14 Feb 2003 23:32:39 -0000
@@ -48,40 +48,13 @@ const Node::NodeList Node::get_children(
   return const_cast<Node*>(this)->get_children(name);
 }
 
-Element* Node::append_child(const std::string& name)
+Element* Node::add_child(const std::string& name)
 {
-  if(_impl->type != XML_ELEMENT_NODE)
-    throw internal_error("you can only add child nodes to element nodes");
+   if(_impl->type != XML_ELEMENT_NODE)
+      throw internal_error("you can only add child nodes to element nodes");
       
-  xmlNode* node = xmlAddChild(_impl, xmlNewNode(0, (xmlChar*)name.c_str()));
-  return static_cast<Element*>(node->_private);
-}
-
-Element* Node::insert_child(child_iterator i, const std::string& name)
-{
-  if(_impl->type != XML_ELEMENT_NODE)
-    throw internal_error("you can only add child nodes to element nodes");
-
-  xmlNode* node = 0;
-  if (i._current)
-    node = xmlAddPrevSibling(i._current, xmlNewNode(0, (xmlChar*)name.c_str()));
-  else
-    node = xmlAddChild(_impl, xmlNewNode(0, (xmlChar*)name.c_str()));
-  return static_cast<Element*>(node->_private);
-}
-
-Node* Node::insert_child(child_iterator i, Node* child)
-{
-  if(_impl->type != XML_ELEMENT_NODE)
-    throw internal_error("you can only add child nodes to element nodes");
-
-  xmlUnlinkNode(child->_impl);
-  xmlNode* node;
-  if (i._current)
-    node = xmlAddPrevSibling(i._current, child->_impl);
-  else
-    node = xmlAddChild(_impl, child->_impl);
-  return static_cast<Element* >(node->_private);
+   xmlNode* node = xmlAddChild(_impl, xmlNewNode(0, (xmlChar*)name.c_str()));
+   return static_cast<Element*>(node->_private);
 }
 
 TextNode* Node::add_content(const std::string& content)
Index: libxml++/nodes/node.h
===================================================================
RCS file: /cvsroot/libxmlplusplus/libxml++/libxml++/nodes/node.h,v
retrieving revision 1.14
diff -u -p -r1.14 node.h
--- libxml++/nodes/node.h	7 Feb 2003 10:41:25 -0000	1.14
+++ libxml++/nodes/node.h	14 Feb 2003 23:32:39 -0000
@@ -16,10 +16,11 @@
 
 namespace xmlpp {
 
-class Node;
 class TextNode;
 class Element;
 class Attribute;
+
+class Node;
 typedef std::vector<Node*> NodeSet;
 
 /** Represents XML Nodes.
@@ -28,20 +29,12 @@ typedef std::vector<Node*> NodeSet;
 class Node
 {
 public:
-  class child_iterator;
-  class const_child_iterator;
   typedef std::list<Node*> NodeList;
   typedef std::list<Attribute*> AttributeList;
 
   explicit Node(xmlNode* node);
   virtual ~Node();
 
-  child_iterator begin_children();
-  child_iterator end_children();
-
-  const_child_iterator begin_const_children() const;
-  const_child_iterator end_const_children() const;
-
   std::string get_name() const;
   int get_line() const;
 
@@ -66,11 +59,11 @@ public:
   NodeList get_children(const std::string& name = std::string());
   const NodeList get_children(const std::string& name = std::string()) const;
 
-  Element* append_child(const std::string& name);
-  // for backward compatibility
-  Element* add_child(const std::string& name) { append_child(name);}
-  Element* insert_child(child_iterator, const std::string& name);
-  Node* insert_child(child_iterator, Node *node);
+  Element* add_child(const std::string& name);
+  // FIXME: how should this work in general (depending on the exact types
+  // of parent and child node)
+  //   Node* add_child(Node* node);
+
 
   /** Remove the child node.
    * @param node The child node to remove. This Node will be deleted and therefore unusable after calling this method.
@@ -87,76 +80,8 @@ public:
   const xmlNode* cobj() const;
 
 private:
-  xmlNode* _impl;
-};
-
-class Node::child_iterator
-{
-  friend class Node;
-public:
-  typedef child_iterator self;
-  typedef Node* value_type;
-  typedef value_type& reference;
-  typedef value_type* pointer;
-  child_iterator() : _current(0) {};
-  bool operator == (self i) { return _current == i._current;}
-  bool operator != (self i) { return !operator==(i);}
-  reference operator *() { return reinterpret_cast<Node*>(_current->_private);}
-  pointer operator ->() { return &(operator *());}
-  self operator ++(int) { increment(); return *this;}
-  self operator ++() { child_iterator tmp = *this; increment(); return tmp;}
-  self operator --(int) { decrement(); return *this;}
-  self operator --() { child_iterator tmp = *this; decrement(); return tmp;}
-private:
-  void increment() { _current = _current->next;}
-  void decrement() { _current = _current->prev;}
-  child_iterator(xmlNode* current) : _current(current) {}
-  xmlNode* _current;
-};
-
-class Node::const_child_iterator
-{
-  friend class Node;
-public:
-  typedef const_child_iterator self;
-  typedef Node* value_type;
-  typedef const value_type& const_reference;
-  typedef const value_type* const_pointer;
-  const_child_iterator() : _current(0) {};
-  bool operator == (self i) { return _current == i._current;}
-  bool operator != (self i) { return !operator==(i);}
-  const_reference operator *() { return reinterpret_cast<Node*>(_current->_private);}
-  const_pointer operator ->() { return &(operator *());}
-  self operator ++(int) { increment(); return *this;}
-  self operator ++() { const_child_iterator tmp = *this; increment(); return tmp;}
-  self operator --(int) { decrement(); return *this;}
-  self operator --() { const_child_iterator tmp = *this; decrement(); return tmp;}
-private:
-  void increment() { _current = _current->next;}
-  void decrement() { _current = _current->prev;}
-  const_child_iterator(xmlNode *current) : _current(current) {}
-  xmlNode* _current;
+   xmlNode* _impl;
 };
-
-inline Node::child_iterator Node::begin_children()
-{
-  return child_iterator(_impl->children);
-}
-
-inline Node::child_iterator Node::end_children()
-{
-  return child_iterator(0);
-}
-
-inline Node::const_child_iterator Node::begin_const_children() const
-{
-  return const_child_iterator(_impl->children);
-}
-
-inline Node::const_child_iterator Node::end_const_children() const
-{
-  return const_child_iterator(0);
-}
 
 } // namespace xmlpp
 


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