liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/json
//
 
#ifndef BOOST_JSON_ERROR_HPP
#define BOOST_JSON_ERROR_HPP
 
#include <boost/json/detail/config.hpp>
#ifndef BOOST_JSON_STANDALONE
# include <boost/system/error_code.hpp>
# include <boost/system/system_error.hpp>
#else
# include <system_error>
#endif
 
BOOST_JSON_NS_BEGIN
 
#ifdef BOOST_JSON_DOCS
 
/** The type of error code used by the library.
 
    This type alias is set depending
    on how the library is configured:
 
    @par Use with Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    not defined, this type will be an alias
    for `boost::system::error_code`.
    Compiling a program using the library will
    require Boost, and a compiler conforming
    to C++11 or later.
 
    @par Use without Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    defined, this type will be an alias
    for `std::error_code`.
    Compiling a program using the library will
    require only a compiler conforming to C++17
    or later.
 
    @see https://en.cppreference.com/w/cpp/error/error_code
*/
using error_code = __see_below__;
 
/** The type of error category used by the library.
 
    This type alias is set depending
    on how the library is configured:
 
    @par Use with Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    not defined, this type will be an alias
    for `boost::system::error_category`.
    Compiling a program using the library will
    require Boost, and a compiler conforming
    to C++11 or later.
 
    @par Use without Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    defined, this type will be an alias
    for `std::error_category`.
    Compiling a program using the library will
    require only a compiler conforming to C++17
    or later.
 
    @see https://en.cppreference.com/w/cpp/error/error_category
*/
using error_category = __see_below__;
 
/** The type of error condition used by the library.
 
    This type alias is set depending
    on how the library is configured:
 
    @par Use with Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    not defined, this type will be an alias
    for `boost::system::error_condition`.
    Compiling a program using the library will
    require Boost, and a compiler conforming
    to C++11 or later.
 
    @par Use without Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    defined, this type will be an alias
    for `std::error_condition`.
    Compiling a program using the library will
    require only a compiler conforming to C++17
    or later.
 
    @see https://en.cppreference.com/w/cpp/error/error_condition
*/
using error_condition = __see_below__;
 
/** The type of system error thrown by the library.
 
    This type alias is set depending
    on how the library is configured:
 
    @par Use with Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    not defined, this type will be an alias
    for `boost::system::system_error`.
    Compiling a program using the library will
    require Boost, and a compiler conforming
    to C++11 or later.
 
    @par Use without Boost
 
    If the macro `BOOST_JSON_STANDALONE` is
    defined, this type will be an alias
    for `std::system_error`.
    Compiling a program using the library will
    require only a compiler conforming to C++17
    or later.
 
    @see https://en.cppreference.com/w/cpp/error/system_error
*/
using system_error = __see_below__;
 
/// Returns the generic error category used by the library.
error_category const&
generic_category();
 
#elif ! defined(BOOST_JSON_STANDALONE)
 
using error_code = boost::system::error_code;
using error_category = boost::system::error_category;
using error_condition = boost::system::error_condition;
using system_error = boost::system::system_error;
using boost::system::generic_category;
 
#else
 
using error_code = std::error_code;
using error_category = std::error_category;
using error_condition = std::error_condition;
using system_error = std::system_error;
using std::generic_category;
 
#endif
 
/** Error codes returned by JSON operations
 
*/
enum class error
{
    //
    // parse errors
    //
 
    /// syntax error
    syntax = 1,
 
    /// extra data
    extra_data,
 
    /// incomplete JSON
    incomplete,
 
    /// exponent too large
    exponent_overflow,
 
    /// too deep
    too_deep,
 
    /// illegal leading surrogate
    illegal_leading_surrogate,
 
    /// illegal trailing surrogate
    illegal_trailing_surrogate,
 
    /// expected hex digit
    expected_hex_digit,
 
    /// expected utf16 escape
    expected_utf16_escape,
 
    /// An object contains too many elements
    object_too_large,
 
    /// An array contains too many elements
    array_too_large,
 
    /// A key is too large
    key_too_large,
 
    /// A string is too large
    string_too_large,
 
    /// The parser encountered an exception and must be reset
    exception,
 
    //----------------------------------
 
    /// not a number
    not_number,
 
    /// number cast is not exact
    not_exact,
 
    /// test failure
    test_failure,
};
 
/** Error conditions corresponding to JSON errors
*/
enum class condition
{
    /// A parser-related error
    parse_error = 1,
 
    /// An error on assignment to or from a JSON value
    assign_error
};
 
BOOST_JSON_NS_END
 
#include <boost/json/impl/error.hpp>
 
#endif