![]() |
ezEngine
Release 25.03
|
Helper functions for handling reflection related operations. More...
#include <ReflectionUtils.h>
Classes | |
struct | EnumConversionMode |
struct | EnumKeyValuePair |
Static Public Member Functions | |
static const ezRTTI * | GetCommonBaseType (const ezRTTI *pRtti1, const ezRTTI *pRtti2) |
static bool | IsBasicType (const ezRTTI *pRtti) |
Returns whether a type can be stored directly inside a ezVariant. | |
static bool | IsValueType (const ezAbstractProperty *pProp) |
Returns whether the property is a non-ptr basic type or custom type. | |
static const ezRTTI * | GetTypeFromVariant (const ezVariant &value) |
Returns the RTTI type matching the variant's type. | |
static const ezRTTI * | GetTypeFromVariant (ezVariantType::Enum type) |
static ezUInt32 | GetComponentCount (ezVariantType::Enum type) |
Sets the Nth component of the vector to the given value. More... | |
static void | SetComponent (ezVariant &ref_vector, ezUInt32 uiComponent, double fValue) |
static double | GetComponent (const ezVariant &vector, ezUInt32 uiComponent) |
static ezVariant | GetMemberPropertyValue (const ezAbstractMemberProperty *pProp, const void *pObject) |
static void | SetMemberPropertyValue (const ezAbstractMemberProperty *pProp, void *pObject, const ezVariant &value) |
static ezVariant | GetArrayPropertyValue (const ezAbstractArrayProperty *pProp, const void *pObject, ezUInt32 uiIndex) |
static void | SetArrayPropertyValue (const ezAbstractArrayProperty *pProp, void *pObject, ezUInt32 uiIndex, const ezVariant &value) |
static void | InsertSetPropertyValue (const ezAbstractSetProperty *pProp, void *pObject, const ezVariant &value) |
static void | RemoveSetPropertyValue (const ezAbstractSetProperty *pProp, void *pObject, const ezVariant &value) |
static ezVariant | GetMapPropertyValue (const ezAbstractMapProperty *pProp, const void *pObject, const char *szKey) |
static void | SetMapPropertyValue (const ezAbstractMapProperty *pProp, void *pObject, const char *szKey, const ezVariant &value) |
static void | InsertArrayPropertyValue (const ezAbstractArrayProperty *pProp, void *pObject, const ezVariant &value, ezUInt32 uiIndex) |
static void | RemoveArrayPropertyValue (const ezAbstractArrayProperty *pProp, void *pObject, ezUInt32 uiIndex) |
static const ezAbstractMemberProperty * | GetMemberProperty (const ezRTTI *pRtti, ezUInt32 uiPropertyIndex) |
static const ezAbstractMemberProperty * | GetMemberProperty (const ezRTTI *pRtti, const char *szPropertyName) |
static void | GatherTypesDerivedFromClass (const ezRTTI *pRtti, ezSet< const ezRTTI * > &out_types) |
Gathers all RTTI types that are derived from pRtti. More... | |
static void | GatherDependentTypes (const ezRTTI *pRtti, ezSet< const ezRTTI * > &inout_typesAsSet, ezDynamicArray< const ezRTTI * > *out_pTypesAsStack=nullptr) |
Gathers all RTTI types that pRtti depends on and adds them to inout_types. More... | |
static ezResult | CreateDependencySortedTypeArray (const ezSet< const ezRTTI * > &types, ezDynamicArray< const ezRTTI * > &out_sortedTypes) |
Sorts the input types according to their dependencies. More... | |
static bool | EnumerationToString (const ezRTTI *pEnumerationRtti, ezInt64 iValue, ezStringBuilder &out_sOutput, ezEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Converts an enum or bitfield value into its string representation. More... | |
template<typename T > | |
static bool | EnumerationToString (ezEnum< T > value, ezStringBuilder &out_sOutput, ezEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Helper template to shorten the call for ezEnums. | |
template<typename T > | |
static bool | BitflagsToString (ezBitflags< T > value, ezStringBuilder &out_sOutput, ezEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Helper template to shorten the call for ezBitflags. | |
static void | GetEnumKeysAndValues (const ezRTTI *pEnumerationRtti, ezDynamicArray< EnumKeyValuePair > &ref_entries, ezEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
If the given type is an enum, entries will be filled with all available keys (strings) and values (integers). More... | |
static bool | StringToEnumeration (const ezRTTI *pEnumerationRtti, const char *szValue, ezInt64 &out_iValue) |
Converts an enum or bitfield in its string representation to its value. More... | |
template<typename T > | |
static bool | StringToEnumeration (const char *szValue, ezEnum< T > &out_value) |
Helper template to shorten the call for ezEnums. | |
static ezInt64 | DefaultEnumerationValue (const ezRTTI *pEnumerationRtti) |
Returns the default value (Enum::Default) for the given enumeration type. | |
static ezInt64 | MakeEnumerationValid (const ezRTTI *pEnumerationRtti, ezInt64 iValue) |
Makes sure the given value is valid under the given enumeration type. More... | |
template<typename T > | |
static bool | IsEqual (const T *pObject, const T *pObject2) |
Templated convenience function that calls IsEqual and automatically deduces the type. | |
static bool | IsEqual (const void *pObject, const void *pObject2, const ezRTTI *pType) |
Compares pObject with pObject2 of type pType and returns whether they are equal. More... | |
static bool | IsEqual (const void *pObject, const void *pObject2, const ezAbstractProperty *pProp) |
Compares property pProp of pObject and pObject2 and returns whether it is equal in both. | |
static void | DeleteObject (void *pObject, const ezAbstractProperty *pOwnerProperty) |
Deletes pObject using the allocator found in the owning property's type. | |
static ezVariant | GetDefaultVariantFromType (ezVariant::Type::Enum type) |
Returns a global default initialization value for the given variant type. | |
static ezVariant | GetDefaultVariantFromType (const ezRTTI *pRtti) |
Returns the default value for the specific type. | |
static ezVariant | GetDefaultValue (const ezAbstractProperty *pProperty, ezVariant index=ezVariant()) |
Returns the default value for the specific type of the given property. | |
static void | SetAllMemberPropertiesToDefault (const ezRTTI *pRtti, void *pObject) |
Sets all member properties in pObject of type pRtti to the value returned by ezToolsReflectionUtils::GetDefaultValue() | |
static ezResult | ClampValue (ezVariant &value, const ezClampValueAttribute *pAttrib) |
If pAttrib is valid and its min/max values are compatible, value will be clamped to them. Returns false if a clamp attribute exists but no clamp code was executed. | |
Helper functions for handling reflection related operations.
|
static |
Sorts the input types according to their dependencies.
Types that have no dependences come first in the output followed by types that have their dependencies met by the previous entries in the output. If a dependent type is not in the given types set the function will fail.
|
static |
Converts an enum or bitfield value into its string representation.
The type of pEnumerationRtti will be automatically detected. The syntax of out_sOutput equals MSVC debugger output.
|
static |
Gathers all RTTI types that pRtti depends on and adds them to inout_types.
Dependencies are either member properties or base classes. The output contains the transitive closure of the dependencies. Note that inout_typesAsSet is not cleared when this function is called. out_pTypesAsStack is all the dependencies sorted by their appearance in the dependency chain. The last entry is the lowest in the chain and has no dependencies on its own.
|
static |
Gathers all RTTI types that are derived from pRtti.
This includes all classes that have pRtti as a base class, either direct or indirect.
|
static |
Sets the Nth component of the vector to the given value.
vector's type needs to be in between ezVariant::Type::Vector2 and ezVariant::Type::Vector4U.
|
static |
If the given type is an enum, entries will be filled with all available keys (strings) and values (integers).
|
static |
Compares pObject with pObject2 of type pType and returns whether they are equal.
In case a class derived from ezReflectedClass is passed in the correct derived type will automatically be determined so it is not necessary to put the exact type into pType, any derived class type will do. However, the function will return false pObject and pObject2 actually have a different type.
|
static |
Makes sure the given value is valid under the given enumeration type.
Invalid bitflag bits are removed and an invalid enum value is replaced by the default value.
|
static |
Converts an enum or bitfield in its string representation to its value.
The type of pEnumerationRtti will be automatically detected. The syntax of szValue must equal the MSVC debugger output.