#include <robometry/TreeNode.h>
template<class T>
TreeNode class
A class to represent the Node in Tree struct.
Public static variables
- static std::string stringSeparator
- The string separator the default value is ::
Public static functions
- static auto splitString(const std::string& input) -> std::vector<std::string>
- Split a string using the separator.
Constructors, destructors, conversion operators
Public functions
- auto childExists(const std::string& name) const -> bool
- Check if a child with a given name exist.
- auto addChild(const std::string& name, std::shared_ptr<TreeNode<T>> node) -> bool
- Add a new node in the tree.
- auto getChild(const std::string& name) const -> std::weak_ptr<TreeNode<T>>
- Get a child from the node.
- auto getValue() -> std::shared_ptr<T>
- Get the value stored in the node.
- auto getChildren() const -> const std::unordered_map<std::string, std::shared_ptr<TreeNode>>&
- Get the map representing all the children associated to the node.
- auto toString(const std::string& name = ".", const unsigned int depth = 0) const -> std::string
- Return a standard text representation of the content of the node.
- auto empty() const -> bool
- Check if the node is empty.
Function documentation
template<class T>
static std::vector<std::string> robometry:: TreeNode<T>:: splitString(const std::string& input)
Split a string using the separator.
Parameters | |
---|---|
input in | the stribg that should be split |
Returns | an std::vector containing the substrings |
template<class T>
robometry:: TreeNode<T>:: TreeNode(std::shared_ptr<T> _value)
Construct an empty Node of tree containing a value.
Parameters | |
---|---|
_value in | An already initialized pointer containing the value stored in the nore |
template<class T>
bool robometry:: TreeNode<T>:: childExists(const std::string& name) const
Check if a child with a given name exist.
Parameters | |
---|---|
name in | The name of the child |
Returns | True if the child exist false otherwise. |
template<class T>
bool robometry:: TreeNode<T>:: addChild(const std::string& name,
std::shared_ptr<TreeNode<T>> node)
Add a new node in the tree.
Parameters | |
---|---|
name in | The name of the child |
node in | A pointer to the node |
Returns | True if the child has been added, false otherwise. |
This node will be the child of the this node
template<class T>
std::shared_ptr<T> robometry:: TreeNode<T>:: getValue()
Get the value stored in the node.
Returns | A pointer to the value stored in the node. |
---|
template<class T>
const std::unordered_map<std::string, std::shared_ptr<TreeNode>>& robometry:: TreeNode<T>:: getChildren() const
Get the map representing all the children associated to the node.
Returns | The map of the children |
---|
template<class T>
std::string robometry:: TreeNode<T>:: toString(const std::string& name = ".",
const unsigned int depth = 0) const
Return a standard text representation of the content of the node.
Returns | a string containing the standard text representation of the content of the object. |
---|
template<class T>
bool robometry:: TreeNode<T>:: empty() const
Check if the node is empty.
Returns | true if a node is empty |
---|