| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
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.
| MetadataNode (const MetadataNode &other)
MetadataNode & | operator= (const MetadataNode &other)
| MetadataNode (MetadataNode &&other) noexcept
MetadataNode & | operator= (MetadataNode &&other) noexcept
std::shared_ptr< MetadataNode > | clone () const
| Method to clone the current node.
const std::string & | key () const
| Accessor to the key of the current node.
std::shared_ptr< VariantDataValue > | value () const
| Accessor to the value of the current node.
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.
std::shared_ptr< const MetadataNode > | child (const std::string &key) const
| Return the child node with the given key.
std::shared_ptr< MetadataNode > | child (const std::string &key)
| Return the child node with the given key.
void | addChild (std::shared_ptr< MetadataNode > child)
| Add a node as child.
void | removeChild (const std::string &key)
| Remove child identified by its key.
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

  key | string which identifies the node
  value | VariantDataValue 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

  child | node 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

  key | the key corresponding to one of the children of current node

Returns
  the child corresponding to given key

Exceptions

  Error | If 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

  key | the key corresponding to one of the children of current node

Returns
  the child corresponding to given key

Exceptions

  Error | If 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

  key | the 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

  key | Key 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:

- iolink/public/include/iolink/metadata/MetadataNode.h