From 3518bb12da2ea54aa0d80db8d7c76b3f81ad7766 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 27 Dec 2016 21:16:27 +0100 Subject: [PATCH] decrease requirements on Group template in xmlApi --- alib2common/src/core/xmlApi.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/alib2common/src/core/xmlApi.hpp b/alib2common/src/core/xmlApi.hpp index 1a7d81bdf9..035232d5ab 100644 --- a/alib2common/src/core/xmlApi.hpp +++ b/alib2common/src/core/xmlApi.hpp @@ -106,7 +106,7 @@ public: public: InputContextDeleter ( ) { std::function < void ( void * ) > deleteCallback = [] ( void * pointer ) { delete ( Group * ) pointer; }; - xmlApiInputContext::deleteCallbacks ( ).insert ( std::make_pair ( Group::getXmlTagRefName(), deleteCallback ) ); + xmlApiInputContext::deleteCallbacks ( ).insert ( std::make_pair ( std::type_name < Group > ( ), deleteCallback ) ); } }; @@ -131,16 +131,15 @@ public: sax::FromXMLParserHelper::skipAttributes ( input, sax::Token::TokenType::START_ELEMENT ); const std::string & tagName = sax::FromXMLParserHelper::getTokenData ( input, sax::Token::TokenType::START_ELEMENT ); - if ( /* common::GlobalData::optimizeXml && */ tagName == "Ref" ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "Ref" ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ATTRIBUTE, "id" ); int id = std::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, void * >::iterator elem = input.idToInstance ( Group::getXmlTagRefName() ).find ( id ); + std::map < int, void * >::iterator elem = input.idToInstance ( std::type_name < Group > ( ) ).find ( id ); - if ( elem == input.idToInstance ( Group::getXmlTagRefName() ).end ( ) ) { + if ( elem == input.idToInstance ( std::type_name < Group > ( ) ).end ( ) ) { std::cerr << input.dump ( ) << std::endl; throw exception::CommonException ( "XML Inconsistent ( id not found " + std::to_string ( id ) + " )" ); } @@ -163,7 +162,7 @@ public: /* if object is a base of reference, register it */ if ( ref ) - input.idToInstance ( Group::getXmlTagRefName() ).insert ( std::make_pair ( id, ( void * ) res ) ); + input.idToInstance ( std::type_name < Group > ( ) ).insert ( std::make_pair ( id, ( void * ) res ) ); return * res; } @@ -184,9 +183,9 @@ public: static void compose ( std::deque < sax::Token > & output, const Group & data ) { xmlApiOutputContext & context = ( xmlApiOutputContext & ) output; - typename std::map < void *, int >::iterator elem = context.instanceToId ( Group::getXmlTagRefName() ).find ( const_cast< void * >(static_cast< const void * > ( & data.getData ( ) ) ) ); + typename std::map < void *, int >::iterator elem = context.instanceToId ( std::type_name < Group > ( ) ).find ( const_cast< void * >(static_cast< const void * > ( & data.getData ( ) ) ) ); - if ( common::GlobalData::optimizeXml && elem != context.instanceToId ( Group::getXmlTagRefName() ).end ( ) ) { + if ( common::GlobalData::optimizeXml && elem != context.instanceToId ( std::type_name < Group > ( ) ).end ( ) ) { output.emplace_back ( "Ref", sax::Token::TokenType::START_ELEMENT ); output.emplace_back ( "id", sax::Token::TokenType::START_ATTRIBUTE ); output.emplace_back ( std::to_string ( elem->second ), sax::Token::TokenType::CHARACTER ); @@ -209,7 +208,7 @@ public: output.emplace ( output.begin ( ) + pos + 2, std::to_string ( id ) , sax::Token::TokenType::CHARACTER ); output.emplace ( output.begin ( ) + pos + 3, "ref", sax::Token::TokenType::END_ATTRIBUTE ); - context.instanceToId ( Group::getXmlTagRefName() ).insert ( std::make_pair ( const_cast< void * > ( static_cast< const void * > ( & data.getData ( ) ) ), id ) ); + context.instanceToId ( std::type_name < Group > ( ) ).insert ( std::make_pair ( const_cast< void * > ( static_cast< const void * > ( & data.getData ( ) ) ), id ) ); } } } -- GitLab