LCOV - code coverage report
Current view: top level - libs/capy/src_zlib - deflate.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 15.7 % 51 8
Test Date: 2025-12-15 05:33:30 Functions: 17.6 % 17 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2025 Mohammad Nejati
       4              : //
       5              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7              : //
       8              : // Official repository: https://github.com/cppalliance/capy
       9              : //
      10              : 
      11              : #include <boost/capy/polystore.hpp>
      12              : #include <boost/capy/zlib/deflate.hpp>
      13              : 
      14              : #include "stream_cast.hpp"
      15              : 
      16              : #include <boost/core/detail/static_assert.hpp>
      17              : 
      18              : #include <zlib.h>
      19              : 
      20              : namespace boost {
      21              : namespace capy {
      22              : namespace zlib {
      23              : 
      24              : BOOST_CORE_STATIC_ASSERT(sizeof(stream) == sizeof(z_stream_s));
      25              : BOOST_CORE_STATIC_ASSERT(is_layout_identical<stream, z_stream_s>());
      26              : 
      27              : //------------------------------------------------
      28              : 
      29              : class deflate_service_impl
      30              :     : public deflate_service
      31              : {
      32              : public:
      33              :     using key_type = deflate_service;
      34              : 
      35              :     explicit
      36            1 :     deflate_service_impl(
      37              :         capy::polystore&) noexcept
      38            1 :     {
      39            1 :     }
      40              : 
      41            1 :     ~deflate_service_impl()
      42            1 :     {
      43            1 :     }
      44              : 
      45              :     char const*
      46            0 :     version() const noexcept override
      47              :     {
      48            0 :         return zlibVersion();
      49              :     }
      50              : 
      51              :     int
      52            0 :     init(
      53              :         stream& st,
      54              :         int level) const override
      55              :     {
      56            0 :         stream_cast sc(st);
      57            0 :         return deflateInit(sc.get(), level);
      58              :     }
      59              : 
      60              :     int
      61            0 :     init2(
      62              :         stream& st,
      63              :         int level,
      64              :         int method,
      65              :         int windowBits,
      66              :         int memLevel,
      67              :         int strategy) const override
      68              :     {
      69            0 :         stream_cast sc(st);
      70            0 :         return deflateInit2(sc.get(),
      71              :             level, method, windowBits,
      72              :             memLevel, strategy);
      73              :     }
      74              : 
      75              :     int
      76            0 :     set_dict(
      77              :         stream& st,
      78              :         unsigned char const* dict,
      79              :         unsigned len) const override
      80              :     {
      81            0 :         stream_cast sc(st);
      82            0 :         return deflateSetDictionary(sc.get(), dict, len);
      83              :     }
      84              : 
      85              :     int
      86            0 :     get_dict(
      87              :         stream& st,
      88              :         unsigned char* dest,
      89              :         unsigned* len) const override
      90              :     {
      91            0 :         stream_cast sc(st);
      92            0 :         return deflateGetDictionary(sc.get(), dest, len);
      93              :     }
      94              : 
      95              :     int
      96            0 :     dup(
      97              :         stream& dest,
      98              :         stream& src) const override
      99              :     {
     100            0 :         stream_cast sc0(dest);
     101            0 :         stream_cast sc1(src);
     102            0 :         return deflateCopy(sc0.get(), sc1.get());
     103              :     }
     104              : 
     105              :     int
     106            0 :     deflate(
     107              :         stream& st,
     108              :         int flush) const override
     109              :     {
     110            0 :         stream_cast sc(st);
     111            0 :         return ::deflate(sc.get(), flush);
     112              :     }
     113              : 
     114              :     int
     115            0 :     deflate_end(
     116              :         stream& st) const override
     117              :     {
     118            0 :         stream_cast sc(st);
     119            0 :         return deflateEnd(sc.get());
     120              :     }
     121              : 
     122              :     int
     123            0 :     reset(
     124              :         stream& st) const override
     125              :     {
     126            0 :         stream_cast sc(st);
     127            0 :         return deflateReset(sc.get());
     128              :     }
     129              : 
     130              :     int
     131            0 :     params(
     132              :         stream& st,
     133              :         int level,
     134              :         int strategy) const override
     135              :     {
     136            0 :         stream_cast sc(st);
     137            0 :         return deflateParams(sc.get(), level, strategy);
     138              :     }
     139              : 
     140              :     std::size_t
     141            0 :     bound(
     142              :         stream& st,
     143              :         unsigned long sourceLen) const override
     144              :     {
     145            0 :         stream_cast sc(st);
     146            0 :         return deflateBound(sc.get(), sourceLen);
     147              :     }
     148              : 
     149              :     int
     150            0 :     pending(
     151              :         stream& st,
     152              :         unsigned* pending,
     153              :         int* bits) const override
     154              :     {
     155            0 :         stream_cast sc(st);
     156            0 :         return deflatePending(sc.get(), pending, bits);
     157              :     }
     158              : 
     159              :     int
     160            0 :     prime(
     161              :         stream& st,
     162              :         int bits,
     163              :         int value) const override
     164              :     {
     165            0 :         stream_cast sc(st);
     166            0 :         return deflatePrime(sc.get(), bits, value);
     167              :     }
     168              : 
     169              :     int
     170            0 :     set_header(
     171              :         stream& st,
     172              :         void* header) const override
     173              :     {
     174            0 :         stream_cast sc(st);
     175            0 :         return deflateSetHeader(sc.get(),
     176            0 :             reinterpret_cast<gz_header*>(header));
     177              :     }
     178              : };
     179              : 
     180              : deflate_service&
     181            1 : install_deflate_service(polystore& ctx)
     182              : {
     183            1 :     return ctx.emplace<deflate_service_impl>(ctx);
     184              : }
     185              : 
     186              : } // zlib
     187              : } // capy
     188              : } // boost
        

Generated by: LCOV version 2.1