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(KTxtHiTHere,"Hi there");
00024 _LIT(KTxtHaveNiceDay,"Have a nice day!");
00025
00026
00027
00028
00029 _LIT(KCommonFormat1,"\"%s\"\n");
00030 _LIT(KCommonFormat3,"length=%d; size=%d;\n");
00031 _LIT(KCommonFormat5,"Ptr()=%x; Length()=%d; Size()=%d\n");
00032 _LIT(KCommonFormat16,"MaxLength()=%d\n");
00033 _LIT(KCommonFormat17,"\"%S\"; ");
00034 _LIT(KCommonFormat18,"Length()=%d; Size()=%d; ");
00035
00036
00037 LOCAL_C void doExampleL()
00038 {
00039
00040 const TText8* cstr8 = (TText8*)"Hello World!";
00041
00042
00043
00044 TBuf<12> temp;
00045 temp.Copy(TPtrC8(cstr8));
00046 console->Printf(temp);
00047
00048
00049
00050
00051 TPtrC8 ptrC8(cstr8);
00052
00053
00054
00055
00056
00057
00058
00059
00060 _LIT(KFormat2,"\nNarrow C string at %x; ");
00061 console->Printf(KFormat2,cstr8);
00062 console->Printf(KCommonFormat3,12,sizeof("Hello World!"));
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 _LIT(KFormat4,"8-bit pointer-descriptor at %x; ");
00074 console->Printf(KFormat4,&ptrC8);
00075 console->Printf(KCommonFormat5,ptrC8.Ptr(),ptrC8.Length(),ptrC8.Size());
00076
00077
00078
00079 const TText16* cstr16 = (TText16*)L"Hello World!";
00080
00081
00082
00083
00084 TPtrC16 ptrC16(cstr16);
00085
00086 _LIT(KFormat7,"\nWide C string at %x; ");
00087 console->Printf(KFormat7,cstr16);
00088 console->Printf(KCommonFormat3,12,sizeof(L"Hello World!"));
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 _LIT(KFormat6,"16-bit pointer-descriptor at %x; ");
00100 console->Printf(KFormat6,&ptrC16);
00101 console->Printf(KCommonFormat5,ptrC16.Ptr(),ptrC16.Length(),ptrC16.Size());
00102
00103
00104
00105
00106
00107
00108
00109
00110 const TText* cstr = _S("Hello World!");
00111
00112
00113
00114
00115 TPtrC ptrc(cstr);
00116
00117 _LIT(KFormat8,"\nBuild-dependent TText at %x; ");
00118 console->Printf(KFormat8,cstr);
00119 console->Printf(KCommonFormat3,12,sizeof(
00120 #ifdef _UNICODE
00121 L"Hello world!"
00122 #else
00123 "Hello world!"
00124 #endif
00125 )
00126 );
00127
00128
00129 _LIT(KTxtBuildDependentptdesc,"Build-dependent pointer-descriptor");
00130 console->Printf(KTxtBuildDependentptdesc);
00131
00132 _LIT(KFormat9," at %x; ");
00133 console->Printf(KFormat9,&ptrc);
00134 _LIT(KFormat10,"Ptr()=%x;\n");
00135 console->Printf(KFormat10,ptrc.Ptr());
00136 _LIT(KFormat11," Length()=%d; Size()=%d\n");
00137 console->Printf(KFormat11,ptrc.Length(),ptrc.Size());
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 console->Printf(_L("\nThe _L macro constructs a TPtrC"));
00151
00152
00153
00154 _LIT(KTxtTPtrBasicConcepts,"\n-->TPtr basic concepts");
00155 console->Printf(KTxtTPtrBasicConcepts);
00156 _LIT(KTxtPressToContinue," (press any key to continue)\n");
00157 console->Printf(KTxtPressToContinue);
00158 console->Getch();
00159
00160
00161
00162
00163
00164 TText str[16] = {'H', 'a', 'v', 'e', ' ', 'a',
00165 ' ', 'n', 'i', 'c', 'e',
00166 ' ', 'd', 'a', 'y', '\0'};
00167
00168
00169 console->Printf(KCommonFormat1,&str[0]);
00170
00171
00172
00173
00174
00175
00176 TPtr ptr(&str[0],15,16);
00177
00178
00179
00180
00181
00182
00183
00184 _LIT(KFormat12,"C string at %x; ");
00185 console->Printf(KFormat12,str);
00186 _LIT(KFormat13,"length=%d; size=%d\n");
00187 console->Printf(KFormat13,15,sizeof(str));
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 _LIT(KFormat14,"Descriptor at %x; ");
00200 console->Printf(KFormat14,&ptr);
00201 _LIT(KFormat15,"Ptr()=%x; Length()=%d; Size()=%d; ");
00202 console->Printf(KFormat15,ptr.Ptr(),ptr.Length(),ptr.Size());
00203 console->Printf(KCommonFormat16,ptr.MaxLength());
00204
00205
00206
00207
00208 ptr = KTxtHiTHere;
00209
00210
00211
00212
00213
00214
00215
00216 console->Printf(KCommonFormat17,&ptr);
00217 console->Printf(KCommonFormat18,ptr.Length(),ptr.Size());
00218 console->Printf(KCommonFormat16,ptr.MaxLength());
00219
00220
00221
00222 ptr.SetLength(2);
00223
00224 console->Printf(KCommonFormat17,&ptr);
00225 console->Printf(KCommonFormat18,ptr.Length(),ptr.Size());
00226 console->Printf(KCommonFormat16,ptr.MaxLength());
00227
00228
00229
00230
00231 ptr.Zero();
00232 console->Printf(KCommonFormat17,&ptr);
00233 console->Printf(KCommonFormat18,ptr.Length(),ptr.Size());
00234 console->Printf(KCommonFormat16,ptr.MaxLength());
00235
00236
00237
00238 ptr = KTxtHaveNiceDay;
00239 console->Printf(KCommonFormat17,&ptr);
00240 console->Printf(KCommonFormat18,ptr.Length(),ptr.Size());
00241 console->Printf(KCommonFormat16,ptr.MaxLength());
00242
00243
00244
00245
00246
00247
00248
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258