59 log (
Error() ,
"Failed to parse file " , aPath.c_str() ,
". PugiXML returned the following description " ,
Quote ( aLoadResult.
description() ) ,
"." );
60 std::size_t lLineCounter ( 1 );
61 std::vector<uint8_t>::const_iterator lIt0 ( aFile.begin() );
62 std::vector<uint8_t>::const_iterator lIt1 ( aFile.begin() + aLoadResult.
offset );
63 std::vector<uint8_t>::const_iterator lIt2 ( lIt1 );
65 for ( ; lIt0!=lIt1 ; ++lIt0 )
73 for ( ; lIt1 != aFile.begin() ; --lIt1 )
82 for ( ; lIt2 != aFile.end() ; ++lIt2 )
91 std::size_t lDist0 ( lIt0 - lIt1 );
92 std::size_t lDist1 ( lIt2 - lIt0 );
94 lLine.reserve ( lIt2 - lIt1 );
96 for ( ; lIt1 != lIt2 ; ++lIt1 )
98 if ( isprint ( *lIt1 ) || *lIt1==10 )
108 log (
Error() ,
"Error occured at line number " ,
Integer ( lLineCounter ) ,
109 ", character " ,
Integer ( lDist0+1 ) ,
"\n"
110 "LINE : " , lLine ,
"\n"
111 "ERROR LOCATION : " , std::string ( lDist0 ,
'_' ) ,
"^" , std::string ( lDist1 ,
'_' ) );
115 template <
bool DebugInfo >
120 if ( ! lAttr.
empty() )
122 aTarget = lAttr.
value();
129 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
140 template <
bool DebugInfo >
145 if ( ! lAttr.
empty() )
147 aTarget = lAttr.
value();
154 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
165 template <
bool DebugInfo >
170 if ( ! lAttr.
empty() )
172 std::string lAttrStr ( lAttr.
value() );
173 std::stringstream ss;
176 if ( lAttrStr.size() > 2 )
178 if ( ( lAttrStr[1] ==
'x' ) || ( lAttrStr[1] ==
'X' ) )
180 ss <<
std::hex << lAttrStr.substr ( 2 );
187 else if ( lAttrStr.size() > 1 )
189 if ( ( lAttrStr[0] ==
'x' ) || ( lAttrStr[0] ==
'X' ) )
191 ss <<
std::hex << lAttrStr.substr ( 1 );
206 if ( ss.str().size() > 10 )
208 exception::StringNumberWillNotFitInto32BitNumber lExc;
209 log ( lExc ,
"XML attribute " ,
Quote ( aAttrName ) ,
" has value " ,
Quote ( ss.str() ) ,
" which is too big to fit into 32-bit number" );
218 exception::StringNumberWillNotFitInto32BitNumber lExc;
219 log ( lExc ,
"XML attribute " ,
Quote ( aAttrName ) ,
" has value " ,
Quote ( ss.str() ) ,
" which is too big to fit into 32-bit number" );
223 aTarget = ( int32_t ) ( lTarget );
230 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
241 template <
bool DebugInfo >
246 if ( ! lAttr.
empty() )
248 std::string lAttrStr ( lAttr.
value() );
249 std::stringstream ss;
251 size_t lBasePrefixLength = 0;
253 if ( lAttrStr.empty() )
254 throw exception::NodeAttributeIncorrectValue(
"XML attribute '" + aAttrName +
"' is empty, so cannot be converted to uint32_t");
257 if ( lAttrStr.size() > 2 )
259 if ( ( lAttrStr[0] ==
'0' ) and ( ( lAttrStr[1] ==
'x' ) or ( lAttrStr[1] ==
'X' ) ) )
261 lBasePrefixLength = 2;
266 if ( lAttrStr.size() > 1 )
268 if ( ( lAttrStr[0] ==
'x' ) || ( lAttrStr[0] ==
'X' ) )
270 lBasePrefixLength = 1;
275 if ( lAttrStr.find_first_not_of(lBasePrefixLength ?
"0123456789abcdefABCDEF" :
"0123456789", lBasePrefixLength) != std::string::npos )
276 throw exception::NodeAttributeIncorrectValue(
"XML attribute '" + aAttrName +
"' has value '" + lAttrStr +
"' that cannot be converted to uint32_t");
278 ss << lAttrStr.substr(lBasePrefixLength);
281 if ( ss.str().size() > 10 )
283 exception::StringNumberWillNotFitInto32BitNumber lExc;
284 log ( lExc ,
"XML attribute " ,
Quote ( aAttrName ) ,
" has value " ,
Quote ( ss.str() ) ,
" which is too big to fit into 32-bit number" );
293 exception::StringNumberWillNotFitInto32BitNumber lExc;
294 log ( lExc ,
"XML attribute " ,
Quote ( aAttrName ) ,
" has value " ,
Quote ( ss.str() ) ,
" which is too big to fit into 32-bit number" );
298 aTarget = ( uint32_t ) ( lTarget );
305 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
316 template <
bool DebugInfo >
321 if ( ! lAttr.
empty() )
330 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
341 template <
bool DebugInfo >
346 if ( ! lAttr.
empty() )
355 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );
366 template <
bool DebugInfo >
371 if ( ! lAttr.
empty() )
380 log (
Error() ,
"Failed to get attribute " ,
Quote ( aAttrName ) ,
" from XML node." );