00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __TYPE_TO_STRING_HH
00018 # define __TYPE_TO_STRING_HH
00019
00020 # include <catsfoot-config.hh>
00021 # ifdef HAVE_CXXABI_H
00022 # include <cxxabi.h>
00023 # include <cstdlib>
00024 # endif
00025 # include <string>
00026
00027 namespace catsfoot {
00028 namespace details {
00029
00034 template <typename T>
00035 std::string type_to_string() {
00036 std::string ret;
00037 # ifdef HAVE_CXXABI_H
00038 int status;
00039 char* name = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status);
00040 if (status != 0) {
00041 # endif
00042 ret = typeid(T).name();
00043 # ifdef HAVE_CXXABI_H
00044 }
00045 else {
00046 ret = name;
00047 free(name);
00048 }
00049 #endif
00050 return ret;
00051 }
00052
00053 }
00054 }
00055
00056 #endif