diff options
author | Adrian Kummerlaender | 2014-09-25 19:13:56 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-09-25 19:13:56 +0200 |
commit | b1e863bf2ae274da155446a8bb4aec5f975a86c5 (patch) | |
tree | 727e95a0753b87e2fe3c66377bc464de3e03e195 /src/tree.h | |
parent | 5be4662e4d7da993373aff1435c68e68c349f09f (diff) | |
download | SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar.gz SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar.bz2 SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar.lz SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar.xz SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.tar.zst SimpleParser-b1e863bf2ae274da155446a8bb4aec5f975a86c5.zip |
Increased tree constness and added constructor aliases
* as with all Node classes the public member methods of the "Tree" class do not need to be non-const
* both constructors are more easily expressed as aliases of a single constructor that takes both the term and a pointer to a constant map instance
* the tree is now constructed during member initialization
Diffstat (limited to 'src/tree.h')
-rw-r--r-- | src/tree.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -11,21 +11,22 @@ namespace SimpleParser { class Tree { public: - explicit Tree(std::string); - Tree(std::string, const ConstantMap*); + Tree(const std::string&, const ConstantMap*); + explicit Tree(const std::string&); - double solve(); - std::string print(); + double solve() const; + std::string print() const; private: template <class NType, typename... Args> Node* addNode(Node**, Args&&... args); Node* buildTree(std::string); - std::string term_; - Node* root_node_; - std::vector<std::unique_ptr<Node>> node_collection_; + const std::string term_; const ConstantMap* constants_; + + std::vector<std::unique_ptr<Node>> node_collection_; + Node* const root_node_; }; } |