Rename the findByName method to findReferenceByName, and add a findReferencesById method.

This commit is contained in:
Username404 2021-08-08 23:44:42 +02:00
parent 9871cc66c7
commit 3c703e55b5
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 7 additions and 1 deletions

View File

@ -63,8 +63,14 @@ public:
return reinterpret_cast<T*>(it); return reinterpret_cast<T*>(it);
}); });
} }
IS_PARSECOMPONENT
auto findReferencesById() const {
return findById<T>() | views::transform([](T* it) {
return static_cast<T&>(*it);
});
}
IS(StandardComponents::NamedIdentifier) IS(StandardComponents::NamedIdentifier)
optional<reference_wrapper<T>> findByName(const string& name) const { optional<reference_wrapper<T>> findReferenceByName(const string& name) const {
auto identifiers = findById<T>(); auto identifiers = findById<T>();
for (T* identifier: identifiers) { for (T* identifier: identifiers) {
if (identifier->getId() == typeid(T) && identifier->name == name) { if (identifier->getId() == typeid(T) && identifier->name == name) {