EventAnalysis  1.0.0
Demangler.h
Go to the documentation of this file.
1 /*
2  * Demangler.h
3  *
4  * Created on: 01 Feb 2017
5  * Author: Nicola Mori
6  */
7 
8 #ifndef DEMANGLER_H_
9 #define DEMANGLER_H_
10 
11 #include <cxxabi.h>
12 #include <string>
13 
14 namespace EA {
15 
18 class Demangler {
19 
20 public:
26  template <class T> static std::string ClassName(const T &obj) {
27  int result;
28  char *demangled = abi::__cxa_demangle(typeid(obj).name(), NULL, NULL, &result);
29  if (result != 0) {
30  free(demangled);
31  return "";
32  } else {
33  std::string retValue(demangled);
34  free(demangled);
35  return retValue;
36  }
37  }
38 
46  template <class T> static std::string ClassName() {
47  int result;
48  char *demangled = abi::__cxa_demangle(typeid(T).name(), NULL, NULL, &result);
49  if (result != 0) {
50  free(demangled);
51  return "";
52  } else {
53  std::string retValue(demangled);
54  free(demangled);
55  return retValue;
56  }
57  }
58 
65  static std::string ClassName(const std::type_info &typeInfo) {
66  int result;
67  char *demangled = abi::__cxa_demangle(typeInfo.name(), NULL, NULL, &result);
68  if (result != 0) {
69  free(demangled);
70  return "";
71  } else {
72  std::string retValue(demangled);
73  free(demangled);
74  return retValue;
75  }
76  }
77 };
78 
79 } // namespace EA
80 
81 #endif /* DEMANGLER_H_ */
static std::string ClassName()
Static method which returns the name of the class.
Definition: Demangler.h:46
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
static std::string ClassName(const T &obj)
Static method which returns the name of the class.
Definition: Demangler.h:26
A simple name demangler.
Definition: Demangler.h:18
static std::string ClassName(const std::type_info &typeInfo)
Static method which returns the name of the class.
Definition: Demangler.h:65