![]() |
XII Release 0.1.0
|
Helper functions for handling reflection related operations. More...
#include <ReflectionUtils.h>
Classes | |
struct | EnumConversionMode |
struct | EnumKeyValuePair |
Static Public Member Functions | |
static const xiiRTTI * | GetCommonBaseType (const xiiRTTI *pRtti1, const xiiRTTI *pRtti2) |
static bool | IsBasicType (const xiiRTTI *pRtti) |
Returns whether a type can be stored directly inside a xiiVariant. | |
static bool | IsValueType (const xiiAbstractProperty *pProp) |
Returns whether the property is a non-ptr basic type or custom type. | |
static const xiiRTTI * | GetTypeFromVariant (const xiiVariant &value) |
Returns the RTTI type matching the variant's type. | |
static const xiiRTTI * | GetTypeFromVariant (xiiVariantType::Enum type) |
static xiiUInt32 | GetComponentCount (xiiVariantType::Enum type) |
Sets the Nth component of the vector to the given value. | |
static void | SetComponent (xiiVariant &ref_vector, xiiUInt32 uiComponent, double fValue) |
static double | GetComponent (const xiiVariant &vector, xiiUInt32 uiComponent) |
static xiiVariant | GetMemberPropertyValue (const xiiAbstractMemberProperty *pProp, const void *pObject) |
static void | SetMemberPropertyValue (const xiiAbstractMemberProperty *pProp, void *pObject, const xiiVariant &value) |
static xiiVariant | GetArrayPropertyValue (const xiiAbstractArrayProperty *pProp, const void *pObject, xiiUInt32 uiIndex) |
static void | SetArrayPropertyValue (const xiiAbstractArrayProperty *pProp, void *pObject, xiiUInt32 uiIndex, const xiiVariant &value) |
static void | InsertSetPropertyValue (const xiiAbstractSetProperty *pProp, void *pObject, const xiiVariant &value) |
static void | RemoveSetPropertyValue (const xiiAbstractSetProperty *pProp, void *pObject, const xiiVariant &value) |
static xiiVariant | GetMapPropertyValue (const xiiAbstractMapProperty *pProp, const void *pObject, xiiStringView sKey) |
static void | SetMapPropertyValue (const xiiAbstractMapProperty *pProp, void *pObject, xiiStringView sKey, const xiiVariant &value) |
static void | InsertArrayPropertyValue (const xiiAbstractArrayProperty *pProp, void *pObject, const xiiVariant &value, xiiUInt32 uiIndex) |
static void | RemoveArrayPropertyValue (const xiiAbstractArrayProperty *pProp, void *pObject, xiiUInt32 uiIndex) |
static const xiiAbstractMemberProperty * | GetMemberProperty (const xiiRTTI *pRtti, xiiUInt32 uiPropertyIndex) |
static const xiiAbstractMemberProperty * | GetMemberProperty (const xiiRTTI *pRtti, xiiStringView sPropertyName) |
static void | GatherTypesDerivedFromClass (const xiiRTTI *pBaseRtti, xiiSet< const xiiRTTI * > &out_types) |
Gathers all RTTI types that are derived from pBaseRtti. | |
static void | GatherDependentTypes (const xiiRTTI *pRtti, xiiSet< const xiiRTTI * > &inout_typesAsSet, xiiDynamicArray< const xiiRTTI * > *out_pTypesAsStack=nullptr) |
Gathers all RTTI types that pRtti depends on and adds them to inout_types. | |
static xiiResult | CreateDependencySortedTypeArray (const xiiSet< const xiiRTTI * > &types, xiiDynamicArray< const xiiRTTI * > &out_sortedTypes) |
Sorts the input types according to their dependencies. | |
static bool | EnumerationToString (const xiiRTTI *pEnumerationRtti, xiiInt64 iValue, xiiStringBuilder &out_sOutput, xiiEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Converts an enum or bitfield value into its string representation. | |
template<typename T> | |
static bool | EnumerationToString (xiiEnum< T > value, xiiStringBuilder &out_sOutput, xiiEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Helper template to shorten the call for xiiEnums. | |
template<typename T> | |
static bool | BitflagsToString (xiiBitflags< T > value, xiiStringBuilder &out_sOutput, xiiEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
Helper template to shorten the call for xiiBitflags. | |
static void | GetEnumKeysAndValues (const xiiRTTI *pEnumerationRtti, xiiDynamicArray< EnumKeyValuePair > &ref_entries, xiiEnum< EnumConversionMode > conversionMode=EnumConversionMode::Default) |
If the given type is an enum, entries will be filled with all available keys (strings) and values (integers). | |
static bool | StringToEnumeration (const xiiRTTI *pEnumerationRtti, xiiStringView sValue, xiiInt64 &out_iValue) |
Converts an enum or bitfield in its string representation to its value. | |
template<typename T> | |
static bool | StringToEnumeration (xiiStringView sValue, xiiEnum< T > &out_value) |
Helper template to shorten the call for xiiEnums. | |
static xiiInt64 | DefaultEnumerationValue (const xiiRTTI *pEnumerationRtti) |
Returns the default value (Enum::Default) for the given enumeration type. | |
static xiiInt64 | MakeEnumerationValid (const xiiRTTI *pEnumerationRtti, xiiInt64 iValue) |
Makes sure the given value is valid under the given enumeration type. | |
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 xiiRTTI *pType) |
Compares pObject with pObject2 of type pType and returns whether they are equal. | |
static bool | IsEqual (const void *pObject, const void *pObject2, const xiiAbstractProperty *pProp) |
Compares property pProp of pObject and pObject2 and returns whether it is equal in both. | |
static void | DeleteObject (void *pObject, const xiiAbstractProperty *pOwnerProperty) |
Deletes pObject using the allocator found in the owning property's type. | |
static xiiVariant | GetDefaultVariantFromType (xiiVariant::Type::Enum type) |
Returns a global default initialization value for the given variant type. | |
static xiiVariant | GetDefaultVariantFromType (const xiiRTTI *pRtti) |
Returns the default value for the specific type. | |
static xiiVariant | GetDefaultValue (const xiiAbstractProperty *pProperty, xiiVariant index=xiiVariant()) |
Returns the default value for the specific type of the given property. | |
static void | SetAllMemberPropertiesToDefault (const xiiRTTI *pRtti, void *pObject) |
Sets all member properties in pObject of type pRtti to the value returned by xiiToolsReflectionUtils::GetDefaultValue() | |
static xiiResult | ClampValue (xiiVariant &value, const xiiClampValueAttribute *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 pBaseRtti.
This includes all classes that have pBaseRtti 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 xiiVariant::Type::Vector2 and xiiVariant::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 xiiReflectedClass 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 sValue must equal the MSVC debugger output.