Make a few members of ParseTree private, and make the internal methods protected

This commit is contained in:
Username404-59 2021-10-01 18:15:59 +02:00
parent 54aa4105b8
commit 525aa0db88
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1

View File

@ -48,23 +48,26 @@ 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 {
subComponents.reserve(components.size());
for (const T& comp: components) addComponent<T>(comp);
}
protected:
mutable vector<unique_ptr<ParseComponent>> subComponents;
using array_type = decltype(subComponents);
using iterator = array_type::iterator;
using const_iterator = array_type::const_iterator;
using constant_iterator = array_type::const_iterator;
protected:
IS_PARSECOMPONENT
void addComponent(const T& component) const
{ subComponents.emplace_back(new T(component)); };
IS_PARSECOMPONENT
void addAllComponents(
const initializer_list<T>& components
) const {
subComponents.reserve(components.size());
for (const T& current: components) addComponent<T>(current);
}
public:
inline iterator begin() const noexcept { return subComponents.begin(); }
inline const_iterator cbegin() const noexcept { return subComponents.cbegin(); }
inline constant_iterator cbegin() const noexcept { return subComponents.cbegin(); }
inline iterator end() const noexcept { return subComponents.end(); }
inline const_iterator cend() const noexcept { return subComponents.cend(); }
inline constant_iterator cend() const noexcept { return subComponents.cend(); }
IS_PARSECOMPONENT
vector<T*> findById() const {
vector<T*> filteredComponents;