Skip to content

Commit

Permalink
added more pretty-prints to demangler
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Feb 19, 2024
1 parent 6c9929c commit 3073f29
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions include/behaviortree_cpp/utils/demangle_util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DEMANGLE_UTIL_H
#define DEMANGLE_UTIL_H

#include <chrono>
#include <string>
#include <typeindex>

Expand Down Expand Up @@ -83,44 +84,39 @@ 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)
{
return p;
}
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
Expand Down

0 comments on commit 3073f29

Please sign in to comment.