proj home

Files   Classes   Functions   Hierarchy  

misclib_testcode::tokenizertest Class Reference

Test the tokenizer and related stuff. More...

#include <tokenizertest.h>

Collaboration diagram for misclib_testcode::tokenizertest:

List of all members.

Public Member Functions

void test00 ()
 Given a paragraph as a string parse into lines.
void test01 ()
 Use STL to erase a token in a string.
void test02 ()
 Use STL to insert white space around a token in a string.
void test03 ()
 Demonstrate the atomize function.
void test04 ()
 Demonstrate the stripcomment function.
void test05 ()
void test06 ()
void test07 ()
 Testing the trim function.
void test08 ()
 Testing the tokenizer on a real VRML file.
void test09 ()
 Test comparewithoutspace(s1,s2).

Static Public Member Functions

static void test10 ()
 atomize_next(<mytag>) to find tagged data.
static int unittest01 ()
 Exploring reading and writing tagged field with tokenizer::atomize_next_tag().
static int unittest02 ()
 tokenizerlocal: reading and writing a tagged string.
static int unittest03 ()
 Reading/writing multiple <obj>.
static int unittest04 ()

Static Public Attributes

static string doc []
 Brief description of each test.


Detailed Description

Test the tokenizer and related stuff.

Definition at line 10 of file tokenizertest.h.


Member Function Documentation

void tokenizertest::test00 (  ) 

Given a paragraph as a string parse into lines.

Definition at line 37 of file tokenizertest.cpp.

References tokenizer::seq, and tokenizer::subtract().

00038 {
00039   tokenizer ss;
00040   string tmp("This is a silly\n sentence that is accross \n several lines.");
00041   tmp += " Will the parser split this string?\n It should unless I screwed up.";
00042 
00043   ss.seq.push_back(tmp);
00044   ss.subtract("\n");
00045   cout << ss << endl;
00046 }

void tokenizertest::test01 (  ) 

Use STL to erase a token in a string.

Definition at line 48 of file tokenizertest.cpp.

References SHOW.

00049 {
00050   cout << "Erase token irrespective of white space." << endl;
00051 
00052   string s1="brownThe quick brown fox";
00053 
00054   string s2="brown";
00055 
00056   cout << SHOW(s1) << endl;
00057   cout << SHOW(s2) << endl;
00058 
00059   string::size_type i = 0;
00060 
00061   i = s1.find(s2,i);
00062   while (i!=string::npos)
00063   {
00064     s1.erase(i, sizeof(s2)+1);
00065     i = s1.find(s2,i);
00066   }
00067   
00068   cout << SHOW(s1) << endl;
00069 }

void tokenizertest::test02 (  ) 

Use STL to insert white space around a token in a string.

Definition at line 71 of file tokenizertest.cpp.

References SHOW.

00072 {
00073   cout << "Find token and insert white space around it." << endl;
00074 
00075   string s1="brownThe quick brown fox";
00076 
00077   string s2="brown";
00078 
00079   cout << SHOW(s1) << endl;
00080   cout << SHOW(s2) << endl;
00081 
00082   string::size_type i = 0;
00083 
00084   i = s1.find(s2,i);
00085   while (i!=string::npos)
00086   {
00087     s1.insert(i+sizeof(s2)+1," ");
00088     s1.insert(i," ");
00089     ++i; ++i;
00090     i = s1.find(s2,i);
00091   }
00092   
00093   cout << SHOW(s1) << endl;
00094 }

void tokenizertest::test03 (  ) 

Demonstrate the atomize function.

Definition at line 96 of file tokenizertest.cpp.

References tokenizer::atomize(), and tokenizer::seq.

00097 {
00098   cout << "Testing tokenizer::atomize function." << endl;
00099   tokenizer ss;
00100   ss.seq.push_back("(a+b)*d+e");
00101   ss.seq.push_back("+gh");
00102   cout << "Print the current state" << endl;
00103   cout << ss << endl << endl;
00104   cout << "Atomize on +" << endl;
00105   ss.atomize("+");
00106   cout << ss << endl;
00107 }

void tokenizertest::test04 (  ) 

