MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / FromXml

Method FromXml

lib/mdflib/mdflib/src/cccomment.cpp:52–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void CcComment::FromXml(const std::string& xml_snippet) {
53 if (xml_snippet.empty()) {
54 return;
55 }
56 try {
57 auto xml_file = CreateXmlFile("Expat");
58 if (!xml_file) {
59 throw std::runtime_error("Failed to create EXPAT parser object");
60 }
61 const bool parse = xml_file->ParseString(xml_snippet);
62 if (!parse) {
63 throw std::runtime_error("Failed to parse the XML string.");
64 }
65 const auto* root_node = xml_file->RootNode();
66 if (root_node == nullptr) {
67 throw std::runtime_error("There is no root node in the XML string");
68 }
69 MdComment::FromXml(*root_node);
70
71 IXmlNode::ChildList node_list;
72 xml_file->GetChildList(node_list);
73 for (const IXmlNode* node : node_list) {
74 if (node == nullptr) {
75 continue;
76 }
77 if (node->IsTagName("COMPU-METHOD")) {
78 method_.FromXml(*node);
79 }
80 }
81 } catch (const std::exception& err) {
82 MDF_ERROR() << "Failed to parse the CC comment. Error: " << err.what();
83 }
84}
85
86
87} // namespace mdf

Callers

nothing calls this directly

Calls 6

CreateXmlFileFunction · 0.85
emptyMethod · 0.80
RootNodeMethod · 0.80
IsTagNameMethod · 0.80
ParseStringMethod · 0.45
GetChildListMethod · 0.45

Tested by

no test coverage detected