33 #ifndef DART_UTILS_XMLHELPERS_HPP_
34 #define DART_UTILS_XMLHELPERS_HPP_
37 #include <Eigen/Dense>
49 std::string
toString(
unsigned int v);
53 std::string
toString(
const Eigen::Vector2d& v);
54 std::string
toString(
const Eigen::Vector3d& v);
55 std::string
toString(
const Eigen::Vector3i& v);
57 std::string
toString(
const Eigen::VectorXd& v);
58 std::string
toString(
const Eigen::Isometry3d& v);
60 bool toBool (
const std::string& str);
61 int toInt (
const std::string& str);
62 unsigned int toUInt (
const std::string& str);
63 float toFloat (
const std::string& str);
64 double toDouble (
const std::string& str);
65 char toChar (
const std::string& str);
66 Eigen::Vector2d
toVector2d (
const std::string& str);
67 Eigen::Vector3d
toVector3d (
const std::string& str);
68 Eigen::Vector3i
toVector3i (
const std::string& str);
70 Eigen::VectorXd
toVectorXd (
const std::string& str);
75 std::string
getValueString (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
76 bool getValueBool (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
77 int getValueInt (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
78 unsigned int getValueUInt (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
79 float getValueFloat (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
80 double getValueDouble (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
81 char getValueChar (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
82 Eigen::Vector2d
getValueVector2d (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
83 Eigen::Vector3d
getValueVector3d (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
84 Eigen::Vector3i
getValueVector3i (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
86 Eigen::VectorXd
getValueVectorXd (
const tinyxml2::XMLElement* parentElement,
const std::string&
name);
91 const common::Uri& uri,
94 bool hasElement(
const tinyxml2::XMLElement* parentElement,
95 const std::string&
name);
98 const tinyxml2::XMLElement* parentElement,
99 const std::string&
name);
101 tinyxml2::XMLElement*
getElement(tinyxml2::XMLElement* parentElement,
102 const std::string&
name);
104 bool hasAttribute(
const tinyxml2::XMLElement* element,
const char*
const name);
112 void getAttribute(tinyxml2::XMLElement* element, const
char* const
name,
double* d);
115 bool getAttributeBool (const tinyxml2::XMLElement* element, const
std::
string& attributeName);
116 int getAttributeInt (const tinyxml2::XMLElement* element, const
std::
string& attributeName);
117 unsigned int getAttributeUInt (const tinyxml2::XMLElement* element, const
std::
string& attributeName);
118 float getAttributeFloat (const tinyxml2::XMLElement* element, const
std::
string& attributeName);
120 char getAttributeChar (const tinyxml2::XMLElement* element, const
std::
string& attributeName);
129 template <typename ElementType>
141 const std::string& childElementName)
142 : mParentElement(parentElement),
143 mChildElementName(childElementName),
144 mCurrentElement(nullptr)
161 = mCurrentElement->NextSiblingElement(mChildElementName.c_str());
166 = mParentElement->FirstChildElement(mChildElementName.c_str());
170 mParentElement =
nullptr;
190 && (this->mCurrentElement !=
nullptr
210 return mCurrentElement !=
nullptr;
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
bool valid
Definition: SkelParser.cpp:1618
std::string * name
Definition: SkelParser.cpp:1642
TemplatedElementEnumerator is a convenience class to help visiting all the child elements of given pa...
Definition: XmlHelpers.hpp:131
bool next()
Set the current element to the next sibling element or to the first child element of given parent ele...
Definition: XmlHelpers.hpp:153
ElementType & ElementRef
Definition: XmlHelpers.hpp:135
ElementPtr get() const
Get the current element.
Definition: XmlHelpers.hpp:176
~TemplatedElementEnumerator()
Destructor.
Definition: XmlHelpers.hpp:149
TemplatedElementEnumerator< ElementType > & operator=(const TemplatedElementEnumerator< ElementType > &rhs)
Assignment operator.
Definition: XmlHelpers.hpp:195
ElementPtr operator->() const
Dereference operator.
Definition: XmlHelpers.hpp:179
bool operator==(const TemplatedElementEnumerator< ElementType > &rhs) const
Equality operator.
Definition: XmlHelpers.hpp:185
ElementPtr mCurrentElement
Currently visiting child element.
Definition: XmlHelpers.hpp:222
bool valid() const
Returns true if the current element is valid (not a nullptr)
Definition: XmlHelpers.hpp:208
std::string mChildElementName
Child element name.
Definition: XmlHelpers.hpp:219
ElementRef operator*() const
Dereference operator.
Definition: XmlHelpers.hpp:182
ElementType * ElementPtr
Definition: XmlHelpers.hpp:134
TemplatedElementEnumerator(ElementPtr parentElement, const std::string &childElementName)
Constructor that takes parent element and.
Definition: XmlHelpers.hpp:140
ElementPtr mParentElement
Parent element.
Definition: XmlHelpers.hpp:216
Definition: Random-impl.hpp:92
Matrix< double, 6, 1 > Vector6d
Definition: MathTypes.hpp:49
std::shared_ptr< ResourceRetriever > ResourceRetrieverPtr
Definition: ResourceRetriever.hpp:76
bool hasElement(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:616
double getAttributeDouble(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:780
bool getValueBool(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:435
unsigned int toUInt(const std::string &str)
Definition: XmlHelpers.cpp:154
Eigen::Vector6d getValueVector6d(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:556
Eigen::Isometry3d getValueIsometry3dWithExtrinsicRotation(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:604
unsigned int getValueUInt(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:472
Eigen::Isometry3d toIsometry3d(const std::string &str)
Definition: XmlHelpers.cpp:346
Eigen::Vector3d getAttributeVector3d(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:817
char getAttributeChar(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:799
Eigen::VectorXd getValueVectorXd(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:568
const tinyxml2::XMLElement * getElement(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:627
Eigen::Vector3d toVector3d(const std::string &str)
Definition: XmlHelpers.cpp:210
double toDouble(const std::string &str)
Definition: XmlHelpers.cpp:166
float getAttributeFloat(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:761
Eigen::Vector6d getAttributeVector6d(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:826
std::string getAttribute(tinyxml2::XMLElement *element, const char *const name)
Definition: XmlHelpers.cpp:674
Eigen::Isometry3d getValueIsometry3d(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:592
int toInt(const std::string &str)
Definition: XmlHelpers.cpp:148
Eigen::Vector3d getValueVector3d(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:532
Eigen::VectorXd getAttributeVectorXd(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:835
Eigen::Vector2d toVector2d(const std::string &str)
Definition: XmlHelpers.cpp:177
float getValueFloat(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:484
Eigen::Vector3i toVector3i(const std::string &str)
Definition: XmlHelpers.cpp:244
Eigen::VectorXd toVectorXd(const std::string &str)
Definition: XmlHelpers.cpp:312
Eigen::Isometry3d toIsometry3dWithExtrinsicRotation(const std::string &str)
Definition: XmlHelpers.cpp:382
float toFloat(const std::string &str)
Definition: XmlHelpers.cpp:160
int getValueInt(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:460
std::string getAttributeString(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:688
char toChar(const std::string &str)
Definition: XmlHelpers.cpp:171
Eigen::Vector3i getValueVector3i(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:544
Eigen::Vector2d getValueVector2d(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:520
std::string toString(bool v)
Definition: XmlHelpers.cpp:48
char getValueChar(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:508
std::string getValueString(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:423
Eigen::Vector2d getAttributeVector2d(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:808
bool toBool(const std::string &str)
Definition: XmlHelpers.cpp:130
bool getAttributeBool(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:705
double getValueDouble(const tinyxml2::XMLElement *parentElement, const std::string &name)
Definition: XmlHelpers.cpp:496
Eigen::Vector6d toVector6d(const std::string &str)
Definition: XmlHelpers.cpp:278
int getAttributeInt(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:724
bool hasAttribute(const tinyxml2::XMLElement *element, const char *const name)
Definition: XmlHelpers.cpp:667
void openXMLFile(tinyxml2::XMLDocument &doc, const common::Uri &uri, const common::ResourceRetrieverPtr &retrieverOrNullPtr)
Definition: XmlHelpers.cpp:646
unsigned int getAttributeUInt(const tinyxml2::XMLElement *element, const std::string &attributeName)
Definition: XmlHelpers.cpp:742
Definition: BulletCollisionDetector.cpp:63
Definition: SharedLibraryManager.hpp:43