MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / writeTreeNodesModelXML

Function writeTreeNodesModelXML

src/xml_parsing.cpp:1441–1471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439} // namespace
1440
1441std::string writeTreeNodesModelXML(const BehaviorTreeFactory& factory,
1442 bool include_builtin)
1443{
1444 XMLDocument doc;
1445
1446 XMLElement* rootXML = doc.NewElement("root");
1447 rootXML->SetAttribute("BTCPP_format", "4");
1448 doc.InsertFirstChild(rootXML);
1449
1450 XMLElement* model_root = doc.NewElement("TreeNodesModel");
1451 rootXML->InsertEndChild(model_root);
1452
1453 std::map<std::string, const TreeNodeManifest*> ordered_models;
1454
1455 for(const auto& [registration_ID, model] : factory.manifests())
1456 {
1457 if(include_builtin || factory.builtinNodes().count(registration_ID) == 0)
1458 {
1459 ordered_models.insert({ registration_ID, &model });
1460 }
1461 }
1462
1463 for(const auto& [registration_ID, model] : ordered_models)
1464 {
1465 addNodeModelToXML(*model, doc, model_root);
1466 }
1467
1468 XMLPrinter printer;
1469 doc.Print(&printer);
1470 return std::string(printer.CStr(), size_t(printer.CStrSize() - 1));
1471}
1472
1473std::string writeTreeXSD(const BehaviorTreeFactory& factory)
1474{

Callers 6

mainFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 7

addNodeModelToXMLFunction · 0.85
stringFunction · 0.85
NewElementMethod · 0.80
SetAttributeMethod · 0.80
InsertFirstChildMethod · 0.80
InsertEndChildMethod · 0.80
PrintMethod · 0.80

Tested by 2

TESTFunction · 0.68
TESTFunction · 0.68