blob: bf4ae083f430ed25cd5b85bfc1f27761d8cdc84b (
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) 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 <QMetaType>
#include <QString>
namespace lsp::Utils::Text {
class Position
{
public:
int line = 0; // 1-based
int column = -1; // 0-based
bool operator<(const Position &other) const
{ return line < other.line || (line == other.line && column < other.column); }
bool operator==(const Position &other) const;
bool operator!=(const Position &other) const { return !(operator==(other)); }
bool isValid() const { return line > 0 && column >= 0; }
static Position fromFileName(QStringView fileName, int &postfixPos);
};
class Range
{
public:
int length(const QString &text) const;
Position begin;
Position end;
bool operator<(const Range &other) const { return begin < other.begin; }
bool operator==(const Range &other) const;
bool operator!=(const Range &other) const { return !(operator==(other)); }
};
QString utf16LineTextInUtf8Buffer(const QByteArray &utf8Buffer, int currentUtf8Offset);
QDebug &operator<<(QDebug &stream, const Position &pos);
} // Text
|