diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2011-06-01 11:04:57 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2011-06-01 11:04:57 +0300 |
| commit | 8eba476357c8488be510f012594f305848a7eeb6 (patch) | |
| tree | 42677f805d20d4b5d0b217aaacf1acedca29d2bd /sxml.h | |
| parent | a71564984253ade92fc4d3c9bf185807efc570bf (diff) | |
| download | sxml-8eba476357c8488be510f012594f305848a7eeb6.tar.gz sxml-8eba476357c8488be510f012594f305848a7eeb6.zip | |
Move add_element() to node and add add_comment()
Diffstat (limited to 'sxml.h')
| -rw-r--r-- | sxml.h | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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. |
