UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StructBuilder.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
8
14{
15public:
16 constexpr FStructBuilder()
17 : EndOfLastMember(0)
18 , Alignment (0)
19 {
20 }
21
30 constexpr int32 AddMember(int32 MemberSize, int32 MemberAlignment)
31 {
32 int32 Result = Align(EndOfLastMember, MemberAlignment);
33 EndOfLastMember = Result + MemberSize;
34 Alignment = FMath::Max(Alignment, MemberAlignment);
35 return Result;
36 }
37
43 constexpr int32 GetSize() const
44 {
45 return Align(EndOfLastMember, Alignment);
46 }
47
53 constexpr int32 GetAlignment() const
54 {
55 return Alignment;
56 }
57
58private:
59 // The offset from the start of the struct to the end of the last added member
60 int32 EndOfLastMember;
61
62 // The alignment of the struct
63 int32 Alignment;
64};
constexpr T Align(T Val, uint64 Alignment)
Definition AlignmentTemplates.h:18
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 StructBuilder.h:14
constexpr FStructBuilder()
Definition StructBuilder.h:16
constexpr int32 GetSize() const
Definition StructBuilder.h:43
constexpr int32 GetAlignment() const
Definition StructBuilder.h:53
constexpr int32 AddMember(int32 MemberSize, int32 MemberAlignment)
Definition StructBuilder.h:30