Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
XMLNode.h
1/*
2 * HalXLMNode.h from HalROOT
3 *
4 * Created on: 30-04-2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HALXLMNODE_H_
10#define HALXLMNODE_H_
11
12#include <Rtypes.h>
13#include <TList.h>
14#include <TNamed.h>
15#include <TObject.h>
16#include <TString.h>
17#include <TXMLEngine.h>
18#include <memory>
19
20class TXMLNode;
21
25namespace Hal {
26 class XMLAttrib : public TNamed {
27 public:
31 XMLAttrib() : TNamed() {}
37 XMLAttrib(TString name, TString value) {
38 SetName(name);
39 SetTitle(value);
40 }
45 TString GetValue() const { return GetTitle(); };
50 void SetValue(TString val) { SetTitle(val); };
51 virtual ~XMLAttrib() {};
52 ClassDef(XMLAttrib, 1);
53 };
57 class XMLNode : public TNamed {
58 TList fChildren;
59 TList fAttrib;
60
61 public:
66 XMLNode(const XMLNode& other);
72 XMLNode(TString name = "", TString value = "");
78 XMLNode& operator=(const XMLNode& other);
83 void Copy(TXMLNode* node);
88 void SetValue(TString value) { SetTitle(value); };
94 void AddChild(XMLNode* node) { fChildren.AddLast(node); };
99 void AddAttrib(XMLAttrib* attrib);
104 Int_t GetNChildren() const { return fChildren.GetEntries(); };
109 Int_t GetNAttributes() const { return fAttrib.GetEntries(); };
115 Int_t GetNChildren(TString name) const;
120 TString GetValue() const { return GetTitle(); };
126 XMLAttrib* GetAttrib(TString name) const;
132 XMLAttrib* GetAttrib(Int_t index) const;
139 XMLNode* GetChild(TString name, Int_t count = 0) const;
145 XMLNode* GetChild(Int_t index) const;
146 virtual ~XMLNode();
147 ClassDef(XMLNode, 1);
148 };
149
153 class XMLFile : public TObject {
154 std::unique_ptr<XMLNode> fRootNode;
155 TString fName;
156 Bool_t fOverwrite;
157 void ExportNode(XMLNodePointer_t& nodePointer, TXMLEngine& engine, const XMLNode& node) const;
158
159 public:
165 XMLFile(TString name = "", TString mode = "read");
170 void CreateRootNode(TString name);
175 void SetRootNode(XMLNode* node);
180 XMLNode* GetRootNode() const { return fRootNode.get(); };
184 void Close();
188 virtual ~XMLFile();
189 ClassDef(XMLFile, 1);
190 };
191} // namespace Hal
192#endif /* HalXLMNODE_H_ */
void SetValue(TString val)
Definition XMLNode.h:50
TString GetValue() const
Definition XMLNode.h:45
XMLAttrib(TString name, TString value)
Definition XMLNode.h:37
void CreateRootNode(TString name)
Definition XMLNode.cxx:128
void Close()
Definition XMLNode.cxx:132
XMLFile(TString name="", TString mode="read")
Definition XMLNode.cxx:114
virtual ~XMLFile()
Definition XMLNode.cxx:158
void SetRootNode(XMLNode *node)
Definition XMLNode.cxx:130
XMLNode * GetRootNode() const
Definition XMLNode.h:180
void Copy(TXMLNode *node)
Definition XMLNode.cxx:48
Int_t GetNChildren() const
Definition XMLNode.h:104
void SetValue(TString value)
Definition XMLNode.h:88
void AddChild(XMLNode *node)
Definition XMLNode.h:94
XMLNode * GetChild(TString name, Int_t count=0) const
Definition XMLNode.cxx:93
Int_t GetNAttributes() const
Definition XMLNode.h:109
XMLAttrib * GetAttrib(TString name) const
Definition XMLNode.cxx:104
TString GetValue() const
Definition XMLNode.h:120
XMLNode(const XMLNode &other)
Definition XMLNode.cxx:24
XMLNode & operator=(const XMLNode &other)
Definition XMLNode.cxx:33
void AddAttrib(XMLAttrib *attrib)
Definition XMLNode.cxx:75