Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ArrayReader.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 "Containers/Array.h"
8#include "Containers/UnrealString.h"
9#include "Serialization/MemoryArchive.h"
10
11class FArrayReader final : public FMemoryArchive, public TArray<uint8>
12{
13public:
14 FArrayReader( bool bIsPersistent=false )
15 {
16 this->SetIsLoading(true);
17 this->SetIsPersistent(bIsPersistent);
18 }
19
20 /**
21 * Returns the name of the Archive. Useful for getting the name of the package a struct or object
22 * is in when a loading error occurs.
23 *
24 * This is overridden for the specific Archive Types
25 **/
26 virtual FString GetArchiveName() const { return TEXT("FArrayReader"); }
27
28 int64 TotalSize()
29 {
30 return (int64)Num();
31 }
32
33 void Serialize(void* Data, int64 Count)
34 {
35 if (Count && !IsError())
36 {
37 // Only serialize if we have the requested amount of data
38 if (Offset + Count <= Num())
39 {
40 FMemory::Memcpy(Data, &((*this)[(int32)Offset]), Count);
41 Offset += Count;
42 }
43 else
44 {
46 }
47 }
48 }
49};
#define TEXT(x)
Definition Platform.h:1108
FArrayReader(bool bIsPersistent=false)
Definition ArrayReader.h:14
virtual FString GetArchiveName() const
Definition ArrayReader.h:26
void Serialize(void *Data, int64 Count)
Definition ArrayReader.h:33
int64 TotalSize()
Definition ArrayReader.h:28
virtual void SetIsPersistent(bool bInIsPersistent)
FORCEINLINE bool IsError() const
Definition Archive.h:337
virtual void SetIsLoading(bool bInIsLoading)