UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FCompositeBuffer Class Reference

#include <CompositeBuffer.h>

Public Member Functions

template<typename... BufferTypes, std::enable_if_t< std::conjunction_v< CanAppendBufferType< std::decay_t< BufferTypes > >... > > * = nullptr>
 FCompositeBuffer (BufferTypes &&... Buffers)
 
CORE_API ~FCompositeBuffer ()
 
CORE_API void Reset ()
 
CORE_API uint64 GetSize () const
 
TConstArrayView< FSharedBufferGetSegments () const
 
 operator bool () const
 
bool IsNull () const
 
CORE_API bool IsOwned () const
 
CORE_API FCompositeBuffer MakeOwned () const &
 
CORE_API FCompositeBuffer MakeOwned () &&
 
CORE_API FSharedBuffer ToShared () const &
 
CORE_API FSharedBuffer ToShared () &&
 
CORE_API FCompositeBuffer Mid (uint64 Offset, uint64 Size=MAX_uint64) const
 
CORE_API FMemoryView ViewOrCopyRange (uint64 Offset, uint64 Size, FUniqueBuffer &CopyBuffer) const
 
CORE_API FMemoryView ViewOrCopyRange (uint64 Offset, uint64 Size, FUniqueBuffer &CopyBuffer, TFunctionRef< FUniqueBuffer(uint64 Size)> Allocator) const
 
CORE_API void CopyTo (FMutableMemoryView Target, uint64 Offset=0) const
 
CORE_API void IterateRange (uint64 Offset, uint64 Size, TFunctionRef< void(FMemoryView View)> Visitor) const
 
CORE_API void IterateRange (uint64 Offset, uint64 Size, TFunctionRef< void(FMemoryView View, const FSharedBuffer &ViewOuter)> Visitor) const
 
CORE_API bool EqualBytes (const FCompositeBuffer &Other) const
 

Static Public Attributes

static CORE_API const FCompositeBuffer Null
 

Detailed Description

FCompositeBuffer is a non-contiguous buffer composed of zero or more immutable shared buffers.

A composite buffer is most efficient when its segments are consumed as they are, but it can be flattened into a contiguous buffer when necessary, by calling ToShared(). Ownership of segment buffers is not changed on construction, but if ownership of segments is required then that can be guaranteed by calling MakeOwned().

Constructor & Destructor Documentation

◆ FCompositeBuffer()

template<typename... BufferTypes, std::enable_if_t< std::conjunction_v< CanAppendBufferType< std::decay_t< BufferTypes > >... > > * = nullptr>
FCompositeBuffer::FCompositeBuffer ( BufferTypes &&...  Buffers)
inlineexplicit

Construct a composite buffer by concatenating the buffers. Does not enforce ownership.

Buffer parameters may be FSharedBuffer, FCompositeBuffer, or TArray<FSharedBuffer>.

◆ ~FCompositeBuffer()

FCompositeBuffer::~FCompositeBuffer ( )
default

Destructor.

Member Function Documentation

◆ CopyTo()

void FCompositeBuffer::CopyTo ( FMutableMemoryView  Target,
uint64  Offset = 0 
) const

Copies a range of the buffer to a contiguous region of memory.

Parameters
TargetThe view to copy to. Must be no larger than the data available at the offset.
OffsetThe byte offset in this buffer to start copying from.

◆ EqualBytes()

bool FCompositeBuffer::EqualBytes ( const FCompositeBuffer Other) const

Returns true if the bytes of this buffer are equal to the bytes of the other buffer.

◆ GetSegments()

TConstArrayView< FSharedBuffer > FCompositeBuffer::GetSegments ( ) const
inline

Returns the segments that the buffer is composed from.

◆ GetSize()

uint64 FCompositeBuffer::GetSize ( ) const

Returns the total size of the composite buffer in bytes.

◆ IsNull()

bool FCompositeBuffer::IsNull ( ) const
inline

Returns true if the composite buffer is null.

◆ IsOwned()

bool FCompositeBuffer::IsOwned ( ) const

Returns true if every segment in the composite buffer is owned.

◆ IterateRange() [1/2]

void FCompositeBuffer::IterateRange ( uint64  Offset,
uint64  Size,
TFunctionRef< void(FMemoryView View)>  Visitor 
) const

Invokes a visitor with a view of each segment that intersects with a range.

Parameters
OffsetThe byte offset in this buffer to start visiting from.
SizeThe number of bytes in the range to visit.
VisitorThe visitor to invoke from zero to GetSegments().Num() times.

◆ IterateRange() [2/2]

void FCompositeBuffer::IterateRange ( uint64  Offset,
uint64  Size,
TFunctionRef< void(FMemoryView View, const FSharedBuffer &ViewOuter)>  Visitor 
) const

◆ MakeOwned() [1/2]

FCompositeBuffer FCompositeBuffer::MakeOwned ( ) &&

◆ MakeOwned() [2/2]

FCompositeBuffer FCompositeBuffer::MakeOwned ( ) const &

Returns a copy of the buffer where every segment is owned.

◆ Mid()

FCompositeBuffer FCompositeBuffer::Mid ( uint64  Offset,
uint64  Size = MAX_uint64 
) const

Returns the middle part of the buffer by taking the size starting at the offset.

◆ operator bool()

FCompositeBuffer::operator bool ( ) const
inlineexplicit

Returns true if the composite buffer is not null.

◆ Reset()

void FCompositeBuffer::Reset ( )

Reset this to null.

◆ ToShared() [1/2]

FSharedBuffer FCompositeBuffer::ToShared ( ) &&

◆ ToShared() [2/2]

FSharedBuffer FCompositeBuffer::ToShared ( ) const &

Returns the concatenation of the segments into a contiguous buffer.

◆ ViewOrCopyRange() [1/2]

FMemoryView FCompositeBuffer::ViewOrCopyRange ( uint64  Offset,
uint64  Size,
FUniqueBuffer CopyBuffer 
) const

Returns a view of the range if contained by one segment, otherwise a view of a copy of the range.

Note
CopyBuffer is reused if large enough, and otherwise allocated when needed.
Parameters
OffsetThe byte offset in this buffer that the range starts at.
SizeThe number of bytes in the range to view or copy.
CopyBufferThe buffer to write the copy into if a copy is required.
AllocatorThe optional allocator to use when the copy buffer is required.

◆ ViewOrCopyRange() [2/2]

FMemoryView FCompositeBuffer::ViewOrCopyRange ( uint64  Offset,
uint64  Size,
FUniqueBuffer CopyBuffer,
TFunctionRef< FUniqueBuffer(uint64 Size)>  Allocator 
) const

Member Data Documentation

◆ Null

const FCompositeBuffer FCompositeBuffer::Null
static

A null composite buffer.


The documentation for this class was generated from the following files: