types.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #include <gtsam/base/types.h>
21 
22 #ifdef _WIN32
23 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25 #include <DbgHelp.h>
26 #endif
27 
28 #ifdef __GNUG__
29 #include <cstdlib>
30 #include <cxxabi.h>
31 #include <string>
32 #endif
33 
34 namespace gtsam {
35 
37 std::string demangle(const char* name) {
38  // by default set to the original mangled name
39  std::string demangled_name = std::string(name);
40 
41 #ifdef __GNUG__
42  // g++ version of demangle
43  char* demangled = nullptr;
44  int status = -1; // some arbitrary value to eliminate the compiler warning
45  demangled = abi::__cxa_demangle(name, nullptr, nullptr, &status),
46 
47  demangled_name = (status == 0) ? std::string(demangled) : std::string(name);
48 
49  std::free(demangled);
50 
51 #elif _WIN32
52  char undecorated_name[1024];
53 
54  if (UnDecorateSymbolName(
55  name, undecorated_name, sizeof(undecorated_name),
56  UNDNAME_COMPLETE))
57  {
58  // successful conversion, take value from: undecorated_name
59  demangled_name = std::string(undecorated_name);
60  }
61  // else keep using mangled name
62 #endif
63 
64  return demangled_name;
65 }
66 
67 } /* namespace gtsam */
Typedefs for easier changing of types.
std::string demangle(const char *name)
Pretty print Value type name.
Definition: types.cpp:37
traits
Definition: chartTesting.h:28
Annotation for function names.
Definition: attr.h:36


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:19