Public Member Functions | List of all members
sdf::SDF_VERSION_NAMESPACE::Element Class Reference

SDF Element class. More...

#include <sdf/sdf.hh>

Inherits enable_shared_from_this< Element >.

Public Member Functions

 Element ()
 Constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
void AddAttribute (const std::string &_key, const std::string &_type, const std::string &_defaultvalue, bool _required, const std::string &_description="")
 Add an attribute value. More...
 
void AddAttribute (const std::string &_key, const std::string &_type, const std::string &_defaultvalue, bool _required, sdf::Errors &_errors, const std::string &_description="")
 Add an attribute value. More...
 
ElementPtr AddElement (const std::string &_name)
 Add a named element. More...
 
ElementPtr AddElement (const std::string &_name, sdf::Errors &_errors)
 Add a named element. More...
 
void AddValue (const std::string &_type, const std::string &_defaultValue, bool _required, const std::string &_description="")
 Add a value to this Element. More...
 
void AddValue (const std::string &_type, const std::string &_defaultValue, bool _required, const std::string &_minValue, const std::string &_maxValue, const std::string &_description="")
 Add a value to this Element. More...
 
void AddValue (const std::string &_type, const std::string &_defaultValue, bool _required, const std::string &_minValue, const std::string &_maxValue, sdf::Errors &_errors, const std::string &_description="")
 Add a value to this Element. More...
 
void AddValue (const std::string &_type, const std::string &_defaultValue, bool _required, sdf::Errors &_errors, const std::string &_description="")
 Add a value to this Element. More...
 
void Clear ()
 Remove all child elements and reset file path and original version. More...
 
void ClearElements ()
 Remove all child elements. More...
 
ElementPtr Clone () const
 Create a copy of this Element. More...
 
ElementPtr Clone (sdf::Errors &_errors) const
 Create a copy of this Element. More...
 
void Copy (const ElementPtr _elem)
 Copy values from an Element. More...
 
void Copy (const ElementPtr _elem, sdf::Errors &_errors)
 Copy values from an Element. More...
 
std::map< std::string, std::size_t > CountNamedElements (const std::string &_type, const std::vector< std::string > &_ignoreElements) const
 Count the number of child elements of the specified element type that have the same name attribute value with the exception of elements listed in _ignoreElements. More...
 
std::map< std::string, std::size_t > CountNamedElements (const std::string &_type="") const
 Count the number of child elements of the specified element type that have the same name attribute value. More...
 
std::map< std::string, std::size_t > CountNamedElements (sdf::Errors &_errors, const std::string &_type, const std::vector< std::string > &_ignoreElements) const
 Count the number of child elements of the specified element type that have the same name attribute value with the exception of elements listed in _ignoreElements. More...
 
std::map< std::string, std::size_t > CountNamedElements (sdf::Errors &_errors, const std::string &_type="") const
 Count the number of child elements of the specified element type that have the same name attribute value. More...
 
const std::string & FilePath () const
 Get the path to the SDF document where this element came from. More...
 
ElementPtr FindElement (const std::string &_name)
 Return a pointer to the child element with the provided name. More...
 
ElementConstPtr FindElement (const std::string &_name) const
 Return a pointer to the child element with the provided name. More...
 
