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

Method ToXml

lib/mdflib/mdflib/src/mdproperty.cpp:80–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 }
79
80 void MdProperty::ToXml(IXmlNode& prop_node) const {
81
82 if (!name_.empty()) {
83 prop_node.SetAttribute("name", name_);
84 } else {
85 MDF_ERROR() << "The XML tag requires an name attribute. Tag: "
86 << prop_node.TagName();
87 }
88
89 if (!desc_.empty()) {
90 prop_node.SetAttribute("desc", desc_ );
91 }
92
93 if (data_type_ != MdDataType::MdString) {
94 prop_node.SetAttribute("type", DataTypeToString());
95 }
96
97 if (!unit_.empty()) {
98 prop_node.SetAttribute("unit", unit_);
99 }
100
101 if (!unit_ref_.empty()) {
102 prop_node.SetAttribute("unit_ref", unit_ref_);
103 }
104
105 if (read_only_) {
106 prop_node.SetAttribute("ro", read_only_);
107 }
108 MdStandardAttribute::ToXml(prop_node);
109
110 // The property value is saved to the XML
111 // but not for an elist property as the
112 // value is a list of values.
113 if (!prop_node.IsTagName("elist")) {
114 prop_node.Value(value_);
115 }
116
117 }
118
119 std::string_view MdProperty::DataTypeToString() const {
120 if (const auto type = static_cast<uint16_t>(data_type_);

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.80
TagNameMethod · 0.80
IsTagNameMethod · 0.80
SetAttributeMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected