Class CNode#

Inheritance Relationships#

Derived Type#

Class Documentation#

class CNode#

Node class allowing access to the type and value.

Subclassed by sdv::toml::CNodeCollection

Public Functions

CNode() = default#

Default constructor.

inline CNode(const TInterfaceAccessPtr &rptrNode)#

Node assignment constructor.

Parameters:

rptrNode[in] Reference to the node interface.

inline CNode &operator=(const TInterfaceAccessPtr &rptrNode)#

Node assignment operator.

Parameters:

rptrNode[in] Reference to the node interface.

Returns:

Reference to this class.

inline virtual bool IsValid() const#

Does the class contain a valid node?

Returns:

Returns ‘true’ if the class contains a valid node; ‘false’ otherwise.

inline virtual operator bool() const#

Does the class contain a valid node?

Returns:

Returns ‘true’ if the class contains a valid node; ‘false’ otherwise.

inline TInterfaceAccessPtr GetInterface()#

Get the underlying interface.

Returns:

The interface pointer.

inline sdv::u8string GetName() const#

Return the node name.

Returns:

String containing the node name.

inline sdv::u8string GetQualifiedPath() const#

Retrurn the node qualified path including the parent path.

The qualified path is a path composed through all parent nodes containing quoted names where needed. The path to the node can be used to directly access the node.

Returns:

String containing the qualified path to the node.

inline ENodeType GetType() const#

Get the node type.

Returns:

The node type.

inline std::string GetComment() const#

Return any associated comment text for this node.

Returns:

The node comment or an empty string when there is not comment for this node.

inline void SetComment(const std::string &rssComment)#

Set comment for this node. Comments are placed before the node if this node is a table or an array and placed behind the node if this node is a value node.

Parameters:

rssComment – Reference to the comment string.

inline sdv::any_t GetValue() const#

Get the node value if the node contains a value.

Returns:

The node value or empty when the node doesn’t have a value.

inline std::string GetValueAsString() const#

Automatically cast the value to a string.

Returns:

String to return or an empty string.

inline std::filesystem::path GetValueAsPath() const#

Automatically cast the value to a path (only for string values).

Returns:

Path to return or an empty path.

inline bool SetValue(const sdv::any_t &ranyValue)#

Set the node value if the node is a value node.

Remark

The value type depends on the node type and will be converted if necessary.

Parameters:

ranyValue[in] Reference to the value to set.

Returns:

Returns ‘true’ on successful setting; ‘false’ otherwise.

inline bool Delete()#

Delete the node including all child nodes.

Returns:

Returns ‘true’ on successful setting; ‘false’ otherwise.

inline virtual void Clear()#

Clear the node class.

inline sdv::u8string GetTOML() const#

Get the TOML string from this node including all children.

Returns:

The TOML string.

Protected Attributes

TInterfaceAccessPtr m_ptrNode#

Pointer to the node interface.

INodeInfo *m_pNodeInfo = nullptr#

Node information interface.