FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_compressorBZ2.hpp
1/*
2 * Copyright 2025 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_COMPRESSORBZ2_HPP_INCLUDED
18#define _FGE_C_COMPRESSORBZ2_HPP_INCLUDED
19
20#include "fge_extern.hpp"
21#include "FastEngine/C_compressor.hpp"
22#include <limits>
23
24/*
25 * This file is using the library :
26 * libbzip2
27 * copyright (C) 1996-2019 Julian R Seward.
28 */
29
30#define FGE_COMPRESSOR_BZ2_DEFAULT_WORKFACTOR 0
31#define FGE_COMPRESSOR_BZ2_DEFAULT_BLOCKSIZE 4
32#define FGE_COMPRESSOR_BZ2_EXTRA_BYTES 10
33#define FGE_COMPRESSOR_BZ2_DEFAULT_MAX_SIZE std::numeric_limits<uint16_t>::max()
34#define FGE_COMPRESSOR_BZ2_VERSION "1.1.0"
35
36namespace fge
37{
38
39class FGE_API CompressorBZ2 : public Compressor
40{
41public:
42 using Compressor::Compressor;
43
44 [[nodiscard]] std::optional<ErrorString> compress(std::span<uint8_t const> const& rawData) override;
45 [[nodiscard]] std::optional<ErrorString> uncompress(std::span<uint8_t const> const& data) override;
46
47 void setMaxUncompressedSize(uint32_t value);
48 [[nodiscard]] uint32_t getMaxUncompressedSize() const;
49
50 void setBlockSize(int blockSize);
51 [[nodiscard]] int getBlockSize() const;
52 void setWorkFactor(int factor);
53 [[nodiscard]] int getWorkFactor() const;
54
55private:
56 uint32_t g_maxUncompressedSize{FGE_COMPRESSOR_BZ2_DEFAULT_MAX_SIZE};
57 int g_blockSize{FGE_COMPRESSOR_BZ2_DEFAULT_BLOCKSIZE};
58 int g_workFactor{FGE_COMPRESSOR_BZ2_DEFAULT_WORKFACTOR};
59};
60
61} // namespace fge
62
63#endif // _FGE_C_COMPRESSORBZ2_HPP_INCLUDED
Definition C_compressorBZ2.hpp:40