NOTE. This question is only related to tinyxml, however, such details may help to better illustrate the concept.
I wrote a function template that will iterate over child nodes of XML child nodes, extract the value of the child element, and then transfer that child value of the element to the vector.
The "get value" part is also written as a function template:
i.e.
template <typename Type>
Type getXmlCollectionItem(
const char* elementName, TiXmlNode* child, TiXmlNode* parent);
There are specialized functions for the search part, for returning the values ββof various types of child elements, for example. std :: string and other user objects.
i.e.
template <>
std::string getXmlCollectionItem<std::string>(
const char* elementName, TiXmlNode* child, TiXmlNode* parent);
template <>
MyObject getXmlCollectionItem<MyObject>(
const char* elementName, TiXmlNode* child, TiXmlNode* parent);
All this works fine, but it seemed to me that it would be very useful to have functions in the shared library when working with tinyxml files.
: , . namespace UtilityFunctions, - , 'MyObject', , , 'MyObject'?
, , , , ...
, - . ( ), .