summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppfileiterationorder.h
blob: 7d681c0b4a9177fbd836b20a812bfc2305265d36 (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
// 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>

#include <set>

namespace CppEditor {

class CPPEDITOR_EXPORT FileIterationOrder {
public:
    struct Entry {
        Entry(const Utils::FilePath &filePath,
              const QString &projectPartId = {},
              int commonFilePathPrefixLength = 0,
              int commonProjectPartPrefixLength = 0);

        friend CPPEDITOR_EXPORT bool operator<(const Entry &first, const Entry &second);

        const Utils::FilePath filePath;
        const QString projectPartId;
        int commonFilePathPrefixLength = 0;
        int commonProjectPartPrefixLength = 0;
    };

    FileIterationOrder();
    FileIterationOrder(const Utils::FilePath &referenceFilePath,
                       const QString &referenceProjectPartId);

    void setReference(const Utils::FilePath &filePath, const QString &projectPartId);
    bool isValid() const;

    void insert(const Utils::FilePath &filePath, const QString &projectPartId = QString());
    void remove(const Utils::FilePath &filePath, const QString &projectPartId);
    QStringList toStringList() const;
    Utils::FilePaths toFilePaths() const;

private:
    Entry createEntryFromFilePath(const Utils::FilePath &filePath,
                                  const QString &projectPartId) const;

private:
    Utils::FilePath m_referenceFilePath;
    QString m_referenceProjectPartId;
    std::multiset<Entry> m_set;
};

CPPEDITOR_EXPORT bool operator<(const FileIterationOrder::Entry &first,
                                const FileIterationOrder::Entry &second);

} // namespace CppEditor