10.53% Lines (2/19) 25.00% Functions (1/4)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2024 Mohammad Nejati 2   // Copyright (c) 2024 Mohammad Nejati
3   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 4   // Distributed under the Boost Software License, Version 1.0. (See accompanying
5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6   // 6   //
7   // Official repository: https://github.com/cppalliance/http 7   // Official repository: https://github.com/cppalliance/http
8   // 8   //
9   9  
10   #include <boost/http/zlib/error.hpp> 10   #include <boost/http/zlib/error.hpp>
11   11  
12   namespace boost { 12   namespace boost {
13   namespace http { 13   namespace http {
14   namespace zlib { 14   namespace zlib {
15   namespace detail { 15   namespace detail {
16   16  
17   const char* 17   const char*
MISUBC 18   error_cat_type:: 18   error_cat_type::
19   name() const noexcept 19   name() const noexcept
20   { 20   {
MISUBC 21   return "boost.http.zlib"; 21   return "boost.http.zlib";
22   } 22   }
23   23  
24   bool 24   bool
HITCBC 25   1 error_cat_type:: 25   1 error_cat_type::
26   failed(int ev) const noexcept 26   failed(int ev) const noexcept
27   { 27   {
HITCBC 28   1 return ev < 0; 28   1 return ev < 0;
29   } 29   }
30   30  
31   std::string 31   std::string
MISUBC 32   error_cat_type:: 32   error_cat_type::
33   message(int ev) const 33   message(int ev) const
34   { 34   {
MISUBC 35   return message(ev, nullptr, 0); 35   return message(ev, nullptr, 0);
36   } 36   }
37   37  
38   char const* 38   char const*
MISUBC 39   error_cat_type:: 39   error_cat_type::
40   message( 40   message(
41   int ev, 41   int ev,
42   char*, 42   char*,
43   std::size_t) const noexcept 43   std::size_t) const noexcept
44   { 44   {
MISUBC 45   switch(static_cast<error>(ev)) 45   switch(static_cast<error>(ev))
46   { 46   {
MISUBC 47   case error::ok: return "Z_OK"; 47   case error::ok: return "Z_OK";
MISUBC 48   case error::stream_end: return "Z_STREAM_END"; 48   case error::stream_end: return "Z_STREAM_END";
MISUBC 49   case error::need_dict: return "Z_NEED_DICT"; 49   case error::need_dict: return "Z_NEED_DICT";
MISUBC 50   case error::errno_: return "Z_ERRNO"; 50   case error::errno_: return "Z_ERRNO";
MISUBC 51   case error::stream_err: return "Z_STREAM_ERROR"; 51   case error::stream_err: return "Z_STREAM_ERROR";
MISUBC 52   case error::data_err: return "Z_DATA_ERROR"; 52   case error::data_err: return "Z_DATA_ERROR";
MISUBC 53   case error::mem_err: return "Z_MEM_ERROR"; 53   case error::mem_err: return "Z_MEM_ERROR";
MISUBC 54   case error::buf_err: return "Z_BUF_ERROR"; 54   case error::buf_err: return "Z_BUF_ERROR";
MISUBC 55   case error::version_err: return "Z_VERSION_ERROR"; 55   case error::version_err: return "Z_VERSION_ERROR";
MISUBC 56   default: 56   default:
MISUBC 57   return "unknown"; 57   return "unknown";
58   } 58   }
59   } 59   }
60   60  
61   // msvc 14.0 has a bug that warns about inability 61   // msvc 14.0 has a bug that warns about inability
62   // to use constexpr construction here, even though 62   // to use constexpr construction here, even though
63   // there's no constexpr construction 63   // there's no constexpr construction
64   #if defined(_MSC_VER) && _MSC_VER <= 1900 64   #if defined(_MSC_VER) && _MSC_VER <= 1900
65   # pragma warning( push ) 65   # pragma warning( push )
66   # pragma warning( disable : 4592 ) 66   # pragma warning( disable : 4592 )
67   #endif 67   #endif
68   68  
69   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L 69   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
70   constinit error_cat_type error_cat; 70   constinit error_cat_type error_cat;
71   #else 71   #else
72   error_cat_type error_cat; 72   error_cat_type error_cat;
73   #endif 73   #endif
74   74  
75   #if defined(_MSC_VER) && _MSC_VER <= 1900 75   #if defined(_MSC_VER) && _MSC_VER <= 1900
76   # pragma warning( pop ) 76   # pragma warning( pop )
77   #endif 77   #endif
78   78  
79   } // detail 79   } // detail
80   } // zlib 80   } // zlib
81   } // http 81   } // http
82   } // boost 82   } // boost