IOLink
IOL_v1.6.1_release
|
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) | |
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. More... | |
const std::string & | key () const |
Accessor to the key of the current node. More... | |
std::shared_ptr< VariantDataValue > | value () 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 MetadataNode > | child (const std::string &key) const |
Return the child node with the given key. More... | |
std::shared_ptr< MetadataNode > | child (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. | |
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.
iolink::MetadataNode::MetadataNode | ( | const std::string & | key, |
std::shared_ptr< VariantDataValue > | value | ||
) |
Constructor which takes a mandatory key, and an optional value.
key | string which identifies the node |
value | VariantDataValue object associated to the key (or null) |
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
child | node to add as child to the current node |
std::shared_ptr<MetadataNode> iolink::MetadataNode::child | ( | const std::string & | key | ) |
Return the child node with the given key.
key | the key corresponding to one of the children of current node |
Error | If the key is not found in the children of the current node |
std::shared_ptr<const MetadataNode> iolink::MetadataNode::child | ( | const std::string & | key | ) | const |
Return the child node with the given key.
key | the key corresponding to one of the children of current node |
Error | If the key is not found in the children of the current node |
std::shared_ptr<MetadataNode> iolink::MetadataNode::clone | ( | ) | const |
Method to clone the current node.
bool iolink::MetadataNode::hasChild | ( | const std::string & | key | ) | const |
Indicate if a child identified by its key is present or not.
key | the key corresponding to a child or not of current node |
const std::string& iolink::MetadataNode::key | ( | ) | const |
Accessor to the key of the current node.
void iolink::MetadataNode::removeChild | ( | const std::string & | key | ) |
Remove child identified by its key.
key | Key whose node must be removed |
std::shared_ptr<VariantDataValue> iolink::MetadataNode::value | ( | ) | const |
Accessor to the value of the current node.