Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:36

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     std::string
0059     message(int ev) const override
0060     {
0061         switch(static_cast<error>(ev))
0062         {
0063         case error::need_buffers: return "need buffers";
0064         case error::end_of_stream: return "unexpected end of deflate stream";
0065         case error::need_dict: return "need dict";
0066         case error::stream_error: return "stream error";
0067 
0068         case error::invalid_block_type: return "invalid block type";
0069         case error::invalid_stored_length: return "invalid stored block length";
0070         case error::too_many_symbols: return "too many symbols";
0071         case error::invalid_code_lengths: return "invalid code lengths";
0072         case error::invalid_bit_length_repeat: return "invalid bit length repeat";
0073         case error::missing_eob: return "missing end of block code";
0074         case error::invalid_literal_length: return "invalid literal/length code";
0075         case error::invalid_distance_code: return "invalid distance code";
0076         case error::invalid_distance: return "invalid distance";
0077 
0078         case error::over_subscribed_length: return "over-subscribed length";
0079         case error::incomplete_length_set: return "incomplete length set";
0080 
0081         case error::general:
0082         default:
0083             return "beast.zlib error";
0084         }
0085     }
0086 
0087     error_condition
0088     default_error_condition(int ev) const noexcept override
0089     {
0090         return error_condition{ev, *this};
0091     }
0092 
0093     bool
0094     equivalent(int ev,
0095         error_condition const& condition
0096             ) const noexcept override
0097     {
0098         return condition.value() == ev &&
0099             &condition.category() == this;
0100     }
0101 
0102     bool
0103     equivalent(error_code const& error, int ev) const noexcept override
0104     {
0105         return error.value() == ev &&
0106             &error.category() == this;
0107     }
0108 };
0109 
0110 } // detail
0111 
0112 error_code
0113 make_error_code(error ev)
0114 {
0115     static detail::error_codes const cat{};
0116     return error_code{static_cast<
0117         std::underlying_type<error>::type>(ev), cat};
0118 }
0119 
0120 } // zlib
0121 } // beast
0122 } // boost
0123 
0124 #endif