1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtCore module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QUTFCODEC_P_H |
43 | #define QUTFCODEC_P_H |
44 | |
45 | // |
46 | // W A R N I N G |
47 | // ------------- |
48 | // |
49 | // This file is not part of the Qt API. It exists purely as an |
50 | // implementation detail. This header file may change from version to |
51 | // version without notice, or even be removed. |
52 | // |
53 | // We mean it. |
54 | // |
55 | |
56 | #include "QtCore/qtextcodec.h" |
57 | #include "private/qtextcodec_p.h" |
58 | |
59 | QT_BEGIN_NAMESPACE |
60 | |
61 | enum DataEndianness |
62 | { |
63 | DetectEndianness, |
64 | BigEndianness, |
65 | LittleEndianness |
66 | }; |
67 | |
68 | struct QUtf8 |
69 | { |
70 | static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *); |
71 | static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *); |
72 | }; |
73 | |
74 | struct QUtf16 |
75 | { |
76 | static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness = DetectEndianness); |
77 | static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *, DataEndianness = DetectEndianness); |
78 | }; |
79 | |
80 | struct QUtf32 |
81 | { |
82 | static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness = DetectEndianness); |
83 | static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *, DataEndianness = DetectEndianness); |
84 | }; |
85 | |
86 | #ifndef QT_NO_TEXTCODEC |
87 | |
88 | class QUtf8Codec : public QTextCodec { |
89 | public: |
90 | ~QUtf8Codec(); |
91 | |
92 | QByteArray name() const; |
93 | int mibEnum() const; |
94 | |
95 | QString convertToUnicode(const char *, int, ConverterState *) const; |
96 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const; |
97 | void convertToUnicode(QString *target, const char *, int, ConverterState *) const; |
98 | }; |
99 | |
100 | class QUtf16Codec : public QTextCodec { |
101 | protected: |
102 | public: |
103 | QUtf16Codec() { e = DetectEndianness; } |
104 | ~QUtf16Codec(); |
105 | |
106 | QByteArray name() const; |
107 | QList<QByteArray> aliases() const; |
108 | int mibEnum() const; |
109 | |
110 | QString convertToUnicode(const char *, int, ConverterState *) const; |
111 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const; |
112 | |
113 | protected: |
114 | DataEndianness e; |
115 | }; |
116 | |
117 | class QUtf16BECodec : public QUtf16Codec { |
118 | public: |
119 | QUtf16BECodec() : QUtf16Codec() { e = BigEndianness; } |
120 | QByteArray name() const; |
121 | QList<QByteArray> aliases() const; |
122 | int mibEnum() const; |
123 | }; |
124 | |
125 | class QUtf16LECodec : public QUtf16Codec { |
126 | public: |
127 | QUtf16LECodec() : QUtf16Codec() { e = LittleEndianness; } |
128 | QByteArray name() const; |
129 | QList<QByteArray> aliases() const; |
130 | int mibEnum() const; |
131 | }; |
132 | |
133 | class QUtf32Codec : public QTextCodec { |
134 | public: |
135 | QUtf32Codec() { e = DetectEndianness; } |
136 | ~QUtf32Codec(); |
137 | |
138 | QByteArray name() const; |
139 | QList<QByteArray> aliases() const; |
140 | int mibEnum() const; |
141 | |
142 | QString convertToUnicode(const char *, int, ConverterState *) const; |
143 | QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const; |
144 | |
145 | protected: |
146 | DataEndianness e; |
147 | }; |
148 | |
149 | class QUtf32BECodec : public QUtf32Codec { |
150 | public: |
151 | QUtf32BECodec() : QUtf32Codec() { e = BigEndianness; } |
152 | QByteArray name() const; |
153 | QList<QByteArray> aliases() const; |
154 | int mibEnum() const; |
155 | }; |
156 | |
157 | class QUtf32LECodec : public QUtf32Codec { |
158 | public: |
159 | QUtf32LECodec() : QUtf32Codec() { e = LittleEndianness; } |
160 | QByteArray name() const; |
161 | QList<QByteArray> aliases() const; |
162 | int mibEnum() const; |
163 | }; |
164 | |
165 | |
166 | #endif // QT_NO_TEXTCODEC |
167 | |
168 | QT_END_NAMESPACE |
169 | |
170 | #endif // QUTFCODEC_P_H |
171 | |