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

Method ToXml

lib/mdflib/mdflib/src/sicomment.cpp:50–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50std::string SiComment::ToXml() const {
51 try {
52 auto xml_file = CreateXmlFile("FileWriter");
53 constexpr bool ho_active = false;
54 auto& root_node = CreateRootNode(*xml_file, ho_active);
55 ToTx(root_node);
56 ToNames(root_node);
57 if (path_.IsActive()) {
58 auto& path_node = root_node.AddNode("path");
59 path_.ToXml(path_node);
60 }
61 if (bus_.IsActive()) {
62 auto& bus_node = root_node.AddNode("bus");
63 bus_.ToXml(bus_node);
64 }
65 if (protocol_.IsActive()) {
66 protocol_.ToXml(root_node, "protocol");
67 }
68 ToCommonProp(root_node);
69 return xml_file->WriteString(true);
70 } catch (const std::exception& err) {
71 MDF_ERROR() << "Failed to create the SI comment. Error: " << err.what();
72 }
73 return {};
74}
75
76void SiComment::FromXml(const std::string& xml_snippet) {
77 if (xml_snippet.empty()) {

Callers

nothing calls this directly

Calls 4

CreateXmlFileFunction · 0.85
AddNodeMethod · 0.80
WriteStringMethod · 0.80
IsActiveMethod · 0.45

Tested by

no test coverage detected