DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Helper.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef XML_HELPER_H
14 #define XML_HELPER_H
15 
16 // Framework include files
17 #include <XML/XML.h>
18 #include <DD4hep/Detector.h>
19 #include <DD4hep/DD4hepUnits.h>
20 
22 namespace dd4hep {
23 
28  template <typename T>
29  T getAttrOrDefault(const dd4hep::xml::Element& e, const dd4hep::xml::XmlChar* attr_name, T default_value)
30  {
31  return (e.hasAttr(attr_name)) ? e.attr<T>(attr_name) : std::move(default_value);
32  }
33 
35  namespace detail {
36 
38  static inline std::string _toString(const dd4hep::xml::XmlChar* value) {
39  return xml::_toString(value);
40  }
41 
43  template <typename T> inline std::string _toString(T value, const char* fmt) {
44  return xml::_toString(value, fmt);
45  }
46  }
47 }
48 
49 #endif // XML_HELPER_H
Detector.h
dd4hep::_toString
std::string _toString(bool value)
String conversions: boolean value to string.
Definition: Handle.cpp:332
dd4hep::getAttrOrDefault
T getAttrOrDefault(const dd4hep::xml::Element &e, const dd4hep::xml::XmlChar *attr_name, T default_value)
Definition: Helper.h:29
dd4hep::xml::_toString
std::string _toString(const Attribute attr)
Convert xml attribute to STL string.
Definition: XMLElements.cpp:234
dd4hep::xml::Element::hasAttr
bool hasAttr(const XmlChar *name) const
Check for the existence of a named attribute.
Definition: XMLElements.h:847
XML.h
dd4hep::xml::XmlChar
XERCES_XMLCH_T XmlChar
Use the definition from the autoconf header of Xerces:
Definition: config.h:53
dd4hep::xml::Element
User abstraction class to manipulate XML elements within a document.
Definition: XMLElements.h:769
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
DD4hepUnits.h
dd4hep::xml::Element::attr
T attr(const XmlAttr *att) const
Access attribute with implicit return type conversion.
Definition: XMLElements.h:851