UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WrappedAttribute.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "UObject/Class.h"
8
9namespace UE
10{
11 namespace Anim
12 {
14 template<typename InAllocator>
16 {
18
24
26 template <typename Type>
27 inline typename TEnableIf<TIsFundamentalType<Type>::Value, Type*>::Type GetPtr()
28 {
29 return (Type*)StructMemory.GetData();
30 }
31
32 template <typename Type>
33 inline typename TEnableIf<!TIsFundamentalType<Type>::Value, Type*>::Type GetPtr()
34 {
35 const UScriptStruct* ScriptStruct = Type::StaticStruct();
36 check(ScriptStruct && ScriptStruct->GetStructureSize() == StructMemory.Num());
37 return (Type*)StructMemory.GetData();
38 }
39
40 template<typename Type>
41 inline Type& GetRef() { return *GetPtr<Type>(); }
42
44 template <typename Type>
45 inline typename TEnableIf<TIsFundamentalType<Type>::Value, const Type*>::Type GetPtr() const
46 {
47 return (const Type*)StructMemory.GetData();
48 }
49
50 template <typename Type>
51 inline typename TEnableIf<!TIsFundamentalType<Type>::Value, const Type*>::Type GetPtr() const
52 {
53 const UScriptStruct* ScriptStruct = Type::StaticStruct();
54 check(ScriptStruct && ScriptStruct->GetStructureSize() == StructMemory.Num());
55 return (const Type*)StructMemory.GetData();
56 }
57
59 template<typename Type>
60 inline const Type& GetRef() const { return *GetPtr<Type>(); }
61
63 template<typename AttributeType>
64 inline void Allocate()
65 {
66 Allocate(AttributeType::StaticStruct());
67 }
68
70 inline void Allocate(const UScriptStruct* InStruct)
71 {
73 if (InStruct)
74 {
75 const int32 StructureSize = InStruct->GetStructureSize();
77
79 InStruct->InitializeStruct(GetPtr<void>());
80 }
81 }
82 protected:
84 };
85 }
86}
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT ElementType * GetData() UE_LIFETIMEBOUND
Definition Array.h:1027
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
Definition EnableIf.h:20
Definition Class.h:1720
UE_FORCEINLINE_HINT int32 GetStructureSize() const
Definition Class.h:775
Definition AdvancedWidgetsModule.cpp:13
Definition WrappedAttribute.h:16
void Allocate()
Definition WrappedAttribute.h:64
TEnableIf<!TIsFundamentalType< Type >::Value, Type * >::Type GetPtr()
Definition WrappedAttribute.h:33
TEnableIf< TIsFundamentalType< Type >::Value, Type * >::Type GetPtr()
Definition WrappedAttribute.h:27
TWrappedAttribute()
Definition WrappedAttribute.h:17
const Type & GetRef() const
Definition WrappedAttribute.h:60
Type & GetRef()
Definition WrappedAttribute.h:41
TWrappedAttribute(const UScriptStruct *InStruct)
Definition WrappedAttribute.h:20
void Allocate(const UScriptStruct *InStruct)
Definition WrappedAttribute.h:70
TEnableIf< TIsFundamentalType< Type >::Value, constType * >::Type GetPtr() const
Definition WrappedAttribute.h:45
TEnableIf<!TIsFundamentalType< Type >::Value, constType * >::Type GetPtr() const
Definition WrappedAttribute.h:51
TArray< uint8, InAllocator > StructMemory
Definition WrappedAttribute.h:83