本文整理汇总了C++中FArchive::ForceByteSwapping方法的典型用法代码示例。如果您正苦于以下问题:C++ FArchive::ForceByteSwapping方法的具体用法?C++ FArchive::ForceByteSwapping怎么用?C++ FArchive::ForceByteSwapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FArchive
的用法示例。
在下文中一共展示了FArchive::ForceByteSwapping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SerializeBulkData
/**
* Serialize just the bulk data portion to/ from the passed in memory.
*
* @param Ar Archive to serialize with
* @param Data Memory to serialize either to or from
*/
void FUntypedBulkData::SerializeBulkData( FArchive& Ar, void* Data )
{
// skip serializing of unused data
if( BulkDataFlags & BULKDATA_Unused )
{
return;
}
// Skip serialization for bulk data of zero length
const int32 BulkDataSize = GetBulkDataSize();
if(BulkDataSize == 0)
{
return;
}
// Allow backward compatible serialization by forcing bulk serialization off if required. Saving also always uses single
// element serialization so errors or oversight when changing serialization code is recoverable.
bool bSerializeInBulk = true;
if( RequiresSingleElementSerialization( Ar )
// Set when serialized like a lazy array.
|| (BulkDataFlags & BULKDATA_ForceSingleElementSerialization)
// We use bulk serialization even when saving 1 byte types (texture & sound bulk data) as an optimization for those.
|| (Ar.IsSaving() && (GetElementSize() > 1) ) )
{
bSerializeInBulk = false;
}
// Raw serialize the bulk data without any possiblity for potential endian conversion.
if( bSerializeInBulk )
{
// Serialize data compressed.
if( BulkDataFlags & BULKDATA_SerializeCompressed )
{
Ar.SerializeCompressed( Data, GetBulkDataSize(), GetDecompressionFlags());
}
// Uncompressed/ regular serialization.
else
{
Ar.Serialize( Data, GetBulkDataSize() );
}
}
// Serialize an element at a time via the virtual SerializeElement function potentialy allowing and dealing with
// endian conversion. Dealing with compression makes this a bit more complex as SerializeCompressed expects the
// full data to be compresed en block and not piecewise.
else
{
// Serialize data compressed.
if( BulkDataFlags & BULKDATA_SerializeCompressed )
{
// Placeholder for to be serialized data.
TArray<uint8> SerializedData;
// Loading, data is compressed in archive and needs to be decompressed.
if( Ar.IsLoading() )
{
// Create space for uncompressed data.
SerializedData.Empty( GetBulkDataSize() );
SerializedData.AddUninitialized( GetBulkDataSize() );
// Serialize data with passed in archive and compress.
Ar.SerializeCompressed( SerializedData.GetData(), SerializedData.Num(), GetDecompressionFlags());
// Initialize memory reader with uncompressed data array and propagate forced byte swapping
FMemoryReader MemoryReader( SerializedData, true );
MemoryReader.SetByteSwapping( Ar.ForceByteSwapping() );
// Serialize each element individually via memory reader.
for( int32 ElementIndex=0; ElementIndex<ElementCount; ElementIndex++ )
{
SerializeElement( MemoryReader, Data, ElementIndex );
}
}
// Saving, data is uncompressed in memory and needs to be compressed.
else if( Ar.IsSaving() )
{
// Initialize memory writer with blank data array and propagate forced byte swapping
FMemoryWriter MemoryWriter( SerializedData, true );
MemoryWriter.SetByteSwapping( Ar.ForceByteSwapping() );
// Serialize each element individually via memory writer.
for( int32 ElementIndex=0; ElementIndex<ElementCount; ElementIndex++ )
{
SerializeElement( MemoryWriter, Data, ElementIndex );
}
// Serialize data with passed in archive and compress.
Ar.SerializeCompressed( SerializedData.GetData(), SerializedData.Num(), GetDecompressionFlags() );
}
}
// Uncompressed/ regular serialization.
else
{
// We can use the passed in archive if we're not compressing the data.
for( int32 ElementIndex=0; ElementIndex<ElementCount; ElementIndex++ )
//.........这里部分代码省略.........