summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-09-30 12:06:24 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-09-30 12:06:24 +0100
commit0d4520ccc18c3b0ff895278a3185af89f65e4db2 (patch)
tree2340cb07bd57205b714270650eb9f6bfdc950793
parentAdd traits for optionals (diff)
downloadslicer-0d4520ccc18c3b0ff895278a3185af89f65e4db2.tar.bz2
slicer-0d4520ccc18c3b0ff895278a3185af89f65e4db2.tar.xz
slicer-0d4520ccc18c3b0ff895278a3185af89f65e4db2.zip
Move demangle wrapper into modelParts
-rw-r--r--slicer/slicer/modelParts.cpp9
-rw-r--r--slicer/slicer/modelParts.h3
-rw-r--r--slicer/slicer/modelPartsTypes.cpp9
-rw-r--r--slicer/slicer/modelPartsTypes.h1
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 <cxxabi.h>
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<char, decltype(free) *>(
+ 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<typename T> 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 <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index_container.hpp>
#include <cstdlib>
-#include <cxxabi.h>
#include <functional>
#include <map>
#include <memory>
@@ -237,14 +236,6 @@ namespace Slicer {
return (id == className) ? TypeId() : ToExchangeTypeName(id);
}
- std::string
- ModelPartForComplexBase::demangle(const char * mangled)
- {
- auto buf = std::unique_ptr<char, decltype(free) *>(
- 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<std::string_view> typeName, const ClassRefBase *);
static void unregisterClass(const std::string_view className, const std::optional<std::string_view> 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 &);