summaryrefslogtreecommitdiff
path: root/src/io/ozlibstream.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:35:01 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:35:01 +0300
commit1a0ffe372f4da8408c5d08a36013536a3396b9e6 (patch)
tree440f2a9a325c9ab4cb5b16dc6a8193317cabf8d7 /src/io/ozlibstream.cpp
parentf4d8ea0fa76174843adf7f77ebad0ad17d2377ed (diff)
downloadProject-Tick-1a0ffe372f4da8408c5d08a36013536a3396b9e6.tar.gz
Project-Tick-1a0ffe372f4da8408c5d08a36013536a3396b9e6.zip
NOISSUE reformat libnbtplusplus to new MeshMC clang format rules
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'src/io/ozlibstream.cpp')
-rw-r--r--src/io/ozlibstream.cpp155
1 files changed, 75 insertions, 80 deletions
diff --git a/src/io/ozlibstream.cpp b/src/io/ozlibstream.cpp
index eefe38a91c..c8a3e862a1 100644
--- a/src/io/ozlibstream.cpp
+++ b/src/io/ozlibstream.cpp
@@ -27,93 +27,88 @@
namespace zlib
{
-deflate_streambuf::deflate_streambuf(std::ostream& output, size_t bufsize, int level, int window_bits, int mem_level, int strategy):
- zlib_streambuf(bufsize), os(output)
-{
- int ret = deflateInit2(&zstr, level, Z_DEFLATED, window_bits, mem_level, strategy);
- if(ret != Z_OK)
- throw zlib_error(zstr.msg, ret);
+ deflate_streambuf::deflate_streambuf(std::ostream& output, size_t bufsize,
+ int level, int window_bits,
+ int mem_level, int strategy)
+ : zlib_streambuf(bufsize), os(output)
+ {
+ int ret = deflateInit2(&zstr, level, Z_DEFLATED, window_bits, mem_level,
+ strategy);
+ if (ret != Z_OK)
+ throw zlib_error(zstr.msg, ret);
- setp(in.data(), in.data() + in.size());
-}
+ setp(in.data(), in.data() + in.size());
+ }
-deflate_streambuf::~deflate_streambuf() noexcept
-{
- try
- {
- close();
- }
- catch(...)
- {
- //ignore as we can't do anything about it
- }
- deflateEnd(&zstr);
-}
+ deflate_streambuf::~deflate_streambuf() noexcept
+ {
+ try {
+ close();
+ } catch (...) {
+ // ignore as we can't do anything about it
+ }
+ deflateEnd(&zstr);
+ }
-void deflate_streambuf::close()
-{
- deflate_chunk(Z_FINISH);
-}
+ void deflate_streambuf::close()
+ {
+ deflate_chunk(Z_FINISH);
+ }
-void deflate_streambuf::deflate_chunk(int flush)
-{
- zstr.next_in = reinterpret_cast<Bytef*>(pbase());
- zstr.avail_in = pptr() - pbase();
- do
- {
- zstr.next_out = reinterpret_cast<Bytef*>(out.data());
- zstr.avail_out = out.size();
- int ret = deflate(&zstr, flush);
- if(ret != Z_OK && ret != Z_STREAM_END)
- {
- os.setstate(std::ios_base::failbit);
- throw zlib_error(zstr.msg, ret);
- }
- int have = out.size() - zstr.avail_out;
- if(!os.write(out.data(), have))
- throw std::ios_base::failure("Could not write to the output stream");
- } while(zstr.avail_out == 0);
- setp(in.data(), in.data() + in.size());
-}
+ void deflate_streambuf::deflate_chunk(int flush)
+ {
+ zstr.next_in = reinterpret_cast<Bytef*>(pbase());
+ zstr.avail_in = pptr() - pbase();
+ do {
+ zstr.next_out = reinterpret_cast<Bytef*>(out.data());
+ zstr.avail_out = out.size();
+ int ret = deflate(&zstr, flush);
+ if (ret != Z_OK && ret != Z_STREAM_END) {
+ os.setstate(std::ios_base::failbit);
+ throw zlib_error(zstr.msg, ret);
+ }
+ int have = out.size() - zstr.avail_out;
+ if (!os.write(out.data(), have))
+ throw std::ios_base::failure(
+ "Could not write to the output stream");
+ } while (zstr.avail_out == 0);
+ setp(in.data(), in.data() + in.size());
+ }
-deflate_streambuf::int_type deflate_streambuf::overflow(int_type ch)
-{
- deflate_chunk();
- if(ch != traits_type::eof())
- {
- *pptr() = ch;
- pbump(1);
- }
- return ch;
-}
+ deflate_streambuf::int_type deflate_streambuf::overflow(int_type ch)
+ {
+ deflate_chunk();
+ if (ch != traits_type::eof()) {
+ *pptr() = ch;
+ pbump(1);
+ }
+ return ch;
+ }
-int deflate_streambuf::sync()
-{
- deflate_chunk();
- return 0;
-}
+ int deflate_streambuf::sync()
+ {
+ deflate_chunk();
+ return 0;
+ }
-void ozlibstream::close()
-{
- // Capture the exception mask so we can restore it if close() fails.
- std::ios_base::iostate old_ex = exceptions();
- try
- {
- buf.close();
- return;
- }
- catch(...)
- {
- // fall through to mark the stream as bad
- }
+ void ozlibstream::close()
+ {
+ // Capture the exception mask so we can restore it if close() fails.
+ std::ios_base::iostate old_ex = exceptions();
+ try {
+ buf.close();
+ return;
+ } catch (...) {
+ // fall through to mark the stream as bad
+ }
- // Setting the stream state while exceptions are enabled may cause
- // `setstate` to throw an `ios_base::failure` which would replace
- // the original exception. Temporarily disable exceptions on this
- // stream, set the `badbit`, then restore the exception mask.
- exceptions(std::ios_base::goodbit);
- setstate(std::ios_base::badbit);
- exceptions(old_ex);
-}
+ // Setting the stream state while exceptions are enabled may cause
+ // `setstate` to throw an `ios_base::failure` which would replace
+ // the original exception. Temporarily disable exceptions on this
+ // stream, set the `badbit`, then restore the exception mask.
+ exceptions(std::ios_base::goodbit);
+ setstate(std::ios_base::badbit);
+ exceptions(old_ex);
+ }
} // namespace zlib