Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QMailCodec Class Reference
[QtMessagingModule, QtPimModule]

The QMailCodec class provides mechanisms for encoding and decoding between 7-bit ASCII strings and arbitrary octet sequences. More...

    #include <QMailCodec>

This class is under development and is subject to change.

Inherited by QMailBase64Codec, QMailLineEndingCodec, QMailPassThroughCodec, and QMailQuotedPrintableCodec.

Public Functions

  • virtual ~QMailCodec ()
  • virtual void decode ( QTextStream & out, QDataStream & in, const QString & charset )
  • virtual void decode ( QDataStream & out, QDataStream & in )
  • QString decode ( const QByteArray & input, const QString & charset )
  • QByteArray decode ( const QByteArray & input )
  • virtual void encode ( QDataStream & out, QTextStream & in, const QString & charset = "UTF-8" )
  • virtual void encode ( QDataStream & out, QDataStream & in )
  • QByteArray encode ( const QString & input, const QString & charset = "UTF-8" )
  • QByteArray encode ( const QByteArray & input )

Static Public Members

  • void copy ( QDataStream & out, QDataStream & in )
  • void copy ( QTextStream & out, QTextStream & in )

Protected Functions

  • virtual void decodeChunk ( QDataStream & out, const char * input, int length, bool finalChunk ) = 0
  • virtual void encodeChunk ( QDataStream & out, const unsigned char * input, int length, bool finalChunk ) = 0

Detailed Description

The QMailCodec class provides mechanisms for encoding and decoding between 7-bit ASCII strings and arbitrary octet sequences.

Messages transferred via the SMTP protocol must be encoded in 7-bit ASCII characters, even though their contents are typically composed in sequences of 8-bit octets. The QMailCodec class provides an interface through which data can be easily converted between an 8-bit octet sequence and a 7-bit ASCII character sequence.

QMailCodec is an abstract class; in order to perform a coding operation, a derived class must be used that provides a policy for mapping 8-bit data to and from 7-bit ASCII characters. This policy is implemented by overriding the encodeChunk() and decodeChunk() virtual functions.

Using the QMailCodec interface, data can be encoded or decoded from an input QDataStream to an output QDataStream, or for convenience, from an input QByteArray to an output QByteArray.

If the data to be encoded is in unicode form, then the QMailCodec interface can be used to convert the data to ASCII via an intermediate QTextCodec, which converts the incoming text to a sequence of octets. The QTextCodec used is specified by the name of the encoding produced, or that decoded when decoding an ASCII input sequence. QMailCodec provides functions to encode from a QTextStream to a QDataStream, and to decode from a QDataStream to a QTextStream. For convenience, it is also possible to encode a QString to a QByteArray, and to decode a QByteArray to a QString.

See also QDataStream, QTextStream, and QTextCodec.


Member Function Documentation

QMailCodec::~QMailCodec ()   [virtual]

Destroys a QMailCodec instance.

void QMailCodec::copy ( QDataStream & out, QDataStream & in )   [static]

Writes the data read from the stream in to the stream out, without conversion.

void QMailCodec::copy ( QTextStream & out, QTextStream & in )   [static]

This is an overloaded member function, provided for convenience.

Writes the data read from the stream in to the stream out, without conversion.

void QMailCodec::decode ( QTextStream & out, QDataStream & in, const QString & charset )   [virtual]

Writes the data read from the stream in to the stream out, converting from a sequence of 7-bit ASCII characters. The characters read from in are decoded from the text encoding charset to unicode.

See also QTextCodec::codecForName().

void QMailCodec::decode ( QDataStream & out, QDataStream & in )   [virtual]

This is an overloaded member function, provided for convenience.

Writes the data read from the stream in to the stream out, converting from a sequence of 7-bit ASCII characters.

QString QMailCodec::decode ( const QByteArray & input, const QString & charset )

This is an overloaded member function, provided for convenience.

Returns a QString containing characters decoded from the text encoding charset, which are decoded from the sequence of 7-bit ASCII characters read from input.

See also QTextCodec::codecForName().

QByteArray QMailCodec::decode ( const QByteArray & input )

This is an overloaded member function, provided for convenience.

Returns a QByteArray containing the octets decoded from the sequence of 7-bit ASCII characters in input.

void QMailCodec::decodeChunk ( QDataStream & out, const char * input, int length, bool finalChunk )   [pure virtual protected]

Overridden by derived classes to perform a decoding operation. The implementation function must decode length ASCII characters at the location input, writing the resulting octets to the stream out. If finalChunk is false, further calls will be made to decodeChunk() with continued input data. Otherwise, the decoding operation is complete.

void QMailCodec::encode ( QDataStream & out, QTextStream & in, const QString & charset = "UTF-8" )   [virtual]

Writes the data read from the stream in to the stream out, as a sequence of 7-bit ASCII characters. The unicode characters read from in are first encoded to the text encoding charset.

See also QTextCodec::codecForName().

void QMailCodec::encode ( QDataStream & out, QDataStream & in )   [virtual]

This is an overloaded member function, provided for convenience.

Writes the data read from the stream in to the stream out, as a sequence of 7-bit ASCII characters.

QByteArray QMailCodec::encode ( const QString & input, const QString & charset = "UTF-8" )

This is an overloaded member function, provided for convenience.

Returns a QByteArray containing the string input, encoded to the text encoding charset and then to a sequence of 7-bit ASCII characters.

See also QTextCodec::codecForName().

QByteArray QMailCodec::encode ( const QByteArray & input )

This is an overloaded member function, provided for convenience.

Returns a QByteArray containing the octets from input, encoded to a sequence of 7-bit ASCII characters.

void QMailCodec::encodeChunk ( QDataStream & out, const unsigned char * input, int length, bool finalChunk )   [pure virtual protected]

Overridden by derived classes to perform an encoding operation. The implementation function must encode length 8-bit octets at the location input, writing the resulting ASCII characters to the stream out. If finalChunk is false, further calls will be made to encodeChunk() with continued input data. Otherwise, the encoding operation is complete.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Quarterly au hasard

Logo

Bibliothèques et plug-ins

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web