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

Method ToXml

lib/mdflib/mdflib/src/cncomment.cpp:92–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92std::string CnComment::ToXml() const {
93 try {
94 auto xml_file = CreateXmlFile("FileWriter");
95 constexpr bool ho_active = false;
96 auto& root_node = CreateRootNode(*xml_file, ho_active);
97 ToTx(root_node);
98 ToNames(root_node);
99 if (linker_name_.IsActive()) {
100 linker_name_.ToXml(root_node, "linker_name");
101 }
102 if (linker_address_.IsActive()) {
103 linker_address_.ToXml(root_node, "linker_address");
104 }
105 if (axis_monotony_.has_value()) {
106 root_node.SetProperty("axis_monotony",
107 MdMonotonyToString(axis_monotony_.value()));
108 }
109 if (raster_.IsActive()) {
110 raster_.ToXml(root_node, "raster");
111 }
112 ToFormula(root_node);
113
114 if (address_.IsActive()) {
115 address_.ToXml(root_node, "address");
116 }
117 ToCommonProp(root_node);
118 return xml_file->WriteString(true);
119 } catch (const std::exception& err) {
120 MDF_ERROR() << "Failed to create the CN comment. Error: " << err.what();
121 }
122 return {};
123}
124
125void CnComment::FromXml(const std::string& xml_snippet) {
126 if (xml_snippet.empty()) {

Callers

nothing calls this directly

Calls 6

CreateXmlFileFunction · 0.85
MdMonotonyToStringFunction · 0.85
WriteStringMethod · 0.80
IsActiveMethod · 0.45
SetPropertyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected