Make const parse trees actually constant, fix formatting in Target.hpp and classes derived from Target
This commit is contained in:
parent
ed3da58e31
commit
beea9bfadf
@ -48,6 +48,12 @@ namespace StandardComponents {
|
||||
|
||||
#define IS_PARSECOMPONENT IS(ParseComponent)
|
||||
class ParseTree {
|
||||
IS_PARSECOMPONENT
|
||||
void addComponent(const T& component) const {
|
||||
subComponents.emplace_back(new T(component));
|
||||
}; IS_PARSECOMPONENT void addAllComponents(const initializer_list<T>& components) const {
|
||||
for (const T& comp: components) addComponent<T>(comp);
|
||||
}
|
||||
protected:
|
||||
mutable vector<unique_ptr<ParseComponent>> subComponents;
|
||||
using array_type = decltype(subComponents);
|
||||
@ -79,19 +85,20 @@ public:
|
||||
return optional<reference_wrapper<T>>();
|
||||
};
|
||||
inline size_t getCompCount() const { return subComponents.size(); }
|
||||
IS_PARSECOMPONENT inline void add(const T& component) { addComponent<T>(component); };
|
||||
IS_PARSECOMPONENT inline void addAll(const initializer_list<T>& components) { addAllComponents<T>(components); }
|
||||
IS_PARSECOMPONENT
|
||||
void add(const T& component) const {
|
||||
subComponents.emplace_back(new T(component));
|
||||
}; IS_PARSECOMPONENT void addAll(const initializer_list<T>& components) const {
|
||||
for (const auto& comp: components) add<T>(comp);
|
||||
}
|
||||
IS_PARSECOMPONENT
|
||||
inline const ParseTree& operator<<(const T& component) const { add(component); return *this; }
|
||||
inline ParseTree& operator<<(const T& component) { add(component); return *this; }
|
||||
ParseTree(): subComponents() {};
|
||||
IS_PARSECOMPONENT
|
||||
explicit ParseTree(const T& element): ParseTree() { add(element); }
|
||||
constexpr explicit ParseTree(const T& element): ParseTree() { addComponent(element); }
|
||||
IS_PARSECOMPONENT
|
||||
ParseTree(const initializer_list<T>& elements): ParseTree() { addAll(elements); }
|
||||
constexpr ParseTree(const initializer_list<T>& elements): ParseTree() { addAllComponents(elements); }
|
||||
ParseTree(const initializer_list<ParseComponent*>& elements): ParseTree() {
|
||||
for_each(elements.begin(), elements.end(), [&](ParseComponent* component){
|
||||
subComponents.emplace_back(component);
|
||||
});
|
||||
}
|
||||
};
|
||||
#undef IS_PARSECOMPONENT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user