AuroraRuntime/Source/Compression/Compression.hpp
2021-06-27 22:25:29 +01:00

25 lines
720 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Compression.hpp
Date: 2021-6-17
Author: Reece
***/
#pragma once
namespace Aurora::Compression
{
static const AuUInt64 kChunkSize = 4096;
// This is acommon prolog required by BlockCompressors and BlockDecompressors. dw about it.
static inline bool StreamRead(void * /*opt*/ buffer, AuUInt32 &len, AuList<AuUInt8> &vec)
{
len = std::min(AuUInt32(vec.size()), len);
if (len == 0) return false;
std::memcpy(buffer, vec.data(), len);
auto rem = vec.size() - len;
std::memmove(vec.data(), vec.data() + len, rem);
vec.resize(rem);
return true;
}
}