@@ -224,7 +224,7 @@ void XMLParser::PImpl::loadDocImpl(tinyxml2::XMLDocument* doc, bool add_includes
224
224
225
225
XMLPrinter printer;
226
226
doc->Print (&printer);
227
- auto xml_text = std::string (printer.CStr (), size_t (printer.CStrSize () - 1 ));
227
+ auto xml_text = std::string (printer.CStr (), size_t (printer.CStrSize ()));
228
228
229
229
// Verify the validity of the XML before adding any behavior trees to the parser's list of registered trees
230
230
VerifyXML (xml_text, registered_nodes);
@@ -254,14 +254,14 @@ void VerifyXML(const std::string& xml_text,
254
254
auto xml_error = doc.Parse (xml_text.c_str (), xml_text.size ());
255
255
if (xml_error)
256
256
{
257
- char buffer[200 ];
257
+ char buffer[512 ];
258
258
sprintf (buffer, " Error parsing the XML: %s" , doc.ErrorName ());
259
259
throw RuntimeError (buffer);
260
260
}
261
261
262
262
// -------- Helper functions (lambdas) -----------------
263
263
auto ThrowError = [&](int line_num, const std::string& text) {
264
- char buffer[256 ];
264
+ char buffer[512 ];
265
265
sprintf (buffer, " Error at line %d: -> %s" , line_num, text.c_str ());
266
266
throw RuntimeError (buffer);
267
267
};
@@ -300,10 +300,10 @@ void VerifyXML(const std::string& xml_text,
300
300
for (auto node = xml_root->FirstChildElement (); node != nullptr ;
301
301
node = node->NextSiblingElement ())
302
302
{
303
- const char * name = node->Name ();
304
- if (StrEqual ( name, " Action" ) || StrEqual ( name, " Decorator" ) ||
305
- StrEqual ( name, " SubTree" ) || StrEqual ( name, " Condition" ) ||
306
- StrEqual ( name, " Control" ) )
303
+ const std::string name = node->Name ();
304
+ if (name == " Action" || name == " Decorator" ||
305
+ name == " SubTree" || name == " Condition" ||
306
+ name == " Control" )
307
307
{
308
308
const char * ID = node->Attribute (" ID" );
309
309
if (!ID)
@@ -321,8 +321,8 @@ void VerifyXML(const std::string& xml_text,
321
321
322
322
recursiveStep = [&](const XMLElement* node) {
323
323
const int children_count = ChildrenCount (node);
324
- const char * name = node->Name ();
325
- if (StrEqual ( name, " Decorator" ) )
324
+ const std::string name = node->Name ();
325
+ if (name == " Decorator" )
326
326
{
327
327
if (children_count != 1 )
328
328
{
@@ -335,7 +335,7 @@ void VerifyXML(const std::string& xml_text,
335
335
" attribute [ID]" );
336
336
}
337
337
}
338
- else if (StrEqual ( name, " Action" ) )
338
+ else if (name == " Action" )
339
339
{
340
340
if (children_count != 0 )
341
341
{
@@ -348,7 +348,7 @@ void VerifyXML(const std::string& xml_text,
348
348
" attribute [ID]" );
349
349
}
350
350
}
351
- else if (StrEqual ( name, " Condition" ) )
351
+ else if (name == " Condition" )
352
352
{
353
353
if (children_count != 0 )
354
354
{
@@ -361,7 +361,7 @@ void VerifyXML(const std::string& xml_text,
361
361
" attribute [ID]" );
362
362
}
363
363
}
364
- else if (StrEqual ( name, " Control" ) )
364
+ else if (name == " Control" )
365
365
{
366
366
if (children_count == 0 )
367
367
{
@@ -374,16 +374,16 @@ void VerifyXML(const std::string& xml_text,
374
374
" attribute [ID]" );
375
375
}
376
376
}
377
- else if (StrEqual ( name, " Sequence" ) || StrEqual ( name, " SequenceStar" ) ||
378
- StrEqual ( name, " Fallback" ) )
377
+ else if (name == " Sequence" || name == " SequenceStar" ||
378
+ name == " Fallback" )
379
379
{
380
380
if (children_count == 0 )
381
381
{
382
382
ThrowError (node->GetLineNum (), " A Control node must have at least 1 "
383
383
" child" );
384
384
}
385
385
}
386
- else if (StrEqual ( name, " SubTree" ) )
386
+ else if (name == " SubTree" )
387
387
{
388
388
auto child = node->FirstChildElement ();
389
389
@@ -405,7 +405,7 @@ void VerifyXML(const std::string& xml_text,
405
405
" attribute [ID]" );
406
406
}
407
407
}
408
- else if (StrEqual ( name, " BehaviorTree" ) )
408
+ else if (name == " BehaviorTree" )
409
409
{
410
410
if (children_count != 1 )
411
411
{
@@ -433,7 +433,7 @@ void VerifyXML(const std::string& xml_text,
433
433
}
434
434
}
435
435
// recursion
436
- if (StrEqual ( name, " SubTree" ) == false )
436
+ if (name != " SubTree" )
437
437
{
438
438
for (auto child = node->FirstChildElement (); child != nullptr ;
439
439
child = child->NextSiblingElement ())
@@ -730,7 +730,7 @@ void BT::XMLParser::PImpl::recursivelyCreateSubtree(
730
730
recursiveStep = [&](TreeNode::Ptr parent_node,
731
731
Tree::Subtree::Ptr subtree,
732
732
std::string prefix,
733
- const XMLElement* element)
733
+ const XMLElement* element)
734
734
{
735
735
// create the node
736
736
auto node = createNodeFromXML (element, blackboard, parent_node, prefix, output_tree);
0 commit comments