13#ifdef GALAXY_WIN_PLATFORM
40 if (deflateInit2(&
m_stream, 9, Z_DEFLATED, 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
53 if (inflateInit2(&
m_stream, 15) != Z_OK)
59 catch (
const std::exception& e)
78 catch (
const std::exception& e)
96 const auto left =
static_cast<unsigned int>(input.length() - i);
100 std::memcpy(
m_in, input.data() + i, current);
110 if (deflate(&
m_stream, end ? Z_SYNC_FLUSH : Z_NO_FLUSH) == Z_STREAM_ERROR)
130 catch (
const std::exception& e)
157 if (deflate(&
m_stream, Z_FINISH) == Z_STREAM_ERROR)
176 catch (
const std::exception& e)
194 const auto left =
static_cast<unsigned int>(input.length() - i);
197 std::memcpy(
m_in, input.data() + i, current);
211 if (inflate(&
m_stream, Z_NO_FLUSH) == Z_STREAM_ERROR)
226 catch (
const std::exception& e)
245 unsigned int total_read = 0;
247 std::stringstream sstream;
253 total_read =
static_cast<unsigned int>(sstream.gcount());
257 result += zlib->compressor({in, total_read});
265 result += zlib->finish();
267 catch (
const std::exception& e)
287 unsigned int total_read = 0;
289 std::stringstream sstream;
295 total_read =
static_cast<unsigned int>(sstream.gcount());
299 result += zlib->decompressor({in, total_read});
307 catch (
const std::exception& e)
318#ifdef GALAXY_WIN_PLATFORM
#define GALAXY_LOG(level, msg,...)
#define GALAXY_DISABLE_WARNING_POP
#define GALAXY_DISABLE_WARNING(x)
#define GALAXY_DISABLE_WARNING_PUSH
Pragma.hpp galaxy.
#define GALAXY_ZLIB_COMPLETE_CHUNK
ZLib inflate/deflate chunk size.
z_stream m_stream
Stream object.
ZLib(const Mode mode)
Constructor.
std::string decompressor(const std::string &input)
Decompresses a zlib string.
std::string compressor(const std::string &input)
Compresses string.
std::string finish()
Completes the compression.
char m_out[GALAXY_ZLIB_COMPLETE_CHUNK]
Output buffer.
bool m_finished
Has the compression finished.
Mode
ZLib mode to start in.
@ COMPRESS
ZLib deflation.
@ DECOMPRESS
ZLib inflation.
char m_in[GALAXY_ZLIB_COMPLETE_CHUNK]
Input buffer.
std::string encode_zlib(const std::string &input)
Compresses string into ZLib.
std::string decode_zlib(const std::string &input)
Decompresses string into ZLib.