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

Method FromXml

lib/mdflib/mdflib/src/evcomment.cpp:72–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void EvComment::FromXml(const std::string& xml_snippet) {
73 if (xml_snippet.empty()) {
74 return;
75 }
76 try {
77 auto xml_file = CreateXmlFile("Expat");
78 if (!xml_file) {
79 throw std::runtime_error("Failed to create EXPAT parser object");
80 }
81 const bool parse = xml_file->ParseString(xml_snippet);
82 if (!parse) {
83 throw std::runtime_error("Failed to parse the XML string.");
84 }
85 const auto* root_node = xml_file->RootNode();
86 if (root_node == nullptr) {
87 throw std::runtime_error("There is no root node in the XML string");
88 }
89 MdComment::FromXml(*root_node);
90
91 IXmlNode::ChildList node_list;
92 xml_file->GetChildList(node_list);
93 for (const IXmlNode* node : node_list) {
94 if (node == nullptr) {
95 continue;
96 }
97 if (node->IsTagName("pre_trigger_interval")) {
98 pre_trigger_interval_.FromXml(*node);
99 } else if (node->IsTagName("post_trigger_interval")) {
100 post_trigger_interval_.FromXml(*node);
101 } else if (node->IsTagName("timeout")) {
102 timeout_.FromXml(*node);
103 }
104 }
105 } catch (const std::exception& err) {
106 MDF_ERROR() << "Failed to parse the EV comment. Error: " << err.what();
107 }
108}
109
110
111} // 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