Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qtextcodec.h 3.3.8 edited Jan 11 14:46 $ 00003 ** 00004 ** Definition of QTextCodec class 00005 ** 00006 ** Created : 981015 00007 ** 00008 ** Copyright (C) 1998-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the tools module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QTEXTCODEC_H 00039 #define QTEXTCODEC_H 00040 00041 #ifndef QT_H 00042 #include "qstring.h" 00043 #endif // QT_H 00044 00045 #ifndef QT_NO_TEXTCODEC 00046 00047 class QTextCodec; 00048 class QIODevice; 00049 class QFont; 00050 00051 class Q_EXPORT QTextEncoder { 00052 public: 00053 virtual ~QTextEncoder(); 00054 virtual QCString fromUnicode(const QString& uc, int& lenInOut) = 0; 00055 }; 00056 00057 class Q_EXPORT QTextDecoder { 00058 public: 00059 virtual ~QTextDecoder(); 00060 virtual QString toUnicode(const char* chars, int len) = 0; 00061 }; 00062 00063 class Q_EXPORT QTextCodec { 00064 public: 00065 virtual ~QTextCodec(); 00066 00067 #ifndef QT_NO_CODECS 00068 static QTextCodec* loadCharmap(QIODevice*); 00069 static QTextCodec* loadCharmapFile(QString filename); 00070 #endif //QT_NO_CODECS 00071 static QTextCodec* codecForMib(int mib); 00072 static QTextCodec* codecForName(const char* hint, int accuracy=0); 00073 static QTextCodec* codecForContent(const char* chars, int len); 00074 static QTextCodec* codecForIndex(int i); 00075 static QTextCodec* codecForLocale(); 00076 static void setCodecForLocale(QTextCodec *c); 00077 00078 static QTextCodec* codecForTr(); 00079 static void setCodecForTr(QTextCodec *c); 00080 static QTextCodec* codecForCStrings(); 00081 static void setCodecForCStrings(QTextCodec *c); 00082 00083 static void deleteAllCodecs(); 00084 00085 static const char* locale(); 00086 00087 virtual const char* name() const = 0; 00088 virtual const char* mimeName() const; 00089 virtual int mibEnum() const = 0; 00090 00091 virtual QTextDecoder* makeDecoder() const; 00092 virtual QTextEncoder* makeEncoder() const; 00093 00094 virtual QString toUnicode(const char* chars, int len) const; 00095 virtual QCString fromUnicode(const QString& uc, int& lenInOut) const; 00096 00097 QCString fromUnicode(const QString& uc) const; 00098 QString toUnicode(const QByteArray&, int len) const; 00099 QString toUnicode(const QByteArray&) const; 00100 QString toUnicode(const QCString&, int len) const; 00101 QString toUnicode(const QCString&) const; 00102 QString toUnicode(const char* chars) const; 00103 virtual bool canEncode( QChar ) const; 00104 virtual bool canEncode( const QString& ) const; 00105 00106 virtual int heuristicContentMatch(const char* chars, int len) const = 0; 00107 virtual int heuristicNameMatch(const char* hint) const; 00108 00109 virtual QByteArray fromUnicode(const QString& uc, int from, int len) const; 00110 virtual unsigned short characterFromUnicode(const QString &str, int pos) const; 00111 00112 protected: 00113 QTextCodec(); 00114 static int simpleHeuristicNameMatch(const char* name, const char* hint); 00115 00116 private: 00117 friend class QFont; 00118 friend class QFontEngineXLFD; 00119 void fromUnicodeInternal( const QChar *in, unsigned short *out, int length ); 00120 00121 static QTextCodec *cftr; 00122 static QTextCodec *cfcs; 00123 }; 00124 00125 inline QTextCodec* QTextCodec::codecForTr() { return cftr; } 00126 inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; } 00127 inline QTextCodec* QTextCodec::codecForCStrings() { return cfcs; } 00128 inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { cfcs = c; } 00129 00130 #endif // QT_NO_TEXTCODEC 00131 #endif // QTEXTCODEC_H