1 | // Copyright (C) 2018 The Qt Company Ltd. |
2 | // Copyright (C) 2018 Intel Corporation. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef QUTFCODEC_P_H |
6 | #define QUTFCODEC_P_H |
7 | |
8 | // |
9 | // W A R N I N G |
10 | // ------------- |
11 | // |
12 | // This file is not part of the Qt API. It exists purely as an |
13 | // implementation detail. This header file may change from version to |
14 | // version without notice, or even be removed. |
15 | // |
16 | // We mean it. |
17 | // |
18 | |
19 | |
20 | #include <QtCore/qendian.h> |
21 | #include <QtCore/qlist.h> |
22 | #include <QtCore/qstring.h> |
23 | |
24 | #include <private/qstringconverter_p.h> |
25 | #include <private/qtextcodec_p.h> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | #if QT_CONFIG(textcodec) |
30 | |
31 | class QUtf8Codec : public QTextCodec { |
32 | public: |
33 | ~QUtf8Codec(); |
34 | |
35 | QByteArray name() const override; |
36 | int mibEnum() const override; |
37 | |
38 | QString convertToUnicode(const char *, int, ConverterState *) const override; |
39 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; |
40 | void convertToUnicode(QString *target, const char *, int, ConverterState *) const; |
41 | }; |
42 | |
43 | class QUtf16Codec : public QTextCodec { |
44 | protected: |
45 | public: |
46 | QUtf16Codec() { e = DetectEndianness; } |
47 | ~QUtf16Codec(); |
48 | |
49 | QByteArray name() const override; |
50 | QList<QByteArray> aliases() const override; |
51 | int mibEnum() const override; |
52 | |
53 | QString convertToUnicode(const char *, int, ConverterState *) const override; |
54 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; |
55 | |
56 | protected: |
57 | DataEndianness e; |
58 | }; |
59 | |
60 | class QUtf16BECodec : public QUtf16Codec { |
61 | public: |
62 | QUtf16BECodec() : QUtf16Codec() { e = BigEndianness; } |
63 | QByteArray name() const override; |
64 | QList<QByteArray> aliases() const override; |
65 | int mibEnum() const override; |
66 | }; |
67 | |
68 | class QUtf16LECodec : public QUtf16Codec { |
69 | public: |
70 | QUtf16LECodec() : QUtf16Codec() { e = LittleEndianness; } |
71 | QByteArray name() const override; |
72 | QList<QByteArray> aliases() const override; |
73 | int mibEnum() const override; |
74 | }; |
75 | |
76 | class QUtf32Codec : public QTextCodec { |
77 | public: |
78 | QUtf32Codec() { e = DetectEndianness; } |
79 | ~QUtf32Codec(); |
80 | |
81 | QByteArray name() const override; |
82 | QList<QByteArray> aliases() const override; |
83 | int mibEnum() const override; |
84 | |
85 | QString convertToUnicode(const char *, int, ConverterState *) const override; |
86 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; |
87 | |
88 | protected: |
89 | DataEndianness e; |
90 | }; |
91 | |
92 | class QUtf32BECodec : public QUtf32Codec { |
93 | public: |
94 | QUtf32BECodec() : QUtf32Codec() { e = BigEndianness; } |
95 | QByteArray name() const override; |
96 | QList<QByteArray> aliases() const override; |
97 | int mibEnum() const override; |
98 | }; |
99 | |
100 | class QUtf32LECodec : public QUtf32Codec { |
101 | public: |
102 | QUtf32LECodec() : QUtf32Codec() { e = LittleEndianness; } |
103 | QByteArray name() const override; |
104 | QList<QByteArray> aliases() const override; |
105 | int mibEnum() const override; |
106 | }; |
107 | |
108 | #endif // textcodec |
109 | |
110 | QT_END_NAMESPACE |
111 | |
112 | #endif // QUTFCODEC_P_H |
113 | |