|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #include "Teuchos_TypeNameTraits.hpp" 00030 #include "Teuchos_TestForException.hpp" 00031 00032 // Define this if you want to fource name demangling if supported 00033 //#define HAVE_TEUCHOS_DEMANGLE 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); // We have to free this before we return! 00062 return demangledName; 00063 #else 00064 return mangledName; 00065 #endif 00066 }
1.7.4