Awali
Another Weighted Automata library
demangle.hxx
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_DEMANGLE_CC
18 #define AWALI_DEMANGLE_CC
19 
20 
21 #ifdef __GNUG__
22 
23 #include<cxxabi.h>
24 
25 
26 namespace awali {
27  namespace internal {
28 
29  inline std::string demangle(char const* name)
30  {
31  int status = -4;
32  char* res = abi::__cxa_demangle (name, NULL, NULL, &status);
33  std::string str_res = (status == 0)?res:name ;
34  if (res != nullptr)
35  free(res);
36  return str_res;
37  }
38 
39  }
40 }
41 
42 #else
43 
44 namespace awali {
45  namespace internal {
46 
47  inline std::string
48  demangle(const char* name)
49  { return name; }
50 
51  }
52 }
53 
54 #endif
55 
56 #endif
std::string demangle(const char *name)
Definition: demangle.hxx:48
Main namespace of Awali.
Definition: ato.hh:22