ATLAS Offline Software
Loading...
Searching...
No Matches
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
14using Attributes_t = std::map<std::string, std::string>;
15using NameValue_t = std::vector<std::string>;
16static const Attributes_t empty;
17
18namespace SCT_CalibAlgs {
19
20XmlStreamer::XmlStreamer(const std::string& name, const Attributes_t& attributes, std::ostream& os):
21 IElementStreamer(name, attributes, 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
34XmlStreamer::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
44XmlStreamer::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
50XmlStreamer::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}
std::vector< std::string > NameValue_t
std::map< std::string, std::string > Attributes_t
static const Attributes_t empty
std::vector< std::string > m_attributeValues
IElementStreamer(const std::string &name, const std::map< std::string, std::string > &attributeMap, std::ostream &os=std::cout)
std::vector< std::string > m_attributeNames
XmlStreamer(const std::string &name, const std::map< std::string, std::string > &attributes, std::ostream &os=std::cout)