Class CNode#
Defined in File parser_node_toml.h
Inheritance Relationships#
Base Types#
public std::enable_shared_from_this< CNode >
public sdv::IInterfaceAccess
(Struct IInterfaceAccess)public sdv::toml::INodeInfo
(Struct INodeInfo)
Derived Types#
public CBooleanNode
(Class CBooleanNode)public CFloatingPointNode
(Class CFloatingPointNode)public CIntegerNode
(Class CIntegerNode)public CNodeCollection
(Class CNodeCollection)public CStringNode
(Class CStringNode)
Class Documentation#
-
class CNode : public std::enable_shared_from_this<CNode>, public sdv::IInterfaceAccess, public sdv::toml::INodeInfo#
Node to build up the parse tree.
Subclassed by CBooleanNode, CFloatingPointNode, CIntegerNode, CNodeCollection, CStringNode
Unnamed Group
Public Functions
-
~CNode()#
Destroy the node object.
-
virtual sdv::u8string GetName() const override#
Get the node name. Overload of sdv::toml::INodeInfo::GetName.
- Returns:
String containing the name of the node.
-
virtual sdv::any_t GetValue() const override#
The node value. Overload of sdv::toml::INodeInfo::GetValue.
- Returns:
For boolean, integer, floating point and strings, the function returns a value. Otherwise the function returns empty.
-
virtual sdv::u8string GetTOML() const override#
The node value. Overload of sdv::toml::INodeInfo::GetTOML.
- Returns:
For boolean, integer, floating point and strings, the function returns a value. Otherwise the function returns empty.
-
std::shared_ptr<const CArray> GetArray() const#
Gets the array value of a node.
- Returns:
Returns a shared pointer of the array value stored in the node if the stored type is array
-
std::shared_ptr<CArray> GetArray()#
Gets the array value of a node.
- Returns:
Returns a shared pointer of the array value stored in the node if the stored type is array
-
std::shared_ptr<const CTable> GetTable() const#
Gets the table value of a node.
- Returns:
Returns a shared pointer of the table value stored in the node if the stored type is table
-
std::shared_ptr<CTable> GetTable()#
Gets the table value of a node.
- Returns:
Returns a shared pointer of the table value stored in the node if the stored type is table
Set the parent node.
- Parameters:
rptrParent – [in] Reference to the node to assign to this node as a parent.
-
virtual std::shared_ptr<CNode> GetDirect(const std::string &rssPath) const#
Accesses a node by its key in the parse tree.
Elements of tables can be accessed and traversed by using ‘.’ to separated the parent name from child name. E.g. ‘parent.child’ would access the ‘child’ element of the ‘parent’ table. Elements of arrays can be accessed and traversed by using the index number in brackets. E.g. ‘array[3]’ would access the fourth element of the array ‘array’. These access conventions can also be chained like ‘table.array[2][1].subtable.integerElement’.
- Attention
Array indexing starts with 0!
- Parameters:
rssPath – [in] The path of the node to searched for.
- Returns:
Returns a shared pointer to the wanted Node if it was found or a node with invalid content if it was not found.
-
std::string CreateTOMLText(const std::string &rssParent = std::string()) const#
Create the TOML text based on the content using an optional parent node.
- Parameters:
rssParent – [in] When present, uses the parent node into the TOML text generation.
- Returns:
The string containing the TOML text.
-
virtual std::string CreateTOMLText(const std::string &rssParent, std::string &rssLastPrintedTable, bool bFirst = true, bool bEmbedded = false, bool bAssignment = true, bool bRoot = false) const = 0#
Get the TOML text based on the content.
- Parameters:
rssParent – [in] When present, uses the parent node into the TOML text generation.
rssLastPrintedTable – [in] Reference to the string containing the last printed table. This might be necessary in case a different table was printed in between.
bFirst – [in] When set, this is the first entry in an array or table.
bEmbedded – [in] When set, this is an embedded definition in an array or table.
bAssignment – [in] When set, this is a table assignment.
bRoot – [in] Only for table entries, when set this is the root entry (suppress the table name).
- Returns:
The string containing the TOML text.
-
virtual std::shared_ptr<CNode> Find(const std::string &rssPath) const#
Searches the subtree of the node for a node at the given location using the provided path.
Remark
The path elements of arrays and tables are separated by a dot.
- Parameters:
rssPath – [in] Reference to the string containing the path of the node to find.
- Returns:
Returns a shared pointer to the wanted Node if it is found or an error-Node if it is not
Adds a given node to a given path in the tree.
Remark
The path elements of arrays and tables are separated by a dot.
- Parameters:
rssPath – [in] Reference to the string containing the path in the tree of the location to the new node to be inserted.
rptrNode – [in] Reference to the smart pointer containing the new node to be added.
bDefinedExplicitly – [in] If a table that is created to create the path of the node to be added is defined explicitly.
- Throws:
XInvalidAccessException – Throws an XInvalidAccessException if a ancestor node is not open to add children.
XDuplicateNameException – Throws a XDuplicateNameException if a node with the same path as the node to be added is already defined explicitly
Protected Functions
-
CNode(const std::string &rssName)#
Constructs a new node object representing a table or an array.
- Parameters:
rssName – [in] Reference to the name of the node.
-
~CNode()#