|
| 1 | +// -*- C++ -*- |
| 2 | +//===----------------------------------------------------------------------===// |
| 3 | +// |
| 4 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | +// See https://llvm.org/LICENSE.txt for license information. |
| 6 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | +// |
| 8 | +//===----------------------------------------------------------------------===// |
| 9 | + |
| 10 | +#ifndef _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H |
| 11 | +#define _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H |
| 12 | + |
| 13 | +#include <__compare/ordering.h> |
| 14 | +#include <__config> |
| 15 | +#include <string> |
| 16 | + |
| 17 | +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | +# pragma GCC system_header |
| 19 | +#endif |
| 20 | + |
| 21 | +_LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | + |
| 23 | +class _LIBCPP_TYPE_VIS error_condition; |
| 24 | +class _LIBCPP_TYPE_VIS error_code; |
| 25 | + |
| 26 | +class _LIBCPP_HIDDEN __do_message; |
| 27 | + |
| 28 | +class _LIBCPP_TYPE_VIS error_category |
| 29 | +{ |
| 30 | +public: |
| 31 | + virtual ~error_category() _NOEXCEPT; |
| 32 | + |
| 33 | +#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) |
| 34 | + error_category() noexcept; |
| 35 | +#else |
| 36 | + _LIBCPP_INLINE_VISIBILITY |
| 37 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default; |
| 38 | +#endif |
| 39 | + error_category(const error_category&) = delete; |
| 40 | + error_category& operator=(const error_category&) = delete; |
| 41 | + |
| 42 | + virtual const char* name() const _NOEXCEPT = 0; |
| 43 | + virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; |
| 44 | + virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; |
| 45 | + virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT; |
| 46 | + virtual string message(int __ev) const = 0; |
| 47 | + |
| 48 | + _LIBCPP_INLINE_VISIBILITY |
| 49 | + bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;} |
| 50 | + |
| 51 | +#if _LIBCPP_STD_VER >= 20 |
| 52 | + |
| 53 | + _LIBCPP_HIDE_FROM_ABI |
| 54 | + strong_ordering operator<=>(const error_category& __rhs) const noexcept {return compare_three_way()(this, std::addressof(__rhs));} |
| 55 | + |
| 56 | +#else // _LIBCPP_STD_VER >= 20 |
| 57 | + |
| 58 | + _LIBCPP_INLINE_VISIBILITY |
| 59 | + bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);} |
| 60 | + |
| 61 | + _LIBCPP_INLINE_VISIBILITY |
| 62 | + bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;} |
| 63 | + |
| 64 | +#endif // _LIBCPP_STD_VER >= 20 |
| 65 | + |
| 66 | + friend class _LIBCPP_HIDDEN __do_message; |
| 67 | +}; |
| 68 | + |
| 69 | +class _LIBCPP_HIDDEN __do_message |
| 70 | + : public error_category |
| 71 | +{ |
| 72 | +public: |
| 73 | + string message(int __ev) const override; |
| 74 | +}; |
| 75 | + |
| 76 | +_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; |
| 77 | +_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; |
| 78 | + |
| 79 | +_LIBCPP_END_NAMESPACE_STD |
| 80 | + |
| 81 | +#endif // _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H |
0 commit comments