ATLAS Offline Software
XmlStreamer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 /*
5  * XmlStreamer.cpp
6  * Formatter
7  *
8  * Created by sroe on 12/01/2010.
9  *
10  */
11 
12 #include "XmlStreamer.h"
13 
14 using Attributes_t = std::map<std::string, std::string>;
15 using NameValue_t = std::vector<std::string>;
16 static const Attributes_t empty;
17 
18 namespace SCT_CalibAlgs {
19 
20 XmlStreamer::XmlStreamer(const std::string& name, const Attributes_t& attributes, std::ostream& os):
22  m_os << "\n<" << m_name;
23  if (not attributes.empty()) {
24  Attributes_t::const_iterator i{attributes.begin()};
25  const Attributes_t::const_iterator end{attributes.end()};
26  for (; i!=end; ++i) {
27  m_os << " " << i->first << "=\"" << i->second << "\"";
28  }
29  }
30  m_os << ">";
31  m_os.flush();
32 }
33 
34 XmlStreamer::XmlStreamer(const std::string& name, const NameValue_t& attributeNames, const NameValue_t& attributeValues, std::ostream& os):
35  IElementStreamer(name, attributeNames, attributeValues, os) {
36  m_os << "\n<" << m_name;
37  for (unsigned int i{0}; i!=attributeNames.size(); ++i) {
38  m_os << " " << attributeNames[i] << "=\"" << attributeValues[i] << "\"";
39  }
40  m_os << ">";
41  m_os.flush();
42 }
43 
44 XmlStreamer::XmlStreamer(const std::string& name, std::ostream& os)
45  :IElementStreamer(name, empty, os) {
46  m_os << "\n<" << m_name << ">";
47  m_os.flush();
48 }
49 
50 XmlStreamer::XmlStreamer(const std::string& name, const std::string& attributeName, const std::string& attributeValue, std::ostream& os):
51  IElementStreamer(name, attributeName, attributeValue, os) {
52  m_os << "\n<" << m_name;
53  for (unsigned int i{0}; i!=m_attributeNames.size(); ++i) {
54  m_os << " " << m_attributeNames[i] << "=\"" << m_attributeValues[i] << "\"";
55  }
56  m_os << ">";
57  m_os.flush();
58 }
59 
61  m_os << "</" << m_name << ">";
62  if (m_depth==1) m_os << "\n";
63 }
64 
65 }
SCT_CalibAlgs::XmlStreamer::XmlStreamer
XmlStreamer(const std::string &name, const std::map< std::string, std::string > &attributes, std::ostream &os=std::cout)
Definition: XmlStreamer.cxx:20
Attributes_t
std::map< std::string, std::string > Attributes_t
Definition: XmlStreamer.cxx:14
SCT_CalibAlgs::IElementStreamer::m_attributeValues
std::vector< std::string > m_attributeValues
Definition: IElementStreamer.h:24
SCT_CalibAlgs::IElementStreamer::m_name
std::string m_name
Definition: IElementStreamer.h:22
SCT_CalibAlgs
Definition: IElementStreamer.cxx:13
SCT_CalibAlgs::IElementStreamer
Definition: IElementStreamer.h:19
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
SCT_CalibAlgs::XmlStreamer::~XmlStreamer
virtual ~XmlStreamer()
Definition: XmlStreamer.cxx:60
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
NameValue_t
std::vector< std::string > NameValue_t
Definition: XmlStreamer.cxx:15
SCT_CalibAlgs::IElementStreamer::m_attributeNames
std::vector< std::string > m_attributeNames
Definition: IElementStreamer.h:23
SCT_CalibAlgs::IElementStreamer::m_os
std::ostream & m_os
Definition: IElementStreamer.h:25
SCT_CalibAlgs::IElementStreamer::m_depth
unsigned int m_depth
Definition: IElementStreamer.h:26
collListGuids.attributes
attributes
Definition: collListGuids.py:46
XmlStreamer.h