From 0d4520ccc18c3b0ff895278a3185af89f65e4db2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 30 Sep 2023 12:06:24 +0100 Subject: Move demangle wrapper into modelParts --- slicer/slicer/modelParts.cpp | 9 +++++++++ slicer/slicer/modelParts.h | 3 +++ slicer/slicer/modelPartsTypes.cpp | 9 --------- slicer/slicer/modelPartsTypes.h | 1 - 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp index 2b2a5ef..f09e0ad 100644 --- a/slicer/slicer/modelParts.cpp +++ b/slicer/slicer/modelParts.cpp @@ -1,4 +1,5 @@ #include "modelParts.h" +#include namespace Slicer { void @@ -75,6 +76,14 @@ namespace Slicer { throw std::logic_error {"OnContained not supported on this ModelPart"}; } + std::string + ModelPart::demangle(const char * mangled) + { + auto buf = std::unique_ptr( + abi::__cxa_demangle(mangled, nullptr, nullptr, nullptr), std::free); + return "::" + std::string(buf.get()); + } + bool HookCommon::filter(const HookFilter & flt) const { diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index d34552e..65be827 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -157,6 +157,9 @@ namespace Slicer { [[nodiscard]] virtual const Metadata & GetMetadata() const; [[nodiscard]] virtual bool IsOptional() const; virtual void OnContained(const ModelPartHandler &); + + protected: + static std::string demangle(const char * mangled); }; template class DLL_PUBLIC ModelPartModel { diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 0fa502b..0e3f78a 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -237,14 +236,6 @@ namespace Slicer { return (id == className) ? TypeId() : ToExchangeTypeName(id); } - std::string - ModelPartForComplexBase::demangle(const char * mangled) - { - auto buf = std::unique_ptr( - abi::__cxa_demangle(mangled, nullptr, nullptr, nullptr), std::free); - return "::" + std::string(buf.get()); - } - void ModelPartForOptionalBase::OnEachChild(const ChildHandler & ch) { diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 93339db..edfb4a7 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -155,7 +155,6 @@ namespace Slicer { const std::string_view className, const std::optional typeName, const ClassRefBase *); static void unregisterClass(const std::string_view className, const std::optional typeName); static TypeId getTypeId(const std::string & id, const std::string_view className); - static std::string demangle(const char * mangled); static const std::string & ToExchangeTypeName(const std::string &); static std::string_view ToModelTypeName(const std::string &); -- cgit v1.2.3