libalcommon  1.14.5
alcommon/alparamtype.h
Go to the documentation of this file.
00001 
00010 #pragma once
00011 #ifndef _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_
00012 #define _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_
00013 
00014 # include <typeinfo>
00015 # include <alcommon/detail/gettype.h>
00016 # include <cstdlib>
00017 
00018 // demangle on linux
00019 #ifndef _WIN32
00020 # include <cxxabi.h>
00021 #endif
00022 
00026 namespace AL
00027 {
00035   std::string getTypeString(int type);
00036 
00044   template <typename T>
00045   std::string getParamStrType() {
00046     int iType = detail::_get_type<T>::value;
00047     if (iType != 0)
00048       return getTypeString(iType);
00049 #ifndef _WIN32
00050     const       std::type_info &info = typeid(T);
00051     int         status;
00052     char*       realname = abi::__cxa_demangle(info.name(), 0, 0, &status);
00053     std::string realname_str = std::string(realname);
00054     free(realname);
00055     return realname_str;
00056 #else
00057     const std::type_info &info = typeid(T);
00058     return info.name();
00059 #endif
00060   }
00061 }
00062 
00063 #endif  // _LIBALCOMMON_ALCOMMON_ALPARAMTYPE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines