5#include "Containers/StringFwd.h"
6#include "Containers/StringView.h"
7#include "Containers/UnrealString.h"
8#include "HAL/Platform.h"
9#include "HAL/PlatformString.h"
10#include "HAL/UnrealMemory.h"
11#include "Memory/MemoryFwd.h"
12#include "Memory/MemoryView.h"
13#include "Misc/AssertionMacros.h"
14#include "Serialization/Archive.h"
15#include "String/BytesToHex.h"
16#include "String/HexToBytes.h"
17#include "Templates/TypeCompatibleBytes.h"
20class FCompositeBuffer;
21template <
typename CharType>
class TStringBuilderBase;
29 using ByteArray = uint8[32];
38 inline explicit FBlake3Hash(FAnsiStringView HexHash);
39 inline explicit FBlake3Hash(FWideStringView HexHash);
40 inline explicit FBlake3Hash(FUtf8StringView HexHash);
49 inline bool IsZero()
const;
81 return *
reinterpret_cast<
const uint32*>(Value
.GetBytes());
106 void Update(
const void* Data, uint64 Size);
107 void Update(
const FCompositeBuffer& Buffer);
110
111
112
113
134 check(HexHash.Len() ==
sizeof(ByteArray) * 2);
135 UE::String::HexToBytes(HexHash, Hash);
140 check(HexHash.Len() ==
sizeof(ByteArray) * 2);
141 UE::String::HexToBytes(HexHash, Hash);
146 check(HexHash.Len() ==
sizeof(ByteArray) * 2);
147 UE::String::HexToBytes(HexHash, Hash);
152 checkf(InHash.GetSize() ==
sizeof(ByteArray),
153 TEXT(
"FBlake3Hash cannot be constructed from a view of %" UINT64_FMT
" bytes."), InHash.GetSize());
155 FMemory::Memcpy(NewHash.Hash, InHash.GetData(),
sizeof(ByteArray));
161 using UInt32Array = uint32[8];
162 static_assert(
sizeof(UInt32Array) ==
sizeof(ByteArray),
"Invalid size for UInt32Array");
163 for (uint32 Value :
reinterpret_cast<
const UInt32Array&>(
Hash))
173template <
typename CharType>
174inline TStringBuilderBase<CharType>& operator<<(TStringBuilderBase<CharType>& Builder,
const FBlake3Hash& Hash)
176 UE::String::BytesToHexLower(Hash.GetBytes(), Builder);
183 OutHash = FBlake3Hash(Buffer);
#define checkf(expr, format,...)
void LexFromString(FBlake3Hash &OutHash, const TCHAR *Buffer)
FString LexToString(const FBlake3Hash &Hash)
virtual void Serialize(void *V, int64 Length)
FBlake3Hash Finalize() const
void Update(FMemoryView View)
TAlignedBytes< 1912, 8 > HasherBytes
static FBlake3Hash HashBuffer(const void *Data, uint64 Size)
void Update(const void *Data, uint64 Size)
static FBlake3Hash HashBuffer(const FCompositeBuffer &Buffer)
void Update(const FCompositeBuffer &Buffer)
FBlake3(const FBlake3 &)=delete
static FBlake3Hash HashBuffer(FMemoryView View)
FBlake3 & operator=(const FBlake3 &)=delete
const ByteArray & GetBytes() const
FBlake3Hash(const ByteArray &Hash)
static const FBlake3Hash Zero
bool operator!=(const FBlake3Hash &B) const
friend uint32 GetTypeHash(const FBlake3Hash &Value)
FBlake3Hash(FUtf8StringView HexHash)
FBlake3Hash(FAnsiStringView HexHash)
static FBlake3Hash FromView(FMemoryView Hash)
FBlake3Hash(FWideStringView HexHash)
bool operator<(const FBlake3Hash &B) const
bool operator==(const FBlake3Hash &B) const
static FORCEINLINE int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
static FORCEINLINE void * Memcpy(void *Dest, const void *Src, SIZE_T Count)