@@ -224,7 +224,7 @@ void XMLParser::PImpl::loadDocImpl(tinyxml2::XMLDocument* doc, bool add_includes
224224
225225 XMLPrinter printer;
226226 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 ()));
228228
229229 // Verify the validity of the XML before adding any behavior trees to the parser's list of registered trees
230230 VerifyXML (xml_text, registered_nodes);
@@ -254,14 +254,14 @@ void VerifyXML(const std::string& xml_text,
254254 auto xml_error = doc.Parse (xml_text.c_str (), xml_text.size ());
255255 if (xml_error)
256256 {
257- char buffer[200 ];
257+ char buffer[512 ];
258258 sprintf (buffer, " Error parsing the XML: %s" , doc.ErrorName ());
259259 throw RuntimeError (buffer);
260260 }
261261
262262 // -------- Helper functions (lambdas) -----------------
263263 auto ThrowError = [&](int line_num, const std::string& text) {
264- char buffer[256 ];
264+ char buffer[512 ];
265265 sprintf (buffer, " Error at line %d: -> %s" , line_num, text.c_str ());
266266 throw RuntimeError (buffer);
267267 };
@@ -300,10 +300,10 @@ void VerifyXML(const std::string& xml_text,
300300 for (auto node = xml_root->FirstChildElement (); node != nullptr ;
301301 node = node->NextSiblingElement ())
302302 {
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" )
307307 {
308308 const char * ID = node->Attribute (" ID" );
309309 if (!ID)
@@ -321,8 +321,8 @@ void VerifyXML(const std::string& xml_text,
321321
322322 recursiveStep = [&](const XMLElement* node) {
323323 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" )
326326 {
327327 if (children_count != 1 )
328328 {
@@ -335,7 +335,7 @@ void VerifyXML(const std::string& xml_text,
335335 " attribute [ID]" );
336336 }
337337 }
338- else if (StrEqual ( name, " Action" ) )
338+ else if (name == " Action" )
339339 {
340340 if (children_count != 0 )
341341 {
@@ -348,7 +348,7 @@ void VerifyXML(const std::string& xml_text,
348348 " attribute [ID]" );
349349 }
350350 }
351- else if (StrEqual ( name, " Condition" ) )
351+ else if (name == " Condition" )
352352 {
353353 if (children_count != 0 )
354354 {
@@ -361,7 +361,7 @@ void VerifyXML(const std::string& xml_text,
361361 " attribute [ID]" );
362362 }
363363 }
364- else if (StrEqual ( name, " Control" ) )
364+ else if (name == " Control" )
365365 {
366366 if (children_count == 0 )
367367 {
@@ -374,16 +374,16 @@ void VerifyXML(const std::string& xml_text,
374374 " attribute [ID]" );
375375 }
376376 }
377- else if (StrEqual ( name, " Sequence" ) || StrEqual ( name, " SequenceStar" ) ||
378- StrEqual ( name, " Fallback" ) )
377+ else if (name == " Sequence" || name == " SequenceStar" ||
378+ name == " Fallback" )
379379 {
380380 if (children_count == 0 )
381381 {
382382 ThrowError (node->GetLineNum (), " A Control node must have at least 1 "
383383 " child" );
384384 }
385385 }
386- else if (StrEqual ( name, " SubTree" ) )
386+ else if (name == " SubTree" )
387387 {
388388 auto child = node->FirstChildElement ();
389389
@@ -405,7 +405,7 @@ void VerifyXML(const std::string& xml_text,
405405 " attribute [ID]" );
406406 }
407407 }
408- else if (StrEqual ( name, " BehaviorTree" ) )
408+ else if (name == " BehaviorTree" )
409409 {
410410 if (children_count != 1 )
411411 {
@@ -433,7 +433,7 @@ void VerifyXML(const std::string& xml_text,
433433 }
434434 }
435435 // recursion
436- if (StrEqual ( name, " SubTree" ) == false )
436+ if (name != " SubTree" )
437437 {
438438 for (auto child = node->FirstChildElement (); child != nullptr ;
439439 child = child->NextSiblingElement ())
@@ -730,7 +730,7 @@ void BT::XMLParser::PImpl::recursivelyCreateSubtree(
730730 recursiveStep = [&](TreeNode::Ptr parent_node,
731731 Tree::Subtree::Ptr subtree,
732732 std::string prefix,
733- const XMLElement* element)
733+ const XMLElement* element)
734734 {
735735 // create the node
736736 auto node = createNodeFromXML (element, blackboard, parent_node, prefix, output_tree);
0 commit comments