00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "CommonFramework.h"
00019
00020
00021
00022
00023 _LIT(KTxtHelloWorld,"Hello World!");
00024 _LIT(KTxtRepText,"Replacement text");
00025 _LIT(KTxtTBufC,"TBufC: ");
00026 _LIT(KTxtTPtr,"TPtr: ");
00027
00028
00029
00030
00031 _LIT(KCommonFormat2,"\"%S\"; ");
00032 _LIT(KCommonFormat3,"Descriptor at %x; Ptr()=%x; ");
00033 _LIT(KCommonFormat6,"\"%S\"; Ptr()=%x; Length()=%d; Size()=%d\n");
00034 _LIT(KCommonFormat7,"\"%S\"; Ptr()=%x; Length()=%d; Size()=%d; ");
00035 _LIT(KCommonFormat8,"\nMaxLength()=%d\n");
00036 _LIT(KCommonFormat9,"Length()=%d; Size()=%d;\n");
00037 _LIT(KCommonFormat10,"MaxLength()=%d\n");
00038
00039
00040 LOCAL_C void doExampleL()
00041 {
00042
00043
00044 TText cstr[13] = {'H', 'e' ,'l' ,'l' ,'o', ' ',
00045 'W', 'o','r', 'l', 'd', '!', '\0'};
00046
00047
00048
00049
00050 TBufC<16> bufc1(&cstr[0]);
00051
00052
00053 _LIT(KFormat1,"C string at %x; \n");
00054 console->Printf(KFormat1,&cstr[0]);
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 console->Printf(KCommonFormat2,&bufc1);
00076 console->Printf(KCommonFormat3,&bufc1,bufc1.Ptr());
00077 _LIT(KFormat4,"Length()=%d; Size()=%d\n");
00078 console->Printf(KFormat4,bufc1.Length(),bufc1.Size());
00079
00080
00081
00082 TBufC<16> bufc2(KTxtHelloWorld);
00083
00084
00085
00086
00087
00088 bufc2 = KTxtRepText;
00089 _LIT(KFormat5,"\"%S\"; Length()=%d; Size()=%d\n");
00090 console->Printf(KFormat5,&bufc2,bufc2.Length(),bufc2.Size());
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 bufc2 = KTxtHelloWorld;
00110 TPtr ptr = bufc2.Des();
00111
00112 console->Printf(KTxtTBufC);
00113 console->Printf(KCommonFormat6,
00114 &bufc2,
00115 bufc2.Ptr(),
00116 bufc2.Length(),
00117 bufc2.Size()
00118 );
00119
00120 console->Printf(KTxtTPtr);
00121 console->Printf(KCommonFormat7,
00122 &ptr,
00123 ptr.Ptr(),
00124 ptr.Length(),
00125 ptr.Size()
00126 );
00127
00128 console->Printf(KCommonFormat8,ptr.MaxLength());
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 _LIT(KTxtAndHi," & Hi");
00141 ptr.Delete((ptr.Length()-1),1);
00142 ptr.Append(KTxtAndHi);
00143
00144 console->Printf(KTxtTBufC);
00145 console->Printf(KCommonFormat6,
00146 &bufc2,
00147 bufc2.Ptr(),
00148 bufc2.Length(),
00149 bufc2.Size()
00150 );
00151
00152 console->Printf(KTxtTPtr);
00153 console->Printf(KCommonFormat7,
00154 &ptr,
00155 ptr.Ptr(),
00156 ptr.Length(),
00157 ptr.Size()
00158 );
00159 console->Printf(KCommonFormat8,ptr.MaxLength());
00160
00161
00162
00163
00164 _LIT(KTxtBasicConcepts,"\n-->TBuf basic concepts");
00165 console->Printf(KTxtBasicConcepts);
00166 _LIT(KTxtPressToContinue," (press any key to continue)\n");
00167 console->Printf(KTxtPressToContinue);
00168 console->Getch();
00169
00170
00171 TBuf<16> buf(KTxtHelloWorld);
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 console->Printf(KCommonFormat2,&buf);
00194 console->Printf(KCommonFormat3,&buf,buf.Ptr());
00195 console->Printf(KCommonFormat9,buf.Length(),buf.Size());
00196 console->Printf(KCommonFormat10,buf.MaxLength());
00197
00198
00199 buf.Append('@');
00200 console->Printf(KCommonFormat2,&buf);
00201 console->Printf(KCommonFormat9,buf.Length(),buf.Size());
00202 console->Printf(KCommonFormat10,buf.MaxLength());
00203
00204
00205
00206 buf.SetLength(3);
00207 console->Printf(KCommonFormat2,&buf);
00208 console->Printf(KCommonFormat9,buf.Length(),buf.Size());
00209 console->Printf(KCommonFormat10,buf.MaxLength());
00210
00211
00212
00213
00214 buf.Zero();
00215 console->Printf(KCommonFormat2,&buf);
00216 console->Printf(KCommonFormat9,buf.Length(),buf.Size());
00217 console->Printf(KCommonFormat10,buf.MaxLength());
00218
00219
00220
00221
00222
00223 buf = KTxtRepText;
00224 console->Printf(KCommonFormat2,&buf);
00225 console->Printf(KCommonFormat9,buf.Length(),buf.Size());
00226 console->Printf(KCommonFormat10,buf.MaxLength());
00227
00228
00229
00230
00231
00232
00233
00234
00235 }
00236
00237
00238
00239
00240
00241
00242