blob: 70b715b7d47509e93a48d0f4e3c067b696df4280 (
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
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "utils_global.h"
#include <QMetaType>
#include <optional>
namespace Utils {
class QTCREATOR_UTILS_EXPORT LineColumn
{
public:
constexpr LineColumn() = default;
constexpr LineColumn(int line, int column) : line(line), column(column) {}
bool isValid() const
{
return line >= 0 && column >= 0;
}
friend bool operator==(LineColumn first, LineColumn second)
{
return first.isValid() && first.line == second.line && first.column == second.column;
}
friend bool operator!=(LineColumn first, LineColumn second)
{
return !(first == second);
}
static LineColumn extractFromFileName(QStringView fileName, int &postfixPos);
public:
int line = -1;
int column = -1;
};
using OptionalLineColumn = std::optional<LineColumn>;
} // namespace Utils
Q_DECLARE_METATYPE(Utils::LineColumn)
|