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 40 41 42 43 44 45 46 47 48 49
|
#pragma once
#include "../../Main.h"
#include <memory>
#include <Containers/StringView.h>
#include <IO/Stream.h>
using namespace Death::Containers;
using namespace Death::IO;
namespace Jazz2::Compatibility
{
/** @brief Processes compressed or uncompressed blocks from original files (in little endian) */
class JJ2Block
{
public:
JJ2Block(std::unique_ptr<Stream>& s, std::int32_t length, std::int32_t uncompressedLength = 0);
void SeekTo(std::int32_t offset);
void DiscardBytes(std::int32_t length);
bool ReadBool();
std::uint8_t ReadByte();
std::int16_t ReadInt16();
std::uint16_t ReadUInt16();
std::int32_t ReadInt32();
std::uint32_t ReadUInt32();
std::int32_t ReadUint7bitEncoded();
float ReadFloat();
float ReadFloatEncoded();
void ReadRawBytes(std::uint8_t* dst, std::int32_t length);
StringView ReadString(std::int32_t length, bool trimToNull);
bool ReachedEndOfStream() {
return (_offset == INT32_MAX);
}
std::int32_t GetLength() {
return _length;
}
private:
std::unique_ptr<std::uint8_t[]> _buffer;
std::int32_t _length;
std::int32_t _offset;
};
}
|