| 1439 | } // namespace |
| 1440 | |
| 1441 | std::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 | |
| 1473 | std::string writeTreeXSD(const BehaviorTreeFactory& factory) |
| 1474 | { |