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
15
16namespace galaxy
17{
21 class ZLib final
22 {
23 public:
27 enum class Mode : int
28 {
32 COMPRESS = 0,
33
37 DECOMPRESS = 1
38 };
39
43 ~ZLib();
44
52 [[nodiscard]]
53 static std::string encode(const std::string& input);
54
62 [[nodiscard]]
63 static std::string decode(const std::string& input);
64
65 private:
71 ZLib(const Mode mode);
72
80 [[nodiscard]]
81 std::string compressor(const std::string& input);
82
88 [[nodiscard]]
89 std::string finish();
90
98 [[nodiscard]]
99 std::string decompressor(const std::string& input);
100
101 private:
106
110 z_stream m_stream;
111
116
121
126 };
127} // namespace galaxy
128
129#endif
#define GALAXY_ZLIB_COMPLETE_CHUNK
Pragma.hpp galaxy.
Definition Pragma.hpp:14
Zip (de)compressor.
Definition ZLib.hpp:22
~ZLib()
Destructor.
Definition ZLib.cpp:62
char m_in[GALAXY_ZLIB_COMPLETE_CHUNK]
Input buffer.
Definition ZLib.hpp:120
static std::string decode(const std::string &input)
Decompresses string into ZLib.
Definition ZLib.cpp:124
std::string finish()
Completes the compression.
Definition ZLib.cpp:219
std::string compressor(const std::string &input)
Compresses string.
Definition ZLib.cpp:165
std::string decompressor(const std::string &input)
Decompresses a zlib string.
Definition ZLib.cpp:265
Mode
ZLib mode to start in.
Definition ZLib.hpp:28
@ COMPRESS
ZLib deflation.
@ DECOMPRESS
ZLib inflation.
z_stream m_stream
Stream object.
Definition ZLib.hpp:110
bool m_finished
Has the compression finished.
Definition ZLib.hpp:115
ZLib(const Mode mode)
Constructor.
Definition ZLib.cpp:23
char m_out[GALAXY_ZLIB_COMPLETE_CHUNK]
Output buffer.
Definition ZLib.hpp:125
Mode m_mode
ZLib mode.
Definition ZLib.hpp:105
static std::string encode(const std::string &input)
Compresses string into ZLib.
Definition ZLib.cpp:81
Timer.hpp galaxy.
Definition Timer.cpp:18