#include <sdf/sdf.hh>
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... | |
ElementPtr | AddElement (const std::string &_name) |
void | AddElementDescription (ElementPtr _elem) |
Add a new element description. 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 | ClearElements () |
Remove all child elements. More... | |
ElementPtr | Clone () const |
Create a copy of this Element. More... | |
void | Copy (const ElementPtr _elem) |
Copy values from an Element. More... | |
template<typename T > | |
T | Get (const std::string &_key="") |
Get the value of a key. More... | |
template<typename T > | |
std::pair< T, bool > | Get (const std::string &_key, const T &_defaultValue) |
Get the value of a key. More... | |
boost::any | GetAny (const std::string &_key="") |
Get the element value/attribute as a boost::any. More... | |
ParamPtr | GetAttribute (const std::string &_key) |
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... | |
bool | GetAttributeSet (const std::string &_key) |
Return true if the attribute was set (i.e. not default value) More... | |
bool | GetCopyChildren () const |
Return true if this Element's child elements should be copied during parsing. More... | |
std::string | GetDescription () const |
Get a text description of the element. More... | |
ElementPtr | GetElement (const std::string &_name) const |
ElementPtr | GetElement (const std::string &_name) |
Return a pointer to the child element with the provided name. More... | |
ElementPtr | GetElementDescription (unsigned int _index) const |
Get an element description using an index. More... | |
ElementPtr | GetElementDescription (const std::string &_key) const |
Get an element descriptio using a key. More... | |
size_t | GetElementDescriptionCount () const |
Get the number of element descriptions. More... | |
ElementPtr | GetElementImpl (const std::string &_name) const |
ElementPtr | GetFirstElement () const |
Get the first child element. More... | |
std::string | GetInclude () const |
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 () |
Get the param of the elements value. More... | |
bool | HasAttribute (const std::string &_key) |
bool | HasElement (const std::string &_name) const |
bool | HasElementDescription (const std::string &_name) |
Return true if an element description exists. More... | |
void | InsertElement (ElementPtr _elem) |
void | PrintDescription (const std::string &_prefix) |
Output Element's description to stdout. More... | |
void | PrintDocLeftPane (std::string &_html, int _spacing, int &_index) |
Helper function for SDF::PrintDoc. More... | |
void | PrintDocRightPane (std::string &_html, int _spacing, int &_index) |
Helper function for SDF::PrintDoc. More... | |
void | PrintValues (std::string _prefix) |
Output Element's values to stdout. More... | |
void | PrintWiki (std::string _prefix) |
std::string | ReferenceSDF () const |
Get the name of the reference SDF element. More... | |
void | RemoveChild (ElementPtr _child) |
Remove a child element. More... | |
void | RemoveFromParent () |
Remove this element from its parent. More... | |
void | Reset () |
template<typename T > | |
bool | Set (const T &_value) |
void | SetCopyChildren (bool _value) |
Set whether this element should copy its child elements during parsing. More... | |
void | SetDescription (const std::string &_desc) |
Set a text description for the element. More... | |
void | SetInclude (const std::string &_filename) |
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) const |
Convert the element values to a string representation. More... | |
void | Update () |
sdf::Element::Element | ( | ) |
Constructor.
|
virtual |
Destructor.
void sdf::Element::AddAttribute | ( | const std::string & | _key, |
const std::string & | _type, | ||
const std::string & | _defaultvalue, | ||
bool | _required, | ||
const std::string & | _description = "" |
||
) |
Add an attribute value.
[in] | _key | Key value. |
[in] | _type | Type of data the attribute will hold. |
[in] | _defaultValue | Default value for the attribute. |
[in] | _required | Requirement string. Element::SetRequired. |
[in] | _description | A text description of the attribute. |
ElementPtr sdf::Element::AddElement | ( | const std::string & | _name | ) |
void sdf::Element::AddElementDescription | ( | ElementPtr | _elem | ) |
Add a new element description.
void sdf::Element::AddValue | ( | const std::string & | _type, |
const std::string & | _defaultValue, | ||
bool | _required, | ||
const std::string & | _description = "" |
||
) |
Add a value to this Element.
[in] | _type | Type of data the attribute will hold. |
[in] | _defaultValue | Default value for the attribute. |
[in] | _required | Requirement string. Element::SetRequired. |
[in] | _description | A text description of the attribute. |
void sdf::Element::ClearElements | ( | ) |
Remove all child elements.
ElementPtr sdf::Element::Clone | ( | ) | const |
void sdf::Element::Copy | ( | const ElementPtr | _elem | ) |
boost::any sdf::Element::GetAny | ( | const std::string & | _key = "" | ) |
Get the element value/attribute as a boost::any.
[in] | _key | The key of the attribute. If empty, get the value of the element. Defaults to empty. |
ParamPtr sdf::Element::GetAttribute | ( | const std::string & | _key | ) |
Get the param of an attribute.
[in] | _key | the name of the attribute |
Referenced by Get().
ParamPtr sdf::Element::GetAttribute | ( | unsigned int | _index | ) | const |
Get an attribute using an index.
size_t sdf::Element::GetAttributeCount | ( | ) | const |
Get the number of attributes.
bool sdf::Element::GetAttributeSet | ( | const std::string & | _key | ) |
Return true if the attribute was set (i.e. not default value)
bool sdf::Element::GetCopyChildren | ( | ) | const |
Return true if this Element's child elements should be copied during parsing.
std::string sdf::Element::GetDescription | ( | ) | const |
Get a text description of the element.
ElementPtr sdf::Element::GetElement | ( | const std::string & | _name | ) | const |
ElementPtr sdf::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.
[in] | _name | Name of the child element to retreive. |
ElementPtr sdf::Element::GetElementDescription | ( | unsigned int | _index | ) | const |
Get an element description using an index.
Referenced by Get().
ElementPtr sdf::Element::GetElementDescription | ( | const std::string & | _key | ) | const |
Get an element descriptio using a key.
size_t sdf::Element::GetElementDescriptionCount | ( | ) | const |
Get the number of element descriptions.
ElementPtr sdf::Element::GetElementImpl | ( | const std::string & | _name | ) | const |
Referenced by Get().
ElementPtr sdf::Element::GetFirstElement | ( | ) | const |
Get the first child element.
std::string sdf::Element::GetInclude | ( | ) | const |
const std::string& sdf::Element::GetName | ( | ) | const |
ElementPtr sdf::Element::GetNextElement | ( | const std::string & | _name = "" | ) | const |
Get the next sibling of this element.
[in] | _name | if given then filter siblings by their xml tag |
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.
ElementPtr sdf::Element::GetParent | ( | ) | const |
const std::string& sdf::Element::GetRequired | ( | ) | const |
ParamPtr sdf::Element::GetValue | ( | ) |
Get the param of the elements value.
bool sdf::Element::HasAttribute | ( | const std::string & | _key | ) |
bool sdf::Element::HasElement | ( | const std::string & | _name | ) | const |
Referenced by Get().
bool sdf::Element::HasElementDescription | ( | const std::string & | _name | ) |
Return true if an element description exists.
Referenced by Get().
void sdf::Element::InsertElement | ( | ElementPtr | _elem | ) |
void sdf::Element::PrintDescription | ( | const std::string & | _prefix | ) |
Output Element's description to stdout.
[in] | _prefix | String value to prefix to the output. |
void sdf::Element::PrintDocLeftPane | ( | std::string & | _html, |
int | _spacing, | ||
int & | _index | ||
) |
Helper function for SDF::PrintDoc.
This generates the SDF html documentation.
[out] | _html | Accumulated HTML for output. |
[in] | _spacing | Amount of spacing for this element. |
[in] | _index | Unique index for this element. |
void sdf::Element::PrintDocRightPane | ( | std::string & | _html, |
int | _spacing, | ||
int & | _index | ||
) |
Helper function for SDF::PrintDoc.
This generates the SDF html documentation.
[out] | _html | Accumulated HTML for output |
[in] | _spacing | Amount of spacing for this element. |
void sdf::Element::PrintValues | ( | std::string | _prefix | ) |
Output Element's values to stdout.
[in] | _prefix | String value to prefix to the output. |
void sdf::Element::PrintWiki | ( | std::string | _prefix | ) |
std::string sdf::Element::ReferenceSDF | ( | ) | const |
void sdf::Element::RemoveChild | ( | ElementPtr | _child | ) |
Remove a child element.
[in] | _child | Pointer to the child to remove. |
void sdf::Element::RemoveFromParent | ( | ) |
Remove this element from its parent.
void sdf::Element::Reset | ( | ) |
void sdf::Element::SetCopyChildren | ( | bool | _value | ) |
Set whether this element should copy its child elements during parsing.
[in] | _value | True to copy Element's children. |
void sdf::Element::SetDescription | ( | const std::string & | _desc | ) |
Set a text description for the element.
void sdf::Element::SetInclude | ( | const std::string & | _filename | ) |
void sdf::Element::SetName | ( | const std::string & | _name | ) |
void sdf::Element::SetParent | ( | const ElementPtr | _parent | ) |
Set the parent of this Element.
[in] | _parent | Paren for this element. |
void sdf::Element::SetReferenceSDF | ( | const std::string & | _value | ) |
Set reference SDF element.
[in] | _value | Name of the reference sdf element. |
void sdf::Element::SetRequired | ( | const std::string & | _req | ) |
Set the requirement type.
[in] | _req | Requirement type for this element: 0: Not required 1: Exactly one element is required +: One or more elements are required *: Zero or more elements are required. |
std::string sdf::Element::ToString | ( | const std::string & | _prefix | ) | const |
Convert the element values to a string representation.
[in] | _prefix | String value to prefix to the output. |
void sdf::Element::Update | ( | ) |