include/boost/http/brotli/impl/error.hpp

100.0% Lines (3/0/3) 100.0% List of functions (1/0/1)
error.hpp
f(x) Functions (1)
Line TLA Hits Source Code
1 //
2 // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2024 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/http
9 //
10
11 #ifndef BOOST_HTTP_BROTLI_IMPL_ERROR_HPP
12 #define BOOST_HTTP_BROTLI_IMPL_ERROR_HPP
13
14 #include <boost/http/detail/config.hpp>
15
16 #include <system_error>
17
18 namespace std {
19 template<>
20 struct is_error_code_enum<
21 ::boost::http::brotli::error>
22 : std::true_type {};
23 } // std
24
25 namespace boost {
26 namespace http {
27 namespace brotli {
28
29 namespace detail {
30
31 struct BOOST_SYMBOL_VISIBLE
32 error_cat_type
33 : std::error_category
34 {
35 BOOST_HTTP_DECL const char* name(
36 ) const noexcept override;
37 BOOST_HTTP_DECL std::string message(
38 int) const override;
39 constexpr error_cat_type() noexcept = default;
40 };
41
42 BOOST_HTTP_DECL extern
43 error_cat_type error_cat;
44
45 } // detail
46
47 inline
48 std::error_code
49 1x make_error_code(
50 error ev) noexcept
51 {
52 1x return std::error_code{
53 static_cast<std::underlying_type<
54 error>::type>(ev),
55 1x detail::error_cat};
56 }
57
58 } // brotli
59 } // http
60 } // boost
61
62 #endif
63