MarlinMT  0.1.0
marlinmt::XMLConfigWriter Class Reference

XMLConfigWriter plugin Write an XML file from the configuration sections and parameters. More...

Inherits marlinmt::ConfigWriter.

Public Types

using StringMap = std::vector< std::pair< std::string, std::string > >
 

Public Member Functions

void init (const std::string &desc) override
 Initialize the parser. More...
 
void write (const Configuration &cfg) override
 Write the configuration object. More...
 
TiXmlElement createParameterSection (const std::string &name, const ConfigSection &section, const StringMap &attrMapping={})
 Create an XML element containing all parameters from a section. More...
 
void appendDescription (TiXmlElement &element, const ConfigSection &section) const
 Append the config section description in the element tree as comment. More...
 
TiXmlElement createElement (const std::string &name, const StringMap &attrs={}) const
 
TiXmlComment createComment (const std::string &comment) const
 
TiXmlText createText (const std::string &text) const
 
TiXmlElement createParameter (const std::string &name, const std::string &value) const
 
- Public Member Functions inherited from marlinmt::ConfigWriter
virtual ~ConfigWriter ()=default
 Default destructor. More...
 

Private Attributes

std::string _fname {}
 The output file name. More...
 

Detailed Description

XMLConfigWriter plugin Write an XML file from the configuration sections and parameters.

Definition at line 23 of file XMLConfigWriter.cc.

Member Typedef Documentation

◆ StringMap

using marlinmt::XMLConfigWriter::StringMap = std::vector<std::pair<std::string, std::string> >

Definition at line 25 of file XMLConfigWriter.cc.

Member Function Documentation

◆ appendDescription()

void marlinmt::XMLConfigWriter::appendDescription ( TiXmlElement &  element,
const ConfigSection section 
) const

Append the config section description in the element tree as comment.

Parameters
elementthe parent element of the XML comment
sectionthe config section to get the description from

Definition at line 153 of file XMLConfigWriter.cc.

References createComment(), and marlinmt::ConfigSection::metadata().

Referenced by write().

◆ createComment()

TiXmlComment marlinmt::XMLConfigWriter::createComment ( const std::string &  comment) const

Definition at line 202 of file XMLConfigWriter.cc.

Referenced by appendDescription(), createParameterSection(), and write().

◆ createElement()

TiXmlElement marlinmt::XMLConfigWriter::createElement ( const std::string &  name,
const StringMap attrs = {} 
) const

Definition at line 192 of file XMLConfigWriter.cc.

Referenced by createParameter(), createParameterSection(), and write().

◆ createParameter()

TiXmlElement marlinmt::XMLConfigWriter::createParameter ( const std::string &  name,
const std::string &  value 
) const

Definition at line 214 of file XMLConfigWriter.cc.

References createElement(), createText(), and MARLINMT_DECLARE_CONFIG_WRITER.

Referenced by createParameterSection().

◆ createParameterSection()

TiXmlElement marlinmt::XMLConfigWriter::createParameterSection ( const std::string &  name,
const ConfigSection section,
const StringMap attrMapping = {} 
)

Create an XML element containing all parameters from a section.

The list of attributes in third argument is a mapping of parameters to write as XML element attribute and not as parameter.

Parameters
namethe XML element name
sectionthe config section to dump
attrMappinga list of parameters to add as element attribute, not in parameter list

Definition at line 162 of file XMLConfigWriter.cc.

References createComment(), createElement(), createParameter(), marlinmt::details::keys(), marlinmt::ConfigSection::metadata(), marlinmt::ConfigSection::parameter(), and marlinmt::ConfigSection::parameters().

Referenced by write().

◆ createText()

TiXmlText marlinmt::XMLConfigWriter::createText ( const std::string &  text) const

Definition at line 208 of file XMLConfigWriter.cc.

Referenced by createParameter().

◆ init()

void marlinmt::XMLConfigWriter::init ( const std::string &  desc)
overridevirtual

Initialize the parser.

The descriptor string can be e.g:

  • file name
  • database description
Parameters
desca descriptor string

Implements marlinmt::ConfigWriter.

Definition at line 64 of file XMLConfigWriter.cc.

References _fname.

◆ write()

void marlinmt::XMLConfigWriter::write ( const Configuration cfg)
overridevirtual

Member Data Documentation

◆ _fname

std::string marlinmt::XMLConfigWriter::_fname {}
private

The output file name.

Definition at line 58 of file XMLConfigWriter.cc.

Referenced by init(), and write().


The documentation for this class was generated from the following file: