Class CValueNode#

Inheritance Relationships#

Base Type#

Derived Types#

Class Documentation#

class CValueNode : public toml_parser::CNode#

Class implementing the value node.

A value always is inline. Two versions exist: the assignment version and the embedded in-an-array-version. Not embedded in an array (with assignment):

<whitespace>KEY<whitespace>.<whitespace>KEY<whitespace>=<whitespace>VALUE<whitespace>
  ^              ^            ^              ^            ^                ^
  pre-node       post_key_ws  pre_key_ws     post_key_ws  pre_value_ws     post-node
Embedded in an array (without assignment):
<whitespace>VALUE<whitespace>
  ^                ^
  pre-node         post-node
The pre- and post-node whitespace areas are covered by the UpdateNodeCode function of the CNode base class. Multiple optional pre- and post-key whitespace areas can be defined.

Subclassed by toml_parser::CBooleanNode, toml_parser::CFloatingPointNode, toml_parser::CIntegerNode, toml_parser::CStringNode

Protected Functions

CValueNode(CParser &rparser, const std::string &rssName, const std::string &rssRawName, const std::string &rssRawValue)#

Constructs a new node object.

Parameters:
  • rparser[in] Reference to the TOML parser.

  • rssName[in] Reference to the name of the node.

  • rssRawName[in] Reference to the raw name of the node.

  • rssRawValue[in] Reference to the raw value string.

virtual bool Inline() const override#

The derived class from the node collection can be inline or not. Overload of CNode::Inline.

Returns:

Returns whether the node is an inline node.

virtual bool Inline(bool bInline) override#

With some node collections it is possible to switch between inline and normal. Overload of CNode::Inline.

Remark

Additional node composition information will be removed and the order within the parent node might be changed.

Parameters:

bInline[in] When set, try to switch to inline. Otherwise try to switch to normal.

Returns:

Returns whether the switch was successful. A switch to the same type (normal to normal or inline to inline is always successful). When returning false, the switching might not be supported for this type.

virtual std::shared_ptr<CNode> Direct(const std::string &rssPath) const override#

Accesses a node by its key in the parse tree. Overload of CNode::Direct.

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!

Attention

For an array, when no indexing is supplied, the latest entry will be returned.

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.

virtual std::string GenerateTOML(const CGenContext &rContext = CGenContext()) const override#

Create the TOML text based on the content using an optional prefix node. Overload of CNode::GenerateTOML.

Parameters:

rContext[in] Reference to the context class to use during TOML code generation.

Returns:

The TOML text string.

virtual std::string ValueText() const = 0#

Get the value in text form.

Returns:

String with the value in text form.

virtual void UpdateNodeCode(const CNodeTokenRange &rNodeRange) override#

Update the node with TOML code information. Overload of CNode::UpdateNodeCode.

Parameters:

rNodeRange[in] Reference to the node range information containing the tokens for the code snippets.

std::string RawValueText() const#

Get the raw value text.

Returns:

The raw value text of the original value token. Or if not existing, the value text.