Skip to content

Commit 3073f29

Browse files
committed
added more pretty-prints to demangler
1 parent 6c9929c commit 3073f29

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

include/behaviortree_cpp/utils/demangle_util.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef DEMANGLE_UTIL_H
22
#define DEMANGLE_UTIL_H
33

4+
#include <chrono>
45
#include <string>
56
#include <typeindex>
67

@@ -83,44 +84,39 @@ inline std::string demangle(const std::type_index& index)
8384
{
8485
return "std::string";
8586
}
86-
87-
scoped_demangled_name demangled_name(index.name());
88-
char const* const p = demangled_name.get();
89-
if (p)
87+
if (index == typeid(std::string_view))
9088
{
91-
return p;
89+
return "std::string_view";
9290
}
93-
else
91+
if (index == typeid(std::chrono::seconds))
9492
{
95-
return index.name();
93+
return "std::chrono::seconds";
9694
}
97-
}
98-
99-
inline std::string demangle(const std::type_info* info)
100-
{
101-
if (!info)
95+
if (index == typeid(std::chrono::milliseconds))
10296
{
103-
return "void";
97+
return "std::chrono::milliseconds";
10498
}
105-
if (info == &typeid(std::string))
99+
if (index == typeid(std::chrono::microseconds))
106100
{
107-
return "std::string";
101+
return "std::chrono::microseconds";
108102
}
109-
scoped_demangled_name demangled_name(info->name());
103+
104+
scoped_demangled_name demangled_name(index.name());
110105
char const* const p = demangled_name.get();
111106
if (p)
112107
{
113108
return p;
114109
}
115110
else
116111
{
117-
return info->name();
112+
return index.name();
118113
}
119114
}
120115

116+
121117
inline std::string demangle(const std::type_info& info)
122118
{
123-
return demangle(&info);
119+
return demangle(std::type_index(info));
124120
}
125121

126122
} // namespace BT

0 commit comments

Comments
 (0)