Class CGenContext#

Class Documentation#

class CGenContext#

Generation context information, allowing the generation to take place from the root node as well as from any node collection that contains sub nodes.

Public Types

enum class EPresentation#

Node presentation form.

Values:

enumerator standard#

Standard presentation (root or within table/table-array)

enumerator standard_inline#

Inline presentation (root or within table/table-array)

enumerator embedded#

Embedded presentation (within array or inline-table)

Public Functions

CGenContext(const std::string &rssPrefixKey = std::string(), uint32_t uiOptions = 0)#

Default constructor.

Parameters:
  • rssPrefixKey[in] Reference to the prefix key that is used as a parent during the generation.

  • uiOptions[in] The initial options to set.

void InitTopMostNode(const std::shared_ptr<const CNode> &rptrNode)#

Called by the node that is generating the TOML. If not initialized before, extract the context from the node and assign this node as top node for the code generation.

Parameters:

rptrNode[in] Reference to the node that could be used for initialization as top most node.

bool PartOfExcludedParents(const std::shared_ptr<const CNode> &rptrNode) const#

Check whether the provided node is a parent of the top most node.

Parameters:

rptrNode[in] Reference to the node to use for the checking.

Returns:

Returns true if the node is a parent of the top most node, false otherwise.

CGenContext CopyWithContext(const std::string &rssNewKeyContext, const std::shared_ptr<CNode> &rptrNode, bool bLastNode) const#

Create a copy of the context class with a new key context.

Parameters:
  • rssNewKeyContext[in] Reference to the string containing the new key context.

  • rptrNode[in] Reference to the node pointer to extract the context from.

  • bLastNode[in] When set, this is the last node in the current view.

Returns:

The copy of the contetx class.

const std::string &PrefixKey() const#

Get the stored prefix key that should be used for the TOML code generation.

Returns:

Reference to the prefix key string.

const std::string &KeyContext() const#

Get the stored key context.

Returns:

Reference to the key context string.

const std::string &KeyPath() const#

The key path composed of the prefix and the relative key path.

Returns:

Reference to the key path string.

const std::string &FullKeyPath() const#

The key path composed of the key kontext and the relative key path.

Returns:

Reference to the key path string.

const std::string &RelKeyPath() const#

The relative key path, relative to the current context.

Returns:

Reference to the key path string.

bool TopMostNode() const#

Is this the top most node?

Returns:

Returns when the node is the top most node.

void SetOption(EGenerateOptions eOption)#

Set a generation option.

Parameters:

eOption[in] Option to set.

bool CheckOption(EGenerateOptions eOption) const#

Check whether a generation option has been set.

Parameters:

eOption[in] Option to set.

Returns:

Returns whether the option was set.

bool LastNode() const#

Is the last-node-flag set?

Returns:

Returns whether the last-node-flag has been set indicating the node using this context to be the last node within the current view.

EPresentation Presentation() const#

Get the presentation form of the node.

Returns:

The node presentation extracted from the node and the generation context.

bool Standard() const#

Is the node a standard node?

Returns:

Returns ‘true’ when the node is a standard node.

bool Inline() const#

Is the node an inline node?

Remark

Embedded nodes are also inline.

Returns:

Returns ‘true’ when the node is an inline node.

bool Embedded() const#

Is the node an embedded node (within an inline table or array)?

Returns:

Returns ‘true’ when the node is an embedded node.

bool Assignment() const#

Does the node need an assignment (key and when inline, equal sign)?

Remark

Embedded nodes within an array do not need an assignment.

Returns:

Returns ‘true’ when the node needs an assignment.

bool CommaNeeded() const#

For an embedded node, is a comma indicating the next node needed?

Remark

Some inline arrays can have a final comma behind the last embedded node.

Returns:

Returns ‘true’ when a comma is needed.

bool CommentAndNewlineAllowed() const#

Are comments and newlines allowed? For an embedded node, this might be prohibited. But can also explicitly be defined in the context.

Remark

Inline tables require a one line definition for the embedded nodes.

Returns:

Returns ‘true’ if comments and newlines are allowed.

bool NewlineAllowed() const#

Are newlines allowed? For an embedded node, this might be prohibited. But can also explicitly be defined in the context.

Remark

Inline tables require a one line definition for the embedded nodes.

Returns:

Returns ‘true’ if comments and newlines are allowed.

bool FinalNewline() const#

For a standard (inline) node, is a newline required at the end of the node definition?

Returns:

Returns’true’ if a newline is required behind the node definition.