aboutsummaryrefslogtreecommitdiff
path: root/sxml.h
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:04:57 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:04:57 +0300
commit8eba476357c8488be510f012594f305848a7eeb6 (patch)
tree42677f805d20d4b5d0b217aaacf1acedca29d2bd /sxml.h
parenta71564984253ade92fc4d3c9bf185807efc570bf (diff)
downloadsxml-8eba476357c8488be510f012594f305848a7eeb6.tar.gz
sxml-8eba476357c8488be510f012594f305848a7eeb6.zip
Move add_element() to node and add add_comment()
Diffstat (limited to 'sxml.h')
-rw-r--r--sxml.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/sxml.h b/sxml.h
index 6bd727a..c2ac7e8 100644
--- a/sxml.h
+++ b/sxml.h
@@ -34,6 +34,8 @@
namespace sxml {
class node;
+class element;
+class comment;
typedef std::vector<node *> node_list;
@@ -52,13 +54,20 @@ class node
//! Destructor. Frees the children of this node.
virtual ~node();
+ //! Returns a string representation of this node. Derived classes should
+ //! implement this.
+ virtual std::string to_string(bool nice , int indent = 0) const;
+
//! Adds a child node to this node. Takes the ownership of the given
//! node. Returns a pointer to the child.
node *add_child(node *child);
- //! Returns a string representation of this node. Derived classes should
- //! implement this.
- virtual std::string to_string(bool nice , int indent = 0) const;
+ //! Adds an element with the given tag to this node. Returns a pointer to
+ //! the element node.
+ element *add_element(const std::string &tag);
+
+ //! Adds a comment to this node. Returns a pointer to the comment node.
+ comment *add_comment(const std::string &text);
protected:
@@ -128,10 +137,6 @@ class element: public node
//! and newlines.
virtual std::string to_string(bool nice = false, int indent = 0) const;
- //! Adds a child with the given tag to this element. Returns a pointer
- //! to the child.
- element *add_element(const std::string &tag);
-
//! Set the text for this element. An element can either have text
//! or children. If an element has both, children take precedence
//! when calling to_string(). Returns a pointer to this element.