Header file generic_code.hpp

#include "status_error.hpp"

namespace system_error2
{
    enum class errc
    : int;

    class _generic_code_domain;

    using generic_error = status_error<system_error2::_generic_code_domain>;

    constexpr system_error2::_generic_code_domain const generic_code_domain;

    static constexpr system_error2::_generic_code_domain const& _generic_code_domain::get();

    constexpr system_error2::generic_code make_status_code(system_error2::errc c) noexcept;

    template <class T>
    bool status_code<void>::equivalent(status_code<T> const& o) const noexcept;

    template <class DomainType1, class DomainType2>
    bool operator==(status_code<DomainType1> const& a, status_code<DomainType2> const& b) noexcept;

    template <class DomainType1, class DomainType2>
    bool operator!=(status_code<DomainType1> const& a, status_code<DomainType2> const& b) noexcept;

    template <class DomainType1>
    bool operator==(status_code<DomainType1> const& a, system_error2::errc b) noexcept;

    template <class DomainType1>
    bool operator==(system_error2::errc a, status_code<DomainType1> const& b) noexcept;

    template <class DomainType1>
    bool operator!=(status_code<DomainType1> const& a, system_error2::errc b) noexcept;

    template <class DomainType1>
    bool operator!=(system_error2::errc a, status_code<DomainType1> const& b) noexcept;
}

Enumeration system_error2::errc

enum class errc
: int
{
    success = 0,
    unknown = -1,
    address_family_not_supported = 97,
    address_in_use = 98,
    address_not_available = 99,
    already_connected = 106,
    argument_list_too_long = 7,
    argument_out_of_domain = 33,
    bad_address = 14,
    bad_file_descriptor = 9,
    bad_message = 74,
    broken_pipe = 32,
    connection_aborted = 103,
    connection_already_in_progress = 114,
    connection_refused = 111,
    connection_reset = 104,
    cross_device_link = 18,
    destination_address_required = 89,
    device_or_resource_busy = 16,
    directory_not_empty = 39,
    executable_format_error = 8,
    file_exists = 17,
    file_too_large = 27,
    filename_too_long = 36,
    function_not_supported = 38,
    host_unreachable = 113,
    identifier_removed = 43,
    illegal_byte_sequence = 84,
    inappropriate_io_control_operation = 25,
    interrupted = 4,
    invalid_argument = 22,
    invalid_seek = 29,
    io_error = 5,
    is_a_directory = 21,
    message_size = 90,
    network_down = 100,
    network_reset = 102,
    network_unreachable = 101,
    no_buffer_space = 105,
    no_child_process = 10,
    no_link = 67,
    no_lock_available = 37,
    no_message = 42,
    no_protocol_option = 92,
    no_space_on_device = 28,
    no_stream_resources = 63,
    no_such_device_or_address = 6,
    no_such_device = 19,
    no_such_file_or_directory = 2,
    no_such_process = 3,
    not_a_directory = 20,
    not_a_socket = 88,
    not_a_stream = 60,
    not_connected = 107,
    not_enough_memory = 12,
    not_supported = 95,
    operation_canceled = 125,
    operation_in_progress = 115,
    operation_not_permitted = 1,
    operation_not_supported = 95,
    operation_would_block = 11,
    owner_dead = 130,
    permission_denied = 13,
    protcol_error = 71,
    protocol_not_supported = 93,
    read_only_file_system = 30,
    resource_deadlock_would_occur = 35,
    resource_unavailable_try_again = 11,
    result_out_of_range = 34,
    state_not_recoverable = 131,
    stream_timeout = 62,
    text_file_busy = 26,
    timed_out = 110,
    too_many_files_open_in_system = 23,
    too_many_files_open = 24,
    too_many_links = 31,
    too_many_symbolic_link_levels = 40,
    value_too_large = 75,
    wrong_protocol_type = 91
};

The generic error coding (POSIX)


Class system_error2::_generic_code_domain

class _generic_code_domain
: public status_code_domain
{
public:
    using value_type = system_error2::errc;

    using string_ref = _base::string_ref;

    constexpr _generic_code_domain(typename _base::unique_id_type id = 0x746d6354f4f733e9) noexcept;

    _generic_code_domain(system_error2::_generic_code_domain const&) = default;

    _generic_code_domain(system_error2::_generic_code_domain&&) = default;

    system_error2::_generic_code_domain& operator=(system_error2::_generic_code_domain const&) = default;

    system_error2::_generic_code_domain& operator=(system_error2::_generic_code_domain&&) = default;

    ~_generic_code_domain() = default;

    static constexpr system_error2::_generic_code_domain const& get();

    virtual _base::string_ref name() const noexcept;

protected:
    virtual bool _do_failure(status_code<void> const& code) const noexcept;

    virtual bool _do_equivalent(status_code<void> const& code1, status_code<void> const& code2) const noexcept;

    virtual system_error2::generic_code _generic_code(status_code<void> const& code) const noexcept;

    virtual _base::string_ref _do_message(status_code<void> const& code) const noexcept;

    virtual void _do_throw_exception(status_code<void> const& code) const;
};

The implementation of the domain for generic status codes, those mapped by errc (POSIX).

Type alias system_error2::_generic_code_domain::value_type

using value_type = system_error2::errc;

The value type of the generic code, which is an errc as per POSIX.


Constructor system_error2::_generic_code_domain::_generic_code_domain

constexpr _generic_code_domain(typename _base::unique_id_type id = 0x746d6354f4f733e9) noexcept;

Default constructor


Function system_error2::_generic_code_domain::get

static constexpr system_error2::_generic_code_domain const& get();

Constexpr singleton getter. Returns the constexpr generic_code_domain variable.



Type alias system_error2::generic_error

using generic_error = status_error<system_error2::_generic_code_domain>;

A specialisation of status_error for the generic code domain.


Variable system_error2::generic_code_domain

constexpr system_error2::_generic_code_domain const generic_code_domain;

A constexpr source variable for the generic code domain, which is that of errc (POSIX). Returned by _generic_code_domain::get().


Function system_error2::operator==

template <class DomainType1, class DomainType2>
bool operator==(status_code<DomainType1> const& a, status_code<DomainType2> const& b) noexcept;

True if the status code’s are semantically equal via equivalent().


Function system_error2::operator!=

template <class DomainType1, class DomainType2>
bool operator!=(status_code<DomainType1> const& a, status_code<DomainType2> const& b) noexcept;

True if the status code’s are not semantically equal via equivalent().


Function system_error2::operator==

template <class DomainType1>
bool operator==(status_code<DomainType1> const& a, system_error2::errc b) noexcept;

True if the status code’s are semantically equal via equivalent() to the generic code.


Function system_error2::operator==

template <class DomainType1>
bool operator==(system_error2::errc a, status_code<DomainType1> const& b) noexcept;

True if the status code’s are semantically equal via equivalent() to the generic code.


Function system_error2::operator!=

template <class DomainType1>
bool operator!=(status_code<DomainType1> const& a, system_error2::errc b) noexcept;

True if the status code’s are not semantically equal via equivalent() to the generic code.


Function system_error2::operator!=

template <class DomainType1>
bool operator!=(system_error2::errc a, status_code<DomainType1> const& b) noexcept;

True if the status code’s are not semantically equal via equivalent() to the generic code.