The interface for creating expressions. More...
#include <iexpression.h>
Public Member Functions | |
Access to related factories. | |
virtual IValue_factory * | get_value_factory () const =0 |
Returns the value factory associated with this expression factory. More... | |
Creation of expressions and expression lists | |
virtual IExpression_constant * | create_constant (IValue *value) const =0 |
Creates a constant (mutable). More... | |
virtual const IExpression_constant * | create_constant (const IValue *value) const =0 |
Creates a constant (const). More... | |
virtual IExpression_call * | create_call (const char *name) const =0 |
Creates a call. More... | |
virtual IExpression_parameter * | create_parameter (const IType *type, Size index) const =0 |
Creates a parameter reference. More... | |
virtual IExpression_direct_call * | create_direct_call (const char *name, IExpression_list *arguments, Sint32 *errors=0) const =0 |
Creates a direct call. More... | |
virtual IExpression_temporary * | create_temporary (const IType *type, Size index) const =0 |
Creates a temporary reference. More... | |
virtual IExpression_list * | create_expression_list () const =0 |
Creates a new expression list. More... | |
Creation of annotations, annotation blocks, and annotations lists | |
virtual IAnnotation * | create_annotation (const char *name, const IExpression_list *arguments) const =0 |
Creates a new annotation. More... | |
virtual IAnnotation_block * | create_annotation_block () const =0 |
Creates a new annotation block. More... | |
virtual IAnnotation_list * | create_annotation_list () const =0 |
Creates a new annotation list. More... | |
Cloning of expressions and expression lists | |
virtual IExpression * | clone (const IExpression *expr) const =0 |
Clones the given expression. More... | |
template<class T> | |
T * | clone (const T *expr) const |
Clones the given expression. More... | |
virtual IExpression_list * | clone (const IExpression_list *expression_list) const =0 |
Clones the given expression list. More... | |
Dumping of expression and expression lists | |
virtual const IString * | dump (const IExpression *expr, const char *name, Size depth=0) const =0 |
Returns a textual representation of an expression. More... | |
virtual const IString * | dump (const IExpression_list *list, const char *name, Size depth=0) const =0 |
Returns a textual representation of an expression list. More... | |
Dumping of annotations, annotation blocks, and annotation lists | |
virtual const IString * | dump (const IAnnotation *annotation, const char *name, Size depth=0) const =0 |
Returns a textual representation of an annotation. More... | |
virtual const IString * | dump (const IAnnotation_block *block, const char *name, Size depth=0) const =0 |
Returns a textual representation of an annotation block. More... | |
virtual const IString * | dump (const IAnnotation_list *list, const char *name, Size depth=0) const =0 |
Returns a textual representation of an annotation list. More... | |
Miscellaneous methods | |
virtual IExpression * | create_cast (IExpression *src_expr, const IType *target_type, const char *cast_db_name, bool force_cast, bool direct_call, Sint32 *errors=0) const =0 |
Returns an expression which casts the source expression to a target type. More... | |
virtual IExpression * | create_decl_cast (IExpression *src_expr, const IType_struct *target_type, const char *cast_db_name, bool force_cast, bool direct_call, Sint32 *errors=0) const =0 |
Returns an expression which casts the source expression to a target type. More... | |
Public Member Functions inherited from mi::base::IInterface | |
virtual Uint32 | retain () const =0 |
Increments the reference count. More... | |
virtual Uint32 | release () const =0 |
Decrements the reference count. More... | |
virtual const IInterface * | get_interface (const Uuid &interface_id) const =0 |
Acquires a const interface from another. More... | |
template<class T> | |
const T * | get_interface () const |
Acquires a const interface from another. More... | |
virtual IInterface * | get_interface (const Uuid &interface_id)=0 |
Acquires a mutable interface from another. More... | |
template<class T> | |
T * | get_interface () |
Acquires a mutable interface from another. More... | |
virtual Uuid | get_iid () const =0 |
Returns the interface ID of the most derived interface. More... | |
Comparison of expression and expression lists | |
enum | Comparison_options { DEFAULT_OPTIONS = 0 , DEEP_CALL_COMPARISONS = 1 , SKIP_TYPE_ALIASES = 2 , COMPARISON_OPTIONS_FORCE_32_BIT = 0xffffffffU } |
Various options for the comparison of expressions or expression lists. More... | |
virtual Sint32 | compare (const IExpression *lhs, const IExpression *rhs, Uint32 flags=0, Float64 epsilon=0.0) const =0 |
Compares two instances of mi::neuraylib::IExpression. More... | |
virtual Sint32 | compare (const IExpression_list *lhs, const IExpression_list *rhs, Uint32 flags=0, Float64 epsilon=0.0) const =0 |
Compares two instances of mi::neuraylib::IExpression_list. More... | |
Additional Inherited Members | |
Public Types inherited from mi::base::Interface_declare< 0x9fd3b2d4, ... > | |
typedef Interface_declare< id1, ... > | Self |
Own type. More... | |
typedef Uuid_t< id1, ... > | IID |
Declares the interface ID (IID) of this interface. More... | |
Public Types inherited from mi::base::IInterface | |
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> | IID |
Declares the interface ID (IID) of this interface. More... | |
Static Public Member Functions inherited from mi::base::Interface_declare< 0x9fd3b2d4, ... > | |
static bool | compare_iid (const Uuid &iid) |
Compares the interface ID iid against the interface ID of this interface and of its ancestors. More... | |
Static Public Member Functions inherited from mi::base::IInterface | |
static bool | compare_iid (const Uuid &iid) |
Compares the interface ID iid against the interface ID of this interface. More... | |
The interface for creating expressions.
An expression factory can be obtained from mi::neuraylib::IMdl_factory::create_expression_factory().
Various options for the comparison of expressions or expression lists.
flags
parameter of compare() Enumerator | |
---|---|
DEFAULT_OPTIONS | Default comparison options. |
DEEP_CALL_COMPARISONS | This option indicates that call expressions should be compared for equality, not for identity. That is, the comparison is not done via mi::neuraylib::IExpression::get_value(), but by traversing into the referenced function call, i.e., comparing the function definition reference and the arguments. This option is useful if you want to decide whether an argument is semantically equal to the corresponding default parameter. |
SKIP_TYPE_ALIASES | This option indicates that all type aliases should be skipped before types of expression are compared. Defaults and argument might sometimes differ in explicit type modifiers, therefore this option is useful if you want to decide whether an argument is semantically equal to the corresponding default parameter. |
|
pure virtual |
Clones the given expression.
Note that referenced DB elements, e.g., resources in constant expressions, or function calls and material instances in call expressions, are not copied, but shared. Function calls and material instances that serve as default arguments, are copied, though.
|
pure virtual |
Clones the given expression list.
Note that referenced DB elements, e.g., resources in constant expressions, or function calls and material instances in call expressions, are not copied, but shared.
|
inline |
Clones the given expression.
Note that referenced DB elements, e.g., resources in constant expressions, or function calls and material instances in call expressions, are not copied, but shared. Function calls and material instances that serve as default arguments, are copied, though.
|
pure virtual |
Compares two instances of mi::neuraylib::IExpression.
The comparison operator for instances of mi::neuraylib::IExpression is defined as follows:
lhs
or rhs
is NULL
, the result is the lexicographic comparison of the pointer addresses themselves.lhs
and rhs
are compared. If they are different, the result is determined by that comparison.operator<
on the mi::neuraylib::IExpression::Kind values. Note that setting SKIP_TYPE_ALIASES in flags
modifies this behavior.flags
). Note that the representation of this call reference is an internal implementation detail, and the comparison result might have the opposite sign as strcmp()
on the strings returned by mi::neuraylib::IExpression_call::get_call().operator<()
on the indices.strcmp()
on the strings returned by mi::neuraylib::IExpression_direct_call::get_definition(). If both indirect call reference the same definition, then the result is defined by comparison of the arguments.lhs | The left-hand side operand for the comparison. |
rhs | The right-hand side operand for the comparison. |
flags | A bitmask of flags of type Comparison_options. |
epsilon | Maximum difference for floating point values to consider them as equal. |
lhs
< rhs
, 0 if lhs
== rhs
, and +1 if lhs
> rhs
.
|
pure virtual |
Compares two instances of mi::neuraylib::IExpression_list.
The comparison operator for instances of mi::neuraylib::IExpression_list is defined as follows:
lhs
or rhs
is NULL
, the result is the lexicographic comparison of the pointer addresses themselves.operator<()
.strcmp()
.lhs | The left-hand side operand for the comparison. |
rhs | The right-hand side operand for the comparison. |
flags | A bitmask of flags of type Comparison_options. |
epsilon | Maximum difference for floating point values to consider them as equal. |
lhs
< rhs
, 0 if lhs
== rhs
, and +1 if lhs
> rhs
.
|
pure virtual |
Creates a new annotation.
Returns NULL
if one of the arguments is not a constant expression.
|
pure virtual |
Creates a new annotation block.
|
pure virtual |
Creates a new annotation list.
|
pure virtual |
Creates a call.
name | The DB name of the referenced function call or material instance. |
NULL
in case of errors.
|
pure virtual |
Returns an expression which casts the source expression to a target type.
This is a convenience function that creates an instance of the cast operator with the necessary arguments, stores it in the database, and returns a call expressions for the just created function. Note that the cast operator requires that the type of the source expression and the target type are compatible (see mi::neuraylib::IType_factory::is_compatible()).
src_expr | The expression whose type is supposed to be cast. |
target_type | The result type of the cast. Note that the inserted cast operator acts on types without qualifiers, i.e., modifiers on target_type are ignored. |
cast_db_name | This name is used when storing the instance of the cast operator in the database. If the name is already taken by another DB element, this string will be used as the base for generating a unique name. If NULL , a unique name is generated. |
force_cast | This flag has only an effect if the type of the source expression is identical to the target type. If true , then the cast expression will still be created. If false , then src_expr itself will be returned. |
direct_call | Indicates whether to create a direct call expression or an (indirect) call expression. |
errors | An optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
|
NULL
in case of failure.
|
pure virtual |
Creates a constant (const).
value | The value of the constant. |
|
pure virtual |
Creates a constant (mutable).
value | The value of the constant. |
NULL
in case of errors.
|
pure virtual |
Returns an expression which casts the source expression to a target type.
This is a convenience function that creates an instance of the decl_cast operator with the necessary arguments, stores it in the database, and returns a call expressions for the just created function. Note that the decl_cast operator requires that the type of the source expression and the target type are struct types from the same struct category (see mi::neuraylib::IType_factory::from_same_struct_category()).
src_expr | The expression whose type is supposed to be cast. |
target_type | The result type of the cast. Note that the inserted decl_cast operator acts on types without qualifiers, i.e., modifiers on target_type are ignored. |
cast_db_name | This name is used when storing the instance of the decl_cast operator in the database. If the name is already taken by another DB element, this string will be used as the base for generating a unique name. If NULL , a unique name is generated. |
force_cast | This flag has only an effect if the type of the source expression is identical to the target type. If true , then the decl_cast expression will still be created. If false , then src_expr itself will be returned. |
direct_call | Indicates whether to create a direct call expression or an (indirect) call expression. |
errors | An optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
|
NULL
in case of failure.
|
pure virtual |
Creates a direct call.
name | The DB name of the referenced function or material definition. | |
arguments | The arguments of the created direct call. Arguments for parameters without default are mandatory, otherwise optional. The type of an argument must match the corresponding parameter type. Any argument missing in arguments will be set to the default of the corresponding parameter. Note that the expressions in arguments are copied. Valid subexpressions are constants, direct calls, and parameter references. operation is a deep copy, e.g., DB elements referenced in call expressions are also copied. NULL is a valid argument which is handled like an empty expression list. | |
[out] | errors | An optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
|
NULL
in case of errors.
|
pure virtual |
Creates a new expression list.
|
pure virtual |
Creates a parameter reference.
type | The type of the parameter. |
index | The index of the parameter. |
NULL
in case of errors.
|
pure virtual |
Creates a temporary reference.
type | The type of the temporary. |
index | The index of the temporary. |
NULL
in case of errors.
|
pure virtual |
Returns a textual representation of an annotation.
The representation of the annotation will contain line breaks. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth
.
|
pure virtual |
Returns a textual representation of an annotation block.
The representation of the annotation block will contain line breaks. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth
.
|
pure virtual |
Returns a textual representation of an annotation list.
The representation of the annotation list will contain line breaks. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth
.
|
pure virtual |
Returns a textual representation of an expression.
The parameter depth
is only relevant for constants, where the argument is passed to mi::neuraylib::IValue_factory::dump().
|
pure virtual |
Returns a textual representation of an expression list.
The representation of the expression list will contain line breaks. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth
.
|
pure virtual |
Returns the value factory associated with this expression factory.