msbGrid  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
classname.hh
Go to the documentation of this file.
1 /*****************************************************************************
2 * This program is part of the msbGrid software *
3 * *
4 * msbGrid stands for multi-structured block Grid generator *
5 * *
6 * msbGrid is a free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * msbGrid is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * See the file COPYING for full copying permissions. *
17 *****************************************************************************/
25 #ifndef _CLASSNAME_HH_
26 #define _CLASSNAME_HH_
27 
28 #include <cstdlib>
29 #include <string>
30 #include <typeinfo>
31 
32 #if defined( __GNUC__ ) && !defined( __clang__ )
33  #include <cxxabi.h>
34 #endif // #ifdef __GNUC__
35 
36 namespace msbGrid
37 {
39 template< class T >
40 std :: string className()
41 {
42  std :: string className = typeid( T ).name();
43 #if defined( __GNUC__ ) && !defined( __clang__ )
44  int status;
45  char *demangled = abi :: __cxa_demangle(className.c_str(), 0, 0, & status);
46  if ( demangled ) {
47  className = demangled;
48  std :: free(demangled);
49  }
50 
51 #endif // #ifdef __GNUC__
52  return className;
53 }
54 } // namespace msbGrid
55 
56 #endif // _CLASSNAME_HH_