12#ifdef GALAXY_WIN_PLATFORM
37 if (deflateInit2(&
m_stream, 9, Z_DEFLATED, 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
50 if (inflateInit2(&
m_stream, 15) != Z_OK)
56 catch (
const std::exception& e)
75 catch (
const std::exception& e)
92 unsigned int total_read = 0;
94 std::stringstream sstream;
100 total_read =
static_cast<unsigned int>(sstream.gcount());
104 result += zlib->compressor({in, total_read});
112 result += zlib->finish();
114 catch (
const std::exception& e)
135 unsigned int total_read = 0;
137 std::stringstream sstream;
143 total_read =
static_cast<unsigned int>(sstream.gcount());
147 result += zlib->decompressor({in, total_read});
155 catch (
const std::exception& e)
177 const auto left =
static_cast<unsigned int>(input.length() - i);
181 std::memcpy(
m_in, input.data() + i, current);
191 if (deflate(&
m_stream, end ? Z_SYNC_FLUSH : Z_NO_FLUSH) == Z_STREAM_ERROR)
211 catch (
const std::exception& e)
238 if (deflate(&
m_stream, Z_FINISH) == Z_STREAM_ERROR)
257 catch (
const std::exception& e)
275 const auto left =
static_cast<unsigned int>(input.length() - i);
278 std::memcpy(
m_in, input.data() + i, current);
292 if (inflate(&
m_stream, Z_NO_FLUSH) == Z_STREAM_ERROR)
307 catch (
const std::exception& e)
316#ifdef GALAXY_WIN_PLATFORM
#define GALAXY_LOG(level, msg,...)
#define GALAXY_DISABLE_WARNING_POP
#define GALAXY_DISABLE_WARNING(x)
#define GALAXY_DISABLE_WARNING_PUSH
Macro for windows platform detection.
#define GALAXY_ZLIB_COMPLETE_CHUNK
Pragma.hpp galaxy.
char m_in[GALAXY_ZLIB_COMPLETE_CHUNK]
Input buffer.
static std::string decode(const std::string &input)
Decompresses string into ZLib.
std::string finish()
Completes the compression.
std::string compressor(const std::string &input)
Compresses string.
std::string decompressor(const std::string &input)
Decompresses a zlib string.
Mode
ZLib mode to start in.
@ COMPRESS
ZLib deflation.
@ DECOMPRESS
ZLib inflation.
z_stream m_stream
Stream object.
bool m_finished
Has the compression finished.
ZLib(const Mode mode)
Constructor.
char m_out[GALAXY_ZLIB_COMPLETE_CHUNK]
Output buffer.
static std::string encode(const std::string &input)
Compresses string into ZLib.