Belle II Software  release-05-02-19
XmlFile.h
1 #pragma once
2 
3 #include <TObject.h>
4 #include <string>
5 #include <fstream>
6 #include <boost/property_tree/xml_parser.hpp>
7 
8 namespace Belle2 {
13  class XmlFile : public TObject {
15 
16  public:
18  XmlFile() {};
19 
21  virtual ~XmlFile()
22  {
23  }
24 
26  void readXml(std::string xmlFileName)
27  {
28  std::ifstream t(xmlFileName);
29  std::stringstream buffer;
30  buffer << t.rdbuf();
31  m_data = buffer.str();
32  }
33 
35  std::string getData()
36  {
37  return m_data;
38  }
39 
41  void fillPropertyTree(boost::property_tree::ptree& tree)
42  {
43  std::stringstream ss; ss << m_data;
44  using boost::property_tree::ptree;
45  read_xml(ss, tree);
46  }
47 
48  private:
50  std::string m_data{""};
51 
52  ClassDef(XmlFile, 1)
53  };
55 }
Belle2::XmlFile::fillPropertyTree
void fillPropertyTree(boost::property_tree::ptree &tree)
Populate boost PropertyTree with stored data.
Definition: XmlFile.h:41
Belle2::XmlFile::m_data
std::string m_data
The xml data as string.
Definition: XmlFile.h:50
Belle2::XmlFile::getData
std::string getData()
Get content as string.
Definition: XmlFile.h:35
Belle2::XmlFile::readXml
void readXml(std::string xmlFileName)
Read content from xml file.
Definition: XmlFile.h:26
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::XmlFile::XmlFile
XmlFile()
Constructor.
Definition: XmlFile.h:18
Belle2::XmlFile::~XmlFile
virtual ~XmlFile()
Destructor.
Definition: XmlFile.h:21
Belle2::XmlFile
DB object which stores whole xml.
Definition: XmlFile.h:14