aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/clangsupport/projectpartcontainer.h
blob: b2133dcaa297eacb9ef9cf80a56db25d3c5de140 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/

#pragma once

#include "clangsupport_global.h"

#include "compilermacro.h"
#include "filepathid.h"
#include "includesearchpath.h"
#include "projectpartartefact.h"
#include "projectpartid.h"

#include <utils/cpplanguage_details.h>
#include <utils/smallstringio.h>

namespace ClangBackEnd {

class ProjectPartContainer : public ProjectPartArtefact
{
    using uchar = unsigned char;
public:
    ProjectPartContainer() = default;
    ProjectPartContainer(ProjectPartId projectPartId,
                         Utils::SmallStringVector &&toolChainArguments,
                         CompilerMacros &&compilerMacros,
                         IncludeSearchPaths &&systemIncludeSearchPaths,
                         IncludeSearchPaths &&projectIncludeSearchPaths,
                         FilePathIds &&headerPathIds,
                         FilePathIds &&sourcePathIds,
                         Utils::Language language,
                         Utils::LanguageVersion languageVersion,
                         Utils::LanguageExtension languageExtension)
        : ProjectPartArtefact(projectPartId,
                              std::move(toolChainArguments),
                              std::move(compilerMacros),
                              std::move(systemIncludeSearchPaths),
                              std::move(projectIncludeSearchPaths),
                              language,
                              languageVersion,
                              languageExtension)
        , headerPathIds(std::move(headerPathIds))
        , sourcePathIds(std::move(sourcePathIds))

    {}

    ProjectPartContainer(Utils::SmallStringView compilerArgumentsText,
                         Utils::SmallStringView compilerMacrosText,
                         Utils::SmallStringView systemIncludeSearchPathsText,
                         Utils::SmallStringView projectIncludeSearchPathsText,
                         int projectPartId,
                         int language,
                         int languageVersion,
                         int languageExtension)
        : ProjectPartArtefact(compilerArgumentsText,
                              compilerMacrosText,
                              systemIncludeSearchPathsText,
                              projectIncludeSearchPathsText,
                              projectPartId,
                              language,
                              languageVersion,
                              languageExtension)
    {}

    friend QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container)
    {
        out << container.projectPartId;
        out << container.toolChainArguments;
        out << container.compilerMacros;
        out << container.systemIncludeSearchPaths;
        out << container.projectIncludeSearchPaths;
        out << container.headerPathIds;
        out << container.sourcePathIds;
        out << uchar(container.language);
        out << uchar(container.languageVersion);
        out << uchar(container.languageExtension);
        return out;
    }

    friend QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container)
    {
        uchar language;
        uchar languageVersion;
        uchar languageExtension;

        in >> container.projectPartId;
        in >> container.toolChainArguments;
        in >> container.compilerMacros;
        in >> container.systemIncludeSearchPaths;
        in >> container.projectIncludeSearchPaths;
        in >> container.headerPathIds;
        in >> container.sourcePathIds;
        in >> language;
        in >> languageVersion;
        in >> languageExtension;

        container.language = static_cast<Utils::Language>(language);
        container.languageVersion = static_cast<Utils::LanguageVersion>(languageVersion);
        container.languageExtension = static_cast<Utils::LanguageExtension>(languageExtension);

        return in;
    }

    friend bool operator==(const ProjectPartContainer &first, const ProjectPartContainer &second)
    {
        return first.projectPartId == second.projectPartId
            && first.toolChainArguments == second.toolChainArguments
            && first.compilerMacros == second.compilerMacros
            && first.systemIncludeSearchPaths == second.systemIncludeSearchPaths
            && first.projectIncludeSearchPaths == second.projectIncludeSearchPaths
            && first.headerPathIds == second.headerPathIds
            && first.sourcePathIds == second.sourcePathIds&& first.language == second.language
               && first.languageVersion == second.languageVersion
               && first.languageExtension == second.languageExtension;
    }

    friend bool operator<(const ProjectPartContainer &first, const ProjectPartContainer &second)
    {
        return std::tie(first.projectPartId,
                        first.toolChainArguments,
                        first.compilerMacros,
                        first.systemIncludeSearchPaths,
                        first.projectIncludeSearchPaths,
                        first.headerPathIds,
                        first.sourcePathIds,
                        first.language,
                        first.languageVersion,
                        first.languageExtension,
                        first.hasPrecompiledHeader)
               < std::tie(second.projectPartId,
                          second.toolChainArguments,
                          second.compilerMacros,
                          second.systemIncludeSearchPaths,
                          second.projectIncludeSearchPaths,
                          second.headerPathIds,
                          second.sourcePathIds,
                          second.language,
                          second.languageVersion,
                          second.languageExtension,
                          second.hasPrecompiledHeader);
    }

    ProjectPartContainer clone() const
    {
        return *this;
    }

public:
    FilePathIds headerPathIds;
    FilePathIds sourcePathIds;
    bool updateIsDeferred = false;
    bool hasPrecompiledHeader = true;
};

using ProjectPartContainerReference = std::reference_wrapper<ProjectPartContainer>;
using ProjectPartContainers = std::vector<ProjectPartContainer>;
using ProjectPartContainerReferences = std::vector<ProjectPartContainerReference>;

CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartContainer &container);

} // namespace ClangBackEnd