Hello, I'm trying to load data from xml-file with TinyXML (c++).
int height = rootElem->attrib<int>("height", 480);
rootElem is a root element of loaded xml-file. I want to load height value from it (integer). But I have a wrapper function for this stuff:
template<typename T>
T getValue(const string &key, const string &defaultValue = "")
{
return mRootElement->attrib<T>(key, defaultValue);
}
It works with string:
std::string temp = getValue<std::string>("width");
And it fails during fetching:
int temp = getValue<int>("width");
>no matching function for call to ‘TiXmlElement::attrib(const std::string&, const std::string&)’
UPD: The new version of code:
template<typename T>
T getValue(const string &key, const T &defaultValue = T())
{
return mRootElement->attrib<T>(key, defaultValue);
}