victorb Messages: 78 Registered: December 2005 Location: Nice, France
Member
Oops... you are right about XmlAttrLoad not always returning Null and thanks for pointing me to the right direction "Maybe we should change it so that XmlAttrLoad would not set the value if it is missing?"
The following function should do the trick:
template <class T> XmlIO Attr(const char *id, T& var, T def) {
if(IsLoading())
if (IsNull(node.Attr(id)))
var = def;
else
XmlAttrLoad(var, node.Attr(id));
else if (var != def)
node.SetAttr(id, XmlAttrStore(var));
return *this;
}