aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/clangsupport
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2022-01-19 11:24:39 +0100
committerMarco Bubke <marco.bubke@qt.io>2022-01-20 11:33:21 +0000
commit7457d3d8b6945e14124cdd7517767a486af00ff7 (patch)
treecfca59ab23fdb2ee1c5290371ff8a65eb55ce084 /src/libs/clangsupport
parentf8385f98c17e09f0dcc5036b79fa5afe9135369c (diff)
ClangSupport: Break artificial dependency to Sqlite
Since the Sqlite library is not used anymore in clang there was only an dependency to the Utf8String in ClangSupport. As we move Utf8String and Utf8StringVector to ClangSupport we can break the dependency to Sqlite. Change-Id: I0012906345bc49a48a7262c1d6e204fb8aff01e1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs/clangsupport')
-rw-r--r--src/libs/clangsupport/CMakeLists.txt4
-rw-r--r--src/libs/clangsupport/clangsupport-lib.pri4
-rw-r--r--src/libs/clangsupport/clangsupport.qbs2
-rw-r--r--src/libs/clangsupport/clangsupportdebugutils.cpp2
-rw-r--r--src/libs/clangsupport/codecompletion.h2
-rw-r--r--src/libs/clangsupport/codecompletionchunk.h2
-rw-r--r--src/libs/clangsupport/filecontainer.h2
-rw-r--r--src/libs/clangsupport/lineprefixer.h2
-rw-r--r--src/libs/clangsupport/requestcompletionsmessage.h2
-rw-r--r--src/libs/clangsupport/sourcelocationcontainer.h2
-rw-r--r--src/libs/clangsupport/tokeninfocontainer.h2
-rw-r--r--src/libs/clangsupport/tooltipinfo.h2
-rw-r--r--src/libs/clangsupport/utf8string.cpp58
-rw-r--r--src/libs/clangsupport/utf8string.h323
-rw-r--r--src/libs/clangsupport/utf8stringvector.cpp113
-rw-r--r--src/libs/clangsupport/utf8stringvector.h105
16 files changed, 615 insertions, 12 deletions
diff --git a/src/libs/clangsupport/CMakeLists.txt b/src/libs/clangsupport/CMakeLists.txt
index 032284a10a..aa3c0ec3da 100644
--- a/src/libs/clangsupport/CMakeLists.txt
+++ b/src/libs/clangsupport/CMakeLists.txt
@@ -2,7 +2,7 @@ set(CLANG_VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PAT
add_qtc_library(ClangSupport
DEPENDS Threads::Threads
- PUBLIC_DEPENDS Utils Sqlite Qt5::Core Qt5::Network
+ PUBLIC_DEPENDS Utils Qt5::Core Qt5::Network
PUBLIC_DEFINES
CLANG_VERSION="${CLANG_VERSION}"
CLANG_INCLUDE_DIR="${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}/include"
@@ -63,6 +63,8 @@ add_qtc_library(ClangSupport
tooltipmessage.cpp tooltipmessage.h
unsavedfilesremovedmessage.cpp unsavedfilesremovedmessage.h
unsavedfilesupdatedmessage.cpp unsavedfilesupdatedmessage.h
+ utf8string.cpp utf8string.h
+ utf8stringvector.cpp utf8stringvector.h
writemessageblock.cpp writemessageblock.h
)
diff --git a/src/libs/clangsupport/clangsupport-lib.pri b/src/libs/clangsupport/clangsupport-lib.pri
index c53974ce0c..4529b4fb62 100644
--- a/src/libs/clangsupport/clangsupport-lib.pri
+++ b/src/libs/clangsupport/clangsupport-lib.pri
@@ -50,6 +50,8 @@ SOURCES += \
$$PWD/tooltipmessage.cpp \
$$PWD/tooltipinfo.cpp \
$$PWD/unsavedfilesremovedmessage.cpp \
+ $$PWD/utf8string.cpp \
+ $$PWD/utf8stringvector.cpp \
$$PWD/documentschangedmessage.cpp \
$$PWD/documentvisibilitychangedmessage.cpp \
$$PWD/writemessageblock.cpp \
@@ -104,6 +106,8 @@ HEADERS += \
$$PWD/tooltipmessage.h \
$$PWD/tooltipinfo.h \
$$PWD/unsavedfilesremovedmessage.h \
+ $$PWD/utf8string.h \
+ $$PWD/utf8stringvector.h \
$$PWD/documentschangedmessage.h \
$$PWD/documentvisibilitychangedmessage.h \
$$PWD/writemessageblock.h \
diff --git a/src/libs/clangsupport/clangsupport.qbs b/src/libs/clangsupport/clangsupport.qbs
index 6b76f784af..f2ca80ce55 100644
--- a/src/libs/clangsupport/clangsupport.qbs
+++ b/src/libs/clangsupport/clangsupport.qbs
@@ -5,7 +5,6 @@ QtcLibrary {
targetName: "Clangbackendipc"
Depends { name: "Qt.network" }
- Depends { name: "Sqlite" }
Depends { name: "Utils" }
cpp.defines: base.concat("CLANGSUPPORT_BUILD_LIB")
@@ -19,7 +18,6 @@ QtcLibrary {
}
Export {
- Depends { name: "Sqlite" }
Depends { name: "Utils" }
Depends { name: "Qt.network" }
cpp.includePaths: [
diff --git a/src/libs/clangsupport/clangsupportdebugutils.cpp b/src/libs/clangsupport/clangsupportdebugutils.cpp
index 864f44a6d0..3d49694884 100644
--- a/src/libs/clangsupport/clangsupportdebugutils.cpp
+++ b/src/libs/clangsupport/clangsupportdebugutils.cpp
@@ -27,7 +27,7 @@
#include "filecontainer.h"
-#include <utf8string.h>
+#include "utf8string.h"
#include <QDir>
#include <QLoggingCategory>
diff --git a/src/libs/clangsupport/codecompletion.h b/src/libs/clangsupport/codecompletion.h
index 4a97fe08c1..a8f0e142b2 100644
--- a/src/libs/clangsupport/codecompletion.h
+++ b/src/libs/clangsupport/codecompletion.h
@@ -29,7 +29,7 @@
#include "codecompletionchunk.h"
#include "fixitcontainer.h"
-#include <sqlite/utf8string.h>
+#include "utf8string.h"
#include <QDataStream>
#include <QVector>
diff --git a/src/libs/clangsupport/codecompletionchunk.h b/src/libs/clangsupport/codecompletionchunk.h
index b1a0ba32e7..e04d3351af 100644
--- a/src/libs/clangsupport/codecompletionchunk.h
+++ b/src/libs/clangsupport/codecompletionchunk.h
@@ -27,7 +27,7 @@
#include "clangsupport_global.h"
-#include <utf8string.h>
+#include "utf8string.h"
#include <QDataStream>
#include <QVector>
diff --git a/src/libs/clangsupport/filecontainer.h b/src/libs/clangsupport/filecontainer.h
index 64180e2141..2c7eb08851 100644
--- a/src/libs/clangsupport/filecontainer.h
+++ b/src/libs/clangsupport/filecontainer.h
@@ -27,7 +27,7 @@
#include "clangsupport_global.h"
-#include <utf8string.h>
+#include "utf8string.h"
#include <utf8stringvector.h>
#include <QDataStream>
diff --git a/src/libs/clangsupport/lineprefixer.h b/src/libs/clangsupport/lineprefixer.h
index 58439875fa..010a5247ea 100644
--- a/src/libs/clangsupport/lineprefixer.h
+++ b/src/libs/clangsupport/lineprefixer.h
@@ -27,9 +27,9 @@
#include "clangsupport_global.h"
+#include "utf8string.h"
#include <QString>
#include <QTextStream>
-#include <utf8string.h>
namespace ClangBackEnd {
diff --git a/src/libs/clangsupport/requestcompletionsmessage.h b/src/libs/clangsupport/requestcompletionsmessage.h
index fa9bd9aebb..90b492c0f3 100644
--- a/src/libs/clangsupport/requestcompletionsmessage.h
+++ b/src/libs/clangsupport/requestcompletionsmessage.h
@@ -27,7 +27,7 @@
#include "clangsupport_global.h"
-#include <utf8string.h>
+#include "utf8string.h"
#include <QDataStream>
diff --git a/src/libs/clangsupport/sourcelocationcontainer.h b/src/libs/clangsupport/sourcelocationcontainer.h
index 1c205755b1..4f13488e21 100644
--- a/src/libs/clangsupport/sourcelocationcontainer.h
+++ b/src/libs/clangsupport/sourcelocationcontainer.h
@@ -27,7 +27,7 @@
#include "clangsupport_global.h"
-#include <sqlite/utf8string.h>
+#include "utf8string.h"
namespace ClangBackEnd {
diff --git a/src/libs/clangsupport/tokeninfocontainer.h b/src/libs/clangsupport/tokeninfocontainer.h
index dc2f8ba252..004bdd3cb9 100644
--- a/src/libs/clangsupport/tokeninfocontainer.h
+++ b/src/libs/clangsupport/tokeninfocontainer.h
@@ -29,7 +29,7 @@
#include "sourcerangecontainer.h"
-#include <sqlite/utf8string.h>
+#include "utf8string.h"
#include <QDataStream>
diff --git a/src/libs/clangsupport/tooltipinfo.h b/src/libs/clangsupport/tooltipinfo.h
index 31bf313ab1..3d443c5b64 100644
--- a/src/libs/clangsupport/tooltipinfo.h
+++ b/src/libs/clangsupport/tooltipinfo.h
@@ -25,7 +25,7 @@
#pragma once
-#include <utf8string.h>
+#include "utf8string.h"
#include <utf8stringvector.h>
#include <QVariant>
diff --git a/src/libs/clangsupport/utf8string.cpp b/src/libs/clangsupport/utf8string.cpp
new file mode 100644
index 0000000000..ad7748cfa5
--- /dev/null
+++ b/src/libs/clangsupport/utf8string.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "utf8string.h"
+
+#include "utf8stringvector.h"
+
+#include <QString>
+#include <QDebug>
+
+#include <ostream>
+
+QDebug operator<<(QDebug debug, const Utf8String &text)
+{
+ debug << text.constData();
+
+ return debug;
+}
+
+std::ostream& operator<<(std::ostream &os, const Utf8String &utf8String)
+{
+ using std::ostream;
+ os << utf8String.constData();
+
+ return os;
+}
+
+Utf8StringVector Utf8String::split(char separator) const
+{
+ Utf8StringVector utf8Vector;
+
+ for (const QByteArray &byteArrayPart : byteArray.split(separator))
+ utf8Vector.append(Utf8String::fromByteArray(byteArrayPart));
+
+ return utf8Vector;
+}
diff --git a/src/libs/clangsupport/utf8string.h b/src/libs/clangsupport/utf8string.h
new file mode 100644
index 0000000000..ebd9aba0a6
--- /dev/null
+++ b/src/libs/clangsupport/utf8string.h
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "clangsupport_global.h"
+
+#include <QByteArray>
+#include <QDataStream>
+#include <QHashFunctions>
+#include <QMetaType>
+#include <QString>
+
+#include <cstring>
+#include <iosfwd>
+
+class Utf8StringVector;
+class Utf8String;
+
+class Utf8String
+{
+ friend class Utf8StringVector;
+
+public:
+ Utf8String() = default;
+
+ explicit Utf8String(const char *utf8Text)
+ : byteArray(utf8Text, utf8Text ? static_cast<int>(std::strlen(utf8Text)) : -1)
+ {}
+
+ explicit Utf8String(const char *utf8Text, int size)
+ : byteArray(utf8Text, size)
+ {}
+
+ Utf8String(const QString &text)
+ : byteArray(text.toUtf8())
+ {
+ }
+
+ const char *constData() const
+ {
+ return byteArray.constData();
+ }
+
+ int byteSize() const
+ {
+ return byteArray.size();
+ }
+
+ static Utf8String fromUtf8(const char *utf8Text)
+ {
+ return Utf8String(utf8Text, -1);
+ }
+
+ static Utf8String fromByteArray(const QByteArray &utf8ByteArray)
+ {
+ return Utf8String(utf8ByteArray);
+ }
+ const QByteArray &toByteArray() const
+ {
+ return byteArray;
+ }
+
+ static Utf8String fromString(const QString &text)
+ {
+ return Utf8String::fromByteArray(text.toUtf8());
+ }
+
+ QString toString() const
+ {
+ return QString::fromUtf8(byteArray, byteArray.size());
+ }
+
+ Utf8String mid(int position, int length = -1) const
+ {
+ return Utf8String(byteArray.mid(position, length));
+ }
+
+ void replace(const Utf8String &before, const Utf8String &after)
+ {
+ byteArray.replace(before.byteArray, after.byteArray);
+ }
+
+ void replace(int position, int length, const Utf8String &after)
+ {
+ byteArray.replace(position, length, after.byteArray);
+ }
+
+ CLANGSUPPORT_EXPORT Utf8StringVector split(char separator) const;
+
+ void clear()
+ {
+ byteArray.clear();
+ }
+
+ void append(const Utf8String &textToAppend)
+ {
+ byteArray.append(textToAppend.byteArray);
+ }
+
+ void chop(int n)
+ {
+ byteArray.chop(n);
+ }
+
+ int indexOf(const Utf8String &text) const
+ {
+ return byteArray.indexOf(text.byteArray);
+ }
+
+ int indexOf(const char *text) const
+ {
+ return byteArray.indexOf(text);
+ }
+
+ int lastIndexOf(const Utf8String &text) const
+ {
+ return byteArray.lastIndexOf(text.byteArray);
+ }
+
+ int lastIndexOf(const char *text) const
+ {
+ return byteArray.lastIndexOf(text);
+ }
+
+ int indexOf(char character) const
+ {
+ return byteArray.indexOf(character);
+ }
+
+ bool contains(const Utf8String &text) const
+ {
+ return byteArray.contains(text.byteArray);
+ }
+
+ bool contains(const char *text) const
+ {
+ return byteArray.contains(text);
+ }
+
+ bool contains(char character) const
+ {
+ return byteArray.contains(character);
+ }
+
+ bool startsWith(const Utf8String &text) const
+ {
+ return byteArray.startsWith(text.byteArray);
+ }
+
+ bool startsWith(const char *text) const
+ {
+ return byteArray.startsWith(text);
+ }
+
+ bool startsWith(char character) const
+ {
+ return byteArray.startsWith(character);
+ }
+
+ bool endsWith(const Utf8String &text) const
+ {
+ return byteArray.endsWith(text.byteArray);
+ }
+
+ bool endsWith(const char *text) const
+ {
+ return byteArray.endsWith(text);
+ }
+
+ bool endsWith(char character) const
+ {
+ return byteArray.endsWith(character);
+ }
+
+ bool isNull() const
+ {
+ return byteArray.isNull();
+ }
+
+ bool isEmpty() const
+ {
+ return byteArray.isEmpty();
+ }
+
+ bool hasContent() const
+ {
+ return !isEmpty();
+ }
+
+ void reserve(int reserveSize)
+ {
+ byteArray.reserve(reserveSize);
+ }
+
+ template<typename T>
+ static Utf8String number(T number, int base = 10)
+ {
+ return Utf8String::fromByteArray(QByteArray::number(number, base));
+ }
+
+ const Utf8String &operator+=(const Utf8String &text)
+ {
+ byteArray += text.byteArray;
+
+ return *this;
+ }
+
+ static void registerType()
+ {
+ qRegisterMetaType<Utf8String>("Utf8String");
+ }
+
+ operator QString() const
+ {
+ return toString();
+ }
+
+ operator const QByteArray &() const
+ {
+ return byteArray;
+ }
+
+ friend const Utf8String operator+(const Utf8String &first, const Utf8String &second)
+ {
+ return Utf8String(first.byteArray + second.byteArray);
+ }
+
+ friend bool operator!=(const Utf8String &first, const Utf8String &second)
+ {
+ return first.byteArray != second.byteArray;
+ }
+
+ friend bool operator==(const Utf8String &first, const Utf8String &second)
+ {
+ return first.byteArray == second.byteArray;
+ }
+
+ friend bool operator==(const Utf8String &first, const char *second)
+ {
+ return first.byteArray == second;
+ }
+
+ friend bool operator==(const char *first, const Utf8String &second)
+ {
+ return second == first;
+ }
+
+ friend bool operator!=(const Utf8String &first, const char *second)
+ {
+ return first.byteArray != second;
+ }
+
+ friend bool operator!=(const char *first, const Utf8String &second) { return second != first; }
+
+ friend bool operator==(const Utf8String &first, const QString &second)
+ {
+ return first.byteArray == second.toUtf8();
+ }
+
+ friend bool operator<(const Utf8String &first, const Utf8String &second)
+ {
+ if (first.byteSize() == second.byteSize())
+ return first.byteArray < second.byteArray;
+
+ return first.byteSize() < second.byteSize();
+ }
+
+ friend QDataStream &operator<<(QDataStream &datastream, const Utf8String &text)
+ {
+ datastream << text.byteArray;
+
+ return datastream;
+ }
+
+ friend QDataStream &operator>>(QDataStream &datastream, Utf8String &text)
+ {
+ datastream >> text.byteArray;
+
+ return datastream;
+ }
+
+ friend auto qHash(const Utf8String &utf8String)
+ {
+ return qHash(utf8String.byteArray);
+ }
+
+protected:
+ explicit Utf8String(const QByteArray &utf8ByteArray)
+ : byteArray(utf8ByteArray)
+ {
+ }
+
+private:
+ QByteArray byteArray;
+};
+
+CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const Utf8String &text);
+CLANGSUPPORT_EXPORT std::ostream &operator<<(std::ostream &os, const Utf8String &utf8String);
+
+#define Utf8StringLiteral(str) Utf8String::fromByteArray(QByteArrayLiteral(str))
diff --git a/src/libs/clangsupport/utf8stringvector.cpp b/src/libs/clangsupport/utf8stringvector.cpp
new file mode 100644
index 0000000000..f892a173db
--- /dev/null
+++ b/src/libs/clangsupport/utf8stringvector.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "utf8stringvector.h"
+
+#include <QStringList>
+#include <QDebug>
+
+#include <ostream>
+
+Utf8StringVector::Utf8StringVector()
+{
+}
+
+Utf8StringVector::Utf8StringVector(std::initializer_list<Utf8String> initializerList)
+ : QVector<Utf8String>(initializerList)
+{
+
+}
+
+Utf8StringVector::Utf8StringVector(const Utf8String &utf8String)
+{
+ append(utf8String);
+}
+
+Utf8StringVector::Utf8StringVector(const QVector<Utf8String> &vector)
+ : QVector<Utf8String>(vector)
+{
+
+}
+
+Utf8StringVector::Utf8StringVector(const QStringList &stringList)
+{
+ reserve(stringList.count());
+
+ foreach (const QString &string, stringList)
+ append(Utf8String(string));
+}
+
+Utf8StringVector::Utf8StringVector(int size, const Utf8String &text)
+ : QVector<Utf8String>(size, text)
+{
+}
+
+Utf8String Utf8StringVector::join(const Utf8String &separator) const
+{
+ Utf8String joindedString;
+
+ joindedString.reserve(totalByteSize() + separator.byteSize() * count());
+
+ for (auto position = begin(); position != end(); ++position) {
+ joindedString.append(*position);
+ if (std::next(position) != end())
+ joindedString.append(separator);
+ }
+
+ return joindedString;
+}
+
+Utf8StringVector Utf8StringVector::fromIntegerVector(const QVector<int> &integerVector)
+{
+ Utf8StringVector utf8StringVector;
+ utf8StringVector.reserve(integerVector.count());
+
+ foreach (int integer, integerVector)
+ utf8StringVector.append(Utf8String::number(integer));
+
+ return utf8StringVector;
+}
+
+void Utf8StringVector::registerType()
+{
+ qRegisterMetaType<Utf8StringVector>("Utf8StringVector");
+}
+
+int Utf8StringVector::totalByteSize() const
+{
+ int totalSize = 0;
+
+ for (const Utf8String &utf8String : *this)
+ totalSize += utf8String.byteSize();
+
+ return totalSize;
+}
+
+QDebug operator<<(QDebug debug, const Utf8StringVector &textVector)
+{
+ debug << "Utf8StringVector(" << textVector.join(Utf8StringLiteral(", ")).constData() << ")";
+
+ return debug;
+}
diff --git a/src/libs/clangsupport/utf8stringvector.h b/src/libs/clangsupport/utf8stringvector.h
new file mode 100644
index 0000000000..31c681ecb9
--- /dev/null
+++ b/src/libs/clangsupport/utf8stringvector.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "clangsupport_global.h"
+#include "utf8string.h"
+
+#include <QDataStream>
+#include <QVector>
+
+#include <ostream>
+
+class CLANGSUPPORT_EXPORT Utf8StringVector : public QVector<Utf8String>
+{
+public:
+ Utf8StringVector();
+ Utf8StringVector(std::initializer_list<Utf8String> initializerList);
+ explicit Utf8StringVector(const Utf8String &utf8String);
+ Utf8StringVector(const QVector<Utf8String> &vector);
+ explicit Utf8StringVector(const QStringList &stringList);
+ explicit Utf8StringVector(int size, const Utf8String &text);
+
+ Utf8String join(const Utf8String &separator) const;
+
+ static Utf8StringVector fromIntegerVector(const QVector<int> &integerVector);
+
+ static void registerType();
+
+ inline bool removeFast(const Utf8String &valueToBeRemoved);
+
+protected:
+ int totalByteSize() const;
+};
+
+bool Utf8StringVector::removeFast(const Utf8String &valueToBeRemoved)
+{
+ auto position = std::remove(begin(), end(), valueToBeRemoved);
+
+ bool hasEntry = position != end();
+
+ erase(position, end());
+
+ return hasEntry;
+}
+
+namespace std { // it has to be in std namespace for lookup
+
+template <typename T>
+ostream &operator<<(ostream &out, const QVector<T> &vector)
+{
+ out << "[";
+
+ copy(vector.cbegin(), vector.cend(), ostream_iterator<T>(out, ", "));
+
+ out << "]";
+
+ return out;
+}
+
+inline
+ostream &operator<<(ostream &out, const Utf8StringVector &vector)
+{
+ out << "[";
+
+ copy(vector.cbegin(), vector.cend(), ostream_iterator<Utf8String>(out, ", "));
+
+ out << "]";
+
+ return out;
+}
+
+} // namespace std
+
+inline QDataStream &operator<<(QDataStream &s, const Utf8StringVector &v)
+{ return s << static_cast<const QVector<Utf8String> &>(v); }
+
+inline QDataStream &operator>>(QDataStream &s, Utf8StringVector &v)
+{ return s >> static_cast<QVector<Utf8String> &>(v); }
+
+CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const Utf8StringVector &textVector);
+
+Q_DECLARE_METATYPE(Utf8StringVector)