-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcond.cpp
More file actions
97 lines (80 loc) · 2.08 KB
/
cond.cpp
File metadata and controls
97 lines (80 loc) · 2.08 KB
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
//
// Copyright (c) 2025 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/cppalliance/capy
//
#include <boost/capy/cond.hpp>
#include <boost/capy/error.hpp>
#include <system_error>
namespace boost {
namespace capy {
namespace detail {
const char*
cond_cat_type::
name() const noexcept
{
return "boost.capy";
}
std::string
cond_cat_type::
message(int code) const
{
switch(static_cast<cond>(code))
{
case cond::eof: return "end of file";
case cond::canceled: return "operation canceled";
case cond::stream_truncated: return "stream truncated";
case cond::not_found: return "not found";
case cond::timeout: return "operation timed out";
default:
return "unknown";
}
}
bool
cond_cat_type::
equivalent(
std::error_code const& ec,
int condition) const noexcept
{
switch(static_cast<cond>(condition))
{
case cond::eof:
return ec == capy::error::eof;
case cond::canceled:
if(ec == capy::error::canceled)
return true;
if(ec == std::errc::operation_canceled)
return true;
return false;
case cond::stream_truncated:
return ec == capy::error::stream_truncated;
case cond::not_found:
return ec == capy::error::not_found;
case cond::timeout:
return ec == capy::error::timeout;
default:
return false;
}
}
//-----------------------------------------------
// msvc 14.0 has a bug that warns about inability
// to use constexpr construction here, even though
// there's no constexpr construction
#if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900)
BOOST_CAPY_MSVC_WARNING_PUSH
BOOST_CAPY_MSVC_WARNING_DISABLE(4592)
#endif
#if defined(__cpp_constinit) && __cpp_constinit >= 201907L
constinit cond_cat_type cond_cat;
#else
cond_cat_type cond_cat;
#endif
#if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900)
BOOST_CAPY_MSVC_WARNING_POP
#endif
} // detail
} // capy
} // boost