CMS 3D CMS Logo

ClassName.h
Go to the documentation of this file.
1 #ifndef UTILITIES_GENERAL_CLASSNAME_H
2 #define UTILITIES_GENERAL_CLASSNAME_H
3 //
4 #include <typeinfo>
5 #include <string>
6 #include <cstdlib>
7 
8 inline std::string firstNonNumeric(const char* sc) {
9  std::string s(sc);
10  size_t pos = s.find_first_not_of("0123456789");
11  s.erase(0, pos);
12  return s;
13 }
14 
15 class Demangle {
16 public:
17  Demangle(const char* sc);
18 
19  const char* operator()() const { return demangle; }
20 
22  if (demangle)
23  free((void*)demangle);
24  }
25 
26 private:
27  char* demangle;
28 };
29 
30 template <class T>
31 inline std::string className(const T& t) {
32  return std::string(Demangle(typeid(t).name())());
33 }
34 
35 template <class T>
36 class ClassName {
37 public:
38  static const std::string& name() {
39  static const std::string ln(Demangle(typeid(T).name())());
40  return ln;
41  }
42 };
43 
44 #endif // UTILITIES_GENERAL_CLASSNAME_H
pos
Definition: PixelAliasList.h:18
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ClassName::name
static const std::string & name()
Definition: ClassName.h:38
Demangle
Definition: ClassName.h:15
OrderedSet.t
t
Definition: OrderedSet.py:90
ClassName
Definition: ClassName.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
firstNonNumeric
std::string firstNonNumeric(const char *sc)
Definition: ClassName.h:8
Demangle::Demangle
Demangle(const char *sc)
Definition: ClassName.cc:5
Demangle::~Demangle
~Demangle()
Definition: ClassName.h:21
T
long double T
Definition: Basic3DVectorLD.h:48
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
className
std::string className(const T &t)
Definition: ClassName.h:31
Demangle::operator()
const char * operator()() const
Definition: ClassName.h:19
Demangle::demangle
char * demangle
Definition: ClassName.h:27