IOLink  IOL_v1.1.0_release
iolink::MetadataNode Class Reference

Class which represents one node from a metadata tree. More...

#include <iolink/metadata/MetadataNode.h>

Public Member Functions

 MetadataNode (const std::string &key, std::shared_ptr< VariantDataValue > value)
 Constructor which takes a mandatory key, and an optional value. More...
 
 MetadataNode (const MetadataNode &other)
 
MetadataNodeoperator= (const MetadataNode &other)
 
 MetadataNode (MetadataNode &&other) noexcept
 
MetadataNodeoperator= (MetadataNode &&other) noexcept
 
std::shared_ptr< MetadataNodeclone () const
 Method to clone the current node. More...
 
const std::string & key () const
 Accessor to the key of the current node. More...
 
std::shared_ptr< VariantDataValuevalue () const
 Accessor to the value of the current node. More...
 
size_t childCount () const
 Return the children's count of this node.
 
bool hasChild (const std::string &key) const
 Indicate if a child identified by its key is present or not. More...
 
std::shared_ptr< const MetadataNodechild (const std::string &key) const
 Return the child node with the given key. More...
 
std::shared_ptr< MetadataNodechild (const std::string &key)
 Return the child node with the given key. More...
 
void addChild (std::shared_ptr< MetadataNode > child)
 Add a node as child. More...
 
void removeChild (const std::string &key)
 Remove child identified by its key. More...
 
MetadataNodeIterator begin ()
 Return iterator on first child.
 
MetadataNodeIterator end ()
 Return iterator which indicates the end of children list.
 
ConstMetadataNodeIterator begin () const
 Return iterator on first child.
 
ConstMetadataNodeIterator end () const
 Return iterator which indicates the end of children list.
 
ConstMetadataNodeIterator cbegin () const
 Return const iterator on first child.
 
ConstMetadataNodeIterator cend () const
 Return const iterator which indicates the end of children list.
 
std::string toString () const
 Return a string representation.
 

Detailed Description

Class which represents one node from a metadata tree.

Each node contains a key and also an associated value (optional). It also contains a list of nodes which represents its children in the tree. Children can be parsed using '(Const)MetadataNodeIterator' objects provided by '(c)begin' and '(c)end' methods, or directly can be retrieved thanks to 'child' accessor method.

Constructor & Destructor Documentation

◆ MetadataNode()

iolink::MetadataNode::MetadataNode ( const std::string &  key,
std::shared_ptr< VariantDataValue value 
)

Constructor which takes a mandatory key, and an optional value.

Parameters
keystring which identifies the node
valueVariantDataValue object associated to the key (or null)

Member Function Documentation

◆ addChild()

void iolink::MetadataNode::addChild ( std::shared_ptr< MetadataNode child)

Add a node as child.

If the given child key already exists in the current node, existing child is replaced by new one

Parameters
childnode to add as child to the current node

◆ child() [1/2]

std::shared_ptr<MetadataNode> iolink::MetadataNode::child ( const std::string &  key)

Return the child node with the given key.

Parameters
keythe key corresponding to one of the children of current node
Returns
the child corresponding to given key
Exceptions
ErrorIf the key is not found in the children of the current node

◆ child() [2/2]

std::shared_ptr<const MetadataNode> iolink::MetadataNode::child ( const std::string &  key) const

Return the child node with the given key.

Parameters
keythe key corresponding to one of the children of current node
Returns
the child corresponding to given key
Exceptions
ErrorIf the key is not found in the children of the current node

◆ clone()

std::shared_ptr<MetadataNode> iolink::MetadataNode::clone ( ) const

Method to clone the current node.

Returns
the new node

◆ hasChild()

bool iolink::MetadataNode::hasChild ( const std::string &  key) const

Indicate if a child identified by its key is present or not.

Parameters
keythe key corresponding to a child or not of current node
Returns
If the node has a child with given key

◆ key()

const std::string& iolink::MetadataNode::key ( ) const

Accessor to the key of the current node.

Returns
the current node key

◆ removeChild()

void iolink::MetadataNode::removeChild ( const std::string &  key)

Remove child identified by its key.

Parameters
keyKey whose node must be removed

◆ value()

std::shared_ptr<VariantDataValue> iolink::MetadataNode::value ( ) const

Accessor to the value of the current node.

Returns
the current node value

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