diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-08-24 15:30:04 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-08-30 10:46:56 +0000 |
commit | 25ff15a1fbe2288b6dc53abdb4a50a642491d118 (patch) | |
tree | 3a8f9877a88a0e6ebc450147867622ccbe1a5de9 /src/plugins/projectexplorer/headerpath.h | |
parent | 5805208cec8ed90f6caa6b1b0263ecdf162227c5 (diff) |
Add convenience functions for creating ProjectExplorer::HeaderPaths
Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/headerpath.h')
-rw-r--r-- | src/plugins/projectexplorer/headerpath.h | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/plugins/projectexplorer/headerpath.h b/src/plugins/projectexplorer/headerpath.h index 09337684b3..37492fe9f1 100644 --- a/src/plugins/projectexplorer/headerpath.h +++ b/src/plugins/projectexplorer/headerpath.h @@ -25,6 +25,9 @@ #pragma once +#include <utils/algorithm.h> +#include <utils/fileutils.h> + #include <QString> #include <QVector> @@ -41,9 +44,10 @@ class HeaderPath { public: HeaderPath() = default; - HeaderPath(const QString &path, HeaderPathType type) - : path(path), type(type) - { } + HeaderPath(const QString &path, HeaderPathType type) : path(path), type(type) { } + HeaderPath(const char *path, HeaderPathType type) : HeaderPath(QLatin1String(path), type) {} + HeaderPath(const Utils::FilePath &path, HeaderPathType type) + : HeaderPath(path.toString(), type) { } bool operator==(const HeaderPath &other) const { @@ -55,6 +59,23 @@ public: return !(*this == other); } + template<typename F> static HeaderPath makeUser(const F &fp) + { + return {fp, HeaderPathType::User}; + } + template<typename F> static HeaderPath makeBuiltIn(const F &fp) + { + return {fp, HeaderPathType::BuiltIn}; + } + template<typename F> static HeaderPath makeSystem(const F &fp) + { + return {fp, HeaderPathType::System}; + } + template<typename F> static HeaderPath makeFramework(const F &fp) + { + return {fp, HeaderPathType::Framework}; + } + QString path; HeaderPathType type = HeaderPathType::User; }; @@ -65,4 +86,23 @@ inline auto qHash(const HeaderPath &key, uint seed = 0) } using HeaderPaths = QVector<HeaderPath>; +template<typename C> HeaderPaths toHeaderPaths(const C &list, HeaderPathType type) +{ + return Utils::transform<HeaderPaths>(list, [type](const auto &fp) { + return HeaderPath(fp, type); + }); +} +template<typename C> HeaderPaths toUserHeaderPaths(const C &list) +{ + return toHeaderPaths(list, HeaderPathType::User); +} +template<typename C> HeaderPaths toBuiltInHeaderPaths(const C &list) +{ + return toHeaderPaths(list, HeaderPathType::BuiltIn); +} +template<typename C> HeaderPaths toFrameworkHeaderPaths(const C &list) +{ + return toHeaderPaths(list, HeaderPathType::Framework); +} + } // namespace ProjectExplorer |