Class CEntityValueNode#

Inheritance Relationships#

Base Type#

  • public std::enable_shared_from_this< CEntityValueNode >

Derived Types#

Class Documentation#

class CEntityValueNode : public std::enable_shared_from_this<CEntityValueNode>#

The entity value node base class.

Entity values form a value tree made of all the values that are part of one assignment. Each value has its special value grammar when used in a assignment. All entities have their own personal linked list, which can be formed from other entities when they are defined as type of a declaration. Variable declarations can also be part of a larger linked list. Arrays form their own links within the linked list Examples:

// Value tree for i: CSimpleTypeValueNode assigning the value 10.
int32 i = 10;

// Value tree for S1: CCompoundTypeValueNode with child CSimpleTypeValueNode assigning the value 20.
struct S1
{
    const int32 m_i1 = 10;      // Value node for m_i1: CSimpleTypeValueNode assigning the value 10.
    int32 m_i2 = 20;            // Part of the value tree of S1.
};

// Value tree for s1: sub-tree of S1 assigning the value 200 to m_i2.
S1 s1 = {200};

// Value tree for S2: CCompoundTypeValueNode with children sub-tree of S1 and CSimpleTypeValueNode assigning the value 5.
struct S2 : S1
{
    int32 m_i3 = 5;             // Part of value tree of S2.
};

// Value tree for s2: sub-tree of S2 assigning the value 150 to S1 and 100 to m_i3.
s2 = {{150}, 100};

// Value tree for rgi: CArrayValueNode having two children assigning the value 10 and 20.
int32 rgi[2] = {10, 20};

// Value tree for rgs3: CarrayValueNode having two children S1 assigning the values 1000 and 2000.
S1 rgs3[2] = {{1000}, {2000}};

Subclassed by CArrayValueNode, CCompoundTypeValueNode, CEnumValueNode, CInterfaceValueNode, CSimpleTypeValueNode

Unnamed Group

template<class TValue>
TValue *Get()#

Get the derived value class.

Template Parameters:

TValue – The value class to request a pointer for.

Returns:

Returns a pointer to the derived class or NULL when the requested class didn’t derive from this value.

template<class TValue>
const TValue *Get() const#

Get the derived value class.

Template Parameters:

TValue – The value class to request a pointer for.

Returns:

Returns a pointer to the derived class or NULL when the requested class didn’t derive from this value.

Unnamed Group

inline const CDeclarationEntity *GetDeclEntity() const#

Get the attached declaration entity.

Returns:

Returns the smart pointer to the entity.

inline CDeclarationEntity *GetDeclEntity()#

Get the attached declaration entity.

Returns:

Returns the smart pointer to the entity.

Unnamed Group

inline virtual bool IsArray() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool IsUnbound() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

virtual bool IsConst() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

virtual bool IsDeclaration() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool IsDynamic() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool IsLiteral() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool IsComplex() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool HasParent() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

inline virtual bool HasChildren() const#

Information functions.

Each function is implemented by an entity value class. The IsConst function traverses through the parents to find out whether or not a value is a const value (this is the case when the entity holding the top most value is a const entity.)

Returns:

Returns the information.

Public Functions

CEntityValueNode(CEntityPtr ptrEntity, const CValueNodePtr ptrParent)#

Constructor.

Parameters:
  • ptrEntity[in] Smart pointer to the entity implementing the type. Cannot be nullptr.

  • ptrParent[in] Smart pointer to the parent value. Can only be nullptr for const and declaration entities or when creating a value node for a definition which will be copied in a larger declaration at a later stage.

CEntityValueNode(const CEntityValueNode &rValueNode, CEntityPtr ptrEntity, const CValueNodePtr ptrParent)#

Copy constructor with new parent and entity.

Parameters:
  • rValueNode[in] Reference to the value node to copy from.

  • ptrEntity[in] Smart pointer to the entity implementing the type. Cannot be nullptr.

  • ptrParent[in] Smart pointer to the parent value. Cannot be nullptr.

virtual ~CEntityValueNode() = default#

Default destructor.

Remark

This constructor needs to be virtual to allow derived classes to be destroyed correctly.

virtual CValueNodePtr CreateCopy(CEntityPtr ptrEntity, const CValueNodePtr ptrParent) const = 0#

Create a copy of the value. Prototype to be implemented from derived class.

Parameters:
  • ptrEntity[in] Smart pointer to the entity receiving the copy of the value node.

  • ptrParent[in] Smart pointer to the parent value. Cannot be nullptr.

Returns:

Returns a smart pointer of the copy of the value.

virtual void ProcessValueAssignment(const CTokenList &rlstExpression) = 0#

Process the assignment. Prototype, to be implemented by derived value class.

Parameters:

rlstExpression[in] Reference to the expression token list.

virtual void ProcessChildNodes(const CTokenList &rlstExpression)#

Process the child nodes.

Parameters:

rlstExpression[in] Reference to the expression token list.

void AddChild(CValueNodePtr ptrChild)#

Add a child node.

Parameters:

ptrChild[in] Pointer to the child value node.

inline const CValueNodePtr &GetParentNode() const#

Get the parent node.

Returns:

Returns a reference to the smart pointer of the parent node (if assigned).

virtual std::string GetDeclTypeStr(bool bResolveTypedef) const#

Get the declaration type build from the value chain.

The declaration type consists of “<base type> <type identifier> <arrays>”.

Parameters:

bResolveTypedef[in] When set, resolve the typedef type into the base type.

Returns:

Returns a string with entity type.

Protected Attributes

CEntityPtr m_ptrEntity#

The entity implementing the value type.

const CValueNodePtr m_ptrParent#

Parent value node - can be nullptr for root node.

std::vector<CValueNodePtr> m_vecChildren#

Child nodes.