32 Date() : day(0), month(0), year(0) { }
34 Int_t GetDay()
const {
return day; }
35 Int_t GetMonth()
const {
return month; }
36 Int_t GetYear()
const {
return year; }
38 void SetMonth(
Int_t m) { month=
m;}
39 void SetYear(
Int_t y) { year=
y;}
50 street(
s), postalCode(p), country(
c) { }
51 TString GetStreet()
const {
return street; }
52 TString GetPostalCode()
const {
return postalCode; }
53 TString GetCountry()
const {
return country; }
54 void SetStreet(
const TString &
s) { street =
s; }
55 void SetPostalCode(
const TString &p) { postalCode = p; }
56 void SetCountry(
const TString &
c) { country =
c; }
67 id(i), firstName(
f), lastName(
l), gender(
g), dateOfBirth(
d), address(
a){ }
74 TString GetFirstName()
const {
return firstName; }
75 TString GetLastName()
const {
return lastName; }
76 Char_t GetGender()
const {
return gender; }
77 Date *GetDate()
const {
return dateOfBirth; }
78 Address *
GetAddress()
const {
return address; }
79 Int_t GetID()
const {
return id; }
81 friend ostream &
operator << (ostream& out,
const Person& p) {
82 out <<
"ID: " << p.id << endl;
83 out <<
"First name: " << p.firstName << endl;
84 out <<
"Last name: " << p.lastName << endl;
85 out <<
"Sex: " << p.gender << endl;
86 out <<
"Date of birth: " << p.dateOfBirth->GetDay() <<
"/"
87 << p.dateOfBirth->GetMonth() <<
"/"
88 << p.dateOfBirth->GetYear() << endl;
89 out <<
"Address: " << p.address->GetStreet() << endl;
90 out <<
"\t" << p.address->GetPostalCode() << endl;
91 out <<
"\t" << p.address->GetCountry() << endl;
108 listOfPerson =
new TList();
122 ParsePersonList(node);
127 void ParsePersonList(
TXMLNode *node) {
135 TIter next(attrList);
137 if (strcmp(attr->
GetName(),
"ID") == 0) {
143 listOfPerson->Add(ParsePerson(node->
GetChildren(),
id));
165 return new Date(
d,
m,
y);
168 Address *ParseAddress(
TXMLNode *node) {
175 if (strcmp(node->
GetNodeName(),
"PostalCode") == 0) {
183 return new Address(
s, p,
c);
200 if (strcmp(node->
GetNodeName(),
"DateOfBirth") == 0)
207 return new Person(
id, firstName, lastName, gender, date, address);
210 friend ostream&
operator << (ostream& out,
const PersonList & pl) {
211 TIter next(pl.listOfPerson);
213 while ((p =(Person*)next())){
220 TIter next(listOfPerson);
222 while ((p =(Person*)next())) {
228 Int_t numberOfPersons;
235 PersonList personlist;
236 gROOT->ProcessLine(
".O 0");
238 if (personlist.ParseFile(dir+
"/xml/person.xml") == 0)
239 cout << personlist << endl;
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
virtual Int_t ParseFile(const char *filename)
Parse the XML file where filename is the XML file name.
Mother of all ROOT objects.
TXMLAttribute is the attribute of an Element.
const char * GetValue() const
const char * GetName() const
Returns name of object.
TXMLNode * GetRootNode() const
Returns the root element node.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
const char * GetText() const
Returns the content of a Text node if node is a TextNode, 0 otherwise.
TXMLNode * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
const char * GetNodeName() const
Returns the node's name.
Bool_t HasAttributes() const
Returns true if Element node has attribute.
EXMLElementType GetNodeType() const
Returns the node's type.
const char * GetParseCodeMessage(Int_t parseCode) const
Returns the parse code message.
ULong64_t GetAddress(std::vector< std::string > &p)
static constexpr double s