Function demangle

Synopsis

#include <lib/inc/drogon/DrClassMap.h>

static std::string demangle(const char *mangled_name)

Description

demangle the type name which is returned by typeid(T).name().

Parameters:

mangled_name - The type name which is returned by typeid(T).name().

Return
std::string The human readable type name.

Source

Lines 107-128 in lib/inc/drogon/DrClassMap.h.

static std::string demangle(const char *mangled_name)
{
def _MSC_VER
    std::size_t len = 0;
    int status = 0;
    std::unique_ptr<char, decltype(&std::free)> ptr(
        __cxxabiv1::__cxa_demangle(mangled_name, nullptr, &len, &status),
        &std::free);
    if (status == 0)
    {
        return std::string(ptr.get());
    }
    LOG_ERROR << "Demangle error!";
    return "";
e
    auto pos = strstr(mangled_name, " ");
    if (pos == nullptr)
        return std::string{mangled_name};
    else
        return std::string{pos + 1};
if
}





Add Discussion as Guest

Log in to DocsForge