| 189 | }; |
| 190 | |
| 191 | void parseSubtreeModelPorts(const XMLElement* sub_node, SubtreeModel& subtree_model) |
| 192 | { |
| 193 | const std::pair<const char*, PortDirection> port_types[3] = { |
| 194 | { "input_port", PortDirection::INPUT }, |
| 195 | { "output_port", PortDirection::OUTPUT }, |
| 196 | { "inout_port", PortDirection::INOUT } |
| 197 | }; |
| 198 | |
| 199 | for(const auto& [name, direction] : port_types) |
| 200 | { |
| 201 | for(auto port_node = sub_node->FirstChildElement(name); port_node != nullptr; |
| 202 | port_node = port_node->NextSiblingElement(name)) |
| 203 | { |
| 204 | PortInfo port(direction); |
| 205 | auto port_name = port_node->Attribute("name"); |
| 206 | if(port_name == nullptr) |
| 207 | { |
| 208 | throw RuntimeError("Missing attribute [name] in port (SubTree model)"); |
| 209 | } |
| 210 | validatePortName(port_name, port_node->GetLineNum()); |
| 211 | if(auto default_value = port_node->Attribute("default")) |
| 212 | { |
| 213 | port.setDefaultValue(default_value); |
| 214 | } |
| 215 | if(auto description = port_node->Attribute("description")) |
| 216 | { |
| 217 | port.setDescription(description); |
| 218 | } |
| 219 | subtree_model.ports[port_name] = std::move(port); |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | } // namespace |
| 225 |
no test coverage detected