Add DemangleTypeName function

This commit is contained in:
Georg Hagen
2024-12-11 00:23:47 +01:00
parent 6ca7329f7a
commit 2a7cf31471
2 changed files with 14 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
#include <Windows.h>
#else
#include <pthread.h>
#include <cxxabi.h>
#endif
#include <fstream>
#include <filesystem>
@@ -90,5 +91,15 @@ namespace OpenVulkano
template Array<char> Utils::ReadFile<std::string>(const std::string& filePath, bool emptyOnMissing, bool nullTerminateString);
template Array<char> Utils::ReadFile<std::filesystem::path>(const std::filesystem::path& filePath,
bool emptyOnMissing, bool nullTerminateString);
std::string Utils::DemangleTypeName(const char* name)
{
#ifdef _MSC_VER
return name
#else
int status = 0;
std::unique_ptr<char, void(*)(void*)> res(abi::__cxa_demangle(name, NULL, NULL, &status), std::free);
return (status==0) ? res.get() : name ;
#endif
}
}

View File

@@ -196,5 +196,7 @@ namespace OpenVulkano
static const int id = uniqueTypeID++;
return id;
}
static std::string DemangleTypeName(const char* name);
};
}