libkdenetwork Library API Documentation

KMime::Codec Class Reference

Abstract base class of codecs like base64 and quoted-printable. Codecs for common mail transfer encodings. More...

#include <kmime_codecs.h>

List of all members.

Public Member Functions

virtual int maxEncodedSizeFor (int insize, bool withCRLF=false) const =0
virtual int maxDecodedSizeFor (int insize, bool withCRLF=false) const =0
virtual EncodermakeEncoder (bool withCRLF=false) const =0
virtual Decoder * makeDecoder (bool withCRLF=false) const =0
virtual bool encode (const char *&scursor, const char *const send, char *&dcursor, const char *const dend, 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 QCString encodeToQCString (const QByteArray &src, bool withCRLF=false) const
virtual QByteArray decode (const QByteArray &src, bool withCRLF=false) const
virtual const char * name () const =0

Static Public Member Functions

CodeccodecForName (const char *name)
CodeccodecForName (const QCString &name)

Static Protected Attributes

QAsciiDict< Codecall


Detailed Description

Abstract base class of codecs like base64 and quoted-printable. Codecs for common mail transfer encodings.

It's a singleton.

Author:
Marc Mutz <mutz@kde.org>

Definition at line 56 of file kmime_codecs.h.


Member Function Documentation

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" );
 kdFatal( !codec ) << "no base64 codec found!?" << endl;
 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() ) ) {
   kdDebug() << "output buffer too small" << endl;
   return;
 }
 kdDebug() << "Size of encoded data: " << oit - out.begin() << endl;
 

Parameters:
scursor/send begin and end of input buffer
dcursor/dend begin and end of output buffer
withCRLF If true, make the lineends CRLF, else make them LF only.
Returns:
false if the encoded data didn't fit into the output buffer.
Definition at line 94 of file kmime_codecs.cpp.

References KMime::Encoder::encode(), and KMime::Encoder::finish().

Referenced by encode(), and encodeToQCString().

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" );
 kdFatal( !codec ) << "no base64 codec found!?" << endl;
 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() ) ) {
   kdDebug() << "output buffer too small" << endl;
   return;
 }
 kdDebug() << "Size of decoded data: " << oit - out.begin() << endl;
 

Parameters:
scursor/send begin and end of input buffer
dcursor/dend begin and end of output buffer
withCRLF If true, make the lineends CRLF, else make them LF only.
Returns:
false if the decoded data didn't fit into the output buffer.
Definition at line 187 of file kmime_codecs.cpp.

Referenced by decode().

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. Definition at line 121 of file kmime_codecs.cpp.

References encode(), and name().

QCString KMime::Codec::encodeToQCString 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 QCString to the actual size again.

For use with small src.

This method only works for codecs whose output is in the 8bit domain (ie. not in the binary domain). Codecs that do not fall into this category will return a null QCString. Definition at line 143 of file kmime_codecs.cpp.

References encode(), and name().

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. Definition at line 165 of file kmime_codecs.cpp.

References decode(), and name().

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

Returns:
the name of the encoding. Guaranteed to be lowercase.

Referenced by decode(), encode(), and encodeToQCString().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:48:49 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003