Skip to content
Snippets Groups Projects
Commit 19c07d82 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

more concrete cast

parent 3976194a
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
 
#include <exception/AlibException.h>
#include <factory/XmlDataFactory.hpp>
#include <cxxabi.h>
 
template<typename T, typename R, typename std::enable_if< std::is_constructible<T, R>::value >::type* = nullptr >
T cast(const R& orig) {
......@@ -84,7 +85,15 @@ public:
 
template<typename BaseVisitor, typename Base, typename Types, typename R, typename ... Rs >
void cast_helper<BaseVisitor, Base, Types, R, Rs ...>::do_cast(const std::string& name, const Base& obj) {
if(std::string(typeid(R).name()).find(name) != std::string::npos) {
int status;
char namespaceId[100];
char classId[100];
char* ret = abi::__cxa_demangle(typeid(R).name(), 0, 0, &status);
sscanf(ret, "%[a-zA-Z]::%[a-zA-Z]", namespaceId, classId);
free( ret );
if(std::string(classId) == name) {
cast_implementer<BaseVisitor, Base, R, Types>::cast(obj);
} else {
cast_helper<BaseVisitor, Base, Types, Rs ...>::do_cast(name, obj);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment