aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/lsp/textutils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lsp/textutils.h')
-rw-r--r--src/shared/lsp/textutils.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/shared/lsp/textutils.h b/src/shared/lsp/textutils.h
new file mode 100644
index 000000000..bf4ae083f
--- /dev/null
+++ b/src/shared/lsp/textutils.h
@@ -0,0 +1,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