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

Function SetCommonProperty

lib/mdflib/mdflib/src/hd4block.cpp:43–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42template <typename T>
43void SetCommonProperty(mdf::detail::Hd4Block& block, const std::string& key,
44 const T& value) {
45 auto xml_file = mdf::CreateXmlFile("Expat");
46 const auto* md4 = block.Md4();
47 if (md4 != nullptr) {
48 xml_file->ParseString(md4->Text());
49 }
50 auto& root = xml_file->RootName("HDcomment");
51 root.AddUniqueNode("TX"); // Must be first in XML ???
52 auto& common = root.AddUniqueNode("common_properties");
53 auto& key_node = common.AddUniqueNode("e", "name", key);
54 if (typeid(T) == typeid(int64_t)) {
55 key_node.SetAttribute<std::string>("type", "integer");
56 } else if (typeid(T) == typeid(float) || typeid(T) == typeid(double)) {
57 key_node.SetAttribute<std::string>("type", "float");
58 } else if (typeid(T) == typeid(bool)) {
59 key_node.SetAttribute<std::string>("type", "boolean");
60 } else if (typeid(T) == typeid(std::string)) {
61 key_node.SetAttribute<std::string>("type", "string");
62 }
63 key_node.Value(value);
64 block.Md4(xml_file->WriteString(true));
65}
66
67} // namespace
68

Callers 7

AuthorMethod · 0.85
DepartmentMethod · 0.85
ProjectMethod · 0.85
SubjectMethod · 0.85
MeasurementIdMethod · 0.85
RecorderIdMethod · 0.85
RecorderIndexMethod · 0.85

Calls 7

CreateXmlFileFunction · 0.85
Md4Method · 0.80
RootNameMethod · 0.80
WriteStringMethod · 0.80
ParseStringMethod · 0.45
TextMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected