summaryrefslogtreecommitdiff
path: root/src/nodetree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodetree.h')
-rw-r--r--src/nodetree.h49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/nodetree.h b/src/nodetree.h
index f2f4600..41f7272 100644
--- a/src/nodetree.h
+++ b/src/nodetree.h
@@ -29,7 +29,6 @@
#include <list>
#include <map>
-#include <exception>
#include "node.h"
@@ -54,33 +53,57 @@ public:
~NodeTree();
nodeid_t createId();
- bool hasId(nodeid_t nodeid);
+ bool hasId(nodeid_t nodeid) const;
+ //! May throw:
+ //! - Error::MissingParent if the parent node id does not exist in the tree.
+ //! - Error::NoSuchId if the ancestorList cannot be made from the supplied id.
+ //! - Error::IdAlreadyExists if the supplied id already exists in the tree.
+ //! - Error::NewParentIsSelf if id and parentid are the same.
NodeIdList insertAsChild(nodeid_t parentid, nodeid_t id, node_t data,
- nodeid_t insertBeforeId) throw (std::exception);
- NodeIdList remove(nodeid_t id) throw (std::exception);
- NodeIdList move(nodeid_t id, nodeid_t newParentId,
- nodeid_t insertBeforeId) throw (std::exception);
+ nodeid_t insertBeforeId);
+
+ //! May throw:
+ //! - Error::NoSuchId if node id does not exist.
+ //! - Error::ProtectedNode if node is protected and cannot be removed.
+ NodeIdList remove(nodeid_t id);
+
+ //! May throw:
+ //! - Error::NewParentIsSelf if id and parentid are the same.
+ //! - Error::NoSuchId if node id does not exist.
+ //! - Error::MissingParent if new parent node does not exist.
+ //! - Error::ProtectedNode if node is protected and cannot be (re)moved.
+ NodeIdList move(nodeid_t id, nodeid_t newParentId, nodeid_t insertBeforeId);
+
+ //! May throw:
+ //! - Error::NoSuchId if node id does not exist.
NodeIdList updateData(nodeid_t id, const std::string &name,
- const std::string &value) throw (std::exception);
- node_t data(nodeid_t id) throw (std::exception);
+ const std::string &value);
- NodeIdList bfs(nodeid_t id) throw (std::exception);
+ //! May throw:
+ //! - Error::NoSuchId if node id does not exist.
+ node_t data(nodeid_t id);
- NodeIdList ancestorList(nodeid_t id) throw (std::exception);
+ //! May throw:
+ //! - Error::NoSuchId if node id does not exist.
+ NodeIdList bfs(nodeid_t id);
+
+ //! May throw:
+ //! - Error::NoSuchId if node id does not exist.
+ NodeIdList ancestorList(nodeid_t id);
void toStdOut();
std::string toXML();
- void fromXML(const std::string& xml);
- nodeid_t nextid;
+ void fromXML(const std::string& xml);
private:
friend class XmlParser;
Node* createNode(nodeid_t id);
void insertChild(Node* parent, Node* child, nodeid_t insertBeforeId);
- Node* root;
+ nodeid_t nextid{10};
+ Node* root{nullptr};
std::map<int, Node*> id2node;
};