Class CDeclarationEntity#

Inheritance Relationships#

Base Types#

Derived Types#

Class Documentation#

class CDeclarationEntity : public CEntity, public sdv::idl::IDeclarationEntity#

The base for declaration entity definitions within an IDL file (declarations, typedefs, attributes, operations, parameters, case declarations, enum entries).

The declaration entity definitions all have a similar setup with small differences in detail. Consider the following structures:

<type> <name> = <value>
const <type> <name> = <value>
readonly attribute <name>
<operation_type> <operation_name>(<parameter_type> <parameter_name>) const
The following generalized structure applies to all declaration structures:
prefix type name
prefix type name = value
prefix type name(parameters) postfix
The first statement is a declaration. The second statement is a declaration with an assignment. The last statement represents an operation. The prefix is used to provide a specific interpretation to the declaration (in, out, inout, const, attribute, readonly, typedef, struct, union, enum). The type defines the type the declaration represents (either a system type or a typedefed type - scoped name). The name is the defined name o the declaration. The value is the expression used for the assignment. The parameters are a list of zero or more declaration statements. The postfix is used to provide a specific interpretation to the declaration (const). Some declarations might start as a complex type (e.g. struct, union, enum). The might contain the type definition as well as the declaration. For example:
struct <def_name> { <definition> } <decl_name>
struct { <definition> } <decl_name>
In the first statement, the struct is defined and declared in one statement. In the second statement, an anonymous struct is defined and declared in one statement. Multiple declarations are possible for many types. The declarations are separated by a comma and follow the same rules as a single declaration starting at the <name>.
<type> <name_1> = <value_1>, <name_2> = <value_2>, <name_3>, <name_4> = <value_4>

Subclassed by CAttributeEntity, CEnumEntry, COperationEntity, CParameterEntity, CTypedefEntity, CVariableEntity

Public Functions

CDeclarationEntity(const CContextPtr &rptrContext, CEntityPtr ptrParent)#

Default constructor.

Parameters:
  • rptrContext[in] Reference to the smart pointer holding the parse context. Must not be NULL.

  • ptrParent[in] Pointer to the parent class holding this entity. This must not be NULL.

CDeclarationEntity(const CContextPtr &rptrContext, CEntityPtr ptrParent, const CTokenList &rlstTokenList)#

Constructor using the provided token-list to process the code.

Parameters:
  • rptrContext[in] Reference to the smart pointer holding the parse context. Must not be NULL.

  • ptrParent[in] Pointer to the parent class holding this entity. This must not be NULL.

  • rlstTokenList[in] Reference to the token list holding the tokens to process.

virtual ~CDeclarationEntity() override = default#

Destructor.

virtual sdv::interface_t GetInterface(sdv::interface_id idInterface) override#

Get access to another interface. Overload of sdv::IInterfaceAccess::GetInterface.

Parameters:

idInterface[in] The interface id to get access to.

Returns:

Returns a pointer to the interface or NULL when the interface is not supported.

virtual sdv::IInterfaceAccess *GetDeclarationType() const override#

Get declaration type. Overload of sdv::idl::IDeclarationEntity::GetDeclarationType.

Returns:

Interface to the declaration type object.

virtual bool HasArray() const override#

Is array? Overload of sdv::idl::IDeclarationEntity::HasArray/HasDynamicArray.

Returns:

Retrurns whether the declaration reqpresents an array.

virtual sdv::sequence<sdv::idl::SArrayDimension> GetArrayDimensions() const override#

Get the array dimensions (if there are any). Overload of IDeclarationEntity::GetDimensionCount.

Returns:

Smart pointer to the sequence of array dimensions.

virtual bool HasAssignment() const override#

Has assignment? Overload of sdv::idl::IDeclarationEntity::HasAssignment.

Returns:

Returns whether the declaration has an assignment.

virtual sdv::u8string GetAssignment() const override#

Get assignment string. Overload of sdv::idl::IDeclarationEntity::GetAssignment.

The assignment can be an algebraic expression composed from constants and variables. If the assignment is an array, the expression is composed like this: {{expr1},{expr2},{expr…}}

Returns:

On success, returns the assignment string object or an empty string when no assignment is available.

inline virtual sdv::idl::EDeclType GetBaseType() const#

Get the base type of the entity.

