KMIME Library
kmime_codec_identity.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00035 #ifndef __KMIME_CODEC_IDENTITY_H__
00036 #define __KMIME_CODEC_IDENTITY_H__
00037
00038 #include "kmime_codecs.h"
00039
00040 class QByteArray;
00041
00042 namespace KMime {
00043
00048 class KMIME_EXPORT IdentityCodec : public Codec
00049 {
00050 protected:
00051 friend class Codec;
00055 IdentityCodec() : Codec() {}
00056
00057 public:
00061 ~IdentityCodec() {}
00062
00067 QByteArray encode( const QByteArray &src, bool withCRLF=false ) const;
00068
00073 QByteArray decode( const QByteArray &src, bool withCRLF=false ) const;
00074
00079 int maxEncodedSizeFor( int insize, bool withCRLF ) const
00080 {
00081 if ( withCRLF ) {
00082 return 2 * insize;
00083 } else {
00084 return insize;
00085 }
00086 }
00087
00092 int maxDecodedSizeFor( int insize, bool withCRLF ) const
00093 {
00094 if ( withCRLF ) {
00095 return 2 * insize;
00096 } else {
00097 return insize;
00098 }
00099 }
00100
00105 Encoder *makeEncoder( bool withCRLF=false ) const;
00106
00111 Decoder *makeDecoder( bool withCRLF=false ) const;
00112 };
00113
00118 class KMIME_EXPORT SevenBitCodec : public IdentityCodec
00119 {
00120 protected:
00121 friend class Codec;
00125 SevenBitCodec() : IdentityCodec() {}
00126
00127 public:
00131 ~SevenBitCodec() {}
00132
00137 const char *name() const
00138 { return "7bit"; }
00139 };
00140
00145 class KMIME_EXPORT EightBitCodec : public IdentityCodec
00146 {
00147 protected:
00148 friend class Codec;
00152 EightBitCodec() : IdentityCodec() {}
00153
00154 public:
00158 ~EightBitCodec() {}
00159
00164 const char *name() const
00165 { return "8bit"; }
00166 };
00167
00172 class KMIME_EXPORT BinaryCodec : public IdentityCodec
00173 {
00174 protected:
00175 friend class Codec;
00179 BinaryCodec() : IdentityCodec() {}
00180
00181 public:
00185 ~BinaryCodec() {}
00186
00191 const char *name() const
00192 { return "binary"; }
00193
00198 int maxEncodedSizeFor( int insize, bool withCRLF=false ) const
00199 { Q_UNUSED( withCRLF ); return insize; }
00200
00205 int maxDecodedSizeFor( int insize, bool withCRLF=false ) const
00206 { Q_UNUSED( withCRLF ); return insize; }
00207 };
00208
00209 }
00210
00211 #endif // __KMIME_CODEC_IDENTITY_H__