author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 11:15:19 +0300 | |
branch | RCL_3 |
changeset 11 | 25a739ee40f4 |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qtextcodecplugin.h" |
|
43 |
#include "qstringlist.h" |
|
44 |
||
45 |
#ifndef QT_NO_TEXTCODECPLUGIN |
|
46 |
||
47 |
QT_BEGIN_NAMESPACE |
|
48 |
||
49 |
/*! |
|
50 |
\class QTextCodecPlugin |
|
51 |
\brief The QTextCodecPlugin class provides an abstract base for custom QTextCodec plugins. |
|
52 |
\reentrant |
|
53 |
\ingroup plugins |
|
54 |
||
55 |
The text codec plugin is a simple plugin interface that makes it |
|
56 |
easy to create custom text codecs that can be loaded dynamically |
|
57 |
into applications. |
|
58 |
||
59 |
Writing a text codec plugin is achieved by subclassing this base |
|
60 |
class, reimplementing the pure virtual functions names(), |
|
61 |
aliases(), createForName(), mibEnums() and createForMib(), and |
|
62 |
exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How |
|
63 |
to Create Qt Plugins} for details. |
|
64 |
||
65 |
See the \l{http://www.iana.org/assignments/character-sets}{IANA |
|
66 |
character-sets encoding file} for more information on mime |
|
67 |
names and mib enums. |
|
68 |
*/ |
|
69 |
||
70 |
/*! |
|
71 |
\fn QStringList QTextCodecPlugin::names() const |
|
72 |
||
73 |
Returns the list of MIME names supported by this plugin. |
|
74 |
||
75 |
If a codec has several names, the extra names are returned by aliases(). |
|
76 |
||
77 |
\sa createForName(), aliases() |
|
78 |
*/ |
|
79 |
||
80 |
/*! |
|
81 |
\fn QList<QByteArray> QTextCodecPlugin::aliases() const |
|
82 |
||
83 |
Returns the list of aliases supported by this plugin. |
|
84 |
*/ |
|
85 |
||
86 |
/*! |
|
87 |
\fn QTextCodec *QTextCodecPlugin::createForName(const QByteArray &name) |
|
88 |
||
89 |
Creates a QTextCodec object for the codec called \a name. The \a name |
|
90 |
must come from the list of encodings returned by names(). Encoding |
|
91 |
names are case sensitive. |
|
92 |
||
93 |
Example: |
|
94 |
||
95 |
\snippet doc/src/snippets/code/src_corelib_codecs_qtextcodecplugin.cpp 0 |
|
96 |
||
97 |
\sa names() |
|
98 |
*/ |
|
99 |
||
100 |
||
101 |
/*! |
|
102 |
\fn QList<int> QTextCodecPlugin::mibEnums() const |
|
103 |
||
104 |
Returns the list of mib enums supported by this plugin. |
|
105 |
||
106 |
\sa createForMib() |
|
107 |
*/ |
|
108 |
||
109 |
/*! |
|
110 |
\fn QTextCodec *QTextCodecPlugin::createForMib(int mib); |
|
111 |
||
112 |
Creates a QTextCodec object for the mib enum \a mib. |
|
113 |
||
114 |
See \l{http://www.iana.org/assignments/character-sets}{the |
|
115 |
IANA character-sets encoding file} for more information. |
|
116 |
||
117 |
\sa mibEnums() |
|
118 |
*/ |
|
119 |
||
120 |
/*! |
|
121 |
Constructs a text codec plugin with the given \a parent. This is |
|
122 |
invoked automatically by the Q_EXPORT_PLUGIN2() macro. |
|
123 |
*/ |
|
124 |
QTextCodecPlugin::QTextCodecPlugin(QObject *parent) |
|
125 |
: QObject(parent) |
|
126 |
{ |
|
127 |
} |
|
128 |
||
129 |
/*! |
|
130 |
Destroys the text codec plugin. |
|
131 |
||
132 |
You never have to call this explicitly. Qt destroys a plugin |
|
133 |
automatically when it is no longer used. |
|
134 |
*/ |
|
135 |
QTextCodecPlugin::~QTextCodecPlugin() |
|
136 |
{ |
|
137 |
} |
|
138 |
||
139 |
QStringList QTextCodecPlugin::keys() const |
|
140 |
{ |
|
141 |
QStringList keys; |
|
142 |
QList<QByteArray> list = names(); |
|
143 |
list += aliases(); |
|
144 |
for (int i = 0; i < list.size(); ++i) |
|
145 |
keys += QString::fromLatin1(list.at(i)); |
|
146 |
QList<int> mibs = mibEnums(); |
|
147 |
for (int i = 0; i < mibs.count(); ++i) |
|
148 |
keys += QLatin1String("MIB: ") + QString::number(mibs.at(i)); |
|
149 |
return keys; |
|
150 |
} |
|
151 |
||
152 |
QTextCodec *QTextCodecPlugin::create(const QString &name) |
|
153 |
{ |
|
154 |
if (name.startsWith(QLatin1String("MIB: "))) |
|
155 |
return createForMib(name.mid(4).toInt()); |
|
156 |
return createForName(name.toLatin1()); |
|
157 |
} |
|
158 |
||
159 |
QT_END_NAMESPACE |
|
160 |
||
161 |
#endif // QT_NO_TEXTCODECPLUGIN |