| 81 | } |
| 82 | |
| 83 | void FhComment::FromXml(const std::string& xml_snippet) { |
| 84 | if (xml_snippet.empty()) { |
| 85 | return; |
| 86 | } |
| 87 | try { |
| 88 | auto xml_file = CreateXmlFile("Expat"); |
| 89 | if (!xml_file) { |
| 90 | throw std::runtime_error("Failed to create EXPAT parser object"); |
| 91 | } |
| 92 | const bool parse = xml_file->ParseString(xml_snippet); |
| 93 | if (!parse) { |
| 94 | throw std::runtime_error("Failed to parse the XML string."); |
| 95 | } |
| 96 | const auto* root_node = xml_file->RootNode(); |
| 97 | if (root_node == nullptr) { |
| 98 | throw std::runtime_error("There is no root node in the XML string"); |
| 99 | } |
| 100 | IXmlNode::ChildList node_list; |
| 101 | xml_file->GetChildList(node_list); |
| 102 | for (const IXmlNode* node : node_list) { |
| 103 | if (node == nullptr) { |
| 104 | continue; |
| 105 | } |
| 106 | if (node->IsTagName("tool_id")) { |
| 107 | tool_id_.FromXml(*node); |
| 108 | } else if (node->IsTagName("tool_vendor")) { |
| 109 | tool_vendor_.FromXml(*node); |
| 110 | } else if (node->IsTagName("tool_version")) { |
| 111 | tool_version_.FromXml(*node); |
| 112 | } else if (node->IsTagName("user_name")) { |
| 113 | user_name_.FromXml(*node); |
| 114 | } |
| 115 | } |
| 116 | MdComment::FromXml(*root_node); |
| 117 | } catch (const std::exception& err) { |
| 118 | MDF_ERROR() << "Failed to parse the EV comment. Error: " << err.what(); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | |
| 123 | } // namespace mdf |
nothing calls this directly
no test coverage detected