13#ifdef GALAXY_WIN_PLATFORM
38 if (deflateInit2(&
m_stream, 9, Z_DEFLATED, 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
51 if (inflateInit2(&
m_stream, 15) != Z_OK)
57 catch (
const std::exception& e)
76 catch (
const std::exception& e)
93 unsigned int total_read = 0;
95 std::stringstream sstream;
101 total_read =
static_cast<unsigned int>(sstream.gcount());
105 result += zlib->compressor({in, total_read});
113 result += zlib->finish();
115 catch (
const std::exception& e)
136 unsigned int total_read = 0;
138 std::stringstream sstream;
144 total_read =
static_cast<unsigned int>(sstream.gcount());
148 result += zlib->decompressor({in, total_read});
156 catch (
const std::exception& e)
178 const auto left =
static_cast<unsigned int>(input.length() - i);
182 std::memcpy(
m_in, input.data() + i, current);
192 if (deflate(&
m_stream, end ? Z_SYNC_FLUSH : Z_NO_FLUSH) == Z_STREAM_ERROR)
212 catch (
const std::exception& e)
239 if (deflate(&
m_stream, Z_FINISH) == Z_STREAM_ERROR)
258 catch (
const std::exception& e)
276 const auto left =
static_cast<unsigned int>(input.length() - i);
279 std::memcpy(
m_in, input.data() + i, current);
293 if (inflate(&
m_stream, Z_NO_FLUSH) == Z_STREAM_ERROR)
308 catch (
const std::exception& e)
317#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.
char m_out[ZLib::ChunkSize]
Output 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.
char m_in[ZLib::ChunkSize]
Input buffer.
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.
static std::string encode(const std::string &input)
Compresses string into ZLib.
static constexpr const auto ChunkSize
ZLib parsing chunk size.