Support FilePaths instead of raw strings in XML code.
PiperOrigin-RevId: 655177026 Change-Id: I55b055551384b01ba7a4baa5d75fbe3329b7d25d
This commit is contained in:
committed by
Copybara-Service
parent
2d24c58819
commit
2746cb8559
+13
-6
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "tinyxml2.h"
|
||||
|
||||
#include "user/user_util.h"
|
||||
|
||||
// error string copy
|
||||
void mjCopyError(char* dst, const char* src, int maxlen);
|
||||
@@ -101,26 +102,32 @@ class mjXUtil {
|
||||
|
||||
// if attribute is present, return vector of numerical data
|
||||
template<typename T>
|
||||
static std::optional<std::vector<T>> ReadAttrVec(tinyxml2::XMLElement* elem, const char* attr,
|
||||
static std::optional<std::vector<T>> ReadAttrVec(tinyxml2::XMLElement* elem,
|
||||
const char* attr,
|
||||
bool required = false);
|
||||
|
||||
// if attribute is present, return attribute as a string
|
||||
static std::optional<std::string> ReadAttrStr(tinyxml2::XMLElement* elem, const char* attr,
|
||||
static std::optional<std::string> ReadAttrStr(tinyxml2::XMLElement* elem,
|
||||
const char* attr,
|
||||
bool required = false);
|
||||
|
||||
// if attribute is present, return attribute as a filename
|
||||
static std::optional<std::string> ReadAttrFile(tinyxml2::XMLElement* elem, const char* attr,
|
||||
const std::string& dir = "", bool required = false);
|
||||
static std::optional<mujoco::user::FilePath>
|
||||
ReadAttrFile(tinyxml2::XMLElement* elem, const char* attr,
|
||||
const mujoco::user::FilePath& dir = mujoco::user::FilePath(),
|
||||
bool required = false);
|
||||
|
||||
// if attribute is present, return numerical value of attribute
|
||||
template<typename T>
|
||||
static std::optional<T> ReadAttrNum(tinyxml2::XMLElement* elem, const char* attr,
|
||||
static std::optional<T> ReadAttrNum(tinyxml2::XMLElement* elem,
|
||||
const char* attr,
|
||||
bool required = false);
|
||||
|
||||
// if attribute is present, return array of numerical data
|
||||
// N should be small as data is allocated on the stack
|
||||
template<typename T, int N>
|
||||
static std::optional<std::array<T, N>> ReadAttrArr(tinyxml2::XMLElement* elem, const char* attr,
|
||||
static std::optional<std::array<T, N>> ReadAttrArr(tinyxml2::XMLElement* elem,
|
||||
const char* attr,
|
||||
bool required = false) {
|
||||
std::array<T, N> arr;
|
||||
int n = 0;
|
||||
|
||||
Reference in New Issue
Block a user