diff --git a/src/xml/xml_util.cc b/src/xml/xml_util.cc index b706a48a..3be5f937 100644 --- a/src/xml/xml_util.cc +++ b/src/xml/xml_util.cc @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -551,8 +550,8 @@ string mjXUtil::FindValue(const mjMap* map, int mapsz, int value) { // the content is returned in "text", the numeric data in "data" // return true if attribute found, false if not found and not required template -int mjXUtil::ReadAttrCpp(XMLElement* elem, const char* attr, const int len, - T* data, string& text, bool required, bool exact) { +int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, + T* data, string& text, bool required, bool exact) { const char* pstr = elem->Attribute(attr); // check if attribute exists @@ -596,36 +595,17 @@ int mjXUtil::ReadAttrCpp(XMLElement* elem, const char* attr, const int len, return i; } +template int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, + double* data, string& text, bool required, bool exact); +template int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, + float* data, string& text, bool required, bool exact); -int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, - double* data, string& text, bool required, bool exact) { - return ReadAttrCpp(elem, attr, len, data, text, required, exact); -} +template int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, + int* data, string& text, bool required, bool exact); - - -// float version -int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, - float* data, string& text, bool required, bool exact) { - return ReadAttrCpp(elem, attr, len, data, text, required, exact); -} - - - -// int version -int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, - int* data, string& text, bool required, bool exact) { - return ReadAttrCpp(elem, attr, len, data, text, required, exact); -} - - - -// byte version -int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, - mjtByte* data, string& text, bool required, bool exact) { - return ReadAttrCpp(elem, attr, len, data, text, required, exact); -} +template int mjXUtil::ReadAttr(XMLElement* elem, const char* attr, const int len, + mjtByte* data, string& text, bool required, bool exact); diff --git a/src/xml/xml_util.h b/src/xml/xml_util.h index aac25447..a1ee0b4b 100644 --- a/src/xml/xml_util.h +++ b/src/xml/xml_util.h @@ -100,28 +100,8 @@ class mjXUtil { // read any type from attribute, return number read template - static int ReadAttrCpp(tinyxml2::XMLElement* elem, const char* attr, const int len, - T* data, std::string& text, - bool required = false, bool exact = true); - - // read DOUBLE array from attribute, return number read static int ReadAttr(tinyxml2::XMLElement* elem, const char* attr, const int len, - double* data, std::string& text, - bool required = false, bool exact = true); - - // read FLOAT array from attribute, return number read - static int ReadAttr(tinyxml2::XMLElement* elem, const char* attr, const int len, - float* data, std::string& text, - bool required = false, bool exact = true); - - // read INT array from attribute, return number read - static int ReadAttr(tinyxml2::XMLElement* elem, const char* attr, const int len, - int* data, std::string& text, - bool required = false, bool exact = true); - - // read BYTE array from attribute, return number read - static int ReadAttr(tinyxml2::XMLElement* elem, const char* attr, const int len, - mjtByte* data, std::string& text, + T* data, std::string& text, bool required = false, bool exact = true); // read DOUBLE array into C++ vector, return number read