Teuchos_TypeNameTraits.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "Teuchos_TypeNameTraits.hpp"
00030 #include "Teuchos_TestForException.hpp"
00031
00032
00033
00034
00035 #if defined(HAVE_GCC_ABI_DEMANGLE) && defined(HAVE_TEUCHOS_DEMANGLE)
00036 # include <cxxabi.h>
00037 #endif
00038
00039
00040 std::string Teuchos::demangleName( const std::string &mangledName )
00041 {
00042 #if defined(HAVE_GCC_ABI_DEMANGLE) && defined(HAVE_TEUCHOS_DEMANGLE)
00043 int status;
00044 char *_demangledName = abi::__cxa_demangle(mangledName.c_str(),0,0,&status);
00045 if (status != 0 || 0==_demangledName) {
00046 #ifdef TEUCHOS_DEBUG
00047 std::string nullstr("NULL");
00048 const char* demangle_output = _demangledName ? _demangledName : nullstr.c_str();
00049 TEST_FOR_EXCEPTION(
00050 true, std::logic_error,
00051 "Error, name demangling with g++ has been enabled but the function "
00052 "abi::__cxa_demangle("<<mangledName<<") returned returnVal = "<<demangle_output
00053 <<" and status = "<<status<<". Name demangling for this build"
00054 "can be turned off by using --disable-teuchos-demangle at configure time." );
00055 #endif
00056 if (_demangledName != NULL)
00057 free(_demangledName);
00058 return ( mangledName + "<demangle-failed>" );
00059 }
00060 const std::string demangledName(_demangledName);
00061 free(_demangledName);
00062 return demangledName;
00063 #else
00064 return mangledName;
00065 #endif
00066 }