libalcommon  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alparamtype.h
Go to the documentation of this file.
1 
10 #pragma once
11 #ifndef _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_
12 #define _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_
13 
14 # include <typeinfo>
15 # include <alcommon/detail/gettype.h>
16 # include <cstdlib>
17 
18 // demangle on linux
19 #ifndef _WIN32
20 # include <cxxabi.h>
21 #endif
22 
26 namespace AL
27 {
35  std::string getTypeString(int type);
36 
44  template <typename T>
45  std::string getParamStrType() {
46  int iType = detail::_get_type<T>::value;
47  if (iType != 0)
48  return getTypeString(iType);
49 #ifndef _WIN32
50  const std::type_info &info = typeid(T);
51  int status;
52  char* realname = abi::__cxa_demangle(info.name(), 0, 0, &status);
53  std::string realname_str = std::string(realname);
54  free(realname);
55  return realname_str;
56 #else
57  const std::type_info &info = typeid(T);
58  return info.name();
59 #endif
60  }
61 }
62 
63 #endif // _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_