@@ -32,45 +32,47 @@ using namespace PAXCC;
32
32
int main (int arc, char **argv)
33
33
{
34
34
35
- PaxMap<std::string> map; // generally used hashmap ..
36
- map.dbg (); // debugging the pax map ..
35
+ Pax *pax1 = new Pax (" Bob" , " Dylon" );
36
+ pax1->Attrib ()->add (" plays" , " guitar" );
37
+ pax1->Attrib ()->add (" sings" , " songs" );
37
38
38
- Pax *pax1 = new Pax ();
39
- pax1->Tag (" Bob" );
40
- pax1->Val (" Dylon" );
41
- std::cout << pax1->Tag () << " => " << pax1->Val () << std::endl
42
- << std::flush;
39
+ Pax *pax2 = new Pax (" Dolly" , " Parton" );
40
+ pax2->Attrib ()->add (" sings" , " songs" );
41
+ pax2->Attrib ()->add (" plays" , " country guitar" );
43
42
44
- Pax *pax2 = new Pax ();
45
- pax2->Tag (" Dolly" );
46
- pax2->Val (" Parton" );
47
- pax2->Attrib ()->add (" sings" , " country songs" );
48
- pax1->Child ()->add (pax2);
43
+ Pax *pax3 = new Pax (" Johnny" , " Cash" );
44
+ pax3->Attrib ()->add (" plays" , " guitar" );
45
+ pax3->Attrib ()->add (" sings" , " country songs" );
49
46
50
- Pax *pax2_ = new Pax ();
51
- pax2_->Tag (" Dolly" );
52
- pax2_->Val (" Parton" );
53
- pax2_->Attrib ()->add (" sings" , " country songs" );
54
- pax1->Child ()->add (pax2_);
47
+ Pax *pax4 = new Pax (" John" , " Denver" );
48
+ pax4->Attrib ()->add (" sings" , " country songs" );
49
+ pax4->Attrib ()->add (" plays" , " country guitar" );
55
50
51
+ pax1->Child ()->add (pax2); // pax2 as child of pax1
52
+ pax2->Child ()->add (pax3); // pax3 as child of pax2
53
+ pax2->Child ()->add (pax4); // pax3 as child of pax2
56
54
57
- Pax *pax3 = new Pax ();
58
- pax3->Tag (" Johnny" );
59
- pax3->Val (" Cash" );
55
+ std::string xml = pax1->XML ();
56
+ std::cout << xml << std::endl
57
+ << std::flush;
58
+
59
+ Pax* pax2_ = pax1->Child (" Dolly" );
60
60
61
- pax2->Child ()->add (pax3);
61
+ Pax* pax3_ = pax2->Child (" Johnny" ); // from pax2
62
+
63
+ Pax* pax4_ = pax1->Child (" Dolly" )->Child (" John" ); // chained
64
+
65
+ std::string val3_ = pax1->Child (" Dolly" )->Child (" Johnny" )->Val ();
62
66
63
- std::string val2_ = pax1->Child ()->get (" Dolly" )->Val ();
64
- Pax *pax3_ = pax2->Child ()->get (" Johnny" );
65
- std::string val3_ = pax1->Child ()->get (" Dolly" )->Child ()->get (" Johnny" )->Val ();
67
+ Pax* pax = pax1->Child (" Dolly" )->Child (" John" ); // chained
68
+ std::string tag = pax->Tag ();
69
+ std::string val = pax->Val ();
70
+ std::string attribTag = pax->Attrib (" sings" )->Tag ();
71
+ std::string attribVal = pax->Attrib (" sings" )->Val ();
66
72
67
- Pax *pax3__ = pax2->Child (" Johnny" );
68
- pax3__->Attrib ()->add (" plays" , " guitar" );
69
- pax3__->Attrib ()->add (" sings" , " country songs" );
70
- std::string val3__ = pax1->Child (" Dolly" )->Child (" Johnny" )->Val ();
71
73
72
- std::string xml = pax1->XML (); // generate XML from object tree ..
73
- std::cout << xml << std::flush; // print out
74
+ std::string xml_ = pax1->XML (); // generate XML from object tree ..
75
+ std::cout << xml_ << std::flush; // print out
74
76
75
77
delete pax1; // working recursively well on first run ..
76
78
0 commit comments