| 1286 | namespace |
| 1287 | { |
| 1288 | void addNodeModelToXML(const TreeNodeManifest& model, XMLDocument& doc, |
| 1289 | XMLElement* model_root) |
| 1290 | { |
| 1291 | XMLElement* element = doc.NewElement(toStr(model.type).c_str()); |
| 1292 | element->SetAttribute("ID", model.registration_ID.c_str()); |
| 1293 | |
| 1294 | for(const auto& [port_name, port_info] : model.ports) |
| 1295 | { |
| 1296 | XMLElement* port_element = nullptr; |
| 1297 | switch(port_info.direction()) |
| 1298 | { |
| 1299 | case PortDirection::INPUT: |
| 1300 | port_element = doc.NewElement("input_port"); |
| 1301 | break; |
| 1302 | case PortDirection::OUTPUT: |
| 1303 | port_element = doc.NewElement("output_port"); |
| 1304 | break; |
| 1305 | case PortDirection::INOUT: |
| 1306 | port_element = doc.NewElement("inout_port"); |
| 1307 | break; |
| 1308 | } |
| 1309 | |
| 1310 | port_element->SetAttribute("name", port_name.c_str()); |
| 1311 | if(port_info.type() != typeid(void)) |
| 1312 | { |
| 1313 | port_element->SetAttribute("type", BT::demangle(port_info.type()).c_str()); |
| 1314 | } |
| 1315 | if(!port_info.defaultValue().empty()) |
| 1316 | { |
| 1317 | port_element->SetAttribute("default", port_info.defaultValueString().c_str()); |
| 1318 | } |
| 1319 | |
| 1320 | if(!port_info.description().empty()) |
| 1321 | { |
| 1322 | port_element->SetText(port_info.description().c_str()); |
| 1323 | } |
| 1324 | element->InsertEndChild(port_element); |
| 1325 | } |
| 1326 | |
| 1327 | if(!model.metadata.empty()) |
| 1328 | { |
| 1329 | auto metadata_root = doc.NewElement("MetadataFields"); |
| 1330 | |
| 1331 | for(const auto& [name, value] : model.metadata) |
| 1332 | { |
| 1333 | auto metadata_element = doc.NewElement("Metadata"); |
| 1334 | metadata_element->SetAttribute(name.c_str(), value.c_str()); |
| 1335 | metadata_root->InsertEndChild(metadata_element); |
| 1336 | } |
| 1337 | |
| 1338 | element->InsertEndChild(metadata_root); |
| 1339 | } |
| 1340 | |
| 1341 | model_root->InsertEndChild(element); |
| 1342 | } |
| 1343 | |
| 1344 | void addTreeToXML(const Tree& tree, XMLDocument& doc, XMLElement* rootXML, |
| 1345 | bool add_metadata, bool add_builtin_models) |
no test coverage detected