Add a new constructor to ParseTree, and make the compCount variable mutable.
This commit is contained in:
parent
259398f2a3
commit
28175f2d96
@ -11,7 +11,7 @@ class ParseComponent {};
|
|||||||
|
|
||||||
struct ParseTree: public ParseComponent {
|
struct ParseTree: public ParseComponent {
|
||||||
private:
|
private:
|
||||||
unsigned int compCount = 0;
|
mutable unsigned int compCount = 0;
|
||||||
protected:
|
protected:
|
||||||
vector<ParseComponent> subComponents;
|
vector<ParseComponent> subComponents;
|
||||||
public:
|
public:
|
||||||
@ -20,6 +20,8 @@ public:
|
|||||||
void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; };
|
void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; };
|
||||||
void addAll(const vector<ParseComponent>& components) { for (const auto& comp: components) add(comp); }
|
void addAll(const vector<ParseComponent>& components) { for (const auto& comp: components) add(comp); }
|
||||||
void operator<<(const ParseComponent& component) { this->add(component); }
|
void operator<<(const ParseComponent& component) { this->add(component); }
|
||||||
|
explicit ParseTree(const ParseComponent& element): subComponents() { *this << element; }
|
||||||
|
ParseTree(const initializer_list<ParseComponent>& elements): subComponents() { addAll(elements); }
|
||||||
ParseTree(): subComponents() {};
|
ParseTree(): subComponents() {};
|
||||||
~ParseTree() = default;
|
~ParseTree() = default;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user