Class CNodeCollection#
Defined in File toml.h
Inheritance Relationships#
Base Type#
public sdv::toml::CNode(Class CNode)
Derived Type#
public sdv::toml::CTOMLParser(Class CTOMLParser)
Class Documentation#
-
class CNodeCollection : public sdv::toml::CNode#
Node collection class representing a table or array node.
Subclassed by sdv::toml::CTOMLParser
Public Functions
-
CNodeCollection() = default#
Default constructor.
-
inline CNodeCollection(const TInterfaceAccessPtr &rptrNode)#
Node assignment constructor.
- Parameters:
rptrNode – [in] Reference to the node interface.
-
inline CNodeCollection(const CNode &rNode)#
Node assignment constructor.
- Parameters:
rNode – [in] Reference to the node class.
-
inline CNodeCollection &operator=(const TInterfaceAccessPtr &rptrNode)#
Node assignment operator.
- Parameters:
rptrNode – [in] Reference to the node interface.
- Returns:
Reference to this class.
-
inline CNodeCollection &operator=(const CNode &rNode)#
Node assignment operator.
- Parameters:
rNode – [in] Reference to the node class.
- Returns:
Reference to this class.
-
inline virtual bool IsValid() const override#
Does the class contain a valid node?
- Returns:
Returns ‘true’ if the class contains a valid node; ‘false’ otherwise.
-
inline virtual operator bool() const override#
Does the class contain a valid node?
- Returns:
Returns ‘true’ if the class contains a valid node; ‘false’ otherwise.
-
inline size_t GetCount() const#
Return the amount of nodes in this collection.
- Returns:
The amount of nodes.
-
inline CNode Get(size_t nIndex) const#
Get the node at the provided index.
- Parameters:
nIndex – [in] The index number.
- Returns:
Returns the node if available or an empty node when not.
-
inline CNode operator[](size_t nIndex) const#
Get the node at the provided index.
- Parameters:
nIndex – [in] The index number.
- Returns:
Returns the node if available or an empty node when not.
-
inline virtual void Clear() override#
Clear the node class.
-
inline CNode GetDirect(const sdv::u8string &rssNode) const#
Get direct access to a node.
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’.
- Parameters:
rssNode – [in] Reference to the node string.
- Returns:
Returns the node when available or an empty node when not.
-
inline CNode InsertValue(size_t nIndex, const std::string &rssName, const sdv::any_t &ranyValue)#
Insert a value node before the provided position.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
nIndex – [in] The index before which to insert the node. Can be larger than the count value as well as sdv::toml::npos when adding the node at the end.
rssName – [in] Reference to the name of the new value node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
ranyValue – [in] The value to assign to the node. The value also determines the type of value node.
- Returns:
Returns the node when successfully inserted or an empty node when not.
-
inline CNode AddValue(const std::string &rssName, const sdv::any_t &ranyValue)#
Add a value node to the collection.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
rssName – [in] Reference to the name of the new array collection node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
ranyValue – [in] The value to assign to the node. The value also determines the type of value node.
- Returns:
Returns the node when successfully added or an empty node when not.
-
inline CNodeCollection InsertArray(size_t nIndex, const std::string &rssName)#
Insert an array collection before the provided position.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
nIndex – [in] The index before which to insert the node. Can be larger than the count value as well as sdv::toml::npos when adding the node at the end.
rssName – [in] Reference to the name of the new value node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
- Returns:
Returns the collection node when successfully inserted or an empty node when not.
-
inline CNodeCollection AddArray(const std::string &rssName)#
Add an array collection to this collection.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
rssName – [in] Reference to the name of the new array collection node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
- Returns:
Returns the collection node when successfully added or an empty node when not.
-
inline CNodeCollection InsertTable(size_t nIndex, const std::string &rssName, bool bFavorInline = false)#
Insert a table collection before the provided position.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
nIndex – [in] The index before which to insert the node. Can be larger than the count value as well as sdv::toml::npos when adding the node at the end.
rssName – [in] Reference to the name of the new table collection node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
bFavorInline – [in] When set, the node will be added as inline collection node. When not, the node will be inserted as inline collection if the this collection is also inline, as standard when not.
- Returns:
Returns the collection node when successfully inserted or an empty node when not.
-
inline CNodeCollection AddTable(const std::string &rssName, bool bFavorInline = false)#
Add a table collection to this collection.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
rssName – [in] Reference to the name of the new table collection node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
bFavorInline – [in] When set, the node will be added as inline collection node. When not, the node will be inserted as inline collection if the this collection is also inline, as standard when not.
- Returns:
Returns the collection node when successfully added or an empty node when not.
-
inline CNodeCollection InsertTableArray(size_t nIndex, const std::string &rssName, bool bFavorInline = false)#
Insert a table array collection before the provided position.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
Remark
A table array is an array with table inside. Inserting a table array node can also be done by creating an array, if not existing already, and adding a table to the array.
- Parameters:
nIndex – [in] The index before which to insert the node. Can be larger than the count value as well as sdv::toml::npos when adding the node at the end.
rssName – [in] Reference to the name of the new table array node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
bFavorInline – [in] When set, the node will be added as inline collection node. When not, the node will be inserted as inline collection if the this collection is also inline, as standard when not.
- Returns:
Returns the collection node when successfully inserted or an empty node when not. The collection node represents a table collection.
-
inline CNodeCollection AddTableArray(const std::string &rssName, bool bFavorInline = false)#
Add a table array collection to this collection.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
Remark
A table array is an array with table inside. Inserting a table array node can also be done by creating an array, if not existing already, and adding a table to the array.
- Parameters:
rssName – [in] Reference to the name of the new table array node. If this collection is an array, the name is ignored. Otherwise the name must be unique within this collection.
bFavorInline – [in] When set, the node will be added as inline collection node. When not, the node will be inserted as inline collection if the this collection is also inline, as standard when not.
- Returns:
Returns the collection node when successfully inserted or an empty node when not. The collection node represents a table collection.
-
inline int InsertTOML(size_t nIndex, const std::string &rssTOML, bool bAllowPartial = false)#
Insert a TOML string to the collection. All nodes specified in the TOML will be added in the collection except when the nodes already exist. Comment and whitespace are preserved when possible.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
nIndex – [in] The index before which to insert the node. Can be larger than the count value as well as sdv::toml::npos when adding the node at the end.
rssTOML – [in] Reference to the TOML string containing the nodes. The TOML string can be empty, which is not an error. If required the TOML nodes are converted to inline nodes.
bAllowPartial – [in] When set, duplicate nodes (already present in this collection) will be ignored and do not cause an error. When not set, duplicate nodes will cause the function to return without inserting any node.
- Returns:
Returns 1 if the complete TOMl could be inserted, 0 if no TOML could be inserted or -1 when the TOML could be partially inserted.
-
inline int AddTOML(const std::string &rssTOML, bool bAllowPartial = false)#
Add a TOML string to this collection. All nodes specified in the TOML will be added in the collection except when the nodes already exist. Comment and whitespace are preserved when possible.
Remark
The actual position depends on the type of node and the order the nodes are stored. Inline nodes come before standard nodes.
- Parameters:
rssTOML – [in] Reference to the TOML string containing the nodes. The TOML string can be empty, which is not an error. If required the TOML nodes are converted to inline nodes.
bAllowPartial – [in] When set, duplicate nodes (already present in this collection) will be ignored and do not cause an error. When not set, duplicate nodes will cause the function to return without inserting any node.
- Returns:
Returns 1 if the complete TOMl could be inserted, 0 if no TOML could be inserted or -1 when the TOML could be partially inserted.
-
CNodeCollection() = default#