Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Test/StrTest3.cpp

Go to the documentation of this file.
00001 #define __J2K__QUIET
00002 
00003 #include <j2k/Fred/String/String.cpp>
00004 
00005 int main() {
00006 ////////////////////////////////////////////////////////////////////////////
00007 /// Constructor, Copy Constructor and Destructor                         ///
00008 ////////////////////////////////////////////////////////////////////////////
00009 
00010   size_t sz = 20;
00011 
00012   JString s1a;
00013   JString s1b( strNull );
00014 
00015   JString s2("Hello");
00016   JString s3("World", sz);
00017 
00018   JString s4a( (char*)NULL );
00019   JString s4b( (size_t)NULL );  // Both are valid
00020   JString s4c( sz*2 );
00021   JString s4d( "  ", 10 ); // 2 of 10
00022 
00023   JString s5( s3 );
00024 
00025 
00026   JString s6a( "A" );
00027   JString s7a( "", sz );
00028   s7a.FillBuffer( '#' );
00029   assert( s7a == "####################" );  // 20s#
00030 
00031   JString s6b( (char)'A' );
00032   assert( s6b == "A" );
00033 
00034   JString s7b( (char)'#', 5 );
00035   assert( s7b == "#####" );
00036 
00037   JString s8( new JStringData( "Fred" ) );  // Verify this.
00038   JString s9("World", sz-10);
00039   JString strPI( "3.14159265358979" );
00040 
00041 ////////////////////////////////////////////////////////////////////////////
00042 /// Simple Attributes & Operations...                                    ///
00043 ////////////////////////////////////////////////////////////////////////////
00044      
00045   assert( s1a == (char*)NULL );  // Both shall be valid
00046   assert( s1a == (char )NULL );  // The compiler doesn't know which one to choose.
00047 
00048   assert( s1b == (char*)NULL );
00049   assert( s1b == (char )NULL );
00050 
00051   assert( s1a == (char*)0    );  // Like C++ NULL
00052   assert( s1a == (char )0    );
00053 
00054   assert( s1b == (char*)0    );
00055   assert( s1b == (char )0    );
00056 
00057   assert( s1a == (char*)((void*)0) );  // Old way C NULL
00058   assert( s1a == (char )((void*)0) );
00059 
00060   assert( s1b == (char*)((void*)0) );
00061   assert( s1b == (char )((void*)0) );
00062 
00063   assert( s1a == (char*)'\0' );  // Forced
00064   assert( s1b == (char*)'\0' );
00065 
00066   assert( s1a == (char )'\0' );  // Default assumption
00067   assert( s1b == (char )'\0' );
00068 
00069   assert( s1a == '\0' );         // Default assumed (char)
00070   assert( s1b == '\0' );
00071 
00072   assert( s1a == ""   );
00073   assert( s1b == ""   );
00074  
00075   assert( s2  == "Hello" );
00076   assert( s3  == "World" );
00077   assert( s4a ==  s1a    );
00078   assert( s4b ==  s1a    );
00079 
00080   assert( s4c ==  s1a    );
00081   assert( s4a ==  s1b    );
00082   assert( s4b ==  s1b    );
00083   assert( s4c ==  s1b    );
00084   assert( s4d == "  "    );
00085   assert( s5  ==  s3     );
00086 
00087   assert( s6a == 'A'     );
00088   assert( s7a != '#'     );
00089   assert( s6b == 'A'     );
00090   assert( s7b != '#'     );
00091 
00092   assert( s8 == "Fred"  );
00093   assert( s9 == "World" );
00094 
00095   cout << "[s1a[" << s1a << "]\n";
00096   cout << "[s1b[" << s1b << "]\n";
00097   cout << "[s2["  << s2  << "]\n";
00098   cout << "[s3["  << s3  << "]\n";
00099   cout << "[s4a[" << s4a << "]\n";
00100   cout << "[s4b[" << s4b << "]\n";
00101   cout << "[s4c[" << s4c << "]\n";
00102   cout << "[s4d[" << s4d << "]\n";
00103   cout << "[s5["  << s5  << "]\n";
00104   cout << "[s6a[" << s6a << "]\n";
00105   cout << "[s6b[" << s6b << "]\n";
00106   cout << "[s7a[" << s7a << "]\n";
00107   cout << "[s7b[" << s7b << "]\n";
00108   cout << "[s8["  << s8  << "]\n";
00109   cout << "Is OK ?\n";
00110 
00111   assert( s1a.OK() );
00112   assert( s1b.OK() );
00113   assert(  s2.OK() );
00114   assert(  s3.OK() );
00115   assert( s4a.OK() );
00116   assert( s4b.OK() );
00117   assert( s4c.OK() );
00118   assert(  s5.OK() );
00119   assert( s6a.OK() );
00120   assert( s6b.OK() );
00121   assert( s7a.OK() );
00122   assert( s7b.OK() );
00123   assert(  s8.OK() );
00124 
00125   assert(  s1a.isEmpty() );
00126   assert(  s1b.isEmpty() );
00127   
00128   assert(  s4a.isEmpty() );
00129   assert(  s4b.isEmpty() );
00130   assert(  s4c.isEmpty() );
00131 
00132   assert(  !s2.isEmpty() );
00133   assert(  !s3.isEmpty() );
00134 
00135   assert(  !s5.isEmpty() );
00136   assert( !s6a.isEmpty() );
00137   assert( !s6b.isEmpty() );
00138   assert( !s7a.isEmpty() );
00139   assert( !s7b.isEmpty() );
00140   assert(  !s8.isEmpty() );
00141 
00142   s4c = s8;
00143   s4c.Clear();
00144 
00145 #ifndef __J2K__QUIET
00146   cout << "[s4c[Clear[" << s4c << "]\n";
00147   cout << "[s8[" << s8 << "]\n";
00148 #endif
00149   
00150   s4c = s3;
00151 
00152   assert( s3 == s4c );
00153 
00154   s4c.Empty();
00155 
00156 #ifndef __J2K__QUIET
00157   cout << "[s3[Empty(" << s3 << ") == [" << s4c << "]\n";
00158 #endif
00159 
00160   assert( s4d.length() ==  2 );
00161 
00162   cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00163 
00164   s4a.FillString( '1' );
00165   s4b.FillString( '1' );
00166   s4c.FillString( '1' );
00167   s4d.FillString( '1' );
00168 
00169 #ifndef __J2K__QUIET
00170   cout << "[s4a[Fill(1)[" << s4a << "]\n";
00171   cout << "[s4b[Fill(1)[" << s4b << "]\n";
00172   cout << "[s4c[Fill(1)[" << s4c << "]\n";
00173   cout << "[s4d[Fill(1)[" << s4d << "]\n";
00174 #endif
00175 
00176   cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00177 
00178   assert( s4d.length() ==  2 );
00179   assert( s4d.getBufferSize() ==  10 );
00180 
00181   s4a.FillBuffer( '2' );
00182   s4b.FillBuffer( '2' );
00183   s4c.FillBuffer( '2' );
00184   s4d.FillBuffer( '2' );
00185 
00186   assert( s4d.length() ==  10 );
00187   assert( s4d.getBufferSize() ==  10 );
00188 
00189   cout << s4d.length() << "-" << s4d.getBufferSize() << endl;
00190 
00191 #ifndef __J2K__QUIET
00192   cout << "[s4a[FillBuf(2)[" << s4a << "]\n";
00193   cout << "[s4b[FillBuf(2)[" << s4b << "]\n";
00194   cout << "[s4c[FillBuf(2)[" << s4c << "]\n";
00195   cout << "[s4d[FillBuf(2)[" << s4d << "]\n";
00196 #endif
00197 
00198   cout << "Display all\n";
00199   s1a.Display();
00200   cout << endl;
00201   s1b.Display();
00202   cout << endl;
00203   s2.Display();
00204   cout << endl;
00205   s3.Display();
00206   cout << endl;
00207   s4a.Display();
00208   cout << endl;
00209   s4b.Display();
00210   cout << endl;
00211   s4c.Display();
00212   cout << endl;
00213   s4d.Display();
00214   cout << endl;
00215   s5.Display();
00216   cout << endl;
00217   s6a.Display();
00218   cout << endl;
00219   s6b.Display();
00220   cout << endl;
00221   s7a.Display();
00222   cout << endl;
00223   s7b.Display();
00224   cout << endl;
00225   s8.Display();
00226   cout << endl;
00227 
00228 
00229   assert( s1a.getLength() ==  0 );
00230   assert( s1b.getLength() ==  0 );
00231   assert(  s2.getLength() ==  5 );
00232   assert(  s3.getLength() ==  5 );
00233   assert( s4a.getLength() ==  0 );
00234   assert( s4b.getLength() ==  0 );
00235   assert( s4c.getLength() ==  0 );
00236   assert(  s5.getLength() ==  5 );
00237   assert( s6a.getLength() ==  1 );
00238   assert( s6b.getLength() ==  1 );
00239   assert( s7a.getLength() == 20 );
00240   assert( s7b.getLength() ==  5 );
00241   assert(  s8.getLength() ==  4 );
00242 
00243   assert( s1a.length() ==  0 );
00244   assert( s1b.length() ==  0 );
00245   assert(  s2.length() ==  5 );
00246   assert(  s3.length() ==  5 );
00247   assert( s4a.length() ==  0 );
00248   assert( s4b.length() ==  0 );
00249   assert( s4c.length() ==  0 );
00250   assert(  s5.length() ==  5 );
00251   assert( s6a.length() ==  1 );
00252   assert( s6b.length() ==  1 );
00253   assert( s7a.length() == 20 );
00254   assert( s7b.length() ==  5 );
00255   assert(  s8.length() ==  4 );
00256 
00257   assert( s1a.getLength() ==  s1a.length() );
00258   assert( s1b.getLength() ==  s1b.length() );
00259   assert(  s2.getLength() ==  s2.length() );
00260   assert(  s3.getLength() ==  s3.length() );
00261   assert( s4a.getLength() ==  s4a.length() );
00262   assert( s4b.getLength() ==  s4b.length() );
00263   assert( s4c.getLength() ==  s4c.length() );
00264   assert(  s5.getLength() ==  s5.length() );
00265   assert( s6a.getLength() ==  s6a.length() );
00266   assert( s6b.getLength() ==  s6b.length() );
00267   assert( s7a.getLength() ==  s7a.length() );
00268   assert( s7b.getLength() ==  s7b.length() );
00269   assert(  s8.getLength() ==  s8.length() );
00270 
00271   assert( s1a.getAllocLength() ==  0 );
00272   assert( s1b.getAllocLength() ==  0 );
00273   assert(  s2.getAllocLength() ==  5 );
00274   assert(  s3.getAllocLength() == 20 );
00275   assert( s4a.getAllocLength() ==  0 );
00276   assert( s4b.getAllocLength() ==  0 );
00277   assert( s4c.getAllocLength() ==  0 );
00278   assert(  s5.getAllocLength() == 20 );
00279   assert( s6a.getAllocLength() ==  1 );
00280   assert( s6b.getAllocLength() ==  1 );
00281   assert( s7a.getAllocLength() == 20 );
00282   assert( s7b.getAllocLength() ==  5 );
00283   assert(  s8.getAllocLength() ==  4 );
00284 
00285   assert( s1a.getBufferSize() ==  0 );
00286   assert( s1b.getBufferSize() ==  0 );
00287   assert(  s2.getBufferSize() ==  5 );
00288   assert(  s3.getBufferSize() == 20 );
00289   assert( s4a.getBufferSize() ==  0 );
00290   assert( s4b.getBufferSize() ==  0 );
00291   assert( s4c.getBufferSize() ==  0 );
00292   assert(  s5.getBufferSize() == 20 );
00293   assert( s6a.getBufferSize() ==  1 );
00294   assert( s6b.getBufferSize() ==  1 );
00295   assert( s7a.getBufferSize() == 20 );
00296   assert( s7b.getBufferSize() ==  5 );
00297   assert(  s8.getBufferSize() ==  4 );
00298 
00299   // Nobody holds a lock
00300   assert( s1a.getLockNb() ==  0 );
00301   assert( s1b.getLockNb() ==  0 );
00302   assert(  s2.getLockNb() ==  0 );
00303   assert(  s3.getLockNb() ==  0 );
00304   assert( s4a.getLockNb() ==  0 );
00305   assert( s4b.getLockNb() ==  0 );
00306   assert( s4c.getLockNb() ==  0 );
00307   assert(  s5.getLockNb() ==  0 );
00308   assert( s6a.getLockNb() ==  0 );
00309   assert( s6b.getLockNb() ==  0 );
00310   assert( s7a.getLockNb() ==  0 );
00311   assert( s7b.getLockNb() ==  0 );
00312   assert(  s8.getLockNb() ==  0 );
00313 
00314   assert( !s1a.isLock() );
00315   assert( !s1b.isLock() );
00316   assert(  !s2.isLock() );
00317   assert(  !s3.isLock() );
00318   assert( !s4a.isLock() );
00319   assert( !s4b.isLock() );
00320   assert( !s4c.isLock() );
00321   assert(  !s5.isLock() );
00322   assert( !s6a.isLock() );
00323   assert( !s6b.isLock() );
00324   assert( !s7a.isLock() );
00325   assert( !s7b.isLock() );
00326   assert(  !s8.isLock() );
00327 
00328   assert(  s1a.isUnlock() );
00329   assert(  s1b.isUnlock() );
00330   assert(   s2.isUnlock() );
00331   assert(   s3.isUnlock() );
00332   assert(  s4a.isUnlock() );
00333   assert(  s4b.isUnlock() );
00334   assert(  s4c.isUnlock() );
00335   assert(   s5.isUnlock() );
00336   assert(  s6a.isUnlock() );
00337   assert(  s6b.isUnlock() );
00338   assert(  s7a.isUnlock() );
00339   assert(  s7b.isUnlock() );
00340   assert(   s8.isUnlock() );
00341 
00342 ////////////////////////////////////////////////////
00343 /// Compare utilities...                         ///
00344 ////////////////////////////////////////////////////
00345 
00346 /* Not Implemented Yet.
00347   int CompareNoCase(const char* s) const;   // ignore case
00348   int Collate(const char *s) const;         // NLS aware
00349 */
00350 
00351 #ifndef __J2K__QUIET
00352   cout << "Compare:\n";
00353 #endif
00354 
00355   assert( s3.compare( s9 ) == 0 );
00356   assert( s3.compare( (char*)s9 ) == 0 );
00357   assert( s3.compare( "World" ) == 0 );
00358   assert( s9.compare( s3 ) == 0 );
00359 
00360   assert( s2 < s3  );
00361   assert( s2 < "Z" );
00362   assert( s3 > s2  );
00363   assert( s3 > "A" );
00364 
00365   assert( s2 <= s3  );
00366   assert( s2 <= "Z" );
00367   assert( s3 >= s2  );
00368   assert( s3 >= "A" );
00369 
00370   assert( s3 == s9 );
00371   assert( s3 == "World" );
00372 
00373   assert( s2 != s3 );
00374   assert( s3 != "Hello" );
00375 
00376 //////////////////////////////////////////////////////////
00377 /// Parsing and Casting utilities...                   ///
00378 //////////////////////////////////////////////////////////
00379 
00380   // CAN BE DANGEROUS !
00381 
00382   assert( !strcmp( (char*)strPI, "3.14159265358979" ) );
00383 
00384   assert( ((int)(strPI)   ) == 3 );
00385   assert( ((long)(strPI)  ) == 3 );
00386   assert( ((double)(strPI)) == 3.14159265358979 );
00387 
00388 #ifndef __J2K__QUIET
00389   cout << "Compare PI:\n";
00390 #endif
00391 
00392   assert( strPI.parseInt()    == 3 );
00393   assert( strPI.parseLong()   == 3 );
00394   assert( strPI.parseDouble() == 3.14159265358979 );
00395 
00396   assert( !strcmp( strPI.parseString(), "3.14159265358979" ) );
00397 
00398   assert( !strcmp( strPI.toString(),  "3.14159265358979" ) );
00399   assert( !strcmp( strPI.getText(),   "3.14159265358979" ) );
00400 
00401 ///////////////////////////////////////////////////
00402 /// Stream utilities...                         ///
00403 ///////////////////////////////////////////////////
00404 #ifndef __J2K__QUIET
00405   cout  << "[strPI[" << strPI  << "]\n";
00406 #endif
00407 
00408 ///////////////////////////////////////////////////
00409 /// JString Assignment                          ///
00410 ///////////////////////////////////////////////////
00411   JString temp( (size_t)80 );
00412 
00413   temp = strPI;
00414 
00415   strPI = "9.81";
00416 
00417   assert( strPI.parseDouble() == 9.81 );
00418 
00419   strPI = temp;
00420 
00421   assert(  strPI == temp   );
00422   assert( !( strPI != temp ) );
00423 
00424 #ifndef __J2K__QUIET
00425   cout << "[temp[" << temp << "]\n";
00426 #endif
00427 
00428   temp = 'a';
00429 
00430 #ifndef __J2K__QUIET
00431   cout << "[temp[" << temp << "]\n";
00432 #endif
00433 
00434   
00435   assert( !strcmp( temp, "a" )  );
00436 
00437   temp = "Fred";
00438 
00439   assert( temp == "Fred" );
00440   assert( temp != "FRED" );
00441   assert( temp != "fred" );
00442 
00443 /////////////////////////////////////////////////////
00444 /// JString Concatenation                         ///
00445 /////////////////////////////////////////////////////
00446 
00447 #ifndef __J2K__QUIET
00448   cout << "Additions:\n";
00449 #endif
00450 
00451   temp = s2;
00452 
00453   s2.Append( " Fred...", 8 );
00454 
00455   assert( s2 == "Hello Fred...");
00456 
00457   s2 = temp;
00458 
00459   s2 += s3;
00460 
00461   assert( s2 == "HelloWorld" );
00462 
00463   s2 = temp;
00464 
00465   JString temp2 = s3;
00466 
00467   s3 += s2;
00468 
00469   assert( s3 == "WorldHello" );
00470   assert( s2.OK() );
00471   assert( s3.OK() );
00472 
00473   s3 += "!";
00474   assert( s3.OK() );
00475   assert( s3 == "WorldHello!" );
00476 
00477   s2 += temp2;
00478   s2 += "$";
00479   assert( s2.OK() );
00480 
00481   assert( temp  == "Hello" );
00482   assert( temp2 == "World" );
00483   assert( s2 == "HelloWorld$" );
00484 
00485   s2 += " Fred $ ";
00486 
00487   assert( s2 == "HelloWorld$ Fred $ " );
00488 
00489   s3 = temp2;
00490   s2 = temp;
00491 
00492   assert( s3 == "World" );
00493   assert( s2 == "Hello" );
00494 
00495 ////////////////////////////////////////////////////////////////////////////
00496 /// JString Addition                                                     ///
00497 ////////////////////////////////////////////////////////////////////////////
00498 
00499   temp = s2 + s3;
00500   temp += '!';
00501 
00502   char* A = "Alpha";
00503   char* B = "Beta";
00504 
00505   assert( temp == "HelloWorld!" );
00506 
00507   temp += A;
00508   temp += B;
00509 
00510   assert( temp == "HelloWorld!AlphaBeta" );
00511 
00512   temp = temp + "=)";
00513 
00514   assert( temp == "HelloWorld!AlphaBeta=)" );
00515 
00516   temp = "=]" + temp + " =}";
00517 
00518   assert( temp == "=]HelloWorld!AlphaBeta=) =}" );
00519 
00520   temp = "{" + temp;
00521 
00522   assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00523 
00524   temp2 = temp;
00525 
00526 ////////////////////////////////////////////////////////////////////////////
00527 /// Upper/Lower/Reverse Conversion (QuickBasic Compatible)               ///
00528 ////////////////////////////////////////////////////////////////////////////
00529 /// Defined in:  StrTools.cpp                                            ///
00530 ////////////////////////////////////////////////////////////////////////////
00531 
00532   temp.MakeUpper();
00533   assert( temp == "{=]HELLOWORLD!ALPHABETA=) =}" );
00534   
00535   temp.MakeLower();
00536   assert( temp == "{=]helloworld!alphabeta=) =}" );
00537 
00538   temp.MakeReverse();
00539 
00540   assert( temp == "}= )=atebahpla!dlrowolleh]={" );
00541   
00542   temp.MakeReverse();
00543   assert( temp == "{=]helloworld!alphabeta=) =}" );
00544 
00545   temp.UCase();
00546   assert( temp == "{=]HELLOWORLD!ALPHABETA=) =}" );
00547   
00548   temp.LCase();
00549   assert( temp == "{=]helloworld!alphabeta=) =}" );
00550 
00551   temp.Reverse();
00552 
00553 #ifndef __J2K__QUIET
00554   cout << "T:" << "[temp[" << temp << "]\n";
00555   cout << "R:" << Reverse( temp ) << endl;
00556 #endif
00557 
00558   assert( temp == "}= )=atebahpla!dlrowolleh]={" );
00559   assert( Reverse( temp ) == "{=]helloworld!alphabeta=) =}" );
00560 
00561   temp = temp2;
00562 
00563 #ifndef __J2K__QUIET
00564   cout << "T:" << "[temp[" << temp << "]\n";
00565   cout << "U:" << UCase( temp ) << endl;
00566   cout << "RR:" << LCase( temp ) << endl;
00567   cout << "RR:" << Reverse( Reverse( temp2 ) ) << endl;
00568   cout << "URR:" << UCase( Reverse( Reverse( temp2 ) ) ) << endl;
00569   cout << "LRR:" << LCase( Reverse( Reverse( temp2 ) ) ) << endl;
00570 #endif
00571 
00572   assert( temp == temp2 );
00573   assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00574   assert( UCase( temp ) == "{=]HELLOWORLD!ALPHABETA=) =}" );
00575   assert( LCase( temp ) == "{=]helloworld!alphabeta=) =}" );
00576   assert( Reverse( Reverse( temp2 ) ) == temp2 );
00577   assert( UCase( Reverse( Reverse( temp2 ) ) ) == "{=]HELLOWORLD!ALPHABETA=) =}" );
00578   assert( LCase( Reverse( Reverse( temp2 ) ) ) == "{=]helloworld!alphabeta=) =}" );
00579 
00580   assert( temp == temp2 );
00581   assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00582   assert( temp.setUpper() == "{=]HELLOWORLD!ALPHABETA=) =}" );
00583   assert( temp.setLower() == "{=]helloworld!alphabeta=) =}" );
00584 
00585   temp = temp2;
00586   assert( temp == temp2 );
00587   assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00588   assert( temp.setReverse().setReverse() == temp2 );
00589   assert( temp.setUpper().setReverse().setReverse() == "{=]HELLOWORLD!ALPHABETA=) =}" );
00590   assert( temp.setLower().setReverse().setReverse() == "{=]helloworld!alphabeta=) =}" );
00591 
00592   temp = temp2;
00593   assert( temp == temp2 );
00594   assert( !strcmp(temp.getUpper(), "{=]HELLOWORLD!ALPHABETA=) =}" ));
00595   assert( !strcmp(temp.getLower(), "{=]helloworld!alphabeta=) =}" ));
00596 
00597   temp = temp2;
00598   assert( temp == temp2 );
00599   assert( temp == "{=]HelloWorld!AlphaBeta=) =}" );
00600   assert( !strcmp(temp.setReverse().getReverse(), temp2.toString() ) );
00601   assert( !strcmp(temp.setReverse().getUpper(), "{=]HELLOWORLD!ALPHABETA=) =}"));
00602   assert( !strcmp(temp.setReverse().setReverse().getLower(), "{=]helloworld!alphabeta=) =}"));
00603 
00604 ////////////////////////////////////////////////////////////////////////////
00605 /// Search/Find/ReverseFind function (QuickBasic Compatible)             ///
00606 ////////////////////////////////////////////////////////////////////////////
00607 
00608   // searching (return starting index,
00609   // or -1 if not found)
00610   // look for a single character match
00611   temp = LCase( temp2 );
00612   assert( temp2 == "{=]HelloWorld!AlphaBeta=) =}" );
00613   assert( temp.Find( 'w' ) == 8 );  // i.e. temp[8] == 'w'
00614   assert( Reverse( temp ).Find( 'w' ) == 19 );
00615   assert( UCase( Reverse( temp ) ).Find( 'w' ) == -1 );
00616   assert( UCase( Reverse( temp ) ).Find( 'W' ) == 19 );
00617   assert( UCase( Reverse( temp ) ).ReverseFind( 'W' ) == 8 );
00618 
00619   assert( temp.Find( "hello"    ) == 3 );
00620   assert( temp.Find( "hello", 3 ) == 0 );
00621 
00622   assert( temp.Find( 'w' ) == 8 );  // i.e. temp[8] == 'w'
00623   assert( temp.setReverse().Find( 'w' ) == 19 );
00624   
00625   temp = temp2;
00626   assert( temp.setReverse().setUpper().Find( 'w' ) == -1 );
00627   
00628   temp = temp2;
00629   assert( temp.setReverse().setUpper().Find( 'W' ) == 19 );
00630 
00631   temp = temp2;
00632   assert( temp.setReverse().setUpper().ReverseFind( 'W' ) == 8 );
00633 
00634   temp = temp2;
00635   assert( temp.setReverse().setReverse().Find( "Hello"    ) == 3 );
00636   assert( temp.setReverse().setReverse().Find( "Hello", 3 ) == 0 );
00637 
00638 
00639 //////////////////////////////////////////////////
00640 /// At X do this...                            ///
00641 //////////////////////////////////////////////////
00642 
00643   s4d = "World";
00644 
00645   assert( s4d == "World" );
00646 
00647   // Should check with at( -1 )
00648   s1a = temp.at(  temp.setReverse().Find( s4d.getReverse() )  ).setReverse();
00649   assert( s1a == "{=]HelloWorld" );
00650 
00651   s1b = s1a.at(  s1a.Find( s4d )  );
00652   assert( s1b.at() == "World" );
00653 
00654   temp.setReverse();
00655   assert( temp == temp2 );
00656 
00657   assert( temp.at( temp.Find( s4d ), s4d.length() ) == s4d );
00658   assert( temp.at( temp.Find( s4d ), s4d.length() ).setReverse() == s4d.getReverse() );
00659 
00660   temp = temp2;
00661 
00662   s4d = "World";
00663 
00664   assert( s4d == "World" );
00665 
00666 
00667 // With operator()
00668 
00669   // Should check with at( -1 )
00670   s1a = temp(  temp.setReverse().Find( s4d.getReverse() )  ).setReverse();
00671   assert( s1a == "{=]HelloWorld" );
00672 
00673   s1b = s1a(  s1a.Find( s4d )  );
00674   assert( s1b.at() == "World" );
00675 
00676   temp.setReverse();
00677   assert( temp == temp2 );
00678 
00679   assert( temp( temp.Find( s4d ), s4d.length() ) == s4d );
00680   assert( temp( temp.Find( s4d ), s4d.length() ).setReverse() == s4d.getReverse() );
00681 
00682   assert( temp.at( s4d.getText(), 0 ).left(5) == s4d );
00683 
00684   assert( temp.at( s4d, 0 ).left(5).right(2) == "ld" );
00685   assert( temp.mid( s4d, 0, 5 ).right( 2 ) == "ld" );
00686 
00687   cout << temp.at( s4d.getText(), 0 ).left(5) << "]\n";
00688   cout << "\n[" << temp( s4d.getText(), 0 ) << "]\n";
00689 
00690   // Use at()  for trim
00691 
00692   s1a = temp.setAt( temp.Find( s4d ), 'w' );
00693   assert( s1a.at( s4d.setLower(), 0 ).left(5) == LCase( s4d ) );
00694   
00695 
00696 //////////////////////////////////////////////////////////////
00697 /// Every function str* from ANSI definition               ///
00698 //////////////////////////////////////////////////////////////
00699 
00700   cout << temp << endl;
00701   cout << temp.firstCharFound( 'l' ) << endl; // forward pos
00702   cout << temp.lastCharFound( 'l'  ) << endl; // forward pos
00703 
00704   assert( temp[ temp.firstCharFound( 'l' ) ] == 'l' );
00705   assert( temp[ temp.lastCharFound( 'l' )  ] == 'l' );
00706 
00707   assert( temp.getAt( temp.firstCharFound( 'l' ) ) == 'l' );
00708   assert( temp.getAt( temp.lastCharFound( 'l' )  ) == 'l' );
00709 
00710   assert( temp.firstCharFound( 'l' ) ==  5 );
00711   assert( temp.lastCharFound( 'l' )  == 15 );
00712 
00713 /*
00714   char*    getConcatenate( const char* src );
00715   JString& setConcatenate( const char* src );
00716   int      compare( const char* src );
00717   int      compareIgnoreCase( const char* src );
00718   int      compareUsingLocaleCollate( const char* src );
00719   char*    copy();
00720   JString& getCopy();
00721   size_t   getNbCharNotFromCharSet( const char* charset );
00722   JString& getDate();  // MM/DD/YY format (not Y2K complient !)
00723   JString& setDate();  // MM/DD/YY format (not Y2K complient !)
00724 
00725   JString& setTime( size_t maxSize, const char* format, const struct tm* currTime );
00726  
00727   char*    duplicate();
00728   JString& duplicateString();
00729   JString& getError( int errnb );
00730   JString& setError( int errnb );
00731   JString& getTimeFormat( size_t maxSize, const char* format, const struct tm* currTime );
00732   JString& setTimeFormat( size_t maxSize, const char* format, const struct tm* currTime );
00733   JString& getTime();  // HH:MM:SS  (24h)
00734   JString& setTime();  // HH:MM:SS  (24h)
00735 
00736   char*    getConcatenateWithLimits( const char* src, size_t n );
00737   JString& setConcatenateWithLimits( const char* src, size_t n );
00738   int      compareWithLimits( const char* src, size_t n );
00739   int      compareIgnoreCaseWithLimits( const char* src, size_t n );
00740   char*    copyWithLimits( size_t n );
00741   JString& getCopyWithLimits( size_t n );
00742   char*    getFillWithChar( const int ch );
00743   JString& setFillWithChar( const int ch );
00744   char*    getFillWithChar( const int ch, size_t n );
00745   JString& setFillWithChar( const int ch, size_t n );
00746  
00747   // Return Where is the first charset in String
00748   long   locateCharSet( const char* charset );
00749   long   locateCharSet( const char* charset, size_t startAt );
00750 
00751   // Return How much of charset in String
00752   size_t   findCharset( const char* charset );
00753   size_t   findCharset( const char* charset, size_t startAt );
00754 
00755 
00756   // Return Where is the first String given in String
00757   long   findString( const char* s );
00758   long   findString( const char* s, size_t startAt );
00759 
00760   double   toDouble();
00761   double   toDouble( size_t startAt );
00762 
00763   long   toLong();
00764   long   toLong( size_t base );
00765   long   toLong( size_t startAt, size_t base );
00766 
00767   ULONG  toULONG();
00768   ULONG  toULONG( size_t base );
00769   ULONG  toULONG( size_t startAt, size_t base );
00770 
00771   char*    getTransform( const char* src, size_t n );
00772   JString& setTransform( const char* src, size_t n );
00773   char*    getTokens( const char* delims, size_t startAt );
00774   char*    getMoreTokens( const char* delims );
00775   JString& getStringTokens( const char* delims, size_t startAt );
00776   JString& getMoreStringTokens( const char* delims );
00777 
00778 */
00779 
00780 /**************************************************************************
00781  *  NOT DEFINED YET !
00782  **************************************************************************/
00783 
00784 ////////////////////////////////////////////////////////////////////////////
00785 /// Trimming Space  (QuickBasic compatible)                              ///
00786 ////////////////////////////////////////////////////////////////////////////
00787 /*
00788   void TrimRight();   // lib g++ format
00789   void TrimLeft();
00790 
00791   // Might return JString object in the future...
00792   inline void LTrim();  // QB format
00793   inline void RTrim();
00794   inline void Trim();
00795 
00796 ////////////////////////////////////////////////////////////////////////////
00797 /// Span Include/Exclude function                                        ///
00798 ////////////////////////////////////////////////////////////////////////////
00799   JString SpanIncluding(const char* s) const;
00800   JString SpanExcluding(const char* s) const;
00801 
00802 ////////////////////////////////////////////////////////////////////////////
00803 /// Simple formatting function ( using  "sprintf"  Format )              ///
00804 ////////////////////////////////////////////////////////////////////////////
00805   // simple formatting
00806   void Format(const char* s Format, ...);
00807   void Format(size_t nFormatID, ...);
00808   void FormatV(const char* lpszFormat, va_list argList);
00809 
00810 *************************************************************************
00811 
00812 */
00813 
00814 ////////////////////////////////////////////////////////////////////////////
00815 /// Unlock/Lock Buffer turn Ref counting on/off (MFC JString compatible) ///
00816 /// AND everything else related to Buffer and Allocation...        ///
00817 ////////////////////////////////////////////////////////////////////////////
00818 /// Defined in:  StrExtra.cpp   (NOT FULLY SUPPORTED YET)        ///
00819 ////////////////////////////////////////////////////////////////////////////
00820 /*  
00821   inline void AllocBuffer(size_t nLen);
00822   inline void AllocBeforeWrite(size_t nLen);
00823 
00824   inline char* LockBuffer();
00825   inline void  UnlockBuffer();
00826 
00827   void  FreeExtra();
00828   char* GetBuffer(size_t minBufferLength);
00829 
00830   inline void  ReleaseBuffer();
00831   */
00832 
00833   cout << "Done! \n";
00834 
00835   return 0;
00836 }

Generated on Sun Oct 14 18:46:45 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001