uniform_type_name.h
Go to the documentation of this file.
1 #ifndef canvas_Utilities_uniform_type_name_h
2 #define canvas_Utilities_uniform_type_name_h
3 
4 #include "cetlib_except/demangle.h"
5 
6 #include <string>
7 #include <typeinfo>
8 
9 namespace art {
10  /// \fn uniform_type_name
11  ///
12  /// \brief Calculate the uniform type name of the provided type.
13  ///
14  /// The CXXABI demangle function can return an answer which is
15  /// compiler-dependent. This function attempts to manipulate that
16  /// compiler-dependent name into a form which is compatible with that
17  /// produced by Reflex::Type::Name(Reflex::SCOPED), for historical
18  /// reasons.
19  ///
20  /// This has been verified to produce good output with GCC 4.9.2.
21  ///
22  /// Adapted from CMSSW's TypeDemangler (authors Bill Tannenbaum and
23  /// Paul Russo).
24  ///
25  /// \returns the uniform type name.
26  ///
27  /// \param[in] tid A reference to the std::type_info for the type in
28  /// question.
29  std::string uniform_type_name(std::type_info const& tid);
30  ///
31  /// \param[in] name The already-demangled name for a type.
33 }
34 
35 inline std::string
36 art::uniform_type_name(std::type_info const& tid)
37 {
38  return uniform_type_name(cet::demangle_symbol(tid.name()));
39 }
40 
41 #endif /* canvas_Utilities_uniform_type_name_h */
42 
43 // Local variables:
44 // mode:c++
45 // End:
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::string uniform_type_name(std::type_info const &tid)