Data Defined Status Domain#

#include <dplx/cncr/data_defined_status_domain.hpp>
namespace dplx::cncr {}

This module allows “generating” a status_code_domain (see the status-code GitHub project) for a return code enumeration. In order to generate a status_code_domain one needs to specialize status_enum_definition with the enumeration type, like so:

enum class test_errc
{
    success = 0,
    perm = 3,
    other_success = 5,
    not_implemented = 7,
};

template <>
struct dplx::cncr::status_enum_definition<test_errc>
    : status_enum_definition_defaults<test_errc>
{
    static constexpr char domain_id[]
            = "{09E0ECBF-A737-454D-8633-17E733CDE15F}";
    static constexpr char domain_name[] = "test-domain";

    static constexpr value_descriptor values[] = {
            {        code::success,           generic_errc::success,       "yay!"},
            {           code::perm, generic_errc::permission_denied,      "oh no"},
            {  code::other_success,           generic_errc::success,     "oh kay"},
            {code::not_implemented,           generic_errc::unknown, "till later"},
    };
}
template<typename Enum>
concept status_enum#

Notation

using definition = status_enum_definition<Enum>#

The specialization containing the domain name, id and value descriptions.

Valid Expressions

template<typename Enum>
struct status_enum_value_descriptor#

A data first descriptor tuple which consists of a description and an equivalent code for a value.

Enum value#

The value to be described.

::system_error2::errc equivalent#

The generic code equivalent to value.

The ::system_error2::errc::success and ::system_error2::errc::unknown values indicate that value is not an error or no equivalent generic code exists respectively.

std::string_view description#

A string describing the situation indicated by value.

template<typename Enum>
struct status_enum_definition_defaults#

A CRTP base class for status_enum_definition specializiations which introduces a few type aliases allowing for terser definitions.

using code = Enum#

The enumeration type the status code is generated for.

using generic_errc = ::system_error2::errc#

The generic error enumeration from the status-code library.

using value_descriptor = status_enum_value_descriptor<Enum>#

The value descriptor type for Enum.

template<status_enum Enum>
inline constexpr data_defined_status_domain_type<Enum> data_defined_status_domain#

The default status domain instance for data defined status enumerations. There shouldn’t be any need to reference it directly.

template<status_enum Enum>
class data_defined_status_domain_type : public SYSTEM_ERROR2_NAMESPACE::status_code_domain#

The domain type template which implements a status domain based on the status_enum_definition<Enum>.

See also

The base class documentation.

template<status_enum Enum>
struct status_enum_definition#

This template serves as the main customization point. There exists no main definition. See the example given at the top for a specialization example.