add test for basic cd parsing
Change-Id: If35d62e323d48db11dc4128fb5c2898ef4ef63a6
diff --git a/src/CTree.hpp b/src/CTree.hpp
index 88bccae..fa99df6 100644
--- a/src/CTree.hpp
+++ b/src/CTree.hpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
+ * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
*
* Written by Václav Kubernát <kubervac@fit.cvut.cz>
*
@@ -9,13 +10,23 @@
#include <stdexcept>
#include <unordered_map>
-#include <unordered_set>
+
+enum NODE_TYPE {
+ TYPE_CONTAINER,
+ TYPE_LIST,
+ TYPE_LIST_ELEMENT
+};
+
+struct TreeNode {
+ bool operator<(const TreeNode& b) const;
+ std::string m_name;
+ NODE_TYPE m_type;
+};
class InvalidNodeException : public std::invalid_argument {
public:
using std::invalid_argument::invalid_argument;
~InvalidNodeException() override;
-
};
/*! \class CTree
@@ -26,15 +37,17 @@
* */
class CTree {
public:
- bool checkNode(const std::string& location, const std::string& node) const;
+ CTree();
+ bool nodeExists(const std::string& location, const std::string& node) const;
+
+ bool isContainer(const std::string& location, const std::string& node) const;
+ void addContainer(const std::string& location, const std::string& node);
void changeNode(const std::string& node);
- void initDefault();
std::string currentNode() const;
private:
- void addNode(const std::string& location, const std::string& node);
- const std::unordered_set<std::string>& children(const std::string& node) const;
+ const std::unordered_map<std::string, NODE_TYPE>& children(const std::string& node) const;
- std::unordered_map<std::string, std::unordered_set<std::string>> m_nodes;
+ std::unordered_map<std::string, std::unordered_map<std::string, NODE_TYPE>> m_nodes;
std::string m_curDir;
};