template<typename T >
std::pair< T, bool > Get (const std::string &_key, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
bool Get (const std::string &_key, T &_param, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
Get (const std::string &_key="") const
 Get the value of a key. More...
 
template<typename T >
std::pair< T, bool > Get (sdf::Errors &_errors, const std::string &_key, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
bool Get (sdf::Errors &_errors, const std::string &_key, T &_param, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
Get (sdf::Errors &_errors, const std::string &_key="") const
 Get the value of a key. More...
 
std::any GetAny (const std::string &_key="") const
 Get the element value/attribute as a std::any. More...
 
std::any GetAny (sdf::Errors &_errors, const std::string &_key="") const
 Get the element value/attribute as a std::any. More...
 
ParamPtr GetAttribute (const std::string &_key) const
 Get the param of an attribute. More...
 
ParamPtr GetAttribute (unsigned int _index) const
 Get an attribute using an index. More...
 
size_t GetAttributeCount () const
 Get the number of attributes. More...
 
const Param_VGetAttributes () const
 Get all the attribute params. More...
 
bool GetAttributeSet (const std::string &_key) const
 Return true if the attribute was set (i.e. More...
 
bool GetCopyChildren () const
 Return true if this Element's child elements should be copied during parsing. More...
 
ElementPtr GetElement (const std::string &_name)
 Return a pointer to the child element with the provided name. More...
 
ElementPtr GetElement (const std::string &_name, sdf::Errors &_errors)
 Return a pointer to the child element with the provided name. More...
 
ElementPtr GetElementDescription (const std::string &_key) const
 Get an element description using a key. More...
 
ElementPtr GetElementDescription (unsigned int _index) const
 Get an element description using an index. More...
 
size_t GetElementDescriptionCount () const
 Get the number of element descriptions. More...
 
std::set< std::string > GetElementTypeNames () const
 Get set of child element type names. More...
 
bool GetExplicitlySetInFile () const
 Return if the element was been explicitly set in the file. More...
 
ElementPtr GetFirstElement () const
 Get the first child element. More...
 
sdf::ElementPtr GetIncludeElement () const
 Get the element that was used to load this element. More...
 
const std::string & GetName () const
 Get the Element's name. More...
 
ElementPtr GetNextElement (const std::string &_name="") const
 Get the next sibling of this element. More...
 
ElementPtr GetParent () const
 Get a pointer to this Element's parent. More...
 
const std::string & GetRequired () const
 Get the requirement string. More...
 
ParamPtr GetValue () const
 Get the param of the elements value return A Param pointer to the value of this element. More...
 
bool HasAttribute (const std::string &_key) const
 Return true if an attribute exists. More...
 
bool HasElement (const std::string &_name) const
 Return true if the named element exists. More...
 
bool HasElementDescription (const std::string &_name) const
 Return true if an element description exists. More...
 
bool HasUniqueChildNames (const std::string &_type, const std::vector< std::string > &_ignoreElements) const
 Checks whether any child elements of the specified element type, except those listed in _ignoreElements, have identical name attribute values and returns false if so. More...
 
bool HasUniqueChildNames (const std::string &_type="") const
 Checks whether any child elements of the specified element type have identical name attribute values and returns false if so. More...
 
bool HasUniqueChildNames (sdf::Errors &_errors, const std::string &_type, const std::vector< std::string > &_ignoreElements) const
 Checks whether any child elements of the specified element type, except those listed in _ignoreElements, have identical name attribute values and returns false if so. More...
 
bool HasUniqueChildNames (sdf::Errors &_errors, const std::string &_type="") const
 Checks whether any child elements of the specified element type have identical name attribute values and returns false if so. More...
 
void InsertElement (ElementPtr _elem)
 Add an element object. More...
 
void InsertElement (ElementPtr _elem, bool _setParentToSelf)
 Add an element object, and optionally set the given element's parent to this object. More...
 
std::optional< int > LineNumber () const
 Get the line number of this element within the SDF document. More...
 
void PrintDescription (const std::string &_prefix) const
 Output Element's description to stdout. More...
 
void PrintDescription (sdf::Errors &_errors, const std::string &_prefix) const
 Output Element's description to stdout. More...
 
void PrintDocLeftPane (std::string &_html, int _spacing, int &_index) const
 Helper function for SDF::PrintDoc. More...
 
void PrintDocRightPane (std::string &_html, int _spacing, int &_index) const
 Helper function for SDF::PrintDoc. More...
 
void PrintValues (const std::string &_prefix, bool _includeDefaultElements, bool _includeDefaultAttributes, const PrintConfig &_config=PrintConfig()) const
 Output Element's values to stdout. More...
 
void PrintValues (sdf::Errors &_errors, const std::string &_prefix, bool _includeDefaultElements, bool _includeDefaultAttributes, const PrintConfig &_config=PrintConfig()) const
 Output Element's values to stdout. More...
 
void PrintValues (sdf::Errors &_errors, std::string _prefix, const PrintConfig &_config=PrintConfig()) const
 Output Element's values to stdout. More...
 
void PrintValues (std::string _prefix, const PrintConfig &_config=PrintConfig()) const
 Output Element's values to stdout. More...
 
std::string ReferenceSDF () const
 Get the name of the reference SDF element. More...
 
void RemoveAllAttributes ()
 Removes all attributes. More...
 
void RemoveAttribute (const std::string &_key)
 Remove an attribute. More...
 
void RemoveChild (ElementPtr _child)
 Remove a child element. More...
 
void RemoveChild (ElementPtr _child, sdf::Errors &_errors)
 Remove a child element. More...
 
void RemoveFromParent ()
 Remove this element from its parent. More...
 
void Reset ()
 Call reset on each element and element description before deleting all of them. More...
 
template<typename T >
bool Set (const T &_value)
 Set the value of this element. More...
 
template<typename T >
bool Set (sdf::Errors &_errors, const T &_value)
 Set the value of this element. More...
 
void SetCopyChildren (bool _value)
 Set whether this element should copy its child elements during parsing. More...
 
void SetExplicitlySetInFile (const bool _value)
 Set if the element and children where set or default in the original file. More...
 
void SetFilePath (const std::string &_path)
 Set the path to the SDF document where this element came from. More...
 
void SetIncludeElement (sdf::ElementPtr _includeElem)
 Set the element that was used to load this element. More...
 
void SetLineNumber (int _lineNumber)
 Set the line number of this element within the SDF document. More...
 
void SetName (const std::string &_name)
 Set the name of the Element. More...
 
void SetParent (const ElementPtr _parent)
 Set the parent of this Element. More...
 
void SetReferenceSDF (const std::string &_value)
 Set reference SDF element. More...
 
void SetRequired (const std::string &_req)
 Set the requirement type. More...
 
std::string ToString (const std::string &_prefix, bool _includeDefaultElements, bool _includeDefaultAttributes, const PrintConfig &_config=PrintConfig()) const
 Convert the element values to a string representation. More...
 
std::string ToString (const std::string &_prefix, const PrintConfig &_config=PrintConfig()) const
 Convert the element values to a string representation. More...
 
std::string ToString (sdf::Errors &_errors, const std::string &_prefix, bool _includeDefaultElements, bool _includeDefaultAttributes, const PrintConfig &_config=PrintConfig()) const
 Convert the element values to a string representation. More...
 
std::string ToString (sdf::Errors &_errors, const std::string &_prefix, const PrintConfig &_config=PrintConfig()) const
 Convert the element values to a string representation. More...
 
void Update ()
 Call the Update() callback on each element, as well as the embedded Param. More...
 
void Update (sdf::Errors &_errors)
 Call the Update() callback on each element, as well as the embedded Param. More...
 

="default"]/model[@name="robot1"]/link[@name="link"])

Set the XML path of this element.

Parameters
[in]_pathFull XML path (i.e., XPath) to the SDF element. E.g., a SDF document: <sdf> <world name="default"> <model name="robot1"> <link name="link"> ... </link> </model> </world> </sdf> The full XML path to the SDF link element would be: /sdf/world[
void SetXmlPath (const std::string &_path)
 Private data pointer. More...
 
const std::string & XmlPath () const
 Get the XML path of this element. More...
 
void SetOriginalVersion (const std::string &_version)
 Set the spec version that this was originally parsed from. More...
 
const std::string & OriginalVersion () const
 Get the spec version that this was originally parsed from. More...
 
std::string GetDescription () const
 Get a text description of the element. More...
 
void SetDescription (const std::string &_desc)
 Set a text description for the element. More...
 
void AddElementDescription (ElementPtr _elem)
 Add a new element description. More...
 
ElementPtr GetElementImpl (const std::string &_name) const
 Get a pointer to the named element. More...
 
static std::vector< std::string > NameUniquenessExceptions ()
 List of elements to which exceptions are made when checking for name uniqueness. More...
 

Detailed Description

SDF Element class.

Constructor & Destructor Documentation

◆ Element()

sdf::SDF_VERSION_NAMESPACE::Element::Element ( )

Constructor.

◆ ~Element()

virtual sdf::SDF_VERSION_NAMESPACE::Element::~Element ( )
virtual

Destructor.

Member Function Documentation

◆ AddAttribute() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::AddAttribute ( const std::string &  _key,
const std::string &  _type,
const std::string &  _defaultvalue,
bool  _required,
const std::string &  _description = "" 
)

Add an attribute value.

Parameters
[in]_keyKey value.
[in]_typeType of data the attribute will hold.
[in]_defaultValueDefault value for the attribute.
[in]_requiredRequirement string. \as Element::SetRequired.
[in]_descriptionA text description of the attribute.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ AddAttribute() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::AddAttribute ( const std::string &  _key,
const std::string &  _type,
const std::string &  _defaultvalue,
bool  _required,
sdf::Errors _errors,
const std::string &  _description = "" 
)

Add an attribute value.

Parameters
[in]_keyKey value.
[in]_typeType of data the attribute will hold.
[in]_defaultValueDefault value for the attribute.
[in]_requiredRequirement string. \as Element::SetRequired.
[out]_errorsVector of errors.
[in]_descriptionA text description of the attribute.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ AddElement() [1/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::AddElement ( const std::string &  _name)

Add a named element.

Parameters
[in]_namethe name of the element to add.
Returns
A pointer to the newly created Element object.

◆ AddElement() [2/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::AddElement ( const std::string &  _name,
sdf::Errors _errors 
)

Add a named element.

Parameters
[in]_namethe name of the element to add.
[out]_errorsVector of errors.
Returns
A pointer to the newly created Element object.

◆ AddElementDescription()

void sdf::SDF_VERSION_NAMESPACE::Element::AddElementDescription ( ElementPtr  _elem)

Add a new element description.

Parameters
[in]_elemthe Element object to add to the descriptions.

◆ AddValue() [1/4]

void sdf::SDF_VERSION_NAMESPACE::Element::AddValue ( const std::string &  _type,
const std::string &  _defaultValue,
bool  _required,
const std::string &  _description = "" 
)

Add a value to this Element.

Parameters
[in]_typeType of data the parameter will hold.
[in]_defaultValueDefault value for the parameter.
[in]_requiredRequirement string. \as Element::SetRequired.
[in]_descriptionA text description of the parameter.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ AddValue() [2/4]

void sdf::SDF_VERSION_NAMESPACE::Element::AddValue ( const std::string &  _type,
const std::string &  _defaultValue,
bool  _required,
const std::string &  _minValue,
const std::string &  _maxValue,
const std::string &  _description = "" 
)

Add a value to this Element.

This override allows passing min and max values of the parameter.

Parameters
[in]_typeType of data the parameter will hold.
[in]_defaultValueDefault value for the parameter.
[in]_requiredRequirement string. \as Element::SetRequired.
[in]_minValueMinimum allowed value for the parameter.
[in]_maxValueMaximum allowed value for the parameter.
[in]_descriptionA text description of the parameter.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ AddValue() [3/4]

void sdf::SDF_VERSION_NAMESPACE::Element::AddValue ( const std::string &  _type,
const std::string &  _defaultValue,
bool  _required,
const std::string &  _minValue,
const std::string &  _maxValue,
sdf::Errors _errors,
const std::string &  _description = "" 
)

Add a value to this Element.

This override allows passing min and max values of the parameter.

Parameters
[in]_typeType of data the parameter will hold.
[in]_defaultValueDefault value for the parameter.
[in]_requiredRequirement string. \as Element::SetRequired.
[in]_minValueMinimum allowed value for the parameter.
[in]_maxValueMaximum allowed value for the parameter.
[out]_errorsVector of errors.
[in]_descriptionA text description of the parameter.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ AddValue() [4/4]

void sdf::SDF_VERSION_NAMESPACE::Element::AddValue ( const std::string &  _type,
const std::string &  _defaultValue,
bool  _required,
sdf::Errors _errors,
const std::string &  _description = "" 
)

Add a value to this Element.

Parameters
[in]_typeType of data the parameter will hold.
[in]_defaultValueDefault value for the parameter.
[in]_requiredRequirement string. \as Element::SetRequired.
[out]_errorsVector of errors.
[in]_descriptionA text description of the parameter.
Exceptions
sdf::AssertionInternalErrorif an invalid type is given.

◆ Clear()

void sdf::SDF_VERSION_NAMESPACE::Element::Clear ( )

Remove all child elements and reset file path and original version.

◆ ClearElements()

void sdf::SDF_VERSION_NAMESPACE::Element::ClearElements ( )

Remove all child elements.

◆ Clone() [1/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::Clone ( ) const

Create a copy of this Element.

Returns
A copy of this Element.

◆ Clone() [2/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::Clone ( sdf::Errors _errors) const

Create a copy of this Element.

Parameters
[out]_errorsVector of errors.
Returns
A copy of this Element, NULL if there was an error.

◆ Copy() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::Copy ( const ElementPtr  _elem)

Copy values from an Element.

Parameters
[in]_elemElement to copy value from.

◆ Copy() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::Copy ( const ElementPtr  _elem,
sdf::Errors _errors 
)

Copy values from an Element.

Parameters
[in]_elemElement to copy value from.
[out]_errorsVector of errors.

◆ CountNamedElements() [1/4]

std::map<std::string, std::size_t> sdf::SDF_VERSION_NAMESPACE::Element::CountNamedElements ( const std::string &  _type,
const std::vector< std::string > &  _ignoreElements 
) const

Count the number of child elements of the specified element type that have the same name attribute value with the exception of elements listed in _ignoreElements.

Parameters
[in]_typeThe type of Element to check. If empty, count names of all child elements.
[in]_ignoreElementsA list of child element types to ignore when checking for uniqueness.
Returns
Map from Element names to a count of how many times the name occurs. The count should never be 0. If all 2nd values are 1, then there are exclusively unique names.

◆ CountNamedElements() [2/4]

std::map<std::string, std::size_t> sdf::SDF_VERSION_NAMESPACE::Element::CountNamedElements ( const std::string &  _type = "") const

Count the number of child elements of the specified element type that have the same name attribute value.

Parameters
[in]_typeThe type of Element to check. If empty, count names of all child elements.
Returns
Map from Element names to a count of how many times the name occurs. The count should never be 0. If all 2nd values are 1, then there are exclusively unique names.

◆ CountNamedElements() [3/4]

std::map<std::string, std::size_t> sdf::SDF_VERSION_NAMESPACE::Element::CountNamedElements ( sdf::Errors _errors,
const std::string &  _type,
const std::vector< std::string > &  _ignoreElements 
) const

Count the number of child elements of the specified element type that have the same name attribute value with the exception of elements listed in _ignoreElements.

Parameters
[out]_errorsVector of errors.
[in]_typeThe type of Element to check. If empty, count names of all child elements.
[in]_ignoreElementsA list of child element types to ignore when checking for uniqueness.
Returns
Map from Element names to a count of how many times the name occurs. The count should never be 0. If all 2nd values are 1, then there are exclusively unique names.

◆ CountNamedElements() [4/4]

std::map<std::string, std::size_t> sdf::SDF_VERSION_NAMESPACE::Element::CountNamedElements ( sdf::Errors _errors,
const std::string &  _type = "" 
) const

Count the number of child elements of the specified element type that have the same name attribute value.

Parameters
[out]_errorsVector of errors.
[in]_typeThe type of Element to check. If empty, count names of all child elements.
Returns
Map from Element names to a count of how many times the name occurs. The count should never be 0. If all 2nd values are 1, then there are exclusively unique names.

◆ FilePath()

const std::string& sdf::SDF_VERSION_NAMESPACE::Element::FilePath ( ) const

Get the path to the SDF document where this element came from.

Returns
Full path to SDF document.

◆ FindElement() [1/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::FindElement ( const std::string &  _name)

Return a pointer to the child element with the provided name.

Unlike GetElement, this does not create a new child element if it fails to find an existing element.

Remarks
If there are multiple elements with the given tag, it returns the first one.
Parameters
[in]_nameName of the child element to retreive.
Returns
Pointer to the existing child element, or nullptr if the child element was not found.

◆ FindElement() [2/2]

ElementConstPtr sdf::SDF_VERSION_NAMESPACE::Element::FindElement ( const std::string &  _name) const

Return a pointer to the child element with the provided name.

Unlike GetElement, this does not create a new child element if it fails to find an existing element.

Remarks
If there are multiple elements with the given tag, it returns the first one.
Parameters
[in]_nameName of the child element to retreive.
Returns
Pointer to the existing child element, or nullptr if the child element was not found.

◆ GetAny() [1/2]

std::any sdf::SDF_VERSION_NAMESPACE::Element::GetAny ( const std::string &  _key = "") const

Get the element value/attribute as a std::any.

Parameters
[in]_keyThe key of the attribute. If empty, get the value of the element. Defaults to empty.
Returns
The element as a std::any.

◆ GetAny() [2/2]

std::any sdf::SDF_VERSION_NAMESPACE::Element::GetAny ( sdf::Errors _errors,
const std::string &  _key = "" 
) const

Get the element value/attribute as a std::any.

Parameters
[in]_keyThe key of the attribute. If empty, get the value of the element. Defaults to empty.
[out]_errorsVector of errors.
Returns
The element as a std::any.

◆ GetAttribute() [1/2]

ParamPtr sdf::SDF_VERSION_NAMESPACE::Element::GetAttribute ( const std::string &  _key) const

Get the param of an attribute.

Parameters
[in]_keythe name of the attribute.
Returns
The parameter attribute value. NULL if the key is invalid.

Referenced by Get().

◆ GetAttribute() [2/2]

ParamPtr sdf::SDF_VERSION_NAMESPACE::Element::GetAttribute ( unsigned int  _index) const

Get an attribute using an index.

Parameters
[in]_indexthe index of the attribute to get.
Returns
A Param pointer to the attribute.

◆ GetAttributeCount()

size_t sdf::SDF_VERSION_NAMESPACE::Element::GetAttributeCount ( ) const

Get the number of attributes.

Returns
The number of attributes.

◆ GetAttributes()

const Param_V& sdf::SDF_VERSION_NAMESPACE::Element::GetAttributes ( ) const

Get all the attribute params.

Returns
The vector of parameter attributes.

◆ GetAttributeSet()

bool sdf::SDF_VERSION_NAMESPACE::Element::GetAttributeSet ( const std::string &  _key) const

Return true if the attribute was set (i.e.

not default value)

Parameters
[in]_keythe key to use to find the attribute.
Returns
True if the attribute is set, false otherwise.

◆ GetCopyChildren()

bool sdf::SDF_VERSION_NAMESPACE::Element::GetCopyChildren ( ) const

Return true if this Element's child elements should be copied during parsing.

Returns
True to copy child elements during parsing.

◆ GetDescription()

std::string sdf::SDF_VERSION_NAMESPACE::Element::GetDescription ( ) const

Get a text description of the element.

Returns
The text description of the element.

◆ GetElement() [1/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetElement ( const std::string &  _name)

Return a pointer to the child element with the provided name.

A new child element, with the provided name, is added to this element if there is no existing child element. If this is not desired see FindElement

Remarks
If there are multiple elements with the given tag, it returns the first one.
Parameters
[in]_nameName of the child element to retreive.
Returns
Pointer to the existing child element, or a new child element if an existing child element did not exist.

◆ GetElement() [2/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetElement ( const std::string &  _name,
sdf::Errors _errors 
)

Return a pointer to the child element with the provided name.

A new child element, with the provided name, is added to this element if there is no existing child element. If this is not desired see FindElement

Remarks
If there are multiple elements with the given tag, it returns the first one.
Parameters
[in]_nameName of the child element to retreive.
[out]_errorsVector of errors.
Returns
Pointer to the existing child element, or a new child element if an existing child element did not exist.

◆ GetElementDescription() [1/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetElementDescription ( const std::string &  _key) const

Get an element description using a key.

Parameters
[in]_keythe key to use to find the element.
Returns
An Element pointer to the found element.

◆ GetElementDescription() [2/2]

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetElementDescription ( unsigned int  _index) const

Get an element description using an index.

Parameters
[in]_indexthe index of the element description to get.
Returns
An Element pointer to the found element.

Referenced by Get().

◆ GetElementDescriptionCount()

size_t sdf::SDF_VERSION_NAMESPACE::Element::GetElementDescriptionCount ( ) const

Get the number of element descriptions.

Returns
The number of element descriptions.

◆ GetElementImpl()

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetElementImpl ( const std::string &  _name) const

Get a pointer to the named element.

Parameters
[in]_namethe name of the element to look for.
Returns
A pointer to the named element if found, nullptr otherwise.

Referenced by Get().

◆ GetElementTypeNames()

std::set<std::string> sdf::SDF_VERSION_NAMESPACE::Element::GetElementTypeNames ( ) const

Get set of child element type names.

Returns
A set of the names of the child elements.

◆ GetExplicitlySetInFile()

bool sdf::SDF_VERSION_NAMESPACE::Element::GetExplicitlySetInFile ( ) const

Return if the element was been explicitly set in the file.

Returns
True if the element was set in the file

◆ GetFirstElement()

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetFirstElement ( ) const

Get the first child element.

Returns
A smart pointer to the first child of this element, or sdf::ElementPtr(nullptr) if there are no children.

◆ GetIncludeElement()

sdf::ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetIncludeElement ( ) const

Get the element that was used to load this element.

Returns
The Element pointer to the element, if this element was loaded from an included file. Otherwise, nullptr. This is also nullptr for Elements that cannot be included.

◆ GetName()

const std::string& sdf::SDF_VERSION_NAMESPACE::Element::GetName ( ) const

Get the Element's name.

Returns
The name of this Element.

◆ GetNextElement()

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetNextElement ( const std::string &  _name = "") const

Get the next sibling of this element.

Parameters
[in]_nameif given then filter siblings by their xml tag.
Remarks
This function does not alter or store any state Repeated calls to "GetNextElement()" with the same string will always return a pointer to the same element.
Returns
A pointer to the next element if it exists, sdf::ElementPtr(nullptr) otherwise.

This can be used in combination with GetFirstElement() to walk the SDF tree. First call parent->GetFirstElement() to get the first child. Call child = child->GetNextElement() to iterate through the children.

◆ GetParent()

ElementPtr sdf::SDF_VERSION_NAMESPACE::Element::GetParent ( ) const

Get a pointer to this Element's parent.

Returns
Pointer to this Element's parent, NULL if there is no parent.

◆ GetRequired()

const std::string& sdf::SDF_VERSION_NAMESPACE::Element::GetRequired ( ) const

Get the requirement string.

Returns
The requirement string.
See also
Element::SetRequired

◆ GetValue()

ParamPtr sdf::SDF_VERSION_NAMESPACE::Element::GetValue ( ) const

Get the param of the elements value return A Param pointer to the value of this element.

◆ HasAttribute()

bool sdf::SDF_VERSION_NAMESPACE::Element::HasAttribute ( const std::string &  _key) const

Return true if an attribute exists.

Parameters
[in]_keythe key to use to find the attribute.
Returns
True if the attribute exists, false otherwise.

◆ HasElement()

bool sdf::SDF_VERSION_NAMESPACE::Element::HasElement ( const std::string &  _name) const

Return true if the named element exists.

Parameters
[in]_namethe name of the element to look for.
Returns
True if the named element was found, false otherwise.

Referenced by Get().

◆ HasElementDescription()

bool sdf::SDF_VERSION_NAMESPACE::Element::HasElementDescription ( const std::string &  _name) const

Return true if an element description exists.

Parameters
[in]_namethe name of the element to find.
Returns
True if the element description exists, false otherwise.

Referenced by Get().

◆ HasUniqueChildNames() [1/4]

bool sdf::SDF_VERSION_NAMESPACE::Element::HasUniqueChildNames ( const std::string &  _type,
const std::vector< std::string > &  _ignoreElements 
) const

Checks whether any child elements of the specified element type, except those listed in _ignoreElements, have identical name attribute values and returns false if so.

Parameters
[in]_typeThe type of Element to check. If empty, check names of all child elements.
[in]_ignoreElementsA list of child element types to ignore when checking for uniqueness.
Returns
True if all child elements with name attributes of the specified type have unique names, return false if there are duplicated names. Also return true if no elements of the specified type are found.

◆ HasUniqueChildNames() [2/4]

bool sdf::SDF_VERSION_NAMESPACE::Element::HasUniqueChildNames ( const std::string &  _type = "") const

Checks whether any child elements of the specified element type have identical name attribute values and returns false if so.

Parameters
[in]_typeThe type of Element to check. If empty, check names of all child elements.
Returns
True if all child elements with name attributes of the specified type have unique names, return false if there are duplicated names. Also return true if no elements of the specified type are found.

◆ HasUniqueChildNames() [3/4]

bool sdf::SDF_VERSION_NAMESPACE::Element::HasUniqueChildNames ( sdf::Errors _errors,
const std::string &  _type,
const std::vector< std::string > &  _ignoreElements 
) const

Checks whether any child elements of the specified element type, except those listed in _ignoreElements, have identical name attribute values and returns false if so.

Parameters
[out]_errorsVector of errors.
[in]_typeThe type of Element to check. If empty, check names of all child elements.
[in]_ignoreElementsA list of child element types to ignore when checking for uniqueness.
Returns
True if all child elements with name attributes of the specified type have unique names, return false if there are duplicated names. Also return true if no elements of the specified type are found.

◆ HasUniqueChildNames() [4/4]

bool sdf::SDF_VERSION_NAMESPACE::Element::HasUniqueChildNames ( sdf::Errors _errors,
const std::string &  _type = "" 
) const

Checks whether any child elements of the specified element type have identical name attribute values and returns false if so.

Parameters
[out]_errorsVector of errors.
[in]_typeThe type of Element to check. If empty, check names of all child elements.
Returns
True if all child elements with name attributes of the specified type have unique names, return false if there are duplicated names. Also return true if no elements of the specified type are found.

◆ InsertElement() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::InsertElement ( ElementPtr  _elem)

Add an element object.

Parameters
[in]_elemthe element object to add.

◆ InsertElement() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::InsertElement ( ElementPtr  _elem,
bool  _setParentToSelf 
)

Add an element object, and optionally set the given element's parent to this object.

Parameters
[in]_elemthe element object to add.
[in]_setParentToSelfIf true, set the _elem's parent to this object and then insert.

◆ LineNumber()

std::optional<int> sdf::SDF_VERSION_NAMESPACE::Element::LineNumber ( ) const

Get the line number of this element within the SDF document.

Returns
Line number of this element if it has been set, nullopt otherwise.

◆ NameUniquenessExceptions()

static std::vector<std::string> sdf::SDF_VERSION_NAMESPACE::Element::NameUniquenessExceptions ( )
static

List of elements to which exceptions are made when checking for name uniqueness.

Returns
List of element types that are allowed to have name collisions.

◆ OriginalVersion()

const std::string& sdf::SDF_VERSION_NAMESPACE::Element::OriginalVersion ( ) const

Get the spec version that this was originally parsed from.

Returns
Spec version string.

◆ PrintDescription() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintDescription ( const std::string &  _prefix) const

Output Element's description to stdout.

Parameters
[in]_prefixString value to prefix to the output.

◆ PrintDescription() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintDescription ( sdf::Errors _errors,
const std::string &  _prefix 
) const

Output Element's description to stdout.

Parameters
[out]_errorsVector of errors.
[in]_prefixString value to prefix to the output.

◆ PrintDocLeftPane()

void sdf::SDF_VERSION_NAMESPACE::Element::PrintDocLeftPane ( std::string &  _html,
int  _spacing,
int &  _index 
) const

Helper function for SDF::PrintDoc.

This generates the SDF html documentation.

Parameters
[out]_htmlAccumulated HTML for output.
[in]_spacingAmount of spacing for this element.
[in]_indexUnique index for this element.

◆ PrintDocRightPane()

void sdf::SDF_VERSION_NAMESPACE::Element::PrintDocRightPane ( std::string &  _html,
int  _spacing,
int &  _index 
) const

Helper function for SDF::PrintDoc.

This generates the SDF html documentation.

Parameters
[out]_htmlAccumulated HTML for output.
[in]_spacingAmount of spacing for this element.

◆ PrintValues() [1/4]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintValues ( const std::string &  _prefix,
bool  _includeDefaultElements,
bool  _includeDefaultAttributes,
const PrintConfig _config = PrintConfig() 
) const

Output Element's values to stdout.

Parameters
[in]_prefixString value to prefix to the output.
[in]_includeDefaultElementsflag to print default elements.
[in]_includeDefaultAttributesflag to print default attributes.
[in]_configConfiguration for printing the values.

◆ PrintValues() [2/4]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintValues ( sdf::Errors _errors,
const std::string &  _prefix,
bool  _includeDefaultElements,
bool  _includeDefaultAttributes,
const PrintConfig _config = PrintConfig() 
) const

Output Element's values to stdout.

Parameters
[out]_errorsVector of errors.
[in]_prefixString value to prefix to the output.
[in]_includeDefaultElementsflag to print default elements.
[in]_includeDefaultAttributesflag to print default attributes.
[in]_configConfiguration for printing the values.

◆ PrintValues() [3/4]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintValues ( sdf::Errors _errors,
std::string  _prefix,
const PrintConfig _config = PrintConfig() 
) const

Output Element's values to stdout.

Parameters
[out]_errorsVector of errors.
[in]_prefixString value to prefix to the output.
[in]_configConfiguration for printing the values.

◆ PrintValues() [4/4]

void sdf::SDF_VERSION_NAMESPACE::Element::PrintValues ( std::string  _prefix,
const PrintConfig _config = PrintConfig() 
) const

Output Element's values to stdout.

Parameters
[in]_prefixString value to prefix to the output.
[in]_configConfiguration for printing the values.

◆ ReferenceSDF()

std::string sdf::SDF_VERSION_NAMESPACE::Element::ReferenceSDF ( ) const

Get the name of the reference SDF element.

Returns
Name of the reference SDF element.

◆ RemoveAllAttributes()

void sdf::SDF_VERSION_NAMESPACE::Element::RemoveAllAttributes ( )

Removes all attributes.

◆ RemoveAttribute()

void sdf::SDF_VERSION_NAMESPACE::Element::RemoveAttribute ( const std::string &  _key)

Remove an attribute.

Parameters
[in]_keythe key of the attribute.

◆ RemoveChild() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::RemoveChild ( ElementPtr  _child)

Remove a child element.

Parameters
[in]_childPointer to the child to remove.

◆ RemoveChild() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::RemoveChild ( ElementPtr  _child,
sdf::Errors _errors 
)

Remove a child element.

Parameters
[in]_childPointer to the child to remove.
[out]_errorsVector of errors.

◆ RemoveFromParent()

void sdf::SDF_VERSION_NAMESPACE::Element::RemoveFromParent ( )

Remove this element from its parent.

◆ Reset()

void sdf::SDF_VERSION_NAMESPACE::Element::Reset ( )

Call reset on each element and element description before deleting all of them.

Also clear out the embedded Param.

◆ SetCopyChildren()

void sdf::SDF_VERSION_NAMESPACE::Element::SetCopyChildren ( bool  _value)

Set whether this element should copy its child elements during parsing.

Parameters
[in]_valueTrue to copy Element's children.

◆ SetDescription()

void sdf::SDF_VERSION_NAMESPACE::Element::SetDescription ( const std::string &  _desc)

Set a text description for the element.

Parameters
[in]_descthe text description to set for the element.

◆ SetExplicitlySetInFile()

void sdf::SDF_VERSION_NAMESPACE::Element::SetExplicitlySetInFile ( const bool  _value)

Set if the element and children where set or default in the original file.

This is meant to be used by the parser to indicate whether the element was set by the user in the original file or added by default during parsing.

Parameters
[in]_valueTrue if the element was set

◆ SetFilePath()

void sdf::SDF_VERSION_NAMESPACE::Element::SetFilePath ( const std::string &  _path)

Set the path to the SDF document where this element came from.

Parameters
[in]_pathFull path to SDF document.

◆ SetIncludeElement()

void sdf::SDF_VERSION_NAMESPACE::Element::SetIncludeElement ( sdf::ElementPtr  _includeElem)

Set the element that was used to load this element.

This is set by the parser on the first element of the included object (eg. Model, Actor, Light, etc). It is not passed down to children elements.

Parameters
[in]_includeELemThe Element

◆ SetLineNumber()

void sdf::SDF_VERSION_NAMESPACE::Element::SetLineNumber ( int  _lineNumber)

Set the line number of this element within the SDF document.

Parameters
[in]_lineNumberLine number of element.

◆ SetName()

void sdf::SDF_VERSION_NAMESPACE::Element::SetName ( const std::string &  _name)

Set the name of the Element.

Parameters
[in]_nameThe new name for this Element.

◆ SetOriginalVersion()

void sdf::SDF_VERSION_NAMESPACE::Element::SetOriginalVersion ( const std::string &  _version)

Set the spec version that this was originally parsed from.

Parameters
[in]_versionSpec version string.

◆ SetParent()

void sdf::SDF_VERSION_NAMESPACE::Element::SetParent ( const ElementPtr  _parent)

Set the parent of this Element.

Parameters
[in]_parentParent for this element.

◆ SetReferenceSDF()

void sdf::SDF_VERSION_NAMESPACE::Element::SetReferenceSDF ( const std::string &  _value)

Set reference SDF element.

Parameters
[in]_valueName of the reference sdf element.

◆ SetRequired()

void sdf::SDF_VERSION_NAMESPACE::Element::SetRequired ( const std::string &  _req)

Set the requirement type.

Parameters
[in]_reqRequirement type for this element: -1: Deprecated. 0: Not required. 1: Exactly one element is required. +: One or more elements are required. *: Zero or more elements are required.

◆ SetXmlPath()

void sdf::SDF_VERSION_NAMESPACE::Element::SetXmlPath ( const std::string &  _path)

Private data pointer.

◆ ToString() [1/4]

std::string sdf::SDF_VERSION_NAMESPACE::Element::ToString ( const std::string &  _prefix,
bool  _includeDefaultElements,
bool  _includeDefaultAttributes,
const PrintConfig _config = PrintConfig() 
) const

Convert the element values to a string representation.

Current behavior of ToString(const std::string &_prefix) can be achieved by calling this function with _includeDefaultElements=true and _includeDefaultAttributes=false

Parameters
[in]_prefixString value to prefix to the output.
[in]_includeDefaultElementsflag to include default elements.
[in]_includeDefaultAttributesflag to include default attributes.
[in]_configConfiguration for converting to string.
Returns
The string representation.

◆ ToString() [2/4]

std::string sdf::SDF_VERSION_NAMESPACE::Element::ToString ( const std::string &  _prefix,
const PrintConfig _config = PrintConfig() 
) const

Convert the element values to a string representation.

Parameters
[in]_prefixString value to prefix to the output.
[in]_configConfiguration for printing the values.
Returns
The string representation.

◆ ToString() [3/4]

std::string sdf::SDF_VERSION_NAMESPACE::Element::ToString ( sdf::Errors _errors,
const std::string &  _prefix,
bool  _includeDefaultElements,
bool  _includeDefaultAttributes,
const PrintConfig _config = PrintConfig() 
) const

Convert the element values to a string representation.

Current behavior of ToString(const std::string &_prefix) can be achieved by calling this function with _includeDefaultElements=true and _includeDefaultAttributes=false

Parameters
[out]_errorsVector of errors.
[in]_prefixString value to prefix to the output.
[in]_includeDefaultElementsflag to include default elements.
[in]_includeDefaultAttributesflag to include default attributes.
[in]_configConfiguration for converting to string.
Returns
The string representation.

◆ ToString() [4/4]

std::string sdf::SDF_VERSION_NAMESPACE::Element::ToString ( sdf::Errors _errors,
const std::string &  _prefix,
const PrintConfig _config = PrintConfig() 
) const

Convert the element values to a string representation.

Parameters
[out]_errorsVector of errors.
[in]_prefixString value to prefix to the output.
[in]_configConfiguration for printing the values.
Returns
The string representation.

◆ Update() [1/2]

void sdf::SDF_VERSION_NAMESPACE::Element::Update ( )

Call the Update() callback on each element, as well as the embedded Param.

◆ Update() [2/2]

void sdf::SDF_VERSION_NAMESPACE::Element::Update ( sdf::Errors _errors)

Call the Update() callback on each element, as well as the embedded Param.

Parameters
[out]_errorsVector of errors.

◆ XmlPath()

const std::string& sdf::SDF_VERSION_NAMESPACE::Element::XmlPath ( ) const

Get the XML path of this element.

Returns
Full XML path to the SDF element.

The documentation for this class was generated from the following file: