diff --git a/acast2/src/acast.cpp b/acast2/src/acast.cpp index 25bd0c26fc23d3172996804e9ce490276fd6b1a0..6fe5f611fa2e42c4c7b03a46d7bebe72133c346e 100644 --- a/acast2/src/acast.cpp +++ b/acast2/src/acast.cpp @@ -26,7 +26,7 @@ alib::Object doCast ( const alib::Object & in, const std::string & to ) { if ( alib::castApi::getCastPool ( toType ).castAvailable ( inType ) ) return alib::castApi::getCastPool ( toType ).cast ( inObject ); - throw exception::CommonException ( "Cast from " + std::type_name ( inType ) + " to " + to + " not available" ); + throw exception::CommonException ( "Cast from " + ext::to_string ( inType ) + " to " + to + " not available" ); } int main(int argc, char** argv) { diff --git a/alib2cli/src/ast/statements/SingleStatement.h b/alib2cli/src/ast/statements/SingleStatement.h index 54a51cb36f027d9c19fb0d1e2292aa49957c2449..11de57e28dfa93a14ebf6de909016e999d72fbe6 100644 --- a/alib2cli/src/ast/statements/SingleStatement.h +++ b/alib2cli/src/ast/statements/SingleStatement.h @@ -34,7 +34,7 @@ public: unsigned i = 0; for ( const std::shared_ptr < abstraction::OperationAbstraction > & param : params ) { if ( ! algo->attachInput ( param, i ) ) - throw exception::CommonException ( "Can't connect param at " + ext::to_string ( i ) + " of algorithm " + m_name + " with result of type " + std::type_name ( param->type ( ) ) + "." ); + throw exception::CommonException ( "Can't connect param at " + ext::to_string ( i ) + " of algorithm " + m_name + " with result of type " + ext::to_string ( param->type ( ) ) + "." ); i++; } diff --git a/alib2common/src/abstraction/AlgorithmAbstraction.hpp b/alib2common/src/abstraction/AlgorithmAbstraction.hpp index 273789b69220b24e5da090177e0219eb1c76bd8a..bf1a0e55020885b92f581c443e2083a01a6b791e 100644 --- a/alib2common/src/abstraction/AlgorithmAbstraction.hpp +++ b/alib2common/src/abstraction/AlgorithmAbstraction.hpp @@ -113,7 +113,7 @@ public: virtual std::shared_ptr < OperationAbstraction > getImmediateValueFromParam ( unsigned index, const std::string & value ) const override { auto callback = [ & ] ( auto & param ) { - std::string paramType = std::type_name < typename std::decay < decltype ( param ) >::type::element_type::return_type > ( ); + std::string paramType = ext::to_string < typename std::decay < decltype ( param ) >::type::element_type::return_type > ( ); return Registry::getImmediateAbstraction ( std::move ( paramType ), value ); }; return std::call_on_nth < std::shared_ptr < OperationAbstraction > > ( inputs, index, callback ); @@ -121,7 +121,7 @@ public: virtual std::shared_ptr < OperationAbstraction > getXmlParserFromParam ( unsigned index, std::deque < sax::Token > tokens ) const override { auto callback = [ & ] ( auto & param ) { - std::string paramType = std::type_name < typename std::decay < decltype ( param ) >::type::element_type::return_type > ( ); + std::string paramType = ext::to_string < typename std::decay < decltype ( param ) >::type::element_type::return_type > ( ); return Registry::getXmlParserAbstraction ( std::move ( paramType ), std::move ( tokens ) ); }; return std::call_on_nth < std::shared_ptr < OperationAbstraction > > ( inputs, index, callback ); diff --git a/alib2common/src/abstraction/AlgorithmRegistry.hpp b/alib2common/src/abstraction/AlgorithmRegistry.hpp index d0be14f639f5cd7d3d1d9e20f8283fe062e46c0c..0ffc10c83c3de935283dc201b64fb83604b086e4 100644 --- a/alib2common/src/abstraction/AlgorithmRegistry.hpp +++ b/alib2common/src/abstraction/AlgorithmRegistry.hpp @@ -69,7 +69,7 @@ class AlgorithmRegistry { public: template < class Algo, class ReturnType, class ... ParamTypes > static void registerAlgorithm ( ReturnType ( * callback ) ( ParamTypes ... ), bool downcast, bool normalize ) { - std::string algorithm = std::type_name < Algo > ( ); + std::string algorithm = ext::to_string < Algo > ( ); std::vector < std::type_index > params; ( void ) std::initializer_list < int > { ( params.push_back ( std::type_index ( typeid ( typename std::decay < ParamTypes >::type ) ) ), 0 ) ... }; diff --git a/alib2common/src/abstraction/CastRegistry.hpp b/alib2common/src/abstraction/CastRegistry.hpp index f365c635a6683f88fb1f21f5ecf841ab9ea6b52a..d98fe5d7db8bb5729b4476f3a13eb25af8f9314f 100644 --- a/alib2common/src/abstraction/CastRegistry.hpp +++ b/alib2common/src/abstraction/CastRegistry.hpp @@ -56,8 +56,8 @@ public: template < class TargetType, class ParamType > static void registerCast ( ) { - std::string target = std::type_name < TargetType > ( ); - std::string param = std::type_name < ParamType > ( ); + std::string target = ext::to_string < TargetType > ( ); + std::string param = ext::to_string < ParamType > ( ); registerCast < TargetType, ParamType > ( target, param ); } @@ -70,8 +70,8 @@ public: template < class TargetType, class ParamType > static void registerCastAlgorithm ( TargetType ( * callback ) ( ParamType ) ) { - std::string target = std::type_name < TargetType > ( ); - std::string param = std::type_name < ParamType > ( ); + std::string target = ext::to_string < TargetType > ( ); + std::string param = ext::to_string < ParamType > ( ); registerCastAlgorithm < TargetType, ParamType > ( target, param, callback ); } diff --git a/alib2common/src/abstraction/DowncastRegistry.hpp b/alib2common/src/abstraction/DowncastRegistry.hpp index 223fe6ced478c31043d79c3c499e6991d595ee01..8d06eb442347ef94656cf10cb3107177ea6203bc 100644 --- a/alib2common/src/abstraction/DowncastRegistry.hpp +++ b/alib2common/src/abstraction/DowncastRegistry.hpp @@ -40,8 +40,8 @@ class DowncastRegistry { public: template < class ConcreteType, class BaseType > static void registerDowncast ( ) { - std::string concrete = std::type_name < ConcreteType > ( ); - std::string base = std::type_name < BaseType > ( ); + std::string concrete = ext::to_string < ConcreteType > ( ); + std::string base = ext::to_string < BaseType > ( ); if ( ! getEntries ( ).insert ( std::make_pair ( std::make_pair ( concrete, base ), std::unique_ptr < Entry > ( new EntryImpl < ConcreteType, BaseType > ( ) ) ) ).second ) throw ::exception::CommonException ( "Downcasting for " + base + " to " + concrete + " already registered." ); } diff --git a/alib2common/src/abstraction/ImmediateRegistry.hpp b/alib2common/src/abstraction/ImmediateRegistry.hpp index e85b18c6e9fec3bc0f0561e8d5635ebb1d9d310a..2c4e2a61012e2e3f19c7d766979d34e668fb2788 100644 --- a/alib2common/src/abstraction/ImmediateRegistry.hpp +++ b/alib2common/src/abstraction/ImmediateRegistry.hpp @@ -48,7 +48,7 @@ public: template < class ResultType > static void registerImmediate ( ) { - std::string result = std::type_name < ResultType > ( ); + std::string result = ext::to_string < ResultType > ( ); registerImmediate < ResultType > ( std::move ( result ) ); } diff --git a/alib2common/src/abstraction/NormalizeRegistry.hpp b/alib2common/src/abstraction/NormalizeRegistry.hpp index 45d4429f5f26f1cb67f913bff55409141f0c15bf..8bc3c093b0f818beee1a907ac627fd9b10957d59 100644 --- a/alib2common/src/abstraction/NormalizeRegistry.hpp +++ b/alib2common/src/abstraction/NormalizeRegistry.hpp @@ -45,7 +45,7 @@ public: template < class ParamType > static void registerNormalize ( ) { - std::string param = std::type_name < ParamType > ( ); + std::string param = ext::to_string < ParamType > ( ); registerNormalize < ParamType > ( std::move ( param ) ); } diff --git a/alib2common/src/abstraction/PrimitiveRegistrator.cpp b/alib2common/src/abstraction/PrimitiveRegistrator.cpp index eb4e8049c90c728a994cb765d1b0055ea400cc4b..370bb4b32d39aeaab66b35764ec8f0a176c3b9cb 100644 --- a/alib2common/src/abstraction/PrimitiveRegistrator.cpp +++ b/alib2common/src/abstraction/PrimitiveRegistrator.cpp @@ -30,7 +30,7 @@ public: abstraction::CastRegistry::registerCast < bool, int > ( ); - abstraction::CastRegistry::registerCast < size_t, int > ( "size_t", std::type_name < int > ( ) ); + abstraction::CastRegistry::registerCast < size_t, int > ( "size_t", ext::to_string < int > ( ) ); abstraction::CastRegistry::registerCast < size_t, int > ( ); abstraction::CastRegistry::registerCast < int, size_t > ( ); diff --git a/alib2common/src/abstraction/UnaryOperationAbstraction.hpp b/alib2common/src/abstraction/UnaryOperationAbstraction.hpp index 01681e0ad6b02db4451714225fc28c1c706fead4..6a5e5668cf588140e535f7be639ddfc3a3bf8b0c 100644 --- a/alib2common/src/abstraction/UnaryOperationAbstraction.hpp +++ b/alib2common/src/abstraction/UnaryOperationAbstraction.hpp @@ -73,7 +73,7 @@ public: if ( index != 0 ) throw std::out_of_range ( "Invalid input index" ); - std::string paramType = std::type_name < ParamType > ( ); + std::string paramType = ext::to_string < ParamType > ( ); return Registry::getImmediateAbstraction ( std::move ( paramType ), value ); } @@ -81,7 +81,7 @@ public: if ( index != 0 ) throw exception::CommonException ( "Out of range index: " + ext::to_string ( index ) + " max: " + ext::to_string ( numberOfParams ( ) ) + "." ); - std::string paramType = std::type_name < ParamType > ( ); + std::string paramType = ext::to_string < ParamType > ( ); return Registry::getXmlParserAbstraction ( std::move ( paramType ), std::move ( tokens ) ); } }; diff --git a/alib2common/src/abstraction/ValueOperationAbstraction.hpp b/alib2common/src/abstraction/ValueOperationAbstraction.hpp index 85f5aa9c6a6437e14be4aa545956d448466afd97..bba6748cae983b6242376af613991cbc2f71fe6a 100644 --- a/alib2common/src/abstraction/ValueOperationAbstraction.hpp +++ b/alib2common/src/abstraction/ValueOperationAbstraction.hpp @@ -45,28 +45,28 @@ public: } virtual std::shared_ptr < OperationAbstraction > getXmlFileWriterFromResult ( const std::string & filename ) const override { - std::string param = std::type_name < ReturnType > ( ); + std::string param = ext::to_string < ReturnType > ( ); return Registry::getXmlFileWriterAbstraction ( param, filename ); } virtual std::shared_ptr < OperationAbstraction > getValuePrinterFromResult ( ) const override { - std::string param = std::type_name < ReturnType > ( ); + std::string param = ext::to_string < ReturnType > ( ); return Registry::getValuePrinterAbstraction ( param ); } virtual std::shared_ptr < OperationAbstraction > getCastFromResult ( const std::string & target ) const override { - std::string param = std::type_name < ReturnType > ( ); + std::string param = ext::to_string < ReturnType > ( ); return Registry::getCastAbstraction ( target, param ); } virtual std::shared_ptr < OperationAbstraction > getNormalizeResult ( ) const override { - std::string param = std::type_name < ReturnType > ( ); + std::string param = ext::to_string < ReturnType > ( ); return Registry::getNormalizeAbstraction ( param ); } virtual std::shared_ptr < OperationAbstraction > getDowncastResult ( ) const override { - std::string base = std::type_name < ReturnType > ( ); - std::string concrete = std::type_name ( runtime_type ( ) ); + std::string base = ext::to_string < ReturnType > ( ); + std::string concrete = ext::to_string ( runtime_type ( ) ); return Registry::getDowncastAbstraction ( concrete, base ); } diff --git a/alib2common/src/abstraction/ValuePrinterRegistry.hpp b/alib2common/src/abstraction/ValuePrinterRegistry.hpp index e18ceb73ecf21603726eae46b88c378f31132f44..3f87c784b2f214644537dde1ef94912a90efcd3b 100644 --- a/alib2common/src/abstraction/ValuePrinterRegistry.hpp +++ b/alib2common/src/abstraction/ValuePrinterRegistry.hpp @@ -45,7 +45,7 @@ public: template < class ParamType > static void registerValuePrinter ( ) { - std::string param = std::type_name < ParamType > ( ); + std::string param = ext::to_string < ParamType > ( ); registerValuePrinter < ParamType > ( std::move ( param ) ); } diff --git a/alib2common/src/abstraction/XmlFileWriterRegistry.hpp b/alib2common/src/abstraction/XmlFileWriterRegistry.hpp index 26ab05b9a561bf82e8e577faa5346e9d26534a8f..fcf1f7fcaeafbf53b13f4b95dae53f8298413294 100644 --- a/alib2common/src/abstraction/XmlFileWriterRegistry.hpp +++ b/alib2common/src/abstraction/XmlFileWriterRegistry.hpp @@ -45,7 +45,7 @@ public: template < class ParamType > static void registerXmlFileWriter ( ) { - std::string param = std::type_name < ParamType > ( ); + std::string param = ext::to_string < ParamType > ( ); registerXmlFileWriter < ParamType > ( std::move ( param ) ); } diff --git a/alib2common/src/core/castApi.hpp b/alib2common/src/core/castApi.hpp index ca3cde212bcbbfbf59bba4aa9ac215fad7dc8421..496a927009e71fa5ddd87f59872119ad13b28688 100644 --- a/alib2common/src/core/castApi.hpp +++ b/alib2common/src/core/castApi.hpp @@ -35,7 +35,7 @@ private: 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 ( ) ) { - std::string fromType = std::type_name ( typeid ( from ) ); + std::string fromType = ext::to_string ( typeid ( from ) ); throw exception::CommonException ( "Bad cast: From: " + fromType + " To: " + toType ( ) ); } @@ -58,8 +58,8 @@ private: return alib::Object ( castFunction ( static_cast < const From & > ( from ) ) ); } ) ).second; if ( ! res ) { - std::string fromName = std::type_name < From > ( ); - std::string toName = std::type_name < To > ( ); + std::string fromName = ext::to_string < From > ( ); + std::string toName = ext::to_string < To > ( ); throw::exception::CommonException ( "Casting from " + fromName + " to " + toName + " already registered." ); } @@ -86,7 +86,7 @@ private: } std::string toType ( ) { - return std::type_name < To > ( ); + return ext::to_string < To > ( ); } }; @@ -113,7 +113,7 @@ public: std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( typeId ); if ( res == castFunctionsById ( ).end ( ) ) { - std::string toType = std::type_name ( typeId ); + std::string toType = ext::to_string ( typeId ); throw exception::CommonException ( "Casting to type " + toType + " not available." ); } else { diff --git a/alib2common/src/core/components.hpp b/alib2common/src/core/components.hpp index a0915214962aa9f7df7fbc125d9fa505e46eeaf3..80df73fe9aa81cf28c5b86fd560b716db7a3cc8c 100644 --- a/alib2common/src/core/components.hpp +++ b/alib2common/src/core/components.hpp @@ -74,7 +74,7 @@ class Component { ComponentConstraint < Derived, DataType, SetType >::valid ( static_cast < const Derived & > ( * this ), symbol ); if ( !ComponentConstraint < Derived, DataType, SetType >::available ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( std::type_name < SetType * > ( ) ); + std::string elementTypeName ( ext::to_string < SetType * > ( ) ); elementTypeName.back ( ) = ' '; throw::exception::CommonException ( elementTypeName + "element " + ext::to_string ( symbol ) + " is not available." ); } @@ -86,7 +86,7 @@ class Component { */ void checkRemove ( const DataType & symbol ) { if ( ComponentConstraint < Derived, DataType, SetType >::used ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( std::type_name < SetType * > ( ) ); + std::string elementTypeName ( ext::to_string < SetType * > ( ) ); elementTypeName.back ( ) = ' '; throw::exception::CommonException ( elementTypeName + "element " + ext::to_string ( symbol ) + " is used." ); } @@ -239,7 +239,7 @@ class Element { ElementConstraint < Derived, DataType, ElementType >::valid ( static_cast < const Derived & > ( * this ), symbol ); if ( !ElementConstraint < Derived, DataType, ElementType >::available ( static_cast < const Derived & > ( * this ), symbol ) ) { - std::string elementTypeName ( std::type_name < ElementType * > ( ) ); + std::string elementTypeName ( ext::to_string < ElementType * > ( ) ); elementTypeName.back ( ) = ' '; throw::exception::CommonException ( elementTypeName + ext::to_string ( symbol ) + " is not available." ); } diff --git a/alib2common/src/core/multipleDispatch.hpp b/alib2common/src/core/multipleDispatch.hpp index 4219fee190dcac05941b3a1883d25a92df862494..4d63a26ec8fb81cce9885224776594e6d6da5a87 100644 --- a/alib2common/src/core/multipleDispatch.hpp +++ b/alib2common/src/core/multipleDispatch.hpp @@ -79,9 +79,9 @@ public: if ( ! res ) { std::stringstream ss; - ( void ) std::initializer_list < int > { ( ss << std::type_name < typename std::match_cv_ref < DispatchedParameterTypes, RealParameterTypeBases >::type > ( ), 0 ) ... }; + ( void ) std::initializer_list < int > { ( ss << ext::to_string < typename std::match_cv_ref < DispatchedParameterTypes, RealParameterTypeBases >::type > ( ), 0 ) ... }; - std::string classType = std::type_name < Algorithm > ( ); + std::string classType = ext::to_string < Algorithm > ( ); throw::exception::CommonException ( "Callback for " + ss.str ( ) + " already registered on " + classType + "." ); } @@ -92,9 +92,9 @@ public: if ( callback == getInstance ( ).registeredFunctions.end ( ) ) { std::stringstream ss; - ( void ) std::initializer_list < int > { ( ss << std::type_name ( typeid ( dispatched ) ), 0 ) ... }; + ( void ) std::initializer_list < int > { ( ss << ext::to_string ( typeid ( dispatched ) ), 0 ) ... }; - std::string classType = std::type_name < Algorithm > ( ); + std::string classType = ext::to_string < Algorithm > ( ); throw::exception::CommonException ( "Callback for " + ss.str ( ) + " not registered on " + classType + "." ); } @@ -190,9 +190,9 @@ public: bool res = getInstance ( ).registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( typename std::match_cv_ref < ParametersType, RealParametersTypeBase >::type ) ), std::move ( value ) ) ).second; if ( ! res ) { - std::string paramsType = std::type_name < typename std::match_cv_ref < ParametersType, RealParametersTypeBase >::type > ( ); + std::string paramsType = ext::to_string < typename std::match_cv_ref < ParametersType, RealParametersTypeBase >::type > ( ); - std::string classType = std::type_name < Algorithm > ( ); + std::string classType = ext::to_string < Algorithm > ( ); throw::exception::CommonException ( "Callback for " + paramsType + " already registered on " + classType + "." ); } @@ -209,11 +209,11 @@ public: if ( ( callback != getInstance ( ).registeredFunctions.end ( ) ) && callback->second->available ( false, std::type_index ( typeid ( first ) ), std::type_index ( typeid ( second ) ) ) ) return callback->second->eval ( false, std::forward < ParametersType > ( first ), std::forward < ParametersType > ( second ) ); - std::string firstType = std::type_name ( typeid ( first ) ); + std::string firstType = ext::to_string ( typeid ( first ) ); - std::string secondType = std::type_name ( typeid ( second ) ); + std::string secondType = ext::to_string ( typeid ( second ) ); - std::string classType = std::type_name < Algorithm > ( ); + std::string classType = ext::to_string < Algorithm > ( ); throw::exception::CommonException ( "Callback for (" + firstType + ", " + secondType + ") (promoting) not registered on " + classType + "." ); } diff --git a/alib2common/src/core/xmlApi.hpp b/alib2common/src/core/xmlApi.hpp index b28e5c651c07ce2e665480880d2d818b9a5f1665..7e30172b56ef1040664c70c18f217793fdb9b34d 100644 --- a/alib2common/src/core/xmlApi.hpp +++ b/alib2common/src/core/xmlApi.hpp @@ -133,8 +133,8 @@ public: static void registerType ( ) { bool res = parseFunctions ( ).insert ( std::make_pair ( xmlApi < Type >::xmlTagName(), std::unique_ptr < GroupParser > ( new ParserRegister < Type > ( ) ) ) ).second; if ( ! res ) { - std::string groupName = std::type_name < Group > ( ); - std::string typeName = std::type_name < Type > ( ); + std::string groupName = ext::to_string < Group > ( ); + std::string typeName = ext::to_string < Type > ( ); throw::exception::CommonException ( "Parse callback of " + typeName + " already registered in group " + groupName + "." ); } @@ -151,9 +151,9 @@ public: int id = ext::from_string < int > ( sax::FromXMLParserHelper::popTokenData ( input, sax::Token::TokenType::CHARACTER ) ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ATTRIBUTE, "id" ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "Ref" ); - std::map < int, WrapperBaseBase * >::iterator elem = input.idToInstance ( std::type_name < Group > ( ) ).find ( id ); + std::map < int, WrapperBaseBase * >::iterator elem = input.idToInstance ( ext::to_string < Group > ( ) ).find ( id ); - if ( elem == input.idToInstance ( std::type_name < Group > ( ) ).end ( ) ) { + if ( elem == input.idToInstance ( ext::to_string < Group > ( ) ).end ( ) ) { std::cerr << input.dump ( ) << std::endl; throw exception::CommonException ( "XML Inconsistent ( id not found " + ext::to_string ( id ) + " )" ); } @@ -176,7 +176,7 @@ public: /* if object is a base of reference, register it */ if ( ref ) - input.idToInstance ( std::type_name < Group > ( ) ).insert ( std::make_pair ( id, ( WrapperBaseBase * ) new Group ( res ) ) ); + input.idToInstance ( ext::to_string < Group > ( ) ).insert ( std::make_pair ( id, ( WrapperBaseBase * ) new Group ( res ) ) ); return res; } @@ -195,7 +195,7 @@ public: } static std::string xmlTagName ( ) { - std::string target = std::type_name < Group > ( ); + std::string target = ext::to_string < Group > ( ); throw ::exception::CommonException ( "Type " + target + " does not have xmlTagName." ); } @@ -203,9 +203,9 @@ public: static void compose ( std::deque < sax::Token > & output, const Group & data ) { xmlApiOutputContext & context = ( xmlApiOutputContext & ) output; - typename std::map < const CommonBaseBase *, int >::iterator elem = context.instanceToId ( std::type_name < Group > ( ) ).find ( static_cast < const CommonBaseBase * > ( & data.getData ( ) ) ); + typename std::map < const CommonBaseBase *, int >::iterator elem = context.instanceToId ( ext::to_string < Group > ( ) ).find ( static_cast < const CommonBaseBase * > ( & data.getData ( ) ) ); - if ( common::GlobalData::optimizeXml && elem != context.instanceToId ( std::type_name < Group > ( ) ).end ( ) ) { + if ( common::GlobalData::optimizeXml && elem != context.instanceToId ( ext::to_string < Group > ( ) ).end ( ) ) { output.emplace_back ( "Ref", sax::Token::TokenType::START_ELEMENT ); output.emplace_back ( "id", sax::Token::TokenType::START_ATTRIBUTE ); output.emplace_back ( ext::to_string ( elem->second ), sax::Token::TokenType::CHARACTER ); @@ -228,7 +228,7 @@ public: output.emplace ( output.begin ( ) + pos + 2, ext::to_string ( id ), sax::Token::TokenType::CHARACTER ); output.emplace ( output.begin ( ) + pos + 3, "ref", sax::Token::TokenType::END_ATTRIBUTE ); - context.instanceToId ( std::type_name < Group > ( ) ).insert ( std::make_pair ( static_cast< const CommonBaseBase * > ( & data.getData ( ) ), id ) ); + context.instanceToId ( ext::to_string < Group > ( ) ).insert ( std::make_pair ( static_cast< const CommonBaseBase * > ( & data.getData ( ) ), id ) ); } } } diff --git a/alib2common/src/introspection/Algorithms.hpp b/alib2common/src/introspection/Algorithms.hpp index f50472474109281b46e0a9b3e51430d999dc18cd..225e5e92c346c48be882b6486c73082eda1b8060 100644 --- a/alib2common/src/introspection/Algorithms.hpp +++ b/alib2common/src/introspection/Algorithms.hpp @@ -40,7 +40,7 @@ class Algorithms { class TypesToString < std::tuple < Types ... > > { public: static const std::vector < std::string > & getTypes ( ) { - static std::vector < std::string > res { std::type_name < Types > ( ) ... }; + static std::vector < std::string > res { ext::to_string < Types > ( ) ... }; return res; } @@ -62,16 +62,16 @@ public: template < class Algorithm, class RealReturnType, class RealParameterTypes > static void registerDispatchInAlgorithm ( ) { std::vector < std::string > realParameterTypeNames = TypesToString < RealParameterTypes >::getTypes ( ); - std::string algorithm = std::type_name < Algorithm > ( ); - std::string realReturnType = std::type_name < RealReturnType > ( ); + std::string algorithm = ext::to_string < Algorithm > ( ); + std::string realReturnType = ext::to_string < RealReturnType > ( ); Algorithms::algorithmCallbacks ( ) [ std::move ( algorithm ) ].insert ( std::make_tuple ( std::move ( realReturnType ), std::move ( realParameterTypeNames ) ) ); } template < class Algorithm, class ReturnType, class FrontStaticParamTypes, class DispatchedParameterTypes, class BackStaticParamTypes > static void registerAlgorithmInterface ( ) { - std::string algorithm = std::type_name < Algorithm > ( ); - std::string returnType = std::type_name < ReturnType > ( ); + std::string algorithm = ext::to_string < Algorithm > ( ); + std::string returnType = ext::to_string < ReturnType > ( ); std::vector < std::string > frontStaticParamTypeNames = TypesToString < FrontStaticParamTypes >::getTypes ( ); std::vector < std::string > dispatchedParameterTypeNames = TypesToString < DispatchedParameterTypes >::getTypes ( ); std::vector < std::string > backStaticParamTypeNames = TypesToString < BackStaticParamTypes >::getTypes ( ); @@ -81,7 +81,7 @@ public: template < class Algorithm > static void registerAlgorithm ( ) { - std::string algorithm = std::type_name < Algorithm > ( ); + std::string algorithm = ext::to_string < Algorithm > ( ); Algorithms::algorithms ( ).insert ( std::move ( algorithm ) ); } diff --git a/alib2common/src/introspection/Casts.hpp b/alib2common/src/introspection/Casts.hpp index f1c6a0af556903d401f65fac602244f22be2be9f..3faa7f4980cd83b8493b256a3efffed3310d9cfb 100644 --- a/alib2common/src/introspection/Casts.hpp +++ b/alib2common/src/introspection/Casts.hpp @@ -37,8 +37,8 @@ public: template < class From, class To > static void registerCast ( ) { - std::string fromType = std::type_name < From > ( ); - std::string toType = std::type_name < To > ( ); + std::string fromType = ext::to_string < From > ( ); + std::string toType = ext::to_string < To > ( ); std::set < std::string > & fromToSet = Casts::castsFrom ( ) [ fromType ]; std::set < std::string > & toFromSet = Casts::castsTo ( ) [ toType ]; diff --git a/alib2common/src/introspection/DataTypes.hpp b/alib2common/src/introspection/DataTypes.hpp index 9f71c530bc636d5cb4982177dce584ae3f9301e2..f67a2c1e9dd6ee79347c2c92bdd2c06e8c8b4d18 100644 --- a/alib2common/src/introspection/DataTypes.hpp +++ b/alib2common/src/introspection/DataTypes.hpp @@ -37,15 +37,15 @@ public: template < class Type, class Group > static void registerTypeInGroup ( ) { - std::string type = std::type_name < Type > ( ); - std::string group = std::type_name < Group > ( ); + std::string type = ext::to_string < Type > ( ); + std::string group = ext::to_string < Group > ( ); DataTypes::typesInGroup ( ) [ group ].insert ( std::move ( type ) ); } template < class Group > static void registerGroup ( ) { - std::string group = std::type_name < Group > ( ); + std::string group = ext::to_string < Group > ( ); DataTypes::groups ( ).insert ( std::move ( group ) ); } diff --git a/alib2std/src/extensions/string.cpp b/alib2std/src/extensions/string.cpp index ba99bf16426f299fd0123cb2509d455a1b8a9b46..42937a380029f56716201619d6e4f07f3905166b 100644 --- a/alib2std/src/extensions/string.cpp +++ b/alib2std/src/extensions/string.cpp @@ -10,11 +10,42 @@ namespace ext { -template < > std::string to_string ( const std::string & value ) { return value; } +std::string to_string ( int value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( bool value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( long value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( long long value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( unsigned value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( unsigned long value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( unsigned long long value ) { + return std::to_string__private ( value ); +} + +std::string to_string ( double value ) { + return std::to_string__private ( value ); +} + template < > std::string from_string ( const std::string & value ) { return value; diff --git a/alib2std/src/extensions/string.hpp b/alib2std/src/extensions/string.hpp index 191d6be9dc81fa46059298fd4c214d657735f85f..370ea85a0275f649634aaa4cf01be4d464300957 100644 --- a/alib2std/src/extensions/string.hpp +++ b/alib2std/src/extensions/string.hpp @@ -14,22 +14,33 @@ namespace ext { -template<typename... Ts> -using to_string_type = auto(Ts...) -> decltype(std::to_string__private(std::declval<Ts>()...)); - -template < typename T, typename std::enable_if < std::is_function< to_string_type < T > >::value >::type* = nullptr > -std::string to_string ( T value ) { - return std::to_string__private ( value ); -} - template < typename T, typename std::enable_if < std::is_constructible < std::string, T >::value >::type* = nullptr > std::string to_string ( const T & value ) { return (std::string) value; } -template < > std::string to_string ( const std::string & value ); +std::string to_string ( int value ); + +std::string to_string ( bool value ); + +std::string to_string ( long value ); + +std::string to_string ( long long value ); + +std::string to_string ( unsigned value ); + +std::string to_string ( unsigned long value ); + +std::string to_string ( unsigned long long value ); + +std::string to_string ( double value ); + + + + + template < typename T > T from_string ( const std::string & ); diff --git a/alib2std/src/extensions/typeindex.cpp b/alib2std/src/extensions/typeindex.cpp index 73518eb9919b314337811fc70ce0af88f9f06ca2..cf59e91357650e99d567b7c2f5f2510eb94bba38 100644 --- a/alib2std/src/extensions/typeindex.cpp +++ b/alib2std/src/extensions/typeindex.cpp @@ -13,11 +13,15 @@ namespace std { std::ostream & operator << ( std::ostream & os, const std::type_index & type ) { - os << std::type_name ( type ); + os << ext::to_string ( type ); return os; } -std::string type_name(const std::type_index& type) { +} /* namespace std */ + +namespace ext { + +std::string to_string ( const std::type_index & type ) { int status; char* demangled = abi::__cxa_demangle(type.name(), 0, 0, &status); @@ -26,4 +30,4 @@ std::string type_name(const std::type_index& type) { return res; } -} /* namespace std */ +} /* namespace ext */ diff --git a/alib2std/src/extensions/typeindex.h b/alib2std/src/extensions/typeindex.h index 70026e9f61bd320d5f3aec6214f234669733db07..c698f0c968836331e68e282fb6d0fbbb89a93f5d 100644 --- a/alib2std/src/extensions/typeindex.h +++ b/alib2std/src/extensions/typeindex.h @@ -11,6 +11,8 @@ #include <typeindex> #include <iostream> +#include "string.hpp" + namespace std { inline int operator -( const std::type_index & first, const std::type_index & second ) { @@ -19,8 +21,12 @@ inline int operator -( const std::type_index & first, const std::type_index & se std::ostream & operator << ( std::ostream & os, const std::type_index & type ); -std::string type_name(const std::type_index& type); - } /* namespace std */ +namespace ext { + +std::string to_string ( const std::type_index & type ); + +} /* namespace ext */ + #endif /* __TYPEINDEX_H_ */ diff --git a/alib2std/src/extensions/typeinfo.cpp b/alib2std/src/extensions/typeinfo.cpp index 536e56c733ea87034a07f65a0eba59391090ab83..3ce04b1524eb0c7b1e2e9ced37384a38871ad91d 100644 --- a/alib2std/src/extensions/typeinfo.cpp +++ b/alib2std/src/extensions/typeinfo.cpp @@ -9,14 +9,18 @@ #include <typeindex> #include <iostream> -namespace std { +namespace ext { -std::string type_name(const std::type_info& type) { - return type_name ( std::type_index ( type ) ); +std::string to_string ( const std::type_info & type ) { + return to_string ( std::type_index ( type ) ); } +} /* namespace ext */ + +namespace std { + std::ostream & operator << ( std::ostream & os, const std::type_info & type ) { - os << std::type_name ( type ); + os << ext::to_string ( type ); return os; } diff --git a/alib2std/src/extensions/typeinfo.hpp b/alib2std/src/extensions/typeinfo.hpp index 44fa8ced412f94869d67afe0e2db7d4eb0805dc1..351ced252b13f61a1e4ac32590a7dde09cb405a5 100644 --- a/alib2std/src/extensions/typeinfo.hpp +++ b/alib2std/src/extensions/typeinfo.hpp @@ -14,20 +14,22 @@ #include <cstdio> #include <cstring> -namespace std { +#include "string.hpp" + +namespace ext { -std::string type_name(const std::type_info& type); +std::string to_string ( const std::type_info & type ); -template <class T> -std::string type_name() { - return type_name(typeid(T)); +template < class T > +std::string to_string ( ) { + return to_string (typeid(T)); } template<typename T> bool is_same_type(const char* name) { char namespaceId[100]; char classId[100]; - std::string ret = type_name<T>(); + std::string ret = to_string < T > ( ); sscanf(ret.c_str(), "%[a-zA-Z]::%[a-zA-Z]", namespaceId, classId); if(strcmp(classId, name) == 0) { @@ -37,6 +39,10 @@ bool is_same_type(const char* name) { } } +} /* namespace ext */ + +namespace std { + std::ostream & operator << ( std::ostream & os, const std::type_info & type ); } /* namespace std */ diff --git a/alib2std/test-src/extensions/StringTest.cpp b/alib2std/test-src/extensions/StringTest.cpp index 7b1155c67eeb6dae6e6d3afc63969a95935c3441..15368224cb83fa912855bdd115397f1108e7cb49 100644 --- a/alib2std/test-src/extensions/StringTest.cpp +++ b/alib2std/test-src/extensions/StringTest.cpp @@ -11,7 +11,6 @@ void StringTest::tearDown() { } void StringTest::testToString() { - CPPUNIT_ASSERT ( std::is_function< ext::to_string_type < int > >::value ); CPPUNIT_ASSERT ( ext::to_string ( std::string ( "1" ) ) == "1" ); CPPUNIT_ASSERT ( ext::to_string ( 1 ) == "1" ); CPPUNIT_ASSERT ( ext::to_string ( 1ul ) == "1" );