summaryrefslogtreecommitdiffstats
path: root/src/tools/windeployqt/qtmoduleinfo.h
blob: b35403a090b0852e3a8b2093e8ead74e0386403d (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef QTMODULEINFO_H
#define QTMODULEINFO_H

#include <QString>
#include <QStringList>

#include <bitset>
#include <vector>

constexpr size_t ModuleBitsetSize = 1024;
using ModuleBitset = std::bitset<ModuleBitsetSize>;

struct QtModule
{
    static constexpr size_t InvalidId = ModuleBitsetSize - 1;
    size_t id = InvalidId;
    bool internal = false;
    QString name;
    QString repository;
    QStringList pluginTypes;
    QString translationCatalog;
};

inline bool contains(const ModuleBitset &modules, const QtModule &module)
{
    return modules.test(module.id);
}

class QtModuleInfoStore
{
public:
    QtModuleInfoStore() = default;

    bool populate(const QString &modulesDir, const QString &translationsDir, bool verbose,
                  QString *errorString);

    size_t size() const { return modules.size(); }
    std::vector<QtModule>::const_iterator begin() const { return modules.begin(); }
    std::vector<QtModule>::const_iterator end() const { return modules.end(); }

    const QtModule &moduleById(size_t id) const;
    size_t moduleIdForPluginType(const QString &pluginType) const;

private:
    std::vector<QtModule> modules;
};

#endif