jabyengine/include/PSX/Auxiliary/lz4_decompressor.hpp

46 lines
1.1 KiB
C++

#ifndef __JABYENGINE_LZ4_DECOMPRESSOR_HPP__
#define __JABYENGINE_LZ4_DECOMPRESSOR_HPP__
#include "../../stddef.h"
#include "types.hpp"
namespace JabyEngine {
class LZ4Decompressor {
public:
struct Result {
Progress progress;
size_t bytes_ready;
static constexpr Result new_error() {
return {Progress::Error, 0};
}
static constexpr Result new_done(size_t bytes_ready) {
return {Progress::Done, bytes_ready};
}
static constexpr Result new_in_progress(size_t bytes_ready) {
return {Progress::InProgress, bytes_ready};
}
};
private:
struct State {};
private:
uint8_t* dst_adr = nullptr;
State state;
public:
LZ4Decompressor() = default;
LZ4Decompressor(uint8_t* dst_adr) : LZ4Decompressor() {
LZ4Decompressor::setup(dst_adr);
}
void setup(uint8_t* dst_adr);
void reset();
Result process(const uint8_t* data, size_t size);
};
}
#endif //!__JABYENGINE_LZ4_DECOMPRESSOR_HPP__