• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KMIME Library

KMime::Codec

KMime::Codec Class Reference

An abstract base class of codecs for common mail transfer encodings. More...

#include <kmime_codecs.h>

Inheritance diagram for KMime::Codec:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual QByteArray decode (const QByteArray &src, bool withCRLF=false) const
virtual bool decode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, bool withCRLF=false) const
virtual QByteArray encode (const QByteArray &src, bool withCRLF=false) const
virtual bool encode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, bool withCRLF=false) const
virtual Decoder * makeDecoder (bool withCRLF=false) const =0
virtual Encoder * makeEncoder (bool withCRLF=false) const =0
virtual int maxDecodedSizeFor (int insize, bool withCRLF=false) const =0
virtual int maxEncodedSizeFor (int insize, bool withCRLF=false) const =0
virtual const char * name () const =0
virtual ~Codec ()

Static Public Member Functions

static Codec * codecForName (const QByteArray &name)
static Codec * codecForName (const char *name)

Protected Member Functions

 Codec ()

Detailed Description

An abstract base class of codecs for common mail transfer encodings.

Provides an abstract base class of codecs like base64 and quoted-printable. Implemented as a singleton.

Definition at line 83 of file kmime_codecs.h.


Constructor & Destructor Documentation

KMime::Codec::Codec (  )  [inline, protected]

Contructs the codec.

Definition at line 93 of file kmime_codecs.h.

virtual KMime::Codec::~Codec (  )  [inline, virtual]

Destroys the codec.

Definition at line 256 of file kmime_codecs.h.


Member Function Documentation

Codec * KMime::Codec::codecForName ( const QByteArray &  name  )  [static]

Returns a codec associated with the specified name.

Parameters:
name is a QByteArray containing a valid codec name.

Definition at line 88 of file kmime_codecs.cpp.

Codec * KMime::Codec::codecForName ( const char *  name  )  [static]

Returns a codec associated with the specified name.

Parameters:
name points to a character string containing a valid codec name.

Definition at line 82 of file kmime_codecs.cpp.

QByteArray KMime::Codec::decode ( const QByteArray &  src,
bool  withCRLF = false 
) const [virtual]

Even more convenient, but also a bit slower and more memory intensive, since it allocates storage for the worst case and then shrinks the result QByteArray to the actual size again.

For use with small src.

Parameters:
src is a QByteArray containing the data to decode.
withCRLF if true, make the newlines CRLF; else use LF.

Reimplemented in KMime::IdentityCodec.

Definition at line 160 of file kmime_codecs.cpp.

bool KMime::Codec::decode ( const char *&  scursor,
const char *const   send,
char *&  dcursor,
const char *const   dend,
bool  withCRLF = false 
) const [virtual]

Convenience wrapper that can be used for small chunks of data when you can provide a large enough buffer.

The default implementation creates a Decoder and uses it.

Decodes a chunk of bytes starting at scursor and extending to send into the buffer described by dcursor and dend.

This function doesn't support chaining of blocks. The returned block cannot be added to, but you don't need to finalize it, too.

Example usage (in contains the input data):

      KMime::Codec *codec = KMime::Codec::codecForName( "base64" );
      kFatal( !codec ) << "no base64 codec found!?";
      QByteArray out( in.size() ); // good guess for any encoding...
      QByteArray::Iterator iit = in.begin();
      QByteArray::Iterator oit = out.begin();
      if ( !codec->decode( iit, in.end(), oit, out.end() ) ) {
        kDebug(5320) << "output buffer too small";
        return;
      }
      kDebug(5320) << "Size of decoded data:" << oit - out.begin();
      
Parameters:
scursor is a pointer to the start of the input buffer.
send is a pointer to the end of the input buffer.
dcursor is a pointer to the start of the output buffer.
dend is a pointer to the end of the output buffer.
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
false if the decoded data didn't fit into the output buffer; true otherwise.

Definition at line 183 of file kmime_codecs.cpp.

QByteArray KMime::Codec::encode ( const QByteArray &  src,
bool  withCRLF = false 
) const [virtual]

Even more convenient, but also a bit slower and more memory intensive, since it allocates storage for the worst case and then shrinks the result QByteArray to the actual size again.

For use with small src.

Parameters:
src is a QByteArray containing the data to encode.
withCRLF if true, make the newlines CRLF; else use LF.

