Helios++
Helios software for LiDAR simulations
XmlUtils Class Reference

Common utils for XML handling. More...

#include <XmlUtils.h>

Static Public Member Functions

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...
 

Detailed Description

Common utils for XML handling.

Member Function Documentation

◆ 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
docThe document to be asserted.

◆ createColorFromXml()

Color4f XmlUtils::createColorFromXml ( tinyxml2::XMLElement *  node)
static

Create a color from given XML element (node)

Parameters
nodeXML 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
elementXML 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
noiseXML 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
paramsNodeXML 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
rotGroupNodeXML 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
nodeXML element (node) containing 3D vector data
attrPrefixAttribute 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
elementXML element (node) where the attribute must be taken from
attrNameName of the attribute to be obtained
typeType of the attribute to be obtained
defaultValDefault 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
elementXML node to which children must be checked
attrNameName 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: