summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppprojectfile.h
blob: 529d0bb65589cefd66fc97afd71dc953bf78e276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "cppeditor_global.h"

#include <utils/filepath.h>

namespace Utils { class FilePath; }

namespace CppEditor {

class CPPEDITOR_EXPORT ProjectFile
{
public:
    enum Kind {
        Unclassified,
        Unsupported,
        AmbiguousHeader,
        CHeader,
        CSource,
        CXXHeader,
        CXXSource,
        ObjCHeader,
        ObjCSource,
        ObjCXXHeader,
        ObjCXXSource,
        CudaSource,
        OpenCLSource,
    };

    ProjectFile() = default;
    ProjectFile(const Utils::FilePath &filePath, Kind kind, bool active = true);

    static Kind classifyByMimeType(const QString &mt);
    static Kind classify(const QString &filePath);

    static Kind sourceForHeaderKind(Kind kind);
    static Kind sourceKind(Kind kind);

    static bool isSource(Kind kind);
    static bool isHeader(Kind kind);
    static bool isHeader(const Utils::FilePath &fp);
    static bool isC(Kind kind);
    static bool isCxx(Kind kind);
    static bool isAmbiguousHeader(const QString &filePath);
    static bool isObjC(const QString &filePath);
    static bool isObjC(Kind kind);

    bool isHeader() const;
    bool isSource() const;

    bool isC() const;
    bool isCxx() const;

    bool operator==(const ProjectFile &other) const;
    friend QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile);

public:
    Utils::FilePath path;
    Kind kind = Unclassified;
    bool active = true;
};

using ProjectFiles = QVector<ProjectFile>;

const char *projectFileKindToText(ProjectFile::Kind kind);

} // CppEditor