Line data Source code
1 : #pragma once 2 : 3 : #include <rapidxml.hpp> 4 : 5 : #include "utils/stringify.hpp" 6 : 7 : namespace utils::xml { 8 : template<typename T> 9 0 : void add_attribute(rapidxml::xml_node<> &xmlNode, const std::string &key, const T &val) { 10 0 : rapidxml::xml_document<> &doc = *xmlNode.document(); 11 : 12 0 : auto attr = doc.allocate_attribute( 13 0 : doc.allocate_string( 14 : key.c_str() 15 : ), 16 : doc.allocate_string( 17 : utils::stringify::stringify<T>::toString(val).c_str() 18 : ) 19 : ); 20 0 : xmlNode.append_attribute(attr); 21 0 : } 22 : } // namespace utils::xml