Line data Source code
1 : //
2 : // Copyright (c) 2024 Mohammad Nejati
3 : //
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)
6 : //
7 : // Official repository: https://github.com/cppalliance/capy
8 : //
9 :
10 : #include <boost/capy/brotli/error.hpp>
11 :
12 : namespace boost {
13 : namespace capy {
14 : namespace brotli {
15 : namespace detail {
16 :
17 : const char*
18 0 : error_cat_type::
19 : name() const noexcept
20 : {
21 0 : return "boost.capy.brotli";
22 : }
23 :
24 : bool
25 1 : error_cat_type::
26 : failed(int ev) const noexcept
27 : {
28 1 : return ev < 0;
29 : }
30 :
31 : std::string
32 0 : error_cat_type::
33 : message(int ev) const
34 : {
35 0 : return message(ev, nullptr, 0);
36 : }
37 :
38 : char const*
39 0 : error_cat_type::
40 : message(
41 : int ev,
42 : char*,
43 : std::size_t) const noexcept
44 : {
45 0 : switch(static_cast<error>(ev))
46 : {
47 :
48 0 : case error::no_error: return "no_error";
49 0 : case error::success: return "success";
50 0 : case error::needs_more_input: return "needs_more_input";
51 0 : case error::needs_more_output: return "needs_more_output";
52 0 : case error::format_exuberant_nibble: return "format_exuberant_nibble";
53 0 : case error::format_reserved: return "format_reserved";
54 0 : case error::format_exuberant_meta_nibbl: return "format_exuberant_meta_nibbl";
55 0 : case error::format_simple_huffman_alphabet: return "format_simple_huffman_alphabet";
56 0 : case error::format_simple_huffman_same: return "format_simple_huffman_same";
57 0 : case error::format_cl_space: return "format_cl_space";
58 0 : case error::format_huffman_space: return "format_huffman_space";
59 0 : case error::format_context_map_repea: return "format_context_map_repea";
60 0 : case error::format_block_length_1: return "format_block_length_1";
61 0 : case error::format_block_length_2: return "format_block_length_2";
62 0 : case error::format_transform: return "format_transform";
63 0 : case error::format_dictionary: return "format_dictionary";
64 0 : case error::format_window_bits: return "format_window_bits";
65 0 : case error::format_padding_1: return "format_padding_1";
66 0 : case error::format_padding_2: return "format_padding_2";
67 0 : case error::format_distance: return "format_distance";
68 0 : case error::compound_dictionary: return "compound_dictionary";
69 0 : case error::dictionary_not_set: return "dictionary_not_set";
70 0 : case error::invalid_arguments: return "invalid_arguments";
71 0 : case error::alloc_context_modes: return "alloc_context_modes";
72 0 : case error::alloc_tree_groups: return "alloc_tree_groups";
73 0 : case error::alloc_context_map: return "alloc_context_map";
74 0 : case error::alloc_ring_buffer_1: return "alloc_ring_buffer_1";
75 0 : case error::alloc_ring_buffer_2: return "alloc_ring_buffer_2";
76 0 : case error::alloc_block_type_trees: return "alloc_block_type_trees";
77 0 : case error::unreachable: return "unreachable";
78 0 : default:
79 0 : return "unknown";
80 : }
81 : }
82 :
83 : // msvc 14.0 has a bug that warns about inability
84 : // to use constexpr construction here, even though
85 : // there's no constexpr construction
86 : #if defined(_MSC_VER) && _MSC_VER <= 1900
87 : # pragma warning( push )
88 : # pragma warning( disable : 4592 )
89 : #endif
90 :
91 : #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
92 : constinit error_cat_type error_cat;
93 : #else
94 : error_cat_type error_cat;
95 : #endif
96 :
97 : #if defined(_MSC_VER) && _MSC_VER <= 1900
98 : # pragma warning( pop )
99 : #endif
100 :
101 : } // detail
102 : } // brotli
103 : } // capy
104 : } // boost
|