Common utils for XML handling.
More...
#include <XmlUtils.h>
|
static Color4f | createColorFromXml (tinyxml2::XMLElement *node) |
| Create a color from given XML element (node) More...
|
|
static std::map< std::string, ObjectT > | createParamsFromXml (tinyxml2::XMLElement *paramsNode) |
| Create a map of parameters from given XML element (node) More...
|
|
static Rotation | createRotationFromXml (tinyxml2::XMLElement *rotGroupNode) |
| Create a rotation from given XML element (node) More...
|
|
static glm::dvec3 | createVec3dFromXml (tinyxml2::XMLElement *node, std::string attrPrefix) |
| Create a 3D vector from given XML element (node) More...
|
|
static std::shared_ptr< NoiseSource< double > > | createNoiseSource (tinyxml2::XMLElement *noise) |
| Create a noise source from given XML element (node) More...
|
|
static ObjectT | getAttribute (tinyxml2::XMLElement *element, std::string attrName, std::string type, ObjectT defaultVal, std::string const defaultMsg="Using default value for attribute") |
| Obtain attribute from XML. More...
|
|
static bool | hasAttribute (tinyxml2::XMLElement *element, std::string attrName) |
| Check whether XML node contains an attribute with given name (true) or not (false) More...
|
|
static std::vector< std::shared_ptr< DynMotion > > | createDynMotionsVector (tinyxml2::XMLElement *element) |
| Obtain a dynamic sequence of dynamic motions from given XML element. More...
|
|
static void | assertDocumentForAssetLoading (tinyxml2::XMLDocument &doc, std::string const &filename, std::string const &path, std::string const &type, std::string const &id, std::string const &caller) |
| Assert whether the given document is valid for asset loading or not. If it is in an error state, then adequate logging is printed and the opportune exception is thrown. More...
|
|
Common utils for XML handling.
◆ assertDocumentForAssetLoading()
void XmlUtils::assertDocumentForAssetLoading |
( |
tinyxml2::XMLDocument & |
doc, |
|
|
std::string const & |
filename, |
|
|
std::string const & |
path, |
|
|
std::string const & |
type, |
|
|
std::string const & |
id, |
|
|
std::string const & |
caller |
|
) |
| |
|
static |
Assert whether the given document is valid for asset loading or not. If it is in an error state, then adequate logging is printed and the opportune exception is thrown.
- Parameters
-
doc | The document to be asserted. |
◆ createColorFromXml()
Color4f XmlUtils::createColorFromXml |
( |
tinyxml2::XMLElement * |
node | ) |
|
|
static |
Create a color from given XML element (node)
- Parameters
-
node | XML element (node) containing color data |
- Returns
- Created color
- See also
- Color4f
◆ createDynMotionsVector()
std::vector< std::shared_ptr< DynMotion > > XmlUtils::createDynMotionsVector |
( |
tinyxml2::XMLElement * |
element | ) |
|
|
static |
Obtain a dynamic sequence of dynamic motions from given XML element.
It is expected that given element contains children elements of type <motion type="motion_type"> where motion_type can be either translation, rotation, rotsym, reflection, glideplane or helical. These children element will be used to build the dynamic sequence of dynamic motions with the same order as the one in the XML.
- Parameters
-
element | XML element containing motion children elements |
- Returns
- Vector of dynamic motions built from XML
- See also
- DynSequencer
-
DynSequence
-
rigidmotion::RigidMotion
-
DynMotion
◆ createNoiseSource()
std::shared_ptr< NoiseSource< double > > XmlUtils::createNoiseSource |
( |
tinyxml2::XMLElement * |
noise | ) |
|
|
static |
Create a noise source from given XML element (node)
- Parameters
-
noise | XML element (node) containing noise source specification |
- Returns
- Shared pointer to created noise source
- See also
- NoiseSource
◆ createParamsFromXml()
std::map< std::string, ObjectT > XmlUtils::createParamsFromXml |
( |
tinyxml2::XMLElement * |
paramsNode | ) |
|
|
static |
Create a map of parameters from given XML element (node)
- Parameters
-
paramsNode | XML element (node) containing parameters |
- Returns
- Map with parameters, so each one is identified by a different string
◆ createRotationFromXml()
Rotation XmlUtils::createRotationFromXml |
( |
tinyxml2::XMLElement * |
rotGroupNode | ) |
|
|
static |
Create a rotation from given XML element (node)
- Parameters
-
rotGroupNode | XML element (node) containing rotation data |
- Returns
- Created rotation
- See also
- Rotation
◆ createVec3dFromXml()
glm::dvec3 XmlUtils::createVec3dFromXml |
( |
tinyxml2::XMLElement * |
node, |
|
|
std::string |
attrPrefix |
|
) |
| |
|
static |
Create a 3D vector from given XML element (node)
- Parameters
-
node | XML element (node) containing 3D vector data |
attrPrefix | Attribute prefix. It will be used so x component is "attrPrefix" + "x" and so on for y and z components too. |
- Returns
- Created 3D vector
- See also
- glm::dvec3
◆ getAttribute()
ObjectT XmlUtils::getAttribute |
( |
tinyxml2::XMLElement * |
element, |
|
|
std::string |
attrName, |
|
|
std::string |
type, |
|
|
ObjectT |
defaultVal, |
|
|
std::string const |
defaultMsg = "Using default value for attribute" |
|
) |
| |
|
static |
Obtain attribute from XML.
- Parameters
-
element | XML element (node) where the attribute must be taken from |
attrName | Name of the attribute to be obtained |
type | Type of the attribute to be obtained |
defaultVal | Default value to be used in case attribute was not found |
- Returns
- Obtained attribute or default value if attribute was not found
◆ hasAttribute()
bool XmlUtils::hasAttribute |
( |
tinyxml2::XMLElement * |
element, |
|
|
std::string |
attrName |
|
) |
| |
|
static |
Check whether XML node contains an attribute with given name (true) or not (false)
- Parameters
-
element | XML node to which children must be checked |
attrName | Name of the element to be checked |
- Returns
- True if attribute is contained in XML node, false otherwise
The documentation for this class was generated from the following files:
- src/assetloading/XmlUtils.h
- src/assetloading/XmlUtils.cpp