serdeGetKeyOut

  1. template serdeGetKeyOut(alias symbol)
  2. string serdeGetKeyOut(T value)
    @safe pure nothrow @nogc
    string
    serdeGetKeyOut
    (
    T
    )
    (
    const T value
    )
    if (
    is(T == enum)
    )

Return Value

Type: string

output key for the symbol or enum value

Examples

struct S
{
    int f;

    @serdeKeys("D", "t")
    int d;

    @serdeIgnore
    int i;

    @serdeIgnoreIn
    int ii;

    @serdeIgnoreOut
    int io;

    @serdeKeys("P")
    @serdeKeyOut("")
    void p(int) @property {}
}

static assert(serdeGetKeyOut!(S.f) == "f");
static assert(serdeGetKeyOut!(S.d) == "D");
static assert(serdeGetKeyOut!(S.i) is null);
static assert(serdeGetKeyOut!(S.ii) == "ii");
static assert(serdeGetKeyOut!(S.io) is null);
static assert(serdeGetKeyOut!(S.p) !is null);
static assert(serdeGetKeyOut!(S.p) == "");
enum E
{
    @serdeKeys("A", "alpha")
    a,
    @serdeKeys("B", "beta")
    @serdeKeyOut("o")
    b,
    c,
}

static assert (serdeGetKeyOut(E.a) == "A");
static assert (serdeGetKeyOut(E.b) == "o");
static assert (serdeGetKeyOut(E.c) == "c");

Meta