DelegateFormatter

A delegate formatter allows a delegate to behave as format function. A common use case for this would be to have multiple ways to format a class.

Members

Functions

toString
void toString(StringSink sink)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

formatter
void delegate(StringSink sink) formatter;
Undocumented in source.

Examples

class Foo
{
    DelegateFormatter formatPretty() { return DelegateFormatter(&prettyFormatter); }
    private void prettyFormatter(StringSink sink)
    {
        sink("the pretty format");
    }

    DelegateFormatter formatUgly() { return DelegateFormatter(&uglyFormatter); }
    private void uglyFormatter(StringSink sink)
    {
        sink("the ugly format");
    }
}
Foo foo;
writefln("foo pretty = %s", foo.formatPretty());
writefln("foo ugly   = %s", foo.formatUgly());

Meta