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

Method FromXml

lib/mdflib/mdflib/src/cncomment.cpp:125–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void CnComment::FromXml(const std::string& xml_snippet) {
126 if (xml_snippet.empty()) {
127 return;
128 }
129 try {
130 auto xml_file = CreateXmlFile("Expat");
131 if (!xml_file) {
132 throw std::runtime_error("Failed to create EXPAT parser object");
133 }
134 const bool parse = xml_file->ParseString(xml_snippet);
135 if (!parse) {
136 throw std::runtime_error("Failed to parse the XML string.");
137 }
138 const auto* root_node = xml_file->RootNode();
139 if (root_node == nullptr) {
140 throw std::runtime_error("There is no root node in the XML string");
141 }
142 MdComment::FromXml(*root_node);
143
144 IXmlNode::ChildList node_list;
145 xml_file->GetChildList(node_list);
146 for (const IXmlNode* node : node_list) {
147 if (node == nullptr) {
148 continue;
149 }
150 if (node->IsTagName("linker_name")) {
151 linker_name_.FromXml(*node);
152 } else if (node->IsTagName("linker_address")) {
153 linker_address_.FromXml(*node);
154 } else if (node->IsTagName("axis_monotony")) {
155 const std::string mon_text = node->Value<std::string>();
156 if (!mon_text.empty()) {
157 axis_monotony_ = StringToMdMonotony(mon_text);
158 }
159 } else if (node->IsTagName("raster")) {
160 raster_.FromXml(*node);
161 } else if (node->IsTagName("address")) {
162 address_.FromXml(*node);
163 }
164 }
165 } catch (const std::exception& err) {
166 MDF_ERROR() << "Failed to parse the CN comment. Error: " << err.what();
167 }
168}
169
170
171} // namespace mdf

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected