You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
A payload was conceptually a value with an ID. That has been formalized by removing the ID from the payload and having separate FValue and FValueId types. This separation cleans up the API in a few areas, and provides a more natural path to providing a basic key/value API. #rb Zousar.Shaker #rnx #preflight 61d704c04c252480ca284d61 #ROBOMERGE-AUTHOR: devin.doucette #ROBOMERGE-SOURCE: CL 18531844 in //UE5/Release-5.0/... via CL 18531856 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669) [CL 18531864 by devin doucette in ue5-release-engine-test branch]
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "DerivedDataValue.h"
|
|
|
|
#include "Compression/OodleDataCompression.h"
|
|
#include "Containers/StringConv.h"
|
|
#include "Hash/xxhash.h"
|
|
#include "Serialization/CompactBinary.h"
|
|
#include "Templates/UnrealTemplate.h"
|
|
|
|
namespace UE::DerivedData
|
|
{
|
|
|
|
constexpr ECompressedBufferCompressor GDefaultCompressor = ECompressedBufferCompressor::Mermaid;
|
|
constexpr ECompressedBufferCompressionLevel GDefaultCompressionLevel = ECompressedBufferCompressionLevel::VeryFast;
|
|
|
|
FValue FValue::Compress(const FCompositeBuffer& Buffer, const uint64 BlockSize)
|
|
{
|
|
return FValue(FCompressedBuffer::Compress(Buffer, GDefaultCompressor, GDefaultCompressionLevel, BlockSize));
|
|
}
|
|
|
|
FValue FValue::Compress(const FSharedBuffer& Buffer, const uint64 BlockSize)
|
|
{
|
|
return FValue(FCompressedBuffer::Compress(Buffer, GDefaultCompressor, GDefaultCompressionLevel, BlockSize));
|
|
}
|
|
|
|
FValueId::FValueId(const FMemoryView Id)
|
|
{
|
|
checkf(Id.GetSize() == sizeof(ByteArray),
|
|
TEXT("FValueId cannot be constructed from a view of %" UINT64_FMT " bytes."), Id.GetSize());
|
|
FMemory::Memcpy(Bytes, Id.GetData(), sizeof(ByteArray));
|
|
}
|
|
|
|
FValueId::FValueId(const FCbObjectId& Id)
|
|
: FValueId(ImplicitConv<const ByteArray&>(Id))
|
|
{
|
|
}
|
|
|
|
FValueId::operator FCbObjectId() const
|
|
{
|
|
return FCbObjectId(ImplicitConv<const ByteArray&>(*this));
|
|
}
|
|
|
|
FValueId FValueId::FromHash(const FIoHash& Hash)
|
|
{
|
|
checkf(!Hash.IsZero(), TEXT("FValueId requires a non-zero hash."));
|
|
return FValueId(MakeMemoryView(Hash.GetBytes()).Left(sizeof(ByteArray)));
|
|
}
|
|
|
|
FValueId FValueId::FromName(const FUtf8StringView Name)
|
|
{
|
|
checkf(!Name.IsEmpty(), TEXT("FValueId requires a non-empty name."));
|
|
uint8 HashBytes[16];
|
|
FXxHash128::HashBuffer(Name.GetData(), Name.Len()).ToByteArray(HashBytes);
|
|
return FValueId(MakeMemoryView(HashBytes, sizeof(ByteArray)));
|
|
}
|
|
|
|
FValueId FValueId::FromName(const FWideStringView Name)
|
|
{
|
|
return FValueId::FromName(FTCHARToUTF8(Name));
|
|
}
|
|
|
|
} // UE::DerivedData
|