EnumBase

Template mixin to add enum functionality to a class.

Note that the [0..$] which is used in places in this method is a workaround for various weird compiler issues / segfaults.

Constructors

this
this()

Protected constructor, prevents external instantiation. (Use the singleton instance returned by opCall().)

Public Imports

ocean.meta.types.Qualifiers
public import ocean.meta.types.Qualifiers;
Undocumented in source.

Members

Aliases

Name
alias Name = IEnum.Name
Undocumented in source.
Value
alias Value = IEnum.Value
Undocumented in source.

Functions

length
size_t length()
max
Value max()
min
Value min()
opApply
int opApply(int delegate(ref const(Name) name, ref const(Value) value) dg)

foreach iteration over the names and values in the enum.

opApply
int opApply(int delegate(ref size_t i, ref const(Name) name, ref const(Value) value) dg)

foreach iteration over the names and values in the enum and their indices.

opIn_r
Name* opIn_r(Value v)

Looks up an enum member's name from its value.

opIn_r
Value* opIn_r(Name n)

Looks up an enum member's value from its name.

opIndex
Name opIndex(Value v)

Looks up an enum member's name from its value, using opIndex.

opIndex
Value opIndex(Name n)

Looks up an enum member's value from its name, using opIndex.

Static functions

opCall
This opCall()

Static variables

_internal_names
auto _internal_names;
Undocumented in source.
_internal_names
auto _internal_names;
Undocumented in source.
_internal_values
auto _internal_values;
Undocumented in source.
_internal_values
auto _internal_values;
Undocumented in source.
n_to_v
Value[Name] n_to_v;

Internal maps from names <-> values. The maps are filled in the static constructor.

v_to_n
Name[Value] v_to_n;
Undocumented in source.

Parameters

T

tuple: T[0] must be an associative array of type int[char[]] (Note that the template accepts a tuple purely as a workaround for the compiler's inability to handle templates which accept associative array values.)

TODO: adapt to accept *either* an AA or a simple list of names (for an auto-enum with values starting at 0).

Meta