Reimplemented in KMime::IdentityCodec.

Definition at line 137 of file kmime_codecs.cpp.

bool KMime::Codec::encode ( const char *&  scursor,
const char *const   send,
char *&  dcursor,
const char *const   dend,
bool  withCRLF = false 
) const [virtual]

Convenience wrapper that can be used for small chunks of data when you can provide a large enough buffer.

The default implementation creates an Encoder and uses it.

Encodes a chunk of bytes starting at scursor and extending to send into the buffer described by dcursor and dend.

This function doesn't support chaining of blocks. The returned block cannot be added to, but you don't need to finalize it, too.

Example usage (in contains the input data):

      KMime::Codec *codec = KMime::Codec::codecForName( "base64" );
      kFatal( !codec ) << "no base64 codec found!?";
      QByteArray out( in.size()*1.4 ); // crude maximal size of b64 encoding
      QByteArray::Iterator iit = in.begin();
      QByteArray::Iterator oit = out.begin();
      if ( !codec->encode( iit, in.end(), oit, out.end() ) ) {
        kDebug(5320) << "output buffer too small";
        return;
      }
      kDebug(5320) << "Size of encoded data:" << oit - out.begin();
      
Parameters:
scursor is a pointer to the start of the input buffer.
send is a pointer to the end of the input buffer.
dcursor is a pointer to the start of the output buffer.
dend is a pointer to the end of the output buffer.
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
false if the encoded data didn't fit into the output buffer; true otherwise.

Definition at line 108 of file kmime_codecs.cpp.

virtual Decoder* KMime::Codec::makeDecoder ( bool  withCRLF = false  )  const [pure virtual]

Creates the decoder for the codec.

Parameters:
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
a pointer to an instance of the codec's decoder.

Implemented in KMime::Base64Codec, KMime::IdentityCodec, KMime::QuotedPrintableCodec, KMime::Rfc2047QEncodingCodec, KMime::Rfc2231EncodingCodec, and KMime::UUCodec.

virtual Encoder* KMime::Codec::makeEncoder ( bool  withCRLF = false  )  const [pure virtual]

Creates the encoder for the codec.

Parameters:
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
a pointer to an instance of the codec's encoder.

Implemented in KMime::Base64Codec, KMime::Rfc2047BEncodingCodec, KMime::IdentityCodec, KMime::QuotedPrintableCodec, KMime::Rfc2047QEncodingCodec, KMime::Rfc2231EncodingCodec, and KMime::UUCodec.

virtual int KMime::Codec::maxDecodedSizeFor ( int  insize,
bool  withCRLF = false 
) const [pure virtual]

Computes the maximum size, in characters, needed for the deccoding.

Parameters:
insize is the number of input characters to be decoded.
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
the maximum number of characters in the decoding.

Implemented in KMime::Base64Codec, KMime::Rfc2047BEncodingCodec, KMime::IdentityCodec, KMime::BinaryCodec, KMime::QuotedPrintableCodec, KMime::Rfc2047QEncodingCodec, KMime::Rfc2231EncodingCodec, and KMime::UUCodec.

virtual int KMime::Codec::maxEncodedSizeFor ( int  insize,
bool  withCRLF = false 
) const [pure virtual]

Computes the maximum size, in characters, needed for the encoding.

Parameters:
insize is the number of input characters to be encoded.
withCRLF if true, make the newlines CRLF; else use LF.
Returns:
the maximum number of characters in the encoding.

Implemented in KMime::Base64Codec, KMime::Rfc2047BEncodingCodec, KMime::IdentityCodec, KMime::BinaryCodec, KMime::QuotedPrintableCodec, KMime::Rfc2047QEncodingCodec, KMime::Rfc2231EncodingCodec, and KMime::UUCodec.

virtual const char* KMime::Codec::name (  )  const [pure virtual]

Returns the name of the encoding.

Guaranteed to be lowercase.

Implemented in KMime::Base64Codec, KMime::Rfc2047BEncodingCodec, KMime::SevenBitCodec, KMime::EightBitCodec, KMime::BinaryCodec, KMime::QuotedPrintableCodec, KMime::Rfc2047QEncodingCodec, KMime::Rfc2231EncodingCodec, and KMime::UUCodec.


The documentation for this class was generated from the following files:
  • kmime_codecs.h
  • kmime_codecs.cpp

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal