Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MemoryArchive.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 "Misc/AssertionMacros.h"
7#include "Serialization/Archive.h"
8#include "Containers/UnrealString.h"
9#include "UObject/NameTypes.h"
10
11/**
12 * Base class for serializing arbitrary data in memory.
13 */
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 { return TEXT("FMemoryArchive"); }
24
25 void Seek( int64 InPos ) final
26 {
27 Offset = InPos;
28 }
29 int64 Tell() final
30 {
31 return Offset;
32 }
33
34 using FArchive::operator<<; // For visibility of the overloads we don't override
35
36 virtual FArchive& operator<<( class FName& N ) override
37 {
38 // Serialize the FName as a string
39 if (IsLoading())
40 {
41 FString StringName;
42 *this << StringName;
43 N = FName(*StringName);
44 }
45 else
46 {
47 FString StringName = N.ToString();
48 *this << StringName;
49 }
50 return *this;
51 }
52
53 virtual FArchive& operator<<(struct UObject*& Res ) override
54 {
55 // Not supported through this archive
56 check(0);
57 return *this;
58 }
59
60protected:
61
62 /** Marked as protected to avoid instantiating this class directly */
64 : FArchive(), Offset(0)
65 {
66 }
67
68 int64 Offset;
69};
#define check(expr)
#define TEXT(x)
Definition Platform.h:1108
FArchive()=default
virtual FString GetArchiveName() const
int64 Tell() final
void Seek(int64 InPos) final
FName(const WIDECHAR *Name, EFindName FindType=FNAME_Add)
FString ToString() const
Definition NameTypes.h:662
UE_NODISCARD FORCEINLINE const TCHAR * operator*() const UE_LIFETIMEBOUND
FORCEINLINE bool IsLoading() const
Definition Archive.h:249
Definition UE.h:432