Demonstrate the stripcomment function.

Definition at line 109 of file tokenizertest.cpp.

References tokenizer::printdelimiter, tokenizer::remove(), tokenizer::seq, tokenizer::stripcomment(), and tokenizer::subtract().

00110 {
00111   cout << "Testing tokenizer::stripcomment function." << endl;
00112   tokenizer ss;
00113   ss.printdelimiter="#\n";
00114   ss.seq.push_back("// A silly class.");
00115   ss.seq.push_back("class fred  // A comment");
00116   ss.seq.push_back("{ public:");
00117   ss.seq.push_back("  fred();  //Constructor");
00118   ss.seq.push_back("  ff() { z*z; } // another one.");
00119   ss.seq.push_back("}");
00120   cout << ss << endl;
00121   cout << endl;
00122   cout << "Striping the comments" << endl;
00123 
00124   ss.stripcomment("//");
00125 
00126   cout << ss << endl << endl;
00127   cout << "Remove line" << endl;
00128 
00129   ss.remove("");
00130 
00131   //ss.remove_if();
00132 
00133   cout << ss << endl << endl;
00134 
00135   cout << "Subtract space" << endl;
00136   ss.subtract(" ");
00137   cout << ss << endl;
00138 }

void tokenizertest::test05 (  ) 

Definition at line 140 of file tokenizertest.cpp.

References tokenizer::readaslines(), and tokenizermisc::readfile().

00141 {
00142   string fname("crp.txt");
00143   string s;
00144   if (!tokenizermisc::readfile(s,fname))
00145   {
00146     cout << "error: Can not open " << fname << "." << endl;
00147     return;
00148   }
00149 
00150   tokenizer ss;
00151 
00152   ss.readaslines(s);
00153   cout << ss << endl;
00154 
00155 /*
00156   string fname("crp.txt");
00157   ifstream targ(fname.c_str());
00158 
00159   if (!targ)
00160   {
00161     cout << "error: Can not open " << fname << "." << endl;
00162     return;
00163   }
00164 
00165   string s;
00166   char c;
00167   while (targ.get(c))
00168     s.push_back(c);
00169 
00170   cout << "Printing the file" << endl;
00171   cout << s << endl;
00172 */
00173 }

void tokenizertest::test06 (  ) 

Definition at line 191 of file tokenizertest.cpp.

References tokenizer::atomize(), tokenizer::printdelimiter, tokenizer::readaslines(), tokenizermisc::readfile(), tokenizer::remove_if(), tokenizer::stripcomment(), and tokenizer::subtract().

00192 {
00193   string filename("head.wrl");
00194   string s;
00195   if (!tokenizermisc::readfile(s,filename))
00196   {
00197     cout << "error: Can not open " << filename << "." << endl;
00198     return;
00199   }
00200 
00201   cout << "File read" << endl;
00202 
00203   tokenizer tokenstream;
00204   tokenstream.readaslines(s);
00205   //cout << tokenstream << endl;
00206 
00207   tokenstream.stripcomment("#");
00208 
00209   tokenstream.subtract(",");
00210   tokenstream.atomize("{");
00211   tokenstream.atomize("}");
00212   tokenstream.atomize("[");
00213   tokenstream.atomize("]");
00214 
00215   //tokenstream.seq.remove("\n");
00216   tokenstream.printdelimiter="@\n";
00217 
00218   tokenstream.remove_if(spacerdelete<>());
00219   //tokenstream.seq.remove_if(spacerdelete<>());
00220 
00221 /*
00222   liststringi k = tokenstream.seq.begin();
00223   liststringi kend=tokenstream.seq.end();
00224   for ( ; k!=kend; ++k)
00225   {
00226     if
00227 */
00228   
00229 cout << "***" << endl;
00230 cout << tokenstream << endl;
00231 
00232 }

void tokenizertest::test07 (  ) 

Testing the trim function.

Definition at line 234 of file tokenizertest.cpp.

References tokenizer::printdelimiter, tokenizer::seq, and tokenizer::trim().

