#include <datatypebase.h>
◆ Conversion
A Conversion delegate defines a conversion from a source type to a destination type (such as from Int to Float). You can register Conversion delegates from a source type at the DataType object of the destination type.
- See also
- AddConversion
◆ BASE_OF_MODE
Match mode for IsBaseOfOrSame.
Enumerator |
---|
NONE | |
ORDERED_TYPE_ONLY | When tuple or container types are compared, members have to match only in order and type, their names are ignored.
|
UNORDERED_BY_NAME | When tuple or container types are compared, members are matched by name, so their order is ignored.
|
GENERIC_DOWNCAST | Consider the instantiation of a generic type the same as the generic type.
|
◆ DataType() [1/3]
◆ DataType() [2/3]
◆ DataType() [3/3]
◆ NullValue()
◆ operator Bool()
◆ operator==()
◆ operator!=()
◆ GetHashCode()
◆ GetUniqueHashCode()
◆ operator->()
◆ GetId()
const Id& GetId |
( |
| ) |
const |
Returns the identifier of this data type. Data type identifiers of primary types look like int32
, pointer types are identified by a * suffix as in
{float64*}, tuple types by a parenthesized list of its member types as in
{(int32,float64*)}.
- Returns
- Unique identifier of this type.
◆ ToString()
Returns a String representation of this @CLASS.
- Parameters
-
[in] | formatStatement | Nullptr or additional formatting instruction. |
- Returns
- String representation of this @CLASS.
◆ GetSize()
Returns the size of values of this data type.
- Returns
- Size of values.
◆ GetAlignment()
Int GetAlignment |
( |
| ) |
const |
Returns the alignment of values of this data type. This might by an extended alignment.
- Returns
- Alignment of values.
◆ GetValueKind()
Returns the kind of values of this data type. This is a coarse classification to distinguish between e.g. value types, pointers, references, arrays and tuples.
- Returns
- Kind of values.
◆ CheckValueKind()
Tests the value kind of this data type for the given flags (by using the bitwise and).
- Parameters
-
[in] | test | The flags to test. |
- Returns
- True if the value kind of this data type has one of the given flags, false otherwise.
◆ GetUnqualifiedType()
const DataType& GetUnqualifiedType |
( |
| ) |
const |
Returns the unqualified type of this data type. Currently the only possible qualification is a const qualification. So when this data type represents const T, the returned data type represents T. If the type is already an unqualified type, this functions returns the type itself.
- Returns
- This type with any qualifications removed (or this type itself if it is already unqualified).
◆ ResolveRecursiveType()
const DataType& ResolveRecursiveType |
( |
| ) |
const |
◆ GetUnderlyingType()
const DataType& GetUnderlyingType |
( |
| ) |
const |
Returns the underlying type of this data type. The underlying data type is a layout-compatible more fundamental type, such as the unqualified version T for const T, or the tuple type Tuple<T, T, T> for Vec3<T>.
- Returns
- The underlying type of this type, or nullptr.
◆ GetElementType()
const DataType& GetElementType |
( |
| ) |
const |
Returns the element type of this data type. The element type is used for some parametric types such as pointers or references, so for example the element type of
{T*} or
{StrongRef<T>} is T
.
- Returns
- The element type of this type, or nullptr.
◆ GetDecayedType()
const DataType& GetDecayedType |
( |
| ) |
const |
Returns the decayed type of this data type (in the sense of std::decay). I.e., at first this removes any l- or r-value-reference-qualification, and then it returns the unqualified type of the result.
- Returns
- The decayed type of this type, maybe this type itself.
◆ HasTypeArguments()
Bool HasTypeArguments |
( |
| ) |
const |
Returns true if this data type has valid type arguments, so that it is legal to call GetTypeArguments().
- Returns
- True if this type has valid type arguments, false otherwise.
◆ GetTypeArguments()
Returns the type arguments of this data type. Type arguments are set for some instantiations of parametric types. For example, the 3-dimensional Vector is an instantiation of the parametric type Vec with the arguments (Float, 3).
- Returns
- The type arguments of this type.
◆ GetParametricType()
Returns the parametric type which instantiated this type. For example if this type is Vector, the function returns the parametric type Vec.
- Returns
- The parametric type which instantiated this type, or nullptr.
◆ Get()
Returns the DataType identified by typeId
. This supports primary data types as well as compound data types which are based on other types. E.g., the id "(int64,net.maxon.parametrictype.vec<3,float64>,{net.maxon.interface.functionsignature,net.maxon.interface.genericfunction})[]" identifies an array of tuples with Int64, Vector64 and object members where the object has to implement FunctionSignatureInterface and GenericFunctionInterface.
This function just forwards to DataTypeLib::GetDataType.
- Parameters
-
[in] | typeId | Type identifier. |
- Returns
- DataType for the given id.
◆ GetTupleType()
Returns the underlying tuple type of this type (if it exists). It exists for value types like Vector
whose underlying tuple type is composed of the members (x
, y
, z
for Vector
).
- Returns
- Underlying tuple type of this type, or
nullptr
if this doesn't exist.
◆ AddConversion() [1/2]
Registers a Conversion delegate func from the source type src at this DataType. The Conversion delegate has to convert values of type src to values of this DataType.
- Parameters
-
[in] | src | The source type of the conversion function. |
[in] | kind | The kind of the conversion. |
[in] | func | The conversion delegate. |
- Returns
- OK on success.
◆ AddConversion() [2/2]
Registers a conversion function conversion
from type SRC
to type DEST
at the DataType of SRC
.
- Parameters
-
[in] | conversion | The conversion function. |
- Returns
- OK on success.
◆ Convert()
Converts the value src to the value #dest (the type of which has to match this DataType). This uses the conversion delegates which have been registered with AddConversion, or ParametricTypeInterface::Convert if this DataType is an instance of a parametric type.
- Parameters
-
[in] | dest | The destination value. |
[in] | src | The source value. |
[in] | ignore | Only those conversions are taken into account whose conversion flags aren't set in #ignore. |
- Returns
- OK on success. If there is no conversion from the source type at all, an UnsupportedArgumentError is returned. For narrowing conversions other errors may occur, such as when the representable range is exceeded.
◆ IsCastableFrom()
Checks if a value of the other
type can be cast safely to a value of this type. This holds if either both types are the same, or this type is Generic, or both types are reference or pointer types and the type to which this type points is a base type of the type to which the other
type points (see IsBaseOfOrSame).
- Parameters
-
[in] | other | Another data type. |
- Returns
- True if a value of this data type can be safely cast from a value of the
other
type.
◆ MAXON_ENUM_FLAGS_CLASS()
◆ IsBaseOfOrSame()
Checks if this type is a base type of the other
type (or the same). This takes into account
- the hierarchy of virtual interfaces
- const qualification
- and the element types of Result, ArrayInterface, Block, pointers and references.
For example, const Int is a base type of Int, but not vice versa. const Result<ObjectRef>* is a base type of Result<IoHandler>*.
- Parameters
-
[in] | other | Another data type. |
[in] | mode | Flags for the check. |
- Returns
- True if this type is a base type of the
other
type.
◆ IsSimilar()
Checks if this type is similar to the other type. Two types are similar if they are the same except for differences in const qualifiers. For example, Result<Block<const Int>>* is similar to const Result<Block<Int>>*.
- Parameters
-
[in] | other | Another data type. |
- Returns
- True if both types are similar.
◆ GetNullValue()
Returns a ConstDataPtr which points to a default-constructed object of this type.
- Returns
- ConstDataPtr for a default-constructed object of this type, or an empty ConstDataPtr in case of an error (for example if type is abstract).
◆ Reset()
Resets this @CLASS to the state it has right after default construction. This includes freeing all resources held by this @CLASS.
◆ PrivateGetPointer()
◆ AddReference()
void AddReference |
( |
| ) |
const |
|
private |
◆ RemoveReference()
void RemoveReference |
( |
| ) |
const |
|
private |
◆ IsBaseOfOrSameImpl() [1/2]
◆ IsBaseOfOrSameImpl() [2/2]
◆ Data
◆ DataTypeImpl
◆ DataTypePtr
◆ StrongRefHandler
◆ _ptr