UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BlockRange.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
7
8namespace BuildPatchServices
9{
10 struct FBlockEntry;
11
13 {
14 public:
16 {
17 checkf(Size > 0, TEXT("Using GetFirst for a 0 size range is invalid."));
18 return First;
19 }
20
22 {
23 checkf(Size > 0, TEXT("Using GetLast for a 0 size range is invalid."));
24 return First + (Size - 1);
25 }
26
28 {
29 return Size;
30 }
31
32 bool Overlaps(const FBlockRange& Other) const
33 {
34 return GetSize() > 0 && Other.GetSize() > 0 && GetFirst() <= Other.GetLast() && GetLast() >= Other.GetFirst();
35 }
36
37 bool Touches(const FBlockRange& Other) const
38 {
39 return GetSize() > 0 && Other.GetSize() > 0 && GetFirst() <= (Other.GetLast() + 1) && (GetLast() + 1) >= Other.GetFirst();
40 }
41
43 {
45 BlockRange.First = InFirst;
46 BlockRange.Size = InSize;
47 checkf((BlockRange.GetSize() == 0) || (BlockRange.GetLast() >= BlockRange.GetFirst()), TEXT("Byte range has uint64 overflow."));
48 return BlockRange;
49 }
50
52 {
53 checkf(InFirst <= InLast, TEXT("Invalid args, first must <= last."));
54 return FromFirstAndSize(InFirst, (InLast - InFirst) + 1);
55 }
56
58 {
59 checkf(RangeA.Overlaps(RangeB), TEXT("Invalid args, ranges must overlap."));
60 return FromFirstAndLast(FMath::Max<uint64>(RangeA.GetFirst(), RangeB.GetFirst()), FMath::Min<uint64>(RangeA.GetLast(), RangeB.GetLast()));
61 }
62
64 {
65 checkf(RangeA.Touches(RangeB), TEXT("Invalid args, ranges must overlap or touch."));
66 return FromFirstAndLast(FMath::Min<uint64>(RangeA.GetFirst(), RangeB.GetFirst()), FMath::Max<uint64>(RangeA.GetLast(), RangeB.GetLast()));
67 }
68
69 friend bool operator==(const FBlockRange& Lhs, const FBlockRange& Rhs)
70 {
71 return Lhs.First == Rhs.First && Lhs.Size == Rhs.Size;
72 }
73
74 private:
76 : First(0)
77 , Size(0)
78 {
79 }
80
81 private:
82 uint64 First;
83 uint64 Size;
84 };
85}
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition BuildPatchFileConstructor.h:28
Definition BlockRange.h:13
static FBlockRange FromMerge(const FBlockRange &RangeA, const FBlockRange &RangeB)
Definition BlockRange.h:63
static FBlockRange FromIntersection(const FBlockRange &RangeA, const FBlockRange &RangeB)
Definition BlockRange.h:57
static FBlockRange FromFirstAndLast(uint64 InFirst, uint64 InLast)
Definition BlockRange.h:51
uint64 GetLast() const
Definition BlockRange.h:21
uint64 GetFirst() const
Definition BlockRange.h:15
bool Overlaps(const FBlockRange &Other) const
Definition BlockRange.h:32
static FBlockRange FromFirstAndSize(uint64 InFirst, uint64 InSize)
Definition BlockRange.h:42
bool Touches(const FBlockRange &Other) const
Definition BlockRange.h:37
uint64 GetSize() const
Definition BlockRange.h:27
friend bool operator==(const FBlockRange &Lhs, const FBlockRange &Rhs)
Definition BlockRange.h:69