co_usb
Loading...
Searching...
No Matches
include
co_usb
error.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <libusb-1.0/libusb.h>
4
#include <system_error>
5
6
namespace
co_usb
7
{
8
9
enum class
usb_error
:
int
10
{
11
success
=
LIBUSB_SUCCESS
,
12
14
io_error
=
LIBUSB_ERROR_IO
,
15
17
invalid_param
=
LIBUSB_ERROR_INVALID_PARAM
,
18
20
access_error
=
LIBUSB_ERROR_ACCESS
,
21
23
no_device
=
LIBUSB_ERROR_NO_DEVICE
,
24
26
not_found
=
LIBUSB_ERROR_NOT_FOUND
,
27
29
resource_busy
=
LIBUSB_ERROR_BUSY
,
30
32
timed_out
=
LIBUSB_ERROR_TIMEOUT
,
33
35
overflow
=
LIBUSB_ERROR_OVERFLOW
,
36
38
broken_pipe
=
LIBUSB_ERROR_PIPE
,
39
41
interrupted
=
LIBUSB_ERROR_INTERRUPTED
,
42
44
out_of_memory
=
LIBUSB_ERROR_NO_MEM
,
45
47
not_supported
=
LIBUSB_ERROR_NOT_SUPPORTED
,
48
49
/* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
50
message strings in strerror.c when adding new error codes here. */
51
53
unknown
=
LIBUSB_ERROR_OTHER
,
54
55
};
56
struct
error_category_t
:
public
std::error_category
57
{
58
const
char
*
name
()
const
noexcept
override
59
{
60
return
"co_usb usb error"
;
61
}
62
63
std::string
message
(
int
v
)
const override
64
{
65
return
libusb_strerror
(
v
);
66
}
67
};
68
69
inline
const
std::error_category &
usb_error_category
()
70
{
71
static
error_category_t
instance
;
72
return
instance
;
73
}
74
75
inline
std::error_code
make_usb_error_code
(
usb_error
e
)
noexcept
76
{
77
return
{
static_cast<
int
>
(
e
),
usb_error_category
()};
78
}
79
80
inline
std::error_code
make_usb_error_code
(
libusb_error
e
)
noexcept
81
{
82
return
{
static_cast<
int
>
(
e
),
usb_error_category
()};
83
}
84
85
}
// namespace co_usb
86
87
namespace
std
88
{
89
90
template
<>
struct
is_error_code_enum<
co_usb
::usb_error> : ::std::true_type
91
{
92
};
93
94
}
// namespace std
co_usb
Definition
context.hpp:14
co_usb::usb_error_category
const std::error_category & usb_error_category()
Definition
error.hpp:69
co_usb::usb_error
usb_error
Definition
error.hpp:10
co_usb::usb_error::overflow
@ overflow
co_usb::usb_error::success
@ success
co_usb::usb_error::broken_pipe
@ broken_pipe
co_usb::usb_error::no_device
@ no_device
co_usb::usb_error::access_error
@ access_error
co_usb::usb_error::timed_out
@ timed_out
co_usb::usb_error::out_of_memory
@ out_of_memory
co_usb::usb_error::not_found
@ not_found
co_usb::usb_error::invalid_param
@ invalid_param
co_usb::usb_error::not_supported
@ not_supported
co_usb::usb_error::unknown
@ unknown
co_usb::usb_error::resource_busy
@ resource_busy
co_usb::usb_error::io_error
@ io_error
co_usb::usb_error::interrupted
@ interrupted
co_usb::make_usb_error_code
std::error_code make_usb_error_code(usb_error e) noexcept
Definition
error.hpp:75
co_usb::use_service
use_service
Definition
context.hpp:17
std
Definition
error.hpp:88
co_usb::error_category_t
Definition
error.hpp:57
co_usb::error_category_t::name
const char * name() const noexcept override
Definition
error.hpp:58
co_usb::error_category_t::message
std::string message(int v) const override
Definition
error.hpp:63
Generated by
1.9.8