本文整理汇总了C++中FArchive类的典型用法代码示例。如果您正苦于以下问题:C++ FArchive类的具体用法?C++ FArchive怎么用?C++ FArchive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FArchive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PossiblySerializeObjectGuid
void FLazyObjectPtr::PossiblySerializeObjectGuid(UObject *Object, FArchive& Ar)
{
if (Ar.IsSaving() || Ar.IsCountingMemory())
{
FUniqueObjectGuid Guid = GuidAnnotation.GetAnnotation(Object);
bool HasGuid = Guid.IsValid();
Ar << HasGuid;
if (HasGuid)
{
if (Ar.GetPortFlags() & PPF_DuplicateForPIE)
{
check(GPlayInEditorID != -1);
FGuid &FoundGuid = PIEGuidMap[GPlayInEditorID % MAX_PIE_INSTANCES].FindOrAdd(Guid.GetGuid());
if (!FoundGuid.IsValid())
{
Guid = FoundGuid = FGuid::NewGuid();
}
else
{
Guid = FoundGuid;
}
}
Ar << Guid;
}
}
else if (Ar.IsLoading())
{
bool HasGuid = false;
Ar << HasGuid;
if (HasGuid)
{
FUniqueObjectGuid Guid;
Ar << Guid;
// Don't try and resolve GUIDs when loading a package for diff'ing
const UPackage* Package = Object->GetOutermost();
bool bLoadedForDiff = (Package && (Package->PackageFlags & PKG_ForDiffing));
if (!bLoadedForDiff && (!(Ar.GetPortFlags() & PPF_Duplicate) || (Ar.GetPortFlags() & PPF_DuplicateForPIE)))
{
check(!Guid.IsDefault());
UObject* OtherObject = Guid.ResolveObject();
if (OtherObject != Object) // on undo/redo, the object (potentially) already exists
{
if (OtherObject != NULL)
{
UE_CLOG(!((FApp::IsGame() || GIsPlayInEditorWorld) && Package && Package->ContainsMap()), LogUObjectGlobals, Warning, TEXT("Guid is in use by %s and %s, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE"), *OtherObject->GetFullName(), !!Object ? *Object->GetFullName() : TEXT("NULL"));
// This guid is in use, which should never happen in the editor but could happen at runtime with duplicate level loading or PIE. If so give it a new GUID to avoid crashing
Guid = FGuid::NewGuid();
}
GuidAnnotation.AddAnnotation(Object, Guid);
FUniqueObjectGuid::InvalidateTag();
}
}
}
}
}
示例2: Serialize
void FStreamedAudioChunk::Serialize(FArchive& Ar, UObject* Owner, int32 ChunkIndex)
{
bool bCooked = Ar.IsCooking();
Ar << bCooked;
BulkData.Serialize(Ar, Owner, ChunkIndex);
Ar << DataSize;
#if WITH_EDITORONLY_DATA
if (!bCooked)
{
Ar << DerivedDataKey;
}
#endif // #if WITH_EDITORONLY_DATA
}
示例3: PostSerialize
void FGraphReference::PostSerialize(const FArchive& Ar)
{
#if WITH_EDITORONLY_DATA
if (Ar.UE4Ver() >= VER_UE4_K2NODE_REFERENCEGUIDS)
{
// Because the macro instance could have been saved with a GUID that was allocated
// but the macro graph never actually saved with that value we are forced to make
// sure to refresh the GUID and make sure it is up to date
if (MacroGraph)
{
GraphGuid = MacroGraph->GraphGuid;
}
}
#endif
}
示例4: Serialize
void FUniformExpressionSet::Serialize(FArchive& Ar)
{
Ar << UniformVectorExpressions;
Ar << UniformScalarExpressions;
Ar << Uniform2DTextureExpressions;
Ar << UniformCubeTextureExpressions;
Ar << ParameterCollections;
// Recreate the uniform buffer struct after loading.
if(Ar.IsLoading())
{
CreateBufferStruct();
}
}
示例5: Serialize
void FTextHistory_AsDateTime::Serialize(FArchive& Ar)
{
if(Ar.IsSaving())
{
int8 HistoryType = (int8)ETextHistoryType::AsDateTime;
Ar << HistoryType;
}
Ar << SourceDateTime;
int8 DateStyleInt8 = (int8)DateStyle;
Ar << DateStyleInt8;
DateStyle = (EDateTimeStyle::Type)DateStyleInt8;
int8 TimeStyleInt8 = (int8)TimeStyle;
Ar << TimeStyleInt8;
TimeStyle = (EDateTimeStyle::Type)TimeStyleInt8;
Ar << TimeZone;
if(Ar.IsSaving())
{
FString CultureName = TargetCulture.IsValid()? TargetCulture->GetName() : FString();
Ar << CultureName;
}
else if(Ar.IsLoading())
{
FString CultureName;
Ar << CultureName;
if(!CultureName.IsEmpty())
{
TargetCulture = FInternationalization::Get().GetCulture(CultureName);
}
}
}
示例6: SerializeLineageMoves
void UMeshAnimation::SerializeLineageMoves(FArchive &Ar)
{
guard(UMeshAnimation::SerializeLineageMoves);
if (Ar.ArVer < 123 || Ar.ArLicenseeVer < 0x19)
{
// standard UE2 format
Ar << Moves;
return;
}
assert(Ar.IsLoading);
int pos, count; // pos = global skip pos, count = data count
Ar << pos << AR_INDEX(count);
Moves.Empty(count);
for (int i = 0; i < count; i++)
{
int localPos;
Ar << localPos;
MotionChunk *M = new(Moves) MotionChunk;
Ar << *M;
assert(Ar.Tell() == localPos);
}
assert(Ar.Tell() == pos);
unguard;
}
示例7: Serialize
void FRawCurveTracks::Serialize(FArchive& Ar)
{
// @TODO: If we're about to serialize vector curve, add here
if(Ar.UE4Ver() >= VER_UE4_SKELETON_ADD_SMARTNAMES)
{
for(FFloatCurve& Curve : FloatCurves)
{
Curve.Serialize(Ar);
}
}
#if WITH_EDITORONLY_DATA
if( !Ar.IsCooking() )
{
if( Ar.UE4Ver() >= VER_UE4_ANIMATION_ADD_TRACKCURVES )
{
for( FTransformCurve& Curve : TransformCurves )
{
Curve.Serialize( Ar );
}
}
}
#endif // WITH_EDITORONLY_DATA
}
示例8: Serialize
bool FBuildPatchAppManifest::Serialize(FArchive& Ar)
{
if (Ar.IsLoading())
{
DestroyData();
}
Data->Serialize(Ar);
if (Ar.IsLoading())
{
// If we didn't load the version number, we know it was skipped when saving therefore must be
// the first UObject version
if (Data->ManifestFileVersion == static_cast<uint8>(EBuildPatchAppManifestVersion::Invalid))
{
Data->ManifestFileVersion = EBuildPatchAppManifestVersion::StoredAsCompressedUClass;
}
// Setup internal lookups
InitLookups();
}
return !Ar.IsError();
}
示例9: FILE_IO_STATS_GET_HANDLE
FArchive* FFileManagerWindows::InternalCreateFileWriter( const TCHAR* Filename, DWORD Flags, FOutputDevice* Error )
{
INT StatsHandle = FILE_IO_STATS_GET_HANDLE( Filename );
SCOPED_FILE_IO_WRITE_OPEN_STATS( StatsHandle );
MakeDirectory(*FFilename(Filename).GetPath(), TRUE);
if( (GFileManager->FileSize (Filename) >= 0) && (Flags & FILEWRITE_EvenIfReadOnly) )
{
SetFileAttributesW(Filename, 0);
}
DWORD Access = GENERIC_WRITE;
DWORD WinFlags = (Flags & FILEWRITE_AllowRead) ? FILE_SHARE_READ : 0;
DWORD Create = (Flags & FILEWRITE_Append) ? OPEN_ALWAYS : (Flags & FILEWRITE_NoReplaceExisting) ? CREATE_NEW : CREATE_ALWAYS;
HANDLE Handle = CreateFileW( Filename, Access, WinFlags, NULL, Create, FILE_ATTRIBUTE_NORMAL, NULL );
INT Pos = 0;
if( Handle==INVALID_HANDLE_VALUE )
{
if( Flags & FILEWRITE_NoFail )
{
const DWORD LastError = GetLastError();
appErrorf( TEXT("Failed to create file: %s, GetLastError %u"), Filename, LastError );
}
return NULL;
}
if( Flags & FILEWRITE_Append )
{
Pos = SetFilePointer( Handle, 0, NULL, FILE_END );
}
FArchive* retArch = new FArchiveFileWriterWindows(Handle,StatsHandle,Filename,Error,Pos);
if( retArch && (Flags & FILEWRITE_SaveGame) )
{
retArch->SetIsSaveGame( TRUE );
}
return retArch;
}
示例10: SerializeChain
void DBaseDecal::SerializeChain (FArchive &arc, DBaseDecal **first)
{
DWORD numInChain;
DBaseDecal *fresh;
DBaseDecal **firstptr = first;
if (arc.IsLoading ())
{
numInChain = arc.ReadCount ();
while (numInChain--)
{
arc << fresh;
*firstptr = fresh;
fresh->WallPrev = firstptr;
firstptr = &fresh->WallNext;
}
}
else
{
numInChain = 0;
fresh = *firstptr;
while (fresh != NULL)
{
fresh = fresh->WallNext;
++numInChain;
}
arc.WriteCount (numInChain);
fresh = *firstptr;
while (numInChain--)
{
arc << fresh;
fresh = fresh->WallNext;
}
}
}
示例11: MakeShareable
FLocMetadataValueArray::FLocMetadataValueArray( FArchive& Archive )
{
check(Archive.IsLoading());
int32 ElementCount;
Archive << ElementCount;
Value.SetNum(ElementCount);
for (TSharedPtr<FLocMetadataValue>& Element : Value)
{
FLocMetadataValue* ElementRawPointer = Element.Get();
SerializeLocMetadataValue(Archive, ElementRawPointer);
Element = MakeShareable(ElementRawPointer);
}
}
示例12: Serialize
//==========================================================================
//
//
//
//==========================================================================
void ADynamicLight::Serialize(FArchive &arc)
{
Super::Serialize (arc);
arc << lightflags << lighttype;
arc << m_tickCount << m_currentRadius;
arc << m_Radius[0] << m_Radius[1];
if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler;
if (arc.IsLoading())
{
// The default constructor which is used for creating objects before deserialization will not set this variable.
// It needs to be true for all placed lights.
visibletoplayer = true;
LinkLight();
}
}
示例13: checkf
/**
* Loads the data from disk into the specified memory block. This requires us still being attached to an
* archive we can use for serialization.
*
* @param Dest Memory to serialize data into
*/
void FUntypedBulkData::LoadDataIntoMemory( void* Dest )
{
#if WITH_EDITOR
checkf( AttachedAr, TEXT( "Attempted to load bulk data without an attached archive. Most likely the bulk data was loaded twice on console, which is not supported" ) );
// Keep track of current position in file so we can restore it later.
int64 PushedPos = AttachedAr->Tell();
// Seek to the beginning of the bulk data in the file.
AttachedAr->Seek( BulkDataOffsetInFile );
SerializeBulkData( *AttachedAr, Dest );
// Restore file pointer.
AttachedAr->Seek( PushedPos );
#else
bool bWasLoadedSuccessfully = false;
if (IsInGameThread() && Linker.IsValid())
{
ULinkerLoad* LinkerLoad = Linker.Get();
if ( LinkerLoad && LinkerLoad->Loader && !LinkerLoad->IsCompressed() )
{
FArchive* Ar = LinkerLoad;
// keep track of current position in this archive
int64 CurPos = Ar->Tell();
// Seek to the beginning of the bulk data in the file.
Ar->Seek( BulkDataOffsetInFile );
// serialize the bulk data
SerializeBulkData( *Ar, Dest );
// seek back to the position the archive was before
Ar->Seek(CurPos);
// note that we loaded it
bWasLoadedSuccessfully = true;
}
}
// if we weren't able to load via linker, load directly by filename
if (!bWasLoadedSuccessfully)
{
// load from the specied filename when the linker has been cleared
checkf( Filename != TEXT(""), TEXT( "Attempted to load bulk data without a proper filename." ) );
FArchive* Ar = IFileManager::Get().CreateFileReader(*Filename, FILEREAD_Silent);
checkf( Ar != NULL, TEXT( "Attempted to load bulk data from an invalid filename '%s'." ), *Filename );
// Seek to the beginning of the bulk data in the file.
Ar->Seek( BulkDataOffsetInFile );
SerializeBulkData( *Ar, Dest );
delete Ar;
}
#endif // WITH_EDITOR
}
示例14:
void FGameplayDebuggerCategory_AI::FRepDataPath::Serialize(FArchive& Ar)
{
int32 NumCorridor = PathCorridor.Num();
Ar << NumCorridor;
if (Ar.IsLoading())
{
PathCorridor.SetNum(NumCorridor);
}
for (int32 Idx = 0; Idx < NumCorridor; Idx++)
{
Ar << PathCorridor[Idx].Points;
Ar << PathCorridor[Idx].Color;
}
Ar << PathPoints;
}
示例15: Serialize
void FStreamedAudioChunk::Serialize(FArchive& Ar, UObject* Owner, int32 ChunkIndex)
{
DECLARE_SCOPE_CYCLE_COUNTER( TEXT("FStreamedAudioChunk::Serialize"), STAT_StreamedAudioChunk_Serialize, STATGROUP_LoadTime );
bool bCooked = Ar.IsCooking();
Ar << bCooked;
BulkData.Serialize(Ar, Owner, ChunkIndex);
Ar << DataSize;
#if WITH_EDITORONLY_DATA
if (!bCooked)
{
Ar << DerivedDataKey;
}
#endif // #if WITH_EDITORONLY_DATA
}