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

Method ToXml

lib/mdflib/mdflib/src/ccunit.cpp:49–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49std::string CcUnit::ToXml() const {
50 try {
51 auto xml_file = CreateXmlFile("FileWriter");
52 constexpr bool ho_active = false;
53 auto& root_node = CreateRootNode(*xml_file, ho_active);
54 MdComment::ToXml(root_node);
55 if (unit_ref_.IsActive()) {
56 auto& unit_ref_node = root_node.AddNode("ho_unit");
57 unit_ref_.MdStandardAttribute::ToXml(unit_ref_node);
58 unit_ref_node.SetAttribute("unit_ref", unit_ref_.Text());
59 }
60 return xml_file->WriteString(true);
61 } catch (const std::exception& err) {
62 MDF_ERROR() << "Failed to create the CC unit. Error: " << err.what();
63 }
64 return {};
65}
66
67void CcUnit::FromXml(const std::string& xml_snippet) {
68 if (xml_snippet.empty()) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected