100.00% Lines (5/5) 100.00% Functions (2/2)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 4   // Distributed under the Boost Software License, Version 1.0. (See accompanying
5   // 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)
6   // 6   //
7   // Official repository: https://github.com/boostorg/json 7   // Official repository: https://github.com/boostorg/json
8   // 8   //
9   9  
10   #ifndef BOOST_JSON_IMPL_ERROR_HPP 10   #ifndef BOOST_JSON_IMPL_ERROR_HPP
11   #define BOOST_JSON_IMPL_ERROR_HPP 11   #define BOOST_JSON_IMPL_ERROR_HPP
12   12  
13   #include <boost/system/error_category.hpp> 13   #include <boost/system/error_category.hpp>
14   #include <type_traits> 14   #include <type_traits>
15   15  
16   namespace boost { 16   namespace boost {
17   namespace system { 17   namespace system {
18   template<> 18   template<>
19   struct is_error_code_enum< ::boost::json::error > 19   struct is_error_code_enum< ::boost::json::error >
20   { 20   {
21   static bool const value = true; 21   static bool const value = true;
22   }; 22   };
23   template<> 23   template<>
24   struct is_error_condition_enum< ::boost::json::condition > 24   struct is_error_condition_enum< ::boost::json::condition >
25   { 25   {
26   static bool const value = true; 26   static bool const value = true;
27   }; 27   };
28   } // system 28   } // system
29   } // boost 29   } // boost
30   30  
31   namespace std { 31   namespace std {
32   template<> 32   template<>
33   struct is_error_code_enum< ::boost::json::error > 33   struct is_error_code_enum< ::boost::json::error >
34   { 34   {
35   static bool const value = true; 35   static bool const value = true;
36   }; 36   };
37   template<> 37   template<>
38   struct is_error_condition_enum< ::boost::json::condition > 38   struct is_error_condition_enum< ::boost::json::condition >
39   { 39   {
40   static bool const value = true; 40   static bool const value = true;
41   }; 41   };
42   } // std 42   } // std
43   43  
44   namespace boost { 44   namespace boost {
45   namespace json { 45   namespace json {
46   namespace detail { 46   namespace detail {
47   47  
48   struct error_code_category_t 48   struct error_code_category_t
49   : system::error_category 49   : system::error_category
50   { 50   {
51   constexpr 51   constexpr
52   error_code_category_t() 52   error_code_category_t()
53   : system::error_category(0xB9A9B9922177C772) 53   : system::error_category(0xB9A9B9922177C772)
54   {} 54   {}
55   55  
56   BOOST_JSON_DECL 56   BOOST_JSON_DECL
57   const char* 57   const char*
58   name() const noexcept override; 58   name() const noexcept override;
59   59  
60   BOOST_JSON_DECL 60   BOOST_JSON_DECL
61   char const* 61   char const*
62   message( int ev, char* buf, std::size_t len ) const noexcept override; 62   message( int ev, char* buf, std::size_t len ) const noexcept override;
63   63  
64   BOOST_JSON_DECL 64   BOOST_JSON_DECL
65   std::string 65   std::string
66   message( int ev ) const override; 66   message( int ev ) const override;
67   67  
68   BOOST_JSON_DECL 68   BOOST_JSON_DECL
69   system::error_condition 69   system::error_condition
70   default_error_condition( int ev ) const noexcept override; 70   default_error_condition( int ev ) const noexcept override;
71   }; 71   };
72   72  
73   extern 73   extern
74   BOOST_JSON_DECL 74   BOOST_JSON_DECL
75   error_code_category_t error_code_category; 75   error_code_category_t error_code_category;
76   76  
77   struct error_condition_category_t 77   struct error_condition_category_t
78   : system::error_category 78   : system::error_category
79   { 79   {
80   constexpr 80   constexpr
81   error_condition_category_t() 81   error_condition_category_t()
82   : system::error_category(0x37CEF5A036D24FD1) 82   : system::error_category(0x37CEF5A036D24FD1)
83   {} 83   {}
84   84  
85   BOOST_JSON_DECL 85   BOOST_JSON_DECL
86   const char* 86   const char*
87   name() const noexcept override; 87   name() const noexcept override;
88   88  
89   BOOST_JSON_DECL 89   BOOST_JSON_DECL
90   char const* 90   char const*
91   message( int ev, char*, std::size_t ) const noexcept override; 91   message( int ev, char*, std::size_t ) const noexcept override;
92   92  
93   BOOST_JSON_DECL 93   BOOST_JSON_DECL
94   std::string 94   std::string
95   message( int cv ) const override; 95   message( int cv ) const override;
96   }; 96   };
97   97  
98   extern 98   extern
99   BOOST_JSON_DECL 99   BOOST_JSON_DECL
100   error_condition_category_t error_condition_category; 100   error_condition_category_t error_condition_category;
101   101  
102   } // namespace detail 102   } // namespace detail
103   103  
104   inline 104   inline
105   BOOST_SYSTEM_CONSTEXPR 105   BOOST_SYSTEM_CONSTEXPR
106   system::error_code 106   system::error_code
HITCBC 107   105190 make_error_code(error e) noexcept 107   105190 make_error_code(error e) noexcept
108   { 108   {
109   109  
110   return system::error_code( 110   return system::error_code(
111   static_cast<std::underlying_type<error>::type>(e), 111   static_cast<std::underlying_type<error>::type>(e),
HITCBC 112   105190 detail::error_code_category ); 112   105190 detail::error_code_category );
113   } 113   }
114   114  
115   inline 115   inline
116   BOOST_SYSTEM_CONSTEXPR 116   BOOST_SYSTEM_CONSTEXPR
117   system::error_condition 117   system::error_condition
HITCBC 118   154 make_error_condition(condition c) noexcept 118   154 make_error_condition(condition c) noexcept
119   { 119   {
HITCBC 120   154 return system::error_condition( 120   154 return system::error_condition(
121   static_cast<std::underlying_type<condition>::type>(c), 121   static_cast<std::underlying_type<condition>::type>(c),
HITCBC 122   154 detail::error_condition_category ); 122   154 detail::error_condition_category );
123   } 123   }
124   124  
125   } // namespace json 125   } // namespace json
126   } // namespace boost 126   } // namespace boost
127   127  
128   #endif 128   #endif