00235 {
00236   cout << "Testing spacetrim<>" << endl;
00237   tokenizer ss;
00238   ss.printdelimiter="@\n";
00239   ss.seq.push_back("Nothing");
00240   ss.seq.push_back(" fku");
00241   ss.seq.push_back("  This is a sentence. ");
00242   ss.seq.push_back(" a");
00243   ss.seq.push_back("a ");
00244   ss.seq.push_back(" a ");
00245   ss.seq.push_back(" ");
00246   ss.seq.push_back("      ");
00247 
00248   ss.trim();
00249 
00250   cout << ss << "@" << endl;
00251 }

void tokenizertest::test08 (  ) 

Testing the tokenizer on a real VRML file.

Definition at line 253 of file tokenizertest.cpp.

References tokenizer::atomize(), dbg, tokenizer::printdelimiter, tokenizer::readaslines(), tokenizermisc::readfile(), tokenizer::remove_if(), tokenizer::stripcomment(), tokenizer::subtract(), and tokenizer::trim().

00254 {
00255   string filename("head2.wrl");
00256   string s;
00257   if (!tokenizermisc::readfile(s,filename))
00258   {
00259     cout << "error: Can not open " << filename << "." << endl;
00260     return;
00261   }
00262 
00263   tokenizer tokenstream;
00264   tokenstream.readaslines(s);
00265   //cout << tokenstream << endl;
00266 
00267   tokenstream.stripcomment("#");
00268 
00269   tokenstream.subtract(",");
00270   tokenstream.atomize("{");
00271   tokenstream.atomize("}");
00272   tokenstream.atomize("[");
00273   tokenstream.atomize("]");
00274 
00275   //tokenstream.seq.remove("\n");
00276   tokenstream.printdelimiter="@\n";
00277 
00278   tokenstream.remove_if(spacerdelete<>());
00279 
00280   tokenstream.trim();
00281 
00282   tokenstream.subtract(" ");
00283 
00284   messagefile dbg("debug.txt",true);
00285   dbg() << tokenstream << endl;
00286 }

void tokenizertest::test09 (  ) 

Test comparewithoutspace(s1,s2).

Definition at line 288 of file tokenizertest.cpp.

References tokenizer::atomize(), tokenizermisc::comparewithoutspace(), tokenizer::remove_if(), tokenizer::reset(), SHOW, tokenizer::trim(), and tokenizer::trim_and_prune().

00289 {
00290   string s1 = "The quick brown fox jumped over the lazy dog.\n";
00291   string s2 = "   The quick brown fox\njumped     over the lazy dog.";
00292 
00293   tokenizer t1(s1);
00294   tokenizer t2(s2);
00295 
00296   t1.atomize(" ");
00297   t1.atomize("\n");
00298   t1.atomize("\t");
00299   t1.trim_and_prune();
00300   //t1.trim();
00301   //t1.remove_if(spacerdelete<>());
00302   t1.reset();
00303   for ( ; !t1; ++t1 )
00304     cout << "*" << t1() << "*" << endl;
00305   cout << endl << endl;
00306 
00307   t2.atomize(" ");
00308   t2.atomize("\n");
00309   t2.atomize("\t");
00310   t2.trim();
00311   t2.remove_if(spacerdelete<>());
00312   t2.reset();
00313   for ( ; !t2; ++t2 )
00314     cout << "*" << t2() << "*" << endl;
00315   cout << endl << endl;
00316 
00317   cout << t1 << "@" << endl;
00318   cout << t2 << "@" << endl;
00319 
00320   cout << SHOW(t1==t2) << endl;
00321 
00322   cout << SHOW(tokenizermisc::comparewithoutspace(s1,s2)) << endl;
00323 
00324 }

void tokenizertest::test10 (  )  [static]

atomize_next(<mytag>) to find tagged data.

Definition at line 391 of file tokenizertest.cpp.

References tokenizer::atomize_next(), stl_iterator< Cont, Tp >::reset(), tokenizer::reset(), and tokenizer::seq.

00392 {
00393   string s1;
00394   example01(s1);
00395   tokenizer tk(s1);
00396 
00397   cout << "Display string:" << endl;
00398   cout << tk << endl;
00399   cout << endl;
00400   cout << "atomize_next <startcolor>:" << endl;
00401   tk.reset();
00402   tk.atomize_next("<startcolor>");
00403 
00404   //cout << SHOW(tk()) << endl;
00405 
00406   liststringiterator i1(tk.seq);
00407   for (i1.reset(); !i1; ++i1)
00408     { cout << "*" << *i1 << "*" << endl; }
00409 
00410   cout << "atomize_next </startcolor>:" << endl;
00411   tk.atomize_next("</startcolor>");
00412 
00413   for (i1.reset(); !i1; ++i1)
00414     { cout << "*" << *i1 << "*" << endl; }
00415 }

int tokenizertest::unittest01 (  )  [static]

Exploring reading and writing tagged field with tokenizer::atomize_next_tag().

Definition at line 417 of file tokenizertest.cpp.

References assertreturnOS, tokenizer::atomize(), tokenizer::atomize_next_tag(), tokenizer::current, endln, tokenizer::find(), print(), tokenizer::reset(), tokenizerlocal::scope(), tokenizer::seq, SHOW, and tokenizer::trim_and_prune().

00418 {
00419   {
00420     cout << "Test 1.1" << endln;
00421     string s1;
00422     example01(s1);
00423     tokenizer tk(s1);
00424 
00425     liststringi i1;
00426     liststringi i2;
00427     tk.reset();
00428     bool res;
00429     res=tk.atomize_next_tag(i1,i2,"startcolor");
00430     cout << "Atomize <startcolor> and </startcolor>" << endl;
00431     cout << SHOW(res) << endl;
00432     if (res==false)
00433       return 1;
00434 
00435     cout << "Read the tag." << endl;
00436     cout << "  check 3 strings." << endl;
00437     liststringi i3(i1);
00438     ++i3; ++i3;
00439     if (i3!=i2)
00440       return 1;
00441     --i3;
00442     cout << "tag data=\"" << *i3 << "\"" << endl;
00443     cout << "Writing a value back" << endl;
00444     *i3 = "0.1 0.1 0.1";
00445 
00446     tk.trim_and_prune();
00447 
00448     string s2 = (stringc)tk;
00449     cout << tk << endl;
00450   }
00451 
00452   {
00453     cout << "Test 1.2" << endln;
00454     string s1;
00455     example01(s1);
00456     tokenizer tk(s1);
00457 
00458     tk.reset();
00459     tk.atomize("<settings>");
00460     tk.atomize("<pipes>");
00461 
00462     cout << print(tk.seq,"*") << endln;
00463     string::size_type k1;
00464 
00465     tk.reset();
00466     assertreturnOS( tk.find(k1,"matrixD2") );
00467     cout << SHOW( *tk.current ) << " " << SHOW(k1) << " ";
00468     cout << SHOW(tk.current->substr(k1,8)) << endl;
00469     assertreturnOS(tk.current->substr(k1,8)=="matrixD2");
00470     assertreturnOS( tk.find(k1,"<n>",k1) );
00471     cout << SHOW( *tk.current ) << " " << SHOW(k1) << " ";
00472     cout << SHOW(tk.current->substr(k1,3)) << endl;
00473     assertreturnOS(tk.current->substr(k1,3)=="<n>");
00474 
00475     assertreturnOS( tk.find(k1,"<pipes>",k1) );
00476     cout << SHOW( *tk.current ) << " " << SHOW(k1) << endln;
00477   }
00478 
00479   {
00480     cout << "Test 1.3" << endln;
00481     string s1;
00482     example01(s1);
00483     tokenizer tk(s1);
00484     tokenizerlocal tl(tk);
00485 
00486     tk.reset();
00487     assertreturnOS( tl.scope("settings") );
00488     assertreturnOS( tl.scope("pipes") );
00489 
00490     tokenizerfind tf(tk,"<");
00491     tf.reset();
00492     for ( ; !tf; ++tf)
00493       cout << SHOW(tf()) << " " << SHOW(tf.index) << endln;
00494 
00495     cout << "find(\"matrixD2\",\"n\")" << endl;
00496     
00497     tk.reset();
00498     assertreturnOS( tf.find("<matrixD2>","<n>") );
00499     cout << SHOW(tf()) << " " << SHOW(tf.index) << endln;
00500     cout << SHOW( tf().substr(tf.index,3) ) << endl;
00501 
00502   }
00503 
00504   return 0;
00505 }

int tokenizertest::unittest02 (  )  [static]

tokenizerlocal: reading and writing a tagged string.

Definition at line 507 of file tokenizertest.cpp.

References assertreturnOS, endln, tokenizerlocal::erasetag(), tokenizerlocal::i1, tokenizerlocal::i2, tokenizerlocal::read(), tokenizerlocal::ref, tokenizerlocal::reset(), tokenizer::reset(), tokenizerlocal::scope(), tokenizerlocal::scopesearch(), tokenizer::seq, SHOW, and tokenizerlocal::writetag().

00508 {
00509   string s1;
00510   example01(s1);
00511 
00512   cout << "Testing tokenizerlocal::scope(stringc&);" << endl;
00513   cout << "Looking to see list of strings with *<matrixD2>* ... *</matrixD2>" << endl;
00514 
00515   {
00516     cout << "TEST 2.1" << endl;
00517     cout << "Atomizing tag" << endln;
00518     tokenizer tk(s1);
00519     tokenizerlocal tl(tk);
00520 
00521     tk.reset();
00522     assertreturnOS( tl.scope("matrixD2") );
00523 
00524     liststringiterator i1(tk.seq);
00525     for (i1.reset(); !i1; ++i1)
00526       { cout << "*" << *i1 << "*" << endl; }
00527   }
00528 
00529   {
00530     cout << "TEST 2.2" << endl;
00531     cout << "Atomizing tag depth of 2." << endln;
00532     tokenizer tk(s1);
00533     tokenizerlocal tl(tk);
00534 
00535     tk.reset(); 
00536     assertreturnOS( tl.scope("matrixD2","m") );
00537 
00538     liststringiterator i1(tk.seq);
00539     for (i1.reset(); !i1; ++i1)
00540       { cout << "*" << *i1 << "*" << endl; }
00541   }
00542 
00543   {
00544     cout << "TEST 2.3" << endl;
00545     cout << "Reading and writing a tag at depth of 2." << endln;
00546     tokenizer tk(s1);
00547     tokenizerlocal tl(tk);
00548 
00549     tk.reset(); 
00550 
00551     string val;
00552 
00553     assertreturnOS( tl.read(val,"startcolor") );
00554     cout << "*" << SHOW(val) << "*" << endl;
00555 
00556     assertreturnOS( tl.read(val,"matrixD2","n") );
00557     cout << "*" << SHOW(val) << "*" << endl;
00558 
00559     cout << SHOW(*tl.i1) << SHOW(*tl.i2) << endl;
00560     cout << SHOW(*tl.ref) << endl;
00561 
00562     tl.reset();
00563     tl.writetag("i am starting to dislike working on the parser", "n");
00564     cout << SHOW(*tl.ref) << endl;
00565 
00566     cout << tk << endl;
00567   }
00568 
00569   {
00570     cout << "TEST 2.4" << endl;
00571     tokenizer tk(s1);
00572     tokenizerlocal tl(tk);
00573 
00574     tk.reset();
00575     cout << "Erasing the <settings> tag." << endl;
00576 
00577     bool res;
00578     res = tl.scopesearch("settings");
00579     cout << SHOW(res) << endl;
00580     cout << "Did not expect to find settings as not atomized." << endl;
00581     assertreturnOS(res==false);
00582     tk.reset();
00583     res = tl.scope("settings");
00584     assertreturnOS(res==true);
00585     cout << SHOW(res) << " " << SHOW(*tl.i1) << " " << SHOW(*tl.i2) << endl;
00586     assertreturnOS(tl.erasetag("settings"));
00587 
00588     cout << tk << endl;
00589   }
00590 
00591   return 0;
00592 }

int tokenizertest::unittest03 (  )  [static]

Reading/writing multiple <obj>.

..</obj>'s

Definition at line 594 of file tokenizertest.cpp.

