UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StaticMemoryReader.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"
6#include "HAL/UnrealMemory.h"
10
15{
16public:
23 virtual FString GetArchiveName() const override
24 {
25 return TEXT("FStaticMemoryReader");
26 }
27
28 virtual int64 TotalSize() override
29 {
30 return NumBytes;
31 }
32
33 // returns the raw data ptr assigned to the memory reader.
34 const uint8* GetData() const { return Bytes; }
35
36 void Serialize( void* Data, int64 Num )
37 {
38 if (Num && !IsError())
39 {
40 // Only serialize if we have the requested amount of data
41 if (Offset + Num <= TotalSize())
42 {
43 FMemory::Memcpy( Data, &Bytes[Offset], Num );
44 Offset += Num;
45 }
46 else
47 {
48 SetError();
49 }
50 }
51 }
52
53 explicit FStaticMemoryReader(const uint8* InBytes, int64 InNumBytes)
54 : Bytes (InBytes)
55 , NumBytes(InNumBytes)
56 {
57 this->SetIsLoading(true);
58 }
59
60private:
61 const uint8* Bytes;
62 int64 NumBytes;
63};
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Num
Definition MetalRHIPrivate.h:234
uint8_t uint8
Definition binka_ue_file_header.h:8
virtual CORE_API void SetIsLoading(bool bInIsLoading)
Definition Archive.cpp:1513
CORE_API void SetError()
Definition Archive.cpp:314
UE_FORCEINLINE_HINT bool IsError() const
Definition Archive.h:362
Definition MemoryArchive.h:15
int64 Offset
Definition MemoryArchive.h:68
Definition StaticMemoryReader.h:15
const uint8 * GetData() const
Definition StaticMemoryReader.h:34
virtual int64 TotalSize() override
Definition StaticMemoryReader.h:28
void Serialize(void *Data, int64 Num)
Definition StaticMemoryReader.h:36
FStaticMemoryReader(const uint8 *InBytes, int64 InNumBytes)
Definition StaticMemoryReader.h:53
virtual FString GetArchiveName() const override
Definition StaticMemoryReader.h:23
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160