| 41 | |
| 42 | template <typename T> |
| 43 | void 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 |
no test coverage detected