References assertreturnOS, misclib_testcode::InventoryObj::cost, misclib_testcode::InventoryObj::desc, endln, misclib_testcode::InventoryObj::item, print(), misclib_testcode::InventoryObj::quantity, tokenizerlocal::read(), tokenizerlocal::ref, tokenizerlocal::reset(), tokenizer::reset(), tokenizerlocal::scope(), SHOW, misclib_testcode::InventoryObj::sn, stringfrom(), and tokenizerlocal::writetag().

00595 {
00596   string s1;
00597   example02(s1);
00598 
00599   {
00600     cout << "TEST 3.1" << endl;
00601     tokenizer tk(s1);
00602     tokenizerlocal tl(tk);
00603 
00604     tk.reset();
00605 
00606     cout << "Listing the employees" << endln;
00607     cout << "  reading multiple <emp> string </emp>" << endln;
00608 
00609     string name;
00610     assertreturnOS(tl.read(name,"field","name"));
00611     cout << SHOW(name) << endl;
00612     string ei;
00613     list<string> names;
00614     for ( ; tl.read(ei,"emp"); )
00615       names.push_back(ei); 
00616     cout << "names:" << print(names," ") << endl;
00617     
00618     cout << "Edit by reading the whole list in, editing it";
00619     cout << " there and then re writing it." << endl;
00620 
00621     names.erase(find(names.begin(),names.end(),"Samantha"));
00622 
00623     names.push_back("Zelda");
00624     names.push_back("Ba");
00625 
00626     cout << "###" << print(names," ") << endl;
00627 
00628 
00629     liststringiterator namesi(names); 
00630 
00631     string s2;
00632     s2 = ("<name>" + name + "</name>");
00633     for ( ; !namesi; ++namesi)
00634     {
00635  assert(!namesi);
00636       s2 += ("<emp>"+*namesi+"</emp>");
00637     }
00638     tk.reset();
00639     tl.writetag(s2,"field");
00640 
00641     cout << tk << endl;
00642   }
00643 
00644   {
00645     string s0;
00646     example03(s0);
00647     cout << "TEST 3.2" << endl;
00648     cout << "Reading/writing multiple <obj><Item>...</obj>'s" << endln;
00649     tokenizer tk(s0);
00650     tokenizerlocal tl(tk);
00651     string s2;
00652     tl.read(s2,"Inventory");
00653 
00654     list<InventoryObj> inventory;
00655     InventoryObj prod;
00656 
00657     tokenizer tk2(s2);
00658     tokenizerlocal tl2(tk2);
00659     tokenizerlocal tl3(tk2);
00660     string targ;
00661     spacertrim<> st;
00662     for ( tk2.reset(); tl2.scope("obj"); ++tl2)
00663     {
00664       // Atomic read.
00665       if (tl3.read(prod.item,"Item")==false)
00666         continue;
00667       st(prod.item);
00668       if (tl3.read(targ,"Quantity")==false)
00669         continue;
00670       stringfrom(prod.quantity,targ);
00671       if (tl3.read(prod.desc,"Desc")==false)
00672         continue;
00673       st(prod.desc);
00674       if (tl3.read(prod.sn,"SN")==false)
00675         continue;
00676       st(prod.sn);
00677       if (tl3.read(targ,"Cost")==false)
00678         continue;
00679       stringfrom(prod.cost,targ);
00680       
00681       inventory.push_back(prod);
00682     } 
00683 
00684     list<InventoryObj>::iterator k=inventory.begin();
00685     for ( ; k!=inventory.end(); ++k)
00686       cout << k->xml() << "*" << endl;
00687 
00688     cout << "Making edit" << endl;
00689     for ( k=inventory.begin(); k!=inventory.end(); ++k)
00690     {
00691 //cout << SHOW(k->item) << "*" << endl;
00692       if (k->item=="88329")
00693         k->sn = "S298RT";
00694     }
00695     
00696     string result;
00697     for ( k=inventory.begin(); k!=inventory.end(); ++k)
00698       { result += k->xml(); }
00699     
00700     tl.reset();
00701     tl.writetag(result,"Inventory");
00702 
00703     cout << tl.ref << endl;
00704   }
00705 
00706   return 0;
00707 }

