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

simplify exceptions creation in castApi

parent 019176f6
No related branches found
No related tags found
No related merge requests found
......@@ -34,9 +34,7 @@ struct castApi {
std::map < std::type_index, std::function < alib::Object ( const alib::ObjectBase & ) > >::iterator res = castFunctions.find ( std::type_index ( typeid ( from ) ) );
 
if ( res == castFunctions.end ( ) ) {
char* name = std::type_name(typeid(from));
std::string fromType(name);
std::free(name);
std::string fromType = std::cstringToString(std::type_name(typeid(from)));
 
throw exception::CommonException ( "Bad cast: From: " + fromType + " To: " + toType());
}
......@@ -72,9 +70,7 @@ struct castApi {
}
 
std::string toType ( ) {
char* name = std::type_name<To>();
std::string toType(name);
std::free(name);
std::string toType = std::cstringToString(std::type_name<To>());
return toType;
}
 
......@@ -131,9 +127,7 @@ public:
std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( typeId );
 
if ( res == castFunctionsById ( ).end ( ) ) {
char* name = std::type_name( typeId );
std::string toType(name);
std::free(name);
std::string toType = std::cstringToString(std::type_name( typeId ));
 
throw exception::CommonException ( "Casting to type " + toType + " not available." );
} else
......
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