Debian Codegraph @

headers/system_error

raw
1 /* Copyright (C) 2015 Povilas Kanapickas <[email protected]>
2
3 This file is part of cppreference-doc
4
5 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6 Unported License. To view a copy of this license, visit
7 http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8 Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14 */
15
16 #ifndef CPPREFERENCE_SYSTEM_ERROR_H
17 #define CPPREFERENCE_SYSTEM_ERROR_H
18
19 #if CPPREFERENCE_STDVER>= 2011
20
21 namespace std {
22
23 class error_category {
24 public:
25 error_category(const error_category& other) = delete;
26 #if CPPREFERENCE_STDVER>= 2014
27 constexpr error_category();
28 #endif
29 virtual ~error_category();
30 virtual const char* name() const = 0;
31 virtual std::error_condition default_error_condition(int code) const;
32 virtual bool equivalent(int code,
33 const std::error_condition& condition) const;
34 virtual bool equivalent(const std::error_code& code,
35 int condition) const;
36 virtual std::string message(int condition) const = 0;
37
38 bool operator==(const error_category& rhs) const;
39 bool operator!=(const error_category& rhs) const;
40 bool operator<(const error_category& rhs) const;
41 };
42
43 const std::error_category& generic_category();
44 const std::error_category& system_category();
45
46 class error_condition {
47 public:
48
49 error_condition();
50 error_condition(const error_condition& other);
51 error_condition(int val, const error_category& cat);
52
53 template<class ErrorConditionEnum>
54 error_condition(ErrorConditionEnum e);
55
56 error_condition& operator=(const error_condition& other);
57
58 template<class ErrorConditionEnum>
59 error_condition& operator=(ErrorConditionEnum e);
60
61 void assign(int val, const error_category& cat);
62
63 void clear();
64
65 int value() const;
66
67 const error_category& category() const;
68
69 std::string message() const;
70
71 explicit operator bool() const;
72 };
73
74 bool operator==(const error_condition& lhs, const error_condition& rhs);
75 bool operator==(const error_code& lhs, const error_condition& rhs);
76 bool operator==(const error_condition& lhs, const error_code& rhs);
77 bool operator!=(const error_condition& lhs, const error_condition& rhs);
78 bool operator!=(const error_code& lhs, const error_condition& rhs);
79 bool operator!=(const error_condition& lhs, const error_code& rhs);
80 bool operator<(const error_condition& lhs, const error_condition& rhs);
81
82 enum class errc {
83 address_family_not_supported, // EAFNOSUPPORT
84 address_in_use, // EADDRINUSE
85 address_not_available, // EADDRNOTAVAIL
86 already_connected, // EISCONN
87 argument_list_too_long, // E2BIG
88 argument_out_of_domain, // EDOM
89 bad_address, // EFAULT
90 bad_file_descriptor, // EBADF
91 bad_message, // EBADMSG
92 broken_pipe, // EPIPE
93 connection_aborted, // ECONNABORTED
94 connection_already_in_progress, // EALREADY
95 connection_refused, // ECONNREFUSED
96 connection_reset, // ECONNRESET
97 cross_device_link, // EXDEV
98 destination_address_required, // EDESTADDRREQ
99 device_or_resource_busy, // EBUSY
100 directory_not_empty, // ENOTEMPTY
101 executable_format_error, // ENOEXEC
102 file_exists, // EEXIST
103 file_too_large, // EFBIG
104 filename_too_long, // ENAMETOOLONG
105 function_not_supported, // ENOSYS
106 host_unreachable, // EHOSTUNREACH
107 identifier_removed, // EIDRM
108 illegal_byte_sequence, // EILSEQ
109 inappropriate_io_control_operation, // ENOTTY
110 interrupted, // EINTR
111 invalid_argument, // EINVAL
112 invalid_seek, // ESPIPE
113 io_error, // EIO
114 is_a_directory, // EISDIR
115 message_size, // EMSGSIZE
116 network_down, // ENETDOWN
117 network_reset, // ENETRESET
118 network_unreachable, // ENETUNREACH
119 no_buffer_space, // ENOBUFS
120 no_child_process, // ECHILD
121 no_link, // ENOLINK
122 no_lock_available, // ENOLCK
123 no_message_available, // ENODATA
124 no_message, // ENOMSG
125 no_protocol_option, // ENOPROTOOPT
126 no_space_on_device, // ENOSPC
127 no_stream_resources, // ENOSR
128 no_such_device_or_address, // ENXIO
129 no_such_device, // ENODEV
130 no_such_file_or_directory, // ENOENT
131 no_such_process, // ESRCH
132 not_a_directory, // ENOTDIR
133 not_a_socket, // ENOTSOCK
134 not_a_stream, // ENOSTR
135 not_connected, // ENOTCONN
136 not_enough_memory, // ENOMEM
137 not_supported, // ENOTSUP
138 operation_canceled, // ECANCELED
139 operation_in_progress, // EINPROGRESS
140 operation_not_permitted, // EPERM
141 operation_not_supported, // EOPNOTSUPP
142 operation_would_block, // EWOULDBLOCK
143 owner_dead, // EOWNERDEAD
144 permission_denied, // EACCES
145 protocol_error, // EPROTO
146 protocol_not_supported, // EPROTONOSUPPORT
147 read_only_file_system, // EROFS
148 resource_deadlock_would_occur, // EDEADLK
149 resource_unavailable_try_again, // EAGAIN
150 result_out_of_range, // ERANGE
151 state_not_recoverable, // ENOTRECOVERABLE
152 stream_timeout, // ETIME
153 text_file_busy, // ETXTBSY
154 timed_out, // ETIMEDOUT
155 too_many_files_open_in_system, // ENFILE
156 too_many_files_open, // EMFILE
157 too_many_links, // EMLINK
158 too_many_symbolic_link_levels, // ELOOP
159 value_too_large, // EOVERFLOW
160 wrong_protocol_type, // EPROTOTYPE
161 };
162
163 class error_code {
164 public:
165 error_code();
166 error_code(int ec, const error_category& ecat);
167 template<class ErrorCodeEnum>
168 error_code(ErrorCodeEnum e);
169
170 template<class ErrorCodeEnum>
171 error_code& operator=(ErrorCodeEnum e);
172
173 void assign(int ec, const error_category& ecat);
174 void clear();
175 int value() const;
176
177 const std::error_category& category() const;
178 std::error_condition default_error_condition() const;
179
180 std::string message() const;
181 explicit operator bool() const;
182 };
183
184 bool operator==(const error_code& lhs, const error_code& rhs);
185 bool operator!=(const error_code& lhs, const error_code& rhs);
186 bool operator<(const error_code& lhs, const error_code& rhs);
187
188 template<class CharT, class Traits>
189 std::basic_ostream<CharT, Traits>&
190 operator<<(basic_ostream<CharT, Traits>& os, const error_code& ec);
191
192 class system_error : public runtime_error {
193 public:
194 system_error(std::error_code ec);
195 system_error(std::error_code ec, const std::string& what_arg);
196 system_error(std::error_code ec, const char* what_arg);
197 system_error(int ev, const std::error_category& ecat);
198 system_error(int ev, const std::error_category& ecat,
199 const std::string& what_arg);
200 system_error(int ev, const std::error_category& ecat,
201 const char* what_arg);
202
203 const std::error_code& code() const;
204
205 virtual const char* what() const;
206 };
207
208 template<class T>
209 struct is_error_code_enum : integral_constant<bool, false> {};
210 template<class T>
211 struct is_error_condition_enum : integral_constant<bool, false> {};
212
213 std::error_code make_error_code(std::errc e);
214 std::error_condition make_error_condition(std::errc e);
215
216 } // namespace std
217
218 #endif // CPPREFERENCE_STDVER>= 2011
219
220 #endif // CPPREFERENCE_SYSTEM_ERROR_H