Skip to content

Commit 0527569

Browse files
committed
This is the way: Mando says ..
1 parent 46f61ee commit 0527569

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

main.cpp

+32-30
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,47 @@ using namespace PAXCC;
3232
int main(int arc, char **argv)
3333
{
3434

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");
3738

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");
4342

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");
4946

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");
5550

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
5654

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");
6060

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();
6266

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();
6672

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();
7173

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
7476

7577
delete pax1; // working recursively well on first run ..
7678

0 commit comments

Comments
 (0)