From 3073f2904921fa248185f293f046358c97a42eed Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Mon, 19 Feb 2024 13:20:52 +0100 Subject: [PATCH] added more pretty-prints to demangler --- .../behaviortree_cpp/utils/demangle_util.h | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/include/behaviortree_cpp/utils/demangle_util.h b/include/behaviortree_cpp/utils/demangle_util.h index 1b986084a..93c90d2ad 100644 --- a/include/behaviortree_cpp/utils/demangle_util.h +++ b/include/behaviortree_cpp/utils/demangle_util.h @@ -1,6 +1,7 @@ #ifndef DEMANGLE_UTIL_H #define DEMANGLE_UTIL_H +#include #include #include @@ -83,30 +84,24 @@ inline std::string demangle(const std::type_index& index) { return "std::string"; } - - scoped_demangled_name demangled_name(index.name()); - char const* const p = demangled_name.get(); - if (p) + if (index == typeid(std::string_view)) { - return p; + return "std::string_view"; } - else + if (index == typeid(std::chrono::seconds)) { - return index.name(); + return "std::chrono::seconds"; } -} - -inline std::string demangle(const std::type_info* info) -{ - if (!info) + if (index == typeid(std::chrono::milliseconds)) { - return "void"; + return "std::chrono::milliseconds"; } - if (info == &typeid(std::string)) + if (index == typeid(std::chrono::microseconds)) { - return "std::string"; + return "std::chrono::microseconds"; } - scoped_demangled_name demangled_name(info->name()); + + scoped_demangled_name demangled_name(index.name()); char const* const p = demangled_name.get(); if (p) { @@ -114,13 +109,14 @@ inline std::string demangle(const std::type_info* info) } else { - return info->name(); + return index.name(); } } + inline std::string demangle(const std::type_info& info) { - return demangle(&info); + return demangle(std::type_index(info)); } } // namespace BT