2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/boostorg/beast
10 // This is a derivative work based on Zlib, copyright below:
12 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
14 This software is provided 'as-is', without any express or implied
15 warranty. In no event will the authors be held liable for any damages
16 arising from the use of this software.
18 Permission is granted to anyone to use this software for any purpose,
19 including commercial applications, and to alter it and redistribute it
20 freely, subject to the following restrictions:
22 1. The origin of this software must not be misrepresented; you must not
23 claim that you wrote the original software. If you use this software
24 in a product, an acknowledgment in the product documentation would be
25 appreciated but is not required.
26 2. Altered source versions must be plainly marked as such, and must not be
27 misrepresented as being the original software.
28 3. This notice may not be removed or altered from any source distribution.
30 Jean-loup Gailly Mark Adler
31 jloup@gzip.org madler@alumni.caltech.edu
33 The data format used by the zlib library is described by RFCs (Request for
34 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
35 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
38 #ifndef BOOST_BEAST_ZLIB_IMPL_ERROR_IPP
39 #define BOOST_BEAST_ZLIB_IMPL_ERROR_IPP
41 #include <boost/beast/zlib/error.hpp>
42 #include <type_traits>
49 class error_codes : public error_category
53 name() const noexcept override
55 return "boost.beast.zlib";
59 message(int ev) const override
61 switch(static_cast<error>(ev))
63 case error::need_buffers: return "need buffers";
64 case error::end_of_stream: return "unexpected end of deflate stream";
65 case error::need_dict: return "need dict";
66 case error::stream_error: return "stream error";
68 case error::invalid_block_type: return "invalid block type";
69 case error::invalid_stored_length: return "invalid stored block length";
70 case error::too_many_symbols: return "too many symbols";
71 case error::invalid_code_lengths: return "invalid code lengths";
72 case error::invalid_bit_length_repeat: return "invalid bit length repeat";
73 case error::missing_eob: return "missing end of block code";
74 case error::invalid_literal_length: return "invalid literal/length code";
75 case error::invalid_distance_code: return "invalid distance code";
76 case error::invalid_distance: return "invalid distance";
78 case error::over_subscribed_length: return "over-subscribed length";
79 case error::incomplete_length_set: return "incomplete length set";
83 return "beast.zlib error";
88 default_error_condition(int ev) const noexcept override
90 return error_condition{ev, *this};
95 error_condition const& condition
96 ) const noexcept override
98 return condition.value() == ev &&
99 &condition.category() == this;
103 equivalent(error_code const& error, int ev) const noexcept override
105 return error.value() == ev &&
106 &error.category() == this;
113 make_error_code(error ev)
115 static detail::error_codes const cat{};
116 return error_code{static_cast<
117 std::underlying_type<error>::type>(ev), cat};