proj home

Files   Classes   Functions   Hierarchy  

tokenizertest.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 using namespace std;
00004 
00005 #include <iteratorstypedefs.h>
00006 #include <message.h>
00007 #include <print.h>
00008 #include <stringconvert.h>
00009 #include <tokenizer.h>
00010 #include <tokenizerfind.h>
00011 #include <tokenizerlocal.h>
00012 #include <tokenizertest.h>
00013 
00014 using namespace misclib_testcode;
00015 
00016 string tokenizertest::doc[] = 
00017 {
00018   "Given a paragraph as a string parse into lines.",
00019   "Use STL to erase a token in a string.",
00020   "Use STL to insert white space around a token in a string.",
00021   "Demonstrate the atomize function.",
00022   "Demonstrate the stripcomment function.",
00023   "",
00024   "",
00025   "Testing the trim function.",
00026   "Testing the tokenizer on a real VRML file.",
00027   "Test comparewithoutspace(s1,s2).",
00028   "atomize_next(<mytag>) to find tagged data.",
00029 
00030   "Exploring reading and writing tagged field with tokenizer::atomize_next_tag()",
00031   "tokenizerlocal: reading and writing a tagged string.",
00032   "Reading/writing multiple <obj><Item>...</obj>'s",
00033   "xxx",
00034   ""
00035 };
00036 
00037 void tokenizertest::test00()
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 }
00047 
00048 void tokenizertest::test01()
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 }
00070 
00071 void tokenizertest::test02()
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 }
00095 
00096 void tokenizertest::test03()
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 }
00108 
00109 void tokenizertest::test04()
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 }
00139 
00140 void tokenizertest::test05()
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 }
00174 
00175 /*
00176 void messagetest::test02()
00177 {
00178   string fname("crp.txt");
00179   string s;
00180   if (!readfile(s,fname))
00181   {
00182     cout << "error: Can not open " << fname << "." << endl;
00183     return;
00184   }
00185 
00186   cout << "Printing the file" << endl;
00187   cout << s << endl;
00188 }
00189 */
00190 
00191 void tokenizertest::test06()
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 }
00233 
00234 void tokenizertest::test07()
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 }
00252 
00253 void tokenizertest::test08()
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 }
00287 
00288 void tokenizertest::test09()
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 }
00325 
00326 void tokenizertest::example01(string& s)
00327 {
00328   s=
00329 "<gameD2>\n\
00330   <startcolor>.324,.1,.8928</startcolor>\n\
00331   <matrixD2>\n\
00332     <m>25</m>\n\
00333     <n>23</n>\n\
00334   </matrixD2>\n\
00335   <settings>\n\
00336     <walls>1</walls>\n\
00337     <pipes>0</pipes>\n\
00338   </settings>\n\
00339 </gameD2>\
00340 ";
00341 }
00342 
00343 void tokenizertest::example02(string& s)
00344 {
00345   s=
00346 "<packet>\n\
00347   <header>garbage</header>\n\
00348   <data>\n\
00349   <field>\n\
00350     <name>EMPID</name>\n\
00351     <emp>Joe</emp>\n\
00352     <emp>Samantha</emp>\n\
00353     <emp>Key</emp>\n\
00354   </field>\n\
00355   <sig>ire83402l2992p2l2sl94202</sig>\n\
00356   </data>\n\
00357 </packet>";
00358 }
00359 
00360 void tokenizertest::example03(string& s)
00361 {
00362   s=
00363 "<Warehouse>\
00364 <Inventory>\
00365 <obj>\
00366 <Item>829 </Item>\
00367 <Quantity>5 </Quantity>\
00368 <Desc>Plastic sheet </Desc>\
00369 <SN> 829984j892wwh</SN>\
00370 <Cost> 10</Cost>\
00371 </obj>\
00372 <obj>\
00373 <Item>88329 </Item>\
00374 <Quantity> 1 </Quantity>\
00375 <Desc> Van Guard  </Desc>\
00376 <SN> </SN>\
00377 <Cost> 2089498</Cost>\
00378 </obj>\
00379 <obj>\
00380 <Item>2824 </Item>\
00381 <Quantity> 1 </Quantity>\
00382 <Desc> Dyson Orbital Weapon System  </Desc>\
00383 <SN> 78914JAZY7K</SN>\
00384 <Cost> 184000000</Cost>\
00385 </obj>\
00386 </Inventory>\
00387 <Warehouse>\
00388 ";
00389 }
00390 
00391 void tokenizertest::test10()
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 }
00416 
00417 int tokenizertest::unittest01()
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 }
00506 
00507 int tokenizertest::unittest02()
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 }
00593 
00594 int tokenizertest::unittest03()
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 }
00708 
00709 
00710 stringc InventoryObj::xml()
00711 {
00712   string x;
00713 
00714   x += stringtag(item,"Item");
00715   x += stringtag(quantity,"Quantity"); 
00716   x += stringtag(desc,"Desc");
00717   x += stringtag(sn,"SN");
00718   x += stringtag(cost,"Cost");
00719 
00720   return stringtag(x,"obj");
00721 }
00722 
00723 /*
00724 
00725 // Extract - non specified number of string elements.
00726 // Build a vector of strings for EMPID.
00727 // Assumptions: 1st tag in packet->data->field scope
00728 //   is <name> </name>
00729 // read until no more <emp> records to read. 
00730 
00731 Write a demo function that reads and re writes
00732  the number of emp's.
00733 
00734 */
00735 
00736 
00737 int tokenizertest::unittest04()
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 }
00827 

Generated on Fri Mar 4 00:49:29 2011 for Chelton Evans Source by  doxygen 1.5.8