Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
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"
7#include "Math/UnrealMathUtility.h"
8#include "Containers/UnrealString.h"
9#include "Serialization/MemoryArchive.h"
10
11/**
12 * Archive for reading arbitrary data from the specified memory location
13 */
14class FStaticMemoryReader final : public FMemoryArchive
15{
16public:
17 /**
18 * Returns the name of the Archive. Useful for getting the name of the package a struct or object
19 * is in when a loading error occurs.
20 *
21 * This is overridden for the specific Archive Types
22 **/
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 void Serialize( void* Data, int64 Num )
34 {
35 if (Num && !IsError())
36 {
37 // Only serialize if we have the requested amount of data
38 if (Offset + Num <= TotalSize())
39 {
41 Offset += Num;
42 }
43 else
44 {
46 }
47 }
48 }
49
50 explicit FStaticMemoryReader(const uint8* InBytes, int64 InNumBytes)
51 : Bytes (InBytes)
52 , NumBytes(InNumBytes)
53 {
54 this->SetIsLoading(true);
55 }
56
57private:
58 const uint8* Bytes;
59 int64 NumBytes;
60};
#define TEXT(x)
Definition Platform.h:1108
virtual int64 TotalSize() override
void Serialize(void *Data, int64 Num)
FStaticMemoryReader(const uint8 *InBytes, int64 InNumBytes)
virtual FString GetArchiveName() const override
FORCEINLINE bool IsError() const
Definition Archive.h:337
virtual void SetIsLoading(bool bInIsLoading)
static FORCEINLINE void * Memcpy(void *Dest, const void *Src, SIZE_T Count)