| 108 | /// @param[in,out] data_node The XML node to add data to |
| 109 | template <typename T> |
| 110 | void add_data_float(const std::string& name, |
| 111 | std::span<const std::size_t> num_components, |
| 112 | std::span<const T> values, pugi::xml_node& node) |
| 113 | { |
| 114 | static_assert(std::is_floating_point_v<T>, "Scalar must be a float"); |
| 115 | |
| 116 | constexpr int size = 8 * sizeof(T); |
| 117 | std::string type = std::string("Float") + std::to_string(size); |
| 118 | |
| 119 | pugi::xml_node field_node = node.append_child("DataArray"); |
| 120 | field_node.append_attribute("type") = type.c_str(); |
| 121 | field_node.append_attribute("Name") = name.c_str(); |
| 122 | field_node.append_attribute("format") = "ascii"; |
| 123 | if (!num_components.empty()) |
| 124 | field_node.append_attribute("NumberOfComponents") = num_components.front(); |
| 125 | |
| 126 | field_node.append_child(pugi::node_pcdata) |
| 127 | .set_value(container_to_string(values, 16).str().c_str()); |
| 128 | } |
| 129 | //---------------------------------------------------------------------------- |
| 130 | |
| 131 | /// At data to a pugixml node |
no test coverage detected