galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
ZLib.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_MATH_ZLIB_HPP_
9#define GALAXY_MATH_ZLIB_HPP_
10
11#define MINIZ_HEADER_FILE_ONLY
12#include <miniz.h>
13
14namespace galaxy
15{
19 class ZLib final
20 {
21 public:
25 static constexpr const auto ChunkSize = 16384;
26
30 enum class Mode : int
31 {
35 COMPRESS = 0,
36
40 DECOMPRESS = 1
41 };
42
46 ~ZLib();
47
55 [[nodiscard]]
56 static std::string encode(const std::string& input);
57
65 [[nodiscard]]
66 static std::string decode(const std::string& input);
67
68 private:
74 ZLib(const Mode mode);
75
83 [[nodiscard]]
84 std::string compressor(const std::string& input);
85
91 [[nodiscard]]
92 std::string finish();
93
101 [[nodiscard]]
102 std::string decompressor(const std::string& input);
103
104 private:
109
113 z_stream m_stream;
114
119
124
129 };
130} // namespace galaxy
131
132#endif
Zip (de)compressor.
Definition ZLib.hpp:20
char m_out[ZLib::ChunkSize]
Output buffer.
Definition ZLib.hpp:128
~ZLib()
Destructor.
Definition ZLib.cpp:63
static std::string decode(const std::string &input)
Decompresses string into ZLib.
Definition ZLib.cpp:125
std::string finish()
Completes the compression.
Definition ZLib.cpp:220
std::string compressor(const std::string &input)
Compresses string.
Definition ZLib.cpp:166
char m_in[ZLib::ChunkSize]
Input buffer.
Definition ZLib.hpp:123
std::string decompressor(const std::string &input)
Decompresses a zlib string.
Definition ZLib.cpp:266
Mode
ZLib mode to start in.
Definition ZLib.hpp:31
@ COMPRESS
ZLib deflation.
@ DECOMPRESS
ZLib inflation.
z_stream m_stream
Stream object.
Definition ZLib.hpp:113
bool m_finished
Has the compression finished.
Definition ZLib.hpp:118
ZLib(const Mode mode)
Constructor.
Definition ZLib.cpp:24
Mode m_mode
ZLib mode.
Definition ZLib.hpp:108
static std::string encode(const std::string &input)
Compresses string into ZLib.
Definition ZLib.cpp:82
static constexpr const auto ChunkSize
ZLib parsing chunk size.
Definition ZLib.hpp:25
Animated.cpp galaxy.
Definition Animated.cpp:16