libkmime
kmime_codec_identity.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "kmime_codec_identity.h"
00033
00034 #include <kdebug.h>
00035 #include <kglobal.h>
00036
00037 #include <cassert>
00038 #include <cstring>
00039
00040 using namespace KMime;
00041
00042 namespace KMime {
00043
00044
00045 class IdentityEnDecoder : public Encoder, public Decoder {
00046 protected:
00047 friend class IdentityCodec;
00048 IdentityEnDecoder( bool withCRLF )
00049 : Encoder( false )
00050 {
00051 kdWarning( withCRLF, 5100 ) << "IdentityEnDecoder: withCRLF isn't yet supported!" << endl;
00052 }
00053
00054 public:
00055 ~IdentityEnDecoder() {}
00056
00057 bool encode( const char* & scursor, const char * const send,
00058 char* & dcursor, const char * const dend ) {
00059 return decode( scursor, send, dcursor, dend );
00060 }
00061 bool decode( const char* & scursor, const char * const send,
00062 char* & dcursor, const char * const dend );
00063 bool finish( char* & , const char * const ) { return true; }
00064 };
00065
00066
00067 Encoder * IdentityCodec::makeEncoder( bool withCRLF ) const {
00068 return new IdentityEnDecoder( withCRLF );
00069 }
00070
00071 Decoder * IdentityCodec::makeDecoder( bool withCRLF ) const {
00072 return new IdentityEnDecoder( withCRLF );
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082 bool IdentityEnDecoder::decode( const char* & scursor, const char * const send,
00083 char* & dcursor, const char * const dend )
00084 {
00085 const int size = kMin( send - scursor, dcursor - dend );
00086 if ( size > 0 ) {
00087 std::memmove( dcursor, scursor, size );
00088 dcursor += size;
00089 scursor += size;
00090 }
00091 return scursor == send;
00092 }
00093
00094 QByteArray IdentityCodec::encode( const QByteArray & src, bool withCRLF ) const {
00095 kdWarning( withCRLF, 5100 ) << "IdentityCodec::encode(): withCRLF not yet supported!" << endl;
00096 return src;
00097 }
00098
00099 QByteArray IdentityCodec::decode( const QByteArray & src, bool withCRLF ) const {
00100 kdWarning( withCRLF, 5100 ) << "IdentityCodec::decode(): withCRLF not yet supported!" << endl;
00101 return src;
00102 }
00103
00104 QCString IdentityCodec::encodeToQCString( const QByteArray & src, bool withCRLF ) const {
00105 kdWarning( withCRLF, 5100 ) << "IdentityCodec::encodeToQCString(): withCRLF not yet supported!" << endl;
00106 return QCString( src.data(), src.size() + 1 );
00107 }
00108
00109 }
|