100.00% Lines (12/12) 100.00% Functions (2/2)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2 - // Copyright (c) 2026 Michael Vandeberg  
3   // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
4   // 3   //
5   // Distributed under the Boost Software License, Version 1.0. (See accompanying 4   // Distributed under the Boost Software License, Version 1.0. (See accompanying
6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7   // 6   //
8   // Official repository: https://github.com/cppalliance/capy 7   // Official repository: https://github.com/cppalliance/capy
9   // 8   //
10   9  
11 - #include <boost/capy/cond.hpp>  
12   #include <boost/capy/error.hpp> 10   #include <boost/capy/error.hpp>
13   11  
14   namespace boost { 12   namespace boost {
15   namespace capy { 13   namespace capy {
16   14  
17   namespace detail { 15   namespace detail {
18   16  
19   const char* 17   const char*
HITCBC 20   2 error_cat_type:: 18   2 error_cat_type::
21   name() const noexcept 19   name() const noexcept
22   { 20   {
HITCBC 23   2 return "boost.capy"; 21   2 return "boost.capy";
24   } 22   }
25   23  
26   std::string 24   std::string
HITCBC 27   1037 error_cat_type:: 25   1037 error_cat_type::
28   message(int code) const 26   message(int code) const
29   { 27   {
HITCBC 30   1037 switch(static_cast<error>(code)) 28   1037 switch(static_cast<error>(code))
31   { 29   {
HITCBC 32   6 case error::eof: return "eof"; 30   6 case error::eof: return "eof";
HITCBC 33   3 case error::canceled: return "operation canceled"; 31   3 case error::canceled: return "operation canceled";
HITCBC 34   3090 case error::test_failure: return "test failure"; 32   3090 case error::test_failure: return "test failure";
HITCBC 35   3 case error::stream_truncated: return "stream truncated"; 33   3 case error::stream_truncated: return "stream truncated";
HITCBC 36   3 case error::not_found: return "not found"; 34   3 case error::not_found: return "not found";
HITCBC 37   3 case error::timeout: return "timeout"; 35   3 case error::timeout: return "timeout";
HITCBC 38   1 default: 36   1 default:
DCB 39 - 2 }  
40 - }  
41 -  
42 - // Map each capy error code to its canonical portable condition.  
43 - // canceled and timeout have standard equivalents, so they map to the  
44 - // generic conditions rather than capy's own cond enumerators; this is  
45 - // what lets, e.g., error::canceled compare equal to  
46 - // std::errc::operation_canceled.  
47 - std::error_condition  
48 - error_cat_type::  
DCB 49 - 547 default_error_condition(int code) const noexcept  
50 - {  
51 - switch(static_cast<error>(code))  
DCB 52 - 547 {  
53 - case error::eof: return make_error_condition(cond::eof);  
DCB 54 - 302 case error::canceled: return std::make_error_condition(std::errc::operation_canceled);  
DCB 55 - 4 case error::stream_truncated: return make_error_condition(cond::stream_truncated);  
DCB 56 - 1 case error::not_found: return make_error_condition(cond::not_found);  
DCB 57 - 12 case error::timeout: return std::make_error_condition(std::errc::timed_out);  
DCB 58 - 7 default: return std::error_condition(code, *this);  
HITCBC 59   221 return "unknown"; 37   2 return "unknown";
60   } 38   }
61   } 39   }
62   40  
63   //----------------------------------------------- 41   //-----------------------------------------------
64   42  
65   // msvc 14.0 has a bug that warns about inability 43   // msvc 14.0 has a bug that warns about inability
66   // to use constexpr construction here, even though 44   // to use constexpr construction here, even though
67   // there's no constexpr construction 45   // there's no constexpr construction
68   #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) 46   #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900)
69   BOOST_CAPY_MSVC_WARNING_PUSH 47   BOOST_CAPY_MSVC_WARNING_PUSH
70   BOOST_CAPY_MSVC_WARNING_DISABLE(4592) 48   BOOST_CAPY_MSVC_WARNING_DISABLE(4592)
71   #endif 49   #endif
72   50  
73   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L 51   #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
74   constinit error_cat_type error_cat; 52   constinit error_cat_type error_cat;
75   #else 53   #else
76   error_cat_type error_cat; 54   error_cat_type error_cat;
77   #endif 55   #endif
78   56  
79   #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) 57   #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900)
80   BOOST_CAPY_MSVC_WARNING_POP 58   BOOST_CAPY_MSVC_WARNING_POP
81   #endif 59   #endif
82   60  
83   } // detail 61   } // detail
84   62  
85   } // capy 63   } // capy
86   } // boost 64   } // boost