summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringconverter_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/text/qstringconverter_base.h')
-rw-r--r--src/corelib/text/qstringconverter_base.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/corelib/text/qstringconverter_base.h b/src/corelib/text/qstringconverter_base.h
index 313c88f946..d6b6fcb484 100644
--- a/src/corelib/text/qstringconverter_base.h
+++ b/src/corelib/text/qstringconverter_base.h
@@ -13,6 +13,7 @@
#include <QtCore/qglobal.h> // QT_{BEGIN,END}_NAMESPACE
#include <QtCore/qflags.h> // Q_DECLARE_FLAGS
+#include <QtCore/qcontainerfwd.h>
#include <cstring>
@@ -31,7 +32,8 @@ public:
Stateless = 0x1,
ConvertInvalidToNull = 0x2,
WriteBom = 0x4,
- ConvertInitialBom = 0x8
+ ConvertInitialBom = 0x8,
+ UsesIcu = 0x10,
};
Q_DECLARE_FLAGS(Flags, Flag)
@@ -39,6 +41,7 @@ public:
constexpr State(Flags f = Flag::Default) noexcept
: flags(f), state_data{0, 0, 0, 0} {}
~State() { clear(); }
+
State(State &&other) noexcept
: flags(other.flags),
remainingChars(other.remainingChars),
@@ -59,6 +62,7 @@ public:
return *this;
}
Q_CORE_EXPORT void clear() noexcept;
+ Q_CORE_EXPORT void reset() noexcept;
Flags flags;
int internalState = 0;
@@ -85,12 +89,14 @@ public:
enum Encoding {
Utf8,
+#ifndef QT_BOOTSTRAPPED
Utf16,
Utf16LE,
Utf16BE,
Utf32,
Utf32LE,
Utf32BE,
+#endif
Latin1,
System,
LastEncoding = System
@@ -102,7 +108,8 @@ public:
Stateless = 0x1,
ConvertInvalidToNull = 0x2,
WriteBom = 0x4,
- ConvertInitialBom = 0x8
+ ConvertInitialBom = 0x8,
+ UsesIcu = 0x10,
};
Q_DECLARE_FLAGS(Flags, Flag)
#endif
@@ -125,12 +132,13 @@ protected:
: iface(nullptr)
{}
constexpr explicit QStringConverter(Encoding encoding, Flags f)
- : iface(&encodingInterfaces[int(encoding)]), state(f)
+ : iface(&encodingInterfaces[qsizetype(encoding)]), state(f)
{}
constexpr explicit QStringConverter(const Interface *i) noexcept
: iface(i)
{}
- Q_CORE_EXPORT explicit QStringConverter(const char *name, Flags f) noexcept;
+ Q_CORE_EXPORT explicit QStringConverter(const char *name, Flags f);
+
~QStringConverter() = default;
@@ -142,12 +150,11 @@ public:
void resetState() noexcept
{
- state.clear();
+ state.reset();
}
bool hasError() const noexcept { return state.invalidChars != 0; }
- const char *name() const noexcept
- { return isValid() ? iface->name : nullptr; }
+ Q_CORE_EXPORT const char *name() const noexcept;
Q_CORE_EXPORT static std::optional<Encoding> encodingForName(const char *name) noexcept;
Q_CORE_EXPORT static const char *nameForEncoding(Encoding e);
@@ -155,6 +162,8 @@ public:
encodingForData(QByteArrayView data, char16_t expectedFirstCharacter = 0) noexcept;
Q_CORE_EXPORT static std::optional<Encoding> encodingForHtml(QByteArrayView data);
+ Q_CORE_EXPORT static QStringList availableCodecs();
+
protected:
const Interface *iface;
State state;