Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:28:06

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 // This is a derivative work based on Zlib, copyright below:
0011 /*
0012     Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
0013 
0014     This software is provided 'as-is', without any express or implied
0015     warranty.  In no event will the authors be held liable for any damages
0016     arising from the use of this software.
0017 
0018     Permission is granted to anyone to use this software for any purpose,
0019     including commercial applications, and to alter it and redistribute it
0020     freely, subject to the following restrictions:
0021 
0022     1. The origin of this software must not be misrepresented; you must not
0023        claim that you wrote the original software. If you use this software
0024        in a product, an acknowledgment in the product documentation would be
0025        appreciated but is not required.
0026     2. Altered source versions must be plainly marked as such, and must not be
0027        misrepresented as being the original software.
0028     3. This notice may not be removed or altered from any source distribution.
0029 
0030     Jean-loup Gailly        Mark Adler
0031     jloup@gzip.org          madler@alumni.caltech.edu
0032 
0033     The data format used by the zlib library is described by RFCs (Request for
0034     Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
0035     (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
0036 */
0037 
0038 #ifndef BOOST_BEAST_ZLIB_IMPL_ERROR_IPP
0039 #define BOOST_BEAST_ZLIB_IMPL_ERROR_IPP
0040 
0041 #include <boost/beast/zlib/error.hpp>
0042 #include <type_traits>
0043 
0044 namespace boost {
0045 namespace beast {
0046 namespace zlib {
0047 namespace detail {
0048 
0049 class error_codes : public error_category
0050 {
0051 public:
0052     const char*
0053     name() const noexcept override
0054     {
0055         return "boost.beast.zlib";
0056     }
0057 
0058     BOOST_BEAST_DECL
0059     char const*
0060     message(int ev, char*, std::size_t) const noexcept override
0061     {
0062         switch(static_cast<error>(ev))
0063         {
0064         case error::need_buffers: return "need buffers";
0065         case error::end_of_stream: return "unexpected end of deflate stream";
0066         case error::need_dict: return "need dict";
0067         case error::stream_error: return "stream error";
0068 
0069         case error::invalid_block_type: return "invalid block type";
0070         case error::invalid_stored_length: return "invalid stored block length";
0071         case error::too_many_symbols: return "too many symbols";
0072         case error::invalid_code_lengths: return "invalid code lengths";
0073         case error::invalid_bit_length_repeat: return "invalid bit length repeat";
0074         case error::missing_eob: return "missing end of block code";
0075         case error::invalid_literal_length: return "invalid literal/length code";
0076         case error::invalid_distance_code: return "invalid distance code";
0077         case error::invalid_distance: return "invalid distance";
0078 
0079         case error::over_subscribed_length: return "over-subscribed length";
0080         case error::incomplete_length_set: return "incomplete length set";
0081 
0082         case error::general:
0083         default:
0084             return "beast.zlib error";
0085         }
0086     }
0087 
0088     std::string
0089     message(int ev) const override
0090     {
0091         return message(ev, nullptr, 0);
0092     }
0093 
0094     error_condition
0095     default_error_condition(int ev) const noexcept override
0096     {
0097         return error_condition{ev, *this};
0098     }
0099 
0100     bool
0101     equivalent(int ev,
0102         error_condition const& condition
0103             ) const noexcept override
0104     {
0105         return condition.value() == ev &&
0106             &condition.category() == this;
0107     }
0108 
0109     bool
0110     equivalent(error_code const& error, int ev) const noexcept override
0111     {
0112         return error.value() == ev &&
0113             &error.category() == this;
0114     }
0115 };
0116 
0117 } // detail
0118 
0119 error_code
0120 make_error_code(error ev)
0121 {
0122     static detail::error_codes const cat{};
0123     return error_code{static_cast<
0124         std::underlying_type<error>::type>(ev), cat};
0125 }
0126 
0127 } // zlib
0128 } // beast
0129 } // boost
0130 
0131 #endif