blob: 074bdaffdf2b6c4c5c80bb3d8be3b40a8391124c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zencore/compactbinaryutil.h>
#include <zencore/compress.h>
#include <zencore/filesystem.h>
namespace zen {
CbObject
ValidateAndReadCompactBinaryObject(const SharedBuffer&& Payload, CbValidateError& OutError)
{
if (Payload.GetSize() > 0)
{
if (OutError = ValidateCompactBinary(Payload.GetView(), CbValidateMode::Default); OutError == CbValidateError::None)
{
CbObject Object(std::move(Payload));
if (Object.GetView().GetSize() != Payload.GetSize())
{
OutError |= CbValidateError::OutOfBounds;
return {};
}
return Object;
}
}
return CbObject();
}
CbObject
ValidateAndReadCompactBinaryObject(const CompressedBuffer&& Payload, CbValidateError& OutError)
{
if (CompositeBuffer Decompressed = Payload.DecompressToComposite())
{
return ValidateAndReadCompactBinaryObject(std::move(Decompressed).Flatten(), OutError);
}
return CbObject();
}
} // namespace zen
|