include
hardware_interface
internal
demangle_symbol.h
Go to the documentation of this file.
1
// Copyright (C) 2013, PAL Robotics S.L.
3
//
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are met:
6
// * Redistributions of source code must retain the above copyright notice,
7
// this list of conditions and the following disclaimer.
8
// * Redistributions in binary form must reproduce the above copyright
9
// notice, this list of conditions and the following disclaimer in the
10
// documentation and/or other materials provided with the distribution.
11
// * Neither the name of hiDOF, Inc. nor the names of its
12
// contributors may be used to endorse or promote products derived from
13
// this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
27
29
30
#pragma once
31
32
33
#include <cstdlib>
34
#include <string>
35
36
#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
37
#include <cxxabi.h>
38
#endif
39
40
namespace
hardware_interface
41
{
42
namespace
internal
43
{
44
50
inline
std::string
demangleSymbol
(
const
char
* name)
51
{
52
#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
53
int
status;
54
char
* res = abi::__cxa_demangle(name,
nullptr
,
nullptr
, &status);
55
if
(res)
56
{
57
const
std::string demangled_name(res);
58
std::free(res);
59
return
demangled_name;
60
}
61
// Demangling failed, fallback to mangled name
62
return
std::string(name);
63
#else
64
return
std::string(name);
65
#endif
66
}
67
72
template
<
class
T>
73
inline
std::string
demangledTypeName
()
74
{
75
return
demangleSymbol
(
typeid
(T).name());
76
}
77
82
template
<
class
T>
83
inline
std::string
demangledTypeName
(
const
T& val)
84
{
85
return
demangleSymbol
(
typeid
(val).name());
86
}
87
88
}
89
90
}
hardware_interface::internal::demangledTypeName
std::string demangledTypeName()
Convenience method for demangling type names.
Definition:
demangle_symbol.h:73
hardware_interface::internal::demangleSymbol
std::string demangleSymbol(const char *name)
Demangle symbol, if symbol demangling is available.
Definition:
demangle_symbol.h:50
hardware_interface
Definition:
actuator_command_interface.h:36
hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Tue Oct 15 2024 02:08:19