|
commonlib
|
Node is an abstract class that represents a node in an xml tree and defines functions for writing and reading values/std containers from a node and for building an xml node tree. More...
#include <node.h>
Public Member Functions | |
| virtual void | destroy ()=0 |
| destroy function releases internal node and sets it value to nullptr. | |
| template<typename T > | |
| void | addAttribute (const std::string &name, const T &value) |
| addAttribute function adds an attribute with a given name and given value to a node. More... | |
| template<typename T > | |
| void | write (const std::string &name, const T &value) |
| write function creates a new child with a given name and adds a given value to it. More... | |
| template<typename T , typename U > | |
| void | write (const std::string &name, const T &value, const U &defaultValue) |
| write function creates a new child with a given name and adds a given value to it. More... | |
| template<typename T > | |
| void | read (const std::string &name, T &value) |
| read function reads a value from a nodes child with a given name. More... | |
| template<typename T , typename U > | |
| void | read (const std::string &name, T &value, const U &defaultValue) |
| read function reads a value from a nodes child with a given name. More... | |
| template<typename T > | |
| void | update (const std::string &name, T &value) |
| update function writes or reads a value to/from a node, depends on nodes isWriteUpdateType More... | |
| template<typename T , typename U > | |
| void | update (const std::string &name, T &value, const U &defaultValue) |
| update function writes or reads a value to/from a node, depends on nodes isWriteUpdateType More... | |
| virtual NodePtr | updateChild (const std::string &childName)=0 |
| updateChild function creates or finds a node child with a given name based on update type More... | |
| virtual NodePtr | readChild (const std::string &childName)=0 |
| readChild function finds a node child with a given name More... | |
| virtual NodePtr | createNode (std::string name, std::string value)=0 |
| createNode function creates a new Node and returns a pointer to it. More... | |
| virtual void | initializeNode (std::string name, std::string value)=0 |
| initializeNode function initializes an empty Node with a given name and given value. More... | |
| virtual void | initializeNode (NodePtr node)=0 |
| initializeNode function initializes an empty Node with a given node. More... | |
| virtual void | setValue (std::string value)=0 |
| setValue function sets a given value to a node. More... | |
| virtual NodePtr | addChild (std::string name)=0 |
| addChild function creates and adds a child with a given name to a node and returns a pointer to it. More... | |
| virtual NodePtr | addChild (const NodePtr &childNode)=0 |
| addChild function creates and adds a given child node to a node and returns a pointer to it. More... | |
| virtual NodePtr | clone ()=0 |
| clone function creates a clone of a node. More... | |
| NodePtr | clone (const NodePtr &nodeToClone) |
| clone function creates a clone of a given node and returns a pointer to it. More... | |
| virtual NodePtr | addAttributeNode (const NodePtr &attributeNode)=0 |
| addAttributeNode adds a given attribute node to a node and returns a pointer to it. More... | |
| virtual void | clearChildNodes ()=0 |
| clearChildNodes clears all child nodes. | |
| virtual void | clearAttributeNodes ()=0 |
| clearAttributeNodes clears all attribute nodes. | |
| virtual NodePtr | findChildNode (const std::string &name)=0 |
| findChildNode finds a child node with a given name and returns a pointer to it or nullptr if not found. More... | |
| virtual NodePtr | findAttributeNode (const std::string &name)=0 |
| findAttributeNode finds an attribute node with a given name and returns a pointer to it or nullptr if not found. More... | |
| virtual NodePtr | getAttribute (const size_t attributeIndex)=0 |
| getAttribute returns an attribute with a given index or nullptr if index is invalid. More... | |
| virtual NodePtr | getChild (const size_t childIndex)=0 |
| getChild returns a child with a given index or nullptr if index is invalid. More... | |
| virtual size_t | getAttributeCount ()=0 |
| getAttributeCount returns a number of attributes of a node. More... | |
| virtual size_t | getChildCount ()=0 |
| getChildCount returns a number of children of a node. More... | |
| virtual void | removeAttribute (const std::string &attributeName)=0 |
| removeAttribute removes all attributes with a given name from a node. More... | |
| virtual void | removeAttribute (const size_t attributeIndex)=0 |
| removeAttribute removes an attribute with a given index from a node. More... | |
| virtual void | removeAttribute (NodePtr &attributeNode)=0 |
| removeAttribute removes an attribute that has the same name as given attribute node. More... | |
| virtual void | removeChild (const std::string &childName)=0 |
| removeChild removes all children with a given name from a node. More... | |
| virtual void | removeChild (const size_t childIndex)=0 |
| removeChild removes a child with a given index from a node. More... | |
| virtual void | removeChild (NodePtr &childNode)=0 |
| removeChild removes a child that has the same name as given node. More... | |
| virtual std::string | getName ()=0 |
| getName returns a name of a node. More... | |
| virtual std::string | getValue ()=0 |
| getValue returns a value of a node. More... | |
| virtual NodePtr | getNextSibling ()=0 |
| getNextSibling returns a sibling of a node or nullptr if it doesnt exist. More... | |
| virtual void | updateOperation (bool write)=0 |
| updateOperation sets a node update operation (node can be used either for writting or reading). More... | |
| virtual bool | isWrite ()=0 |
| isWrite returns true if node should be used for writting or false otherwise. More... | |
| virtual bool | isInitialized ()=0 |
| isInitialized returns true if node is initialized or false otherwise. More... | |
| virtual bool | isEmpty ()=0 |
| isEmpty returns true if node does not have any children, attributes and if it does not have any value More... | |
| bool | isDummy () const |
| isDummy returns true if node was created as a dummy node in updateChild function More... | |
Protected Attributes | |
| bool | isDummyNode = false |
Node is an abstract class that represents a node in an xml tree and defines functions for writing and reading values/std containers from a node and for building an xml node tree.
| void Node::addAttribute | ( | const std::string & | name, |
| const T & | value | ||
| ) |
addAttribute function adds an attribute with a given name and given value to a node.
| name | Name of an attribute |
| value | Value of an attribute |
|
pure virtual |
addAttributeNode adds a given attribute node to a node and returns a pointer to it.
| attributeNode | Shared pointer to an attribute node that will be assigned to a node |
Implemented in LibXmlNode.
|
pure virtual |
addChild function creates and adds a child with a given name to a node and returns a pointer to it.
| name | Name of a child |
Implemented in LibXmlNode.
|
pure virtual |
addChild function creates and adds a given child node to a node and returns a pointer to it.
| childNode | Shared pointer to a node that will become a child |
Implemented in LibXmlNode.
|
pure virtual |
clone function creates a clone of a node.
Implemented in LibXmlNode.
| NodePtr Node::clone | ( | const NodePtr & | nodeToClone | ) |
clone function creates a clone of a given node and returns a pointer to it.
| nodeToClone | Shared pointer to a node that will be cloned |
|
pure virtual |
createNode function creates a new Node and returns a pointer to it.
| name | Name of a child |
| value | Value of a child |
Implemented in LibXmlNode.
|
pure virtual |
findAttributeNode finds an attribute node with a given name and returns a pointer to it or nullptr if not found.
| name | Name of a attribute node to search for |
Implemented in LibXmlNode.
|
pure virtual |
findChildNode finds a child node with a given name and returns a pointer to it or nullptr if not found.
| name | Name of a child node to search for |
Implemented in LibXmlNode.
|
pure virtual |
getAttribute returns an attribute with a given index or nullptr if index is invalid.
| attributeIndex | Index of an attribute |
Implemented in LibXmlNode.
|
pure virtual |
getAttributeCount returns a number of attributes of a node.
Implemented in LibXmlNode.
|
pure virtual |
getChild returns a child with a given index or nullptr if index is invalid.
| childIndex | Index of a child |
Implemented in LibXmlNode.
|
pure virtual |
getChildCount returns a number of children of a node.
Implemented in LibXmlNode.
|
pure virtual |
|
pure virtual |
getNextSibling returns a sibling of a node or nullptr if it doesnt exist.
Implemented in LibXmlNode.
|
pure virtual |
|
pure virtual |
initializeNode function initializes an empty Node with a given name and given value.
| name | Name of a node |
| value | Value of a node |
Implemented in LibXmlNode.
|
pure virtual |
initializeNode function initializes an empty Node with a given node.
| node | Shared pointer to a node |
Implemented in LibXmlNode.
| bool Node::isDummy | ( | ) | const |
isDummy returns true if node was created as a dummy node in updateChild function
|
pure virtual |
isEmpty returns true if node does not have any children, attributes and if it does not have any value
Implemented in LibXmlNode.
|
pure virtual |
isInitialized returns true if node is initialized or false otherwise.
Implemented in LibXmlNode.
|
pure virtual |
isWrite returns true if node should be used for writting or false otherwise.
Implemented in LibXmlNode.
| void Node::read | ( | const std::string & | name, |
| T & | value | ||
| ) |
read function reads a value from a nodes child with a given name.
| name | Name of a node |
| value | Value of a node. It can be of any primitive type or any std container type. Does not support C arrays. If node does not exist than value will be default which is 0 for numbers and empty string for strings. |
| void Node::read | ( | const std::string & | name, |
| T & | value, | ||
| const U & | defaultValue | ||
| ) |
read function reads a value from a nodes child with a given name.
| name | Name of a node |
| value | Value of a node. It can be of any primitive type. |
| defaultValue | Default value of a node which is used for output value if node with a given name is not found. |
|
pure virtual |
readChild function finds a node child with a given name
| childName | Name of a child |
Implemented in LibXmlNode.
|
pure virtual |
removeAttribute removes all attributes with a given name from a node.
| attributeName | Name of attributes to remove |
Implemented in LibXmlNode.
|
pure virtual |
removeAttribute removes an attribute with a given index from a node.
| attributeIndex | Index of attribute to remove |
Implemented in LibXmlNode.
|
pure virtual |
removeAttribute removes an attribute that has the same name as given attribute node.
| attributeNode | Shared pointer to an attribute node to remove |
Implemented in LibXmlNode.
|
pure virtual |
removeChild removes all children with a given name from a node.
| childName | Name of children to remove |
Implemented in LibXmlNode.
|
pure virtual |
removeChild removes a child with a given index from a node.
| childIndex | Index of a child to remove |
Implemented in LibXmlNode.
|
pure virtual |
removeChild removes a child that has the same name as given node.
| childNode | Shared pointer to a child node to remove |
Implemented in LibXmlNode.
|
pure virtual |
setValue function sets a given value to a node.
| value | Value of a node |
Implemented in LibXmlNode.
| void Node::update | ( | const std::string & | name, |
| T & | value | ||
| ) |
update function writes or reads a value to/from a node, depends on nodes isWriteUpdateType
| name | Name of a node |
| value | Value of a node. It can be of any primitive type or any std container type. Does not support C arrays. If node does not exist than value that is read will be default which is 0 for numbers and empty string for strings. |
| void Node::update | ( | const std::string & | name, |
| T & | value, | ||
| const U & | defaultValue | ||
| ) |
update function writes or reads a value to/from a node, depends on nodes isWriteUpdateType
| name | Name of a node |
| value | Value of a node. It can be of any primitive type |
| defaultValue | Custom default value of a node which is used for output value if node with a given name does not exist. |
|
pure virtual |
updateChild function creates or finds a node child with a given name based on update type
| childName | Name of a child |
Implemented in LibXmlNode.
|
pure virtual |
updateOperation sets a node update operation (node can be used either for writting or reading).
Setting updateOperation is optional.
| write | can be wither true for writting or false for reading |
Implemented in LibXmlNode.
| void Node::write | ( | const std::string & | name, |
| const T & | value | ||
| ) |
write function creates a new child with a given name and adds a given value to it.
| name | Name of a node |
| value | Value of a node. It can be of any primitive type or any std container type. Does not support C arrays. |
| void Node::write | ( | const std::string & | name, |
| const T & | value, | ||
| const U & | defaultValue | ||
| ) |
write function creates a new child with a given name and adds a given value to it.
If written value is equal to a given default value than node is not created!
| name | Name of a node |
| value | Value of a node. It can be of any primitive type. |
| defaultValue | Default value of a node. If value is equal to node value than node is not created! |