diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index d385c1e..c1bae05 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -12,16 +12,19 @@ class ParseComponent {}; struct ParseTree: public ParseComponent { private: mutable unsigned int compCount = 0; + inline void addComp(const auto& comp) const { + subComponents.push_back(comp); ++compCount; + }; inline void addAllComps(auto& comps) { for (const auto& comp: comps) addComp(comp); } protected: - vector subComponents; + mutable vector subComponents; public: - unsigned int& getCompCount() { return compCount; } - auto& getComponents() { return subComponents; } - void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; }; - void addAll(const vector& components) { for (const auto& comp: components) add(comp); } - void operator<<(const ParseComponent& component) { this->add(component); } - explicit ParseTree(const ParseComponent& element): subComponents() { *this << element; } - ParseTree(const initializer_list& elements): subComponents() { addAll(elements); } + unsigned int& getCompCount() const { return compCount; } + auto& getComponents() const { return subComponents; } + void add(const ParseComponent& component) { addComp(component); }; + void addAll(const vector& components) { } + void operator<<(const ParseComponent& component) { this->addComp(component); } + explicit ParseTree(const ParseComponent& element): subComponents() { addComp(element); } + ParseTree(const initializer_list& elements): subComponents() { addAllComps(elements); } ParseTree(): subComponents() {}; ~ParseTree() = default; };