Awali
Another Weighted Automata library
demangle.hxx
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2023 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 #include <string>
21 
22 
23 #ifdef __GNUG__
24 
25 #include <cxxabi.h>
26 
27 
28 namespace awali { namespace internal {
29 
30  inline std::string demangle(char const* name)
31  {
32  int status = -4;
33  char* res = abi::__cxa_demangle(name, NULL, NULL, &status);
34  std::string str_res = (status == 0) ? res : name;
35  if (res != nullptr)
36  free(res);
37  return str_res;
38  }
39 
40 }} // namespace awali::internal
41 
42 #else
43 
44 namespace awali { namespace internal {
45 
46  inline std::string demangle(const char* name)
47  {
48  return name;
49  }
50 
51 }} // namespace awali::internal
52 
53 #endif
54 
55 #endif
std::string demangle(const char *name)
Definition: demangle.hxx:46
Main namespace of Awali.
Definition: ato.hh:22