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
00063 using Codec::encode;
00064 using Codec::decode;
00065
00070 QByteArray encode( const QByteArray &src, bool withCRLF=false ) const;
00071
00076 QByteArray decode( const QByteArray &src, bool withCRLF=false ) const;
00077
00082 int maxEncodedSizeFor( int insize, bool withCRLF ) const
00083 {
00084 if ( withCRLF ) {
00085 return 2 * insize;
00086 } else {
00087 return insize;
00088 }
00089 }
00090
00095 int maxDecodedSizeFor( int insize, bool withCRLF ) const
00096 {
00097 if ( withCRLF ) {
00098 return 2 * insize;
00099 } else {
00100 return insize;
00101 }
00102 }
00103
00108 Encoder *makeEncoder( bool withCRLF=false ) const;
00109
00114 Decoder *makeDecoder( bool withCRLF=false ) const;
00115 };
00116
00121 class KMIME_EXPORT SevenBitCodec : public IdentityCodec
00122 {
00123 protected:
00124 friend class Codec;
00128 SevenBitCodec() : IdentityCodec() {}
00129
00130 public:
00134 ~SevenBitCodec() {}
00135
00140 const char *name() const
00141 { return "7bit"; }
00142 };
00143
00148 class KMIME_EXPORT EightBitCodec : public IdentityCodec
00149 {
00150 protected:
00151 friend class Codec;
00155 EightBitCodec() : IdentityCodec() {}
00156
00157 public:
00161 ~EightBitCodec() {}
00162
00167 const char *name() const
00168 { return "8bit"; }
00169 };
00170
00175 class KMIME_EXPORT BinaryCodec : public IdentityCodec
00176 {
00177 protected:
00178 friend class Codec;
00182 BinaryCodec() : IdentityCodec() {}
00183
00184 public:
00188 ~BinaryCodec() {}
00189
00194 const char *name() const
00195 { return "binary"; }
00196
00201 int maxEncodedSizeFor( int insize, bool withCRLF=false ) const
00202 { Q_UNUSED( withCRLF ); return insize; }
00203
00208 int maxDecodedSizeFor( int insize, bool withCRLF=false ) const
00209 { Q_UNUSED( withCRLF ); return insize; }
00210 };
00211
00212 }
00213
00214 #endif // __KMIME_CODEC_IDENTITY_H__