00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "client-server.h"
00019 #include <s32mem.h>
00020
00021 EXPORT_C CHerculesData* CHerculesData::NewLC(const TDesC8& aDes1, const TDesC8& aDes2, TInt aVal)
00022 {
00023 CHerculesData* data = new (ELeave)CHerculesData(aVal);
00024 CleanupStack::PushL(data);
00025 data->ConstructL(aDes1, aDes2);
00026 return (data);
00027 }
00028
00029
00030
00031 CHerculesData* CHerculesData::NewLC(const TDesC8& aStreamData)
00032 {
00033 CHerculesData* data = new (ELeave)CHerculesData();
00034 CleanupStack::PushL(data);
00035
00036
00037 RDesReadStream stream(aStreamData);
00038 CleanupClosePushL(stream);
00039 data->InternalizeL(stream);
00040 CleanupStack::PopAndDestroy(&stream);
00041 return (data);
00042 }
00043
00044
00045 EXPORT_C CHerculesData::~CHerculesData()
00046 {
00047 delete iDes1;
00048 delete iDes2;
00049 }
00050
00051 CHerculesData::CHerculesData(TInt aVal)
00052 : iVal(aVal){}
00053
00054 void CHerculesData::ConstructL(const TDesC8& aDes1, const TDesC8& aDes2)
00055 {
00056 iDes1 = aDes1.AllocL();
00057 iDes2 = aDes2.AllocL();
00058 }
00059
00060
00061
00062 EXPORT_C HBufC8* CHerculesData::MarshalDataL() const
00063 {
00064
00065 const TInt KExpandSize = 128;
00066 CBufFlat* buf = CBufFlat::NewL(KExpandSize);
00067 CleanupStack::PushL(buf);
00068 RBufWriteStream stream(*buf);
00069 CleanupClosePushL(stream);
00070
00071 ExternalizeL(stream);
00072 CleanupStack::PopAndDestroy(&stream);
00073
00074
00075 HBufC8* des = HBufC8::NewL(buf->Size());
00076 TPtr8 ptr(des->Des());
00077 buf->Read(0, ptr, buf->Size());
00078
00079 CleanupStack::PopAndDestroy(buf);
00080 return (des);
00081 }
00082
00083
00084 void CHerculesData::ExternalizeL(RWriteStream& aStream) const
00085 {
00086 if (iDes1)
00087 {
00088 aStream << *iDes1;
00089 }
00090 else
00091 {
00092 aStream << KNullDesC8;
00093 }
00094
00095 if (iDes2)
00096 {
00097 aStream << *iDes2;
00098 }
00099 else
00100 {
00101 aStream << KNullDesC8;
00102 }
00103
00104 aStream.WriteInt32L(iVal);
00105 }
00106
00107
00108 void CHerculesData::InternalizeL(RReadStream& aStream)
00109 {
00110 const TInt KMaxReadSize = 1024;
00111 iDes1 = HBufC8::NewL(aStream, KMaxReadSize);
00112 iDes2 = HBufC8::NewL(aStream, KMaxReadSize);
00113 iVal = aStream.ReadInt32L();
00114 }
00115
00116 void CHerculesData::SetDes1L(const TDesC8& aDes)
00117 {
00118 delete iDes1;
00119 iDes1=NULL;
00120 iDes1 = aDes.AllocL();
00121 }
00122
00123 void CHerculesData::SetDes2L(const TDesC8& aDes)
00124 {
00125 delete iDes2;
00126 iDes2=NULL;
00127 iDes2 = aDes.AllocL();
00128 }
00129
00130
00131