int tokenizertest::unittest04 (  )  [static]

Definition at line 737 of file tokenizertest.cpp.

References assertreturnOS, tokenizerlocal::debug01(), tokenizerlocal::read(), tokenizerlocal::reset(), tokenizerlocal::scope(), and SHOW3.

00738 {
00739   {
00740     string s0;
00741     example03(s0);
00742 
00743     cout << "TEST 4.1" << endl;
00744     tokenizer tk(s0);
00745     tokenizerlocal tl(tk);
00746 
00747     bool res;
00748 
00749     res=tl.scope("Inventory");
00750     assertreturnOS(res);
00751 
00752     string SN;
00753     string Desc;
00754 
00755     tokenizerlocal tl2(tl);
00756     for ( ; !tl2; ++tl2 )
00757     {
00758       res=tl2.scope("obj");
00759       if (res)
00760       {
00761         tokenizerlocal tl3(tl2);
00762         if (tl3.read(SN,"SN"))
00763           { cout << SHOW3(SN) << endl; }
00764         tl3.reset(tl2);
00765         if (tl3.read(Desc,"Desc"))
00766           { cout << SHOW3(Desc) << endl; }
00767         
00768       }
00769     }  
00770   }
00771   {
00772     string s0;
00773     example03(s0);
00774 
00775     cout << "TEST 4.2" << endl;
00776     tokenizer tk(s0);
00777     tokenizerlocal tl(tk);
00778 
00779     assertreturnOS( tl.scope("Inventory") );
00780 
00781     string SN;
00782     string Desc;
00783 
00784     tokenizerlocal tl2(tl);
00785     for ( ; tl2.scope("obj"); ++tl2 )
00786     {
00787       tokenizerlocal tl3(tl2);
00788       if (tl3.read(SN,"SN"))
00789         cout << SHOW3(SN) << endl;
00790 cout << SHOW3(tl3.debug01()) << endl;
00791       tl3.reset();
00792 cout << SHOW3(tl3.debug01()) << endl;
00793       if (tl3.read(Desc,"Desc"))
00794         cout << SHOW3(Desc) << endl;
00795     }  
00796   };
00797 
00798   {
00799     string s0;
00800     example03(s0);
00801 
00802     cout << "TEST 4.3" << endl;
00803     tokenizer tk(s0);
00804     tokenizerlocal tl(tk);
00805 
00806     assertreturnOS( tl.scope("Inventory") );
00807 
00808     string SN;
00809     string Desc;
00810 
00811     tokenizerlocalvar tl2(tl,"obj");
00812     for ( ; !tl2; ++tl2 )
00813     {
00814       tokenizerlocal tl3(tl2);
00815       if (tl3.read(SN,"SN"))
00816         cout << SHOW3(SN) << endl;
00817 cout << SHOW3(tl3.debug01()) << endl;
00818       tl3.reset();
00819 cout << SHOW3(tl3.debug01()) << endl;
00820       if (tl3.read(Desc,"Desc"))
00821         cout << SHOW3(Desc) << endl;
00822     }  
00823   };
00824 
00825   return 0;
00826 }


Member Data Documentation

string tokenizertest::doc [static]

Initial value:

 
{
  "Given a paragraph as a string parse into lines.",
  "Use STL to erase a token in a string.",
  "Use STL to insert white space around a token in a string.",
  "Demonstrate the atomize function.",
  "Demonstrate the stripcomment function.",
  "",
  "",
  "Testing the trim function.",
  "Testing the tokenizer on a real VRML file.",
  "Test comparewithoutspace(s1,s2).",
  "atomize_next(<mytag>) to find tagged data.",

  "Exploring reading and writing tagged field with tokenizer::atomize_next_tag()",
  "tokenizerlocal: reading and writing a tagged string.",
  "Reading/writing multiple <obj><Item>...</obj>'s",
  "xxx",
  ""
}
Brief description of each test.

Definition at line 18 of file tokenizertest.h.


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:26 2011 for Chelton Evans Source by  doxygen 1.5.8