diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h')
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h b/sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h index c1deea2c2..2a053ceaf 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h +++ b/sources/shiboken6/ApiExtractor/abstractmetalang_helpers.h @@ -4,21 +4,24 @@ #ifndef ABSTRACTMETALANG_HELPERS_H #define ABSTRACTMETALANG_HELPERS_H +#include "abstractmetalang_typedefs.h" + template <class MetaClass> -MetaClass *findByName(QList<MetaClass *> haystack, QStringView needle) +std::shared_ptr<MetaClass> findByName(const QList<std::shared_ptr<MetaClass> > &haystack, + QStringView needle) { - for (MetaClass *c : haystack) { + for (const auto &c : haystack) { if (c->name() == needle) return c; } - return nullptr; + return {}; } // Helper for recursing the base classes of an AbstractMetaClass. // Returns the class for which the predicate is true. template <class Predicate> -const AbstractMetaClass *recurseClassHierarchy(const AbstractMetaClass *klass, - Predicate pred) +AbstractMetaClassCPtr recurseClassHierarchy(const AbstractMetaClassCPtr &klass, + Predicate pred) { if (pred(klass)) return klass; @@ -26,7 +29,7 @@ const AbstractMetaClass *recurseClassHierarchy(const AbstractMetaClass *klass, if (auto r = recurseClassHierarchy(base, pred)) return r; } - return nullptr; + return {}; } #endif // ABSTRACTMETALANG_HELPERS_H |