00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CommonFramework.h"
00018
00019
00020
00021
00022 _LIT(KTxtHelloWorld,"Hello World!");
00023 _LIT(KTxtHelloWorldMorning,"Hello World! Morning");
00024 _LIT(KTxtAndHi," & Hi");
00025
00026
00027
00028
00029 _LIT(KCommonFormat1,"Size()=%d;\nMaxLength()=%d\n");
00030 _LIT(KCommonFormat2,"Ptr()=%x; Length()=%d; ");
00031 _LIT(KCommonFormat5,"Ptr()=%x; Length()=%d; Size()=%d\n");
00032
00033
00034
00035 LOCAL_C void doExampleL()
00036 {
00037
00038
00039
00040 HBufC* buf;
00041
00042
00043
00044
00045
00046 buf = HBufC::NewL(15);
00047 CleanupStack::PushL(buf);
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 _LIT(KFormat10,"\"%S\"; descriptor at %x; ");
00062 console->Printf(KFormat10,buf,buf);
00063 console->Printf(KCommonFormat5,buf->Ptr(),buf->Length(),buf->Size());
00064
00065
00066 *buf = KTxtHelloWorld;
00067
00068
00069
00070
00071 _LIT(KFormat9,"\"%S\"; ");
00072 console->Printf(KFormat9,buf);
00073 _LIT(KFormat8,"Length()=%d; Size()=%d\n");
00074 console->Printf(KFormat8,buf->Length(),buf->Size());
00075
00076
00077
00078
00079
00080
00081
00082 buf = buf->ReAllocL(20);
00083
00084
00085 *buf = KTxtHelloWorldMorning;
00086
00087
00088 _LIT(KFormat7,"\n\"%S\"; \n(1st realloc') desc'at %x; ");
00089 console->Printf(KFormat7,buf,buf);
00090 console->Printf(KCommonFormat5,buf->Ptr(),buf->Length(),buf->Size());
00091
00092
00093
00094
00095
00096 buf = buf->ReAllocL(22);
00097 _LIT(KFormat6,"\n\"%S\"; \n(2nd realloc') desc'at %x; ");
00098 console->Printf(KFormat6,buf,buf);
00099 console->Printf(KCommonFormat5,buf->Ptr(),buf->Length(),buf->Size());
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 TPtr ptr = buf->Des();
00111
00112 _LIT(KFormat11,"TPtr descriptor at %x; ");
00113 console->Printf(KFormat11,&ptr);
00114 console->Printf(KCommonFormat2,ptr.Ptr(),ptr.Length());
00115 console->Printf(KCommonFormat1,ptr.Size(),ptr.MaxLength());
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 ptr.Delete((ptr.Length()-9),9);
00130 ptr.Append(KTxtAndHi);
00131
00132
00133 _LIT(KFormat4,"\n\"%S\";\nHBufC descriptor at %x; ");
00134 console->Printf(KFormat4,buf,buf);
00135
00136 console->Printf(KCommonFormat5,buf->Ptr(),buf->Length(),buf->Size());
00137
00138
00139 _LIT(KFormat3,"\"%S\"; \nTPtr descriptor at %x; ");
00140 console->Printf(KFormat3,&ptr,&ptr);
00141 console->Printf(KCommonFormat2,ptr.Ptr(),ptr.Length());
00142 console->Printf(KCommonFormat1,ptr.Size(),ptr.MaxLength());
00143
00144
00145 CleanupStack::PopAndDestroy();
00146 }
00147
00148
00149
00150