From 2a7cf31471c2be48e0101be058ca33a310fc8e7c Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Wed, 11 Dec 2024 00:23:47 +0100 Subject: [PATCH] Add DemangleTypeName function --- openVulkanoCpp/Base/Utils.cpp | 13 ++++++++++++- openVulkanoCpp/Base/Utils.hpp | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Base/Utils.cpp b/openVulkanoCpp/Base/Utils.cpp index f9bb154..e1bb9ea 100644 --- a/openVulkanoCpp/Base/Utils.cpp +++ b/openVulkanoCpp/Base/Utils.cpp @@ -10,6 +10,7 @@ #include #else #include + #include #endif #include #include @@ -90,5 +91,15 @@ namespace OpenVulkano template Array Utils::ReadFile(const std::string& filePath, bool emptyOnMissing, bool nullTerminateString); template Array Utils::ReadFile(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 res(abi::__cxa_demangle(name, NULL, NULL, &status), std::free); + return (status==0) ? res.get() : name ; + #endif + } } diff --git a/openVulkanoCpp/Base/Utils.hpp b/openVulkanoCpp/Base/Utils.hpp index 0999241..8782429 100644 --- a/openVulkanoCpp/Base/Utils.hpp +++ b/openVulkanoCpp/Base/Utils.hpp @@ -196,5 +196,7 @@ namespace OpenVulkano static const int id = uniqueTypeID++; return id; } + + static std::string DemangleTypeName(const char* name); }; }