Returns:

Returns the base type.

CEntityPtr GetTypeEntity() const#

Get the type entity if the type is not a system type.

Complex types (struct, enum, union) and type definitions are based on a type entity.

Returns:

Returns a pointer to the type entity if available.

virtual void Process() override#

Process the code. Overload of CEntity::Process.

void ProcessDeclaration(const CTypeDeclaration &rTypeDecl)#

Process a declaration.

The processing of a declaration is done through several steps: processing the declaration type, processing the declaration identifier, processing (multi-dimensional) arrays, processing assignments, processing the next declaration identifier and so on. The following statement are examples:

<type> <identifier>;                                            // No assignment, one declaration
<type> <identifier>, <identifier>;                              // No assignment, multiple declarations
<type> <identifier>=<expression>;                               // One definition (declaration with assignment)
<type> <identifier>=<expressoin>, <identifier>=<expression>;    // Multiple definitions
<type> <identifier>=<expression>, <identifier>;                 // Mixed expression, definition
<type> <identifier>[]={<expression>, <expression>};             // Array definition
<type> <identifier>[<expression>];                              // Array declaration
<type> <identifier>[<expression>]={<expression>, <expression>}; // Array definition
struct <type> <identifier>;                                     // Struct declaration with explicit struct keyword
struct <type> <identifier>={<expression>, <expression>};        // Struct declaration with assignment
union <type> <identifier>;                                      // Union declaration with explicit union keyword
enum <type> <identifier>;                                       // Enum declaration with explicit enum keyword
enum <type> <identifier>=<exppression>;                         // Enum definition with explicit enum keyword
The ‘type’ can be a system type (short, int64, float) or a scoped type definition (MyType, ::MyModule::MyType). Without assignment the type can be ‘struct’ or ‘union’, with or without the ‘struct’ and ‘union’ type identification (not allowed for const entities, which need an assignment). The ‘identifier’ is the unique name for the declaration. This name must be case-insensitive unique within the current scope. The identifier can be followed by square-brackets indicating an array. The size of the array can either be retrieved through the assignment or through the expression. If both an assignment and an expression are available, they must match. The array expression must be of an integral type and is not allowed to become negative. Furthermore, it can be created through a mathematical expression existing of constants and/or when not defined to be a constant entity, through declarations made before (this deviates to C/C++, where dynamic arrays are not allowed). In case of a dynamic array, an assignment is not supported. The assignment ‘expression’ defines a mathematical expression existing of constants and/or when not defined to be a constant entity, through declarations made before.

Remark

Array size expressions and assignment expressions are stored as tokenlists to be processed by the ProcessValueAssignment function.

Parameters:

rTypeDecl[in] Reference to the type identifier (can be a system type as well as a scoped name to a previously defined type).

void PreprocessArrayDeclaration()#

Preprocess the multi-dimensional array declaration.

Preprocess the potential multi-dimensional array declaration by detecting square brackets and storing the tokens between the brackets. The tokens for each dimension are placed in the m_vecMultiArraySizeTokenList vector.

void PreprocessTokenListVector(std::vector<CTokenList> &rvecTokenList)#

Preprocess a list of comma separated declarations.

Preprocess a list of tokens separated by the comma ‘,’ separator and place the tokens in the provided vector. The processing is continued until a square bracket ‘]’ or normal bracket ‘)’ or no token exists any more.

Parameters:

rvecTokenList[in] Reference to the vector containing the token lists to be filled.

void PostProcess()#

Postprocess the token lists that where read in the preprocess functions.

For typedef, const and declaration entities, create the value structure containing the arrays and the values of the type entity. For const and declaration entities, fill the value structure using the assignment stored in the assignment expression token list. For attributes and operations build the raising exception lists. For the operations process the parameter list.

Pre:

SupportAssignments returns true and at least m_vecMultiArraySizeTokenList or m_lstAssignmentTokenList is filled.

inline virtual bool SupportAssignments() const#

Does the entity support assignments (const and variable declarations do, others don’t)?

Determines whether the entity supports assignments. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports assignments; ‘false’ otherwise.

virtual bool RequiresAssignment() const#

Does the entity require an assignment (const declarations do)?

Determines whether the entity requires an assignment. Default value is is based on the presence of an unbound value in the type.

Returns:

Returns ‘true’ when the entity requires an assignment; ‘false’ otherwise.

inline virtual bool CanSupportComplexTypeAssignments() const#

Can the entity be used for assignments of complex types (variable declarations do)?

Returns whether the entity is defined to be usable for complex type assignments. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity defined as declaration; ‘false’ otherwise.

inline virtual bool SupportArrays() const#

Does the entity support arrays (const and variable declarations, as well as typedefs and attributes do)?

Determines whether the entity supports arrays. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports assignments; ‘false’ otherwise.

inline virtual bool IsReadOnly() const override#

Is the entity readonly (variable declarations and writable attributes aren’t)? Overload of IDeclarationEntity::IsReadOnly.

Returns whether the entity is readonly by design or whether it is defined readonly by the code. Default value is ‘true’.

Returns:

Returns ‘true’ when the entity defined as readonly; ‘false’ otherwise.

inline virtual bool IsAnonymous() const override#

Is the entity transparent when used in a struct? Overload of IDeclarationEntity::IsAnonymous.

Returns whether the entity is anonymous when used in a struct/union (unnamed and not declared). This allows its members to appear directly as members within the struct. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity defined as anonymous; ‘false’ otherwise.

inline virtual bool SupportMultipleDeclarations() const#

Does the entity support multiple declarations on one line of code (const and var declarations and attributes do)?

Returns whether the entity supports multiple declarations separated by a comma ‘,’. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports multiple declarations; ‘false’ otherwise.

inline virtual bool DoNotEnfoceNextDeclarationAfterComma() const#

Do not enforce next declaration after comma (enums do)?

Returns whether the entity supports ending the definition after a comma ‘,’. Default value is ‘false’.

Pre:

SupportMultipleDeclarations needs to be supported.

Returns:

Returns ‘true’ when not enforcing the next declaration; ‘false’ otherwise.

inline virtual bool SupportRaiseExceptions() const#

Does the entity support raising exceptions (attributes and operations do)?

Returns whether the entity supports exceptions (defined through the keywords: raises, getraises and setraises). Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports exceptions; ‘false’ otherwise.

inline virtual bool SupportSeparateSetGetRaiseExceptions() const#

Does the entity support separate set/get raising exceptions (only attributes do)?

Returns whether the entity supports exceptions (defined through the keywords: getraises and setraises). Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports separate set/get raise exceptions; ‘false’ otherwise.

inline virtual bool SupportInterface() const#

Does the entity support an interface as base type (non-const variables, operations and parameters do)?

Returns whether the entity supports the an interface as base type base type. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports interfaces as base type; ‘false’ otherwise.

inline virtual bool SupportVoid() const#

Does the entity support ‘void’ as base type (operations do)?

Returns whether the entity supports the ‘void’ base type. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity supports void as base type; ‘false’ otherwise.

inline virtual bool RequiresParameters() const#

Does the entity require parameters (operations do)?

Returns whether the entity requires parameters. Default value is ‘false’.

Returns:

Returns ‘true’ when the entity requires parameters; ‘false’ otherwise.

inline virtual void SetOperationAsConst()#

Set operation as const (operations only).

If the declaration requires parameters, the declaration is checked for being defined as const operation. If so, this function is called. Default implementation doesn’t do anything.

Pre:

Only called when RequiresParameters is true and the declaration is defined as const.

virtual void CalcHash(CHashObject &rHash) const override#

Calculate the hash of this entity and all encapsulated entities. Overload of CBaseEntity::CalcHash.

Parameters:

rHash[inout] Hash object to be filled with data.

Protected Functions

inline CEntityVector &GetParamVector()#

Get parameter vector.

Returns:

Returns the vector with the parameter entities.

inline const CEntityVector &GetParamVector() const#

Get parameter vector.

Returns:

Returns the vector with the parameter entities.

inline CEntityVector &GetExceptionVector()#

Get “raises” exceptions vector.

Returns:

Returns the vector with the exception entities.

inline CEntityVector &GetReadExceptionVector()#

Get “get_raises” exceptions vector.

Returns:

Returns the vector with the exception entities.

inline CEntityVector &GetWriteExceptionVector()#

Get “set_raises” exceptions vector.

Returns:

Returns the vector with the exception entities.