nogcFormatTo

Formats values to with fmt template into provided sink. Note: it supports only a basic subset of format type specifiers, main usage is for nogc logging and error messages formatting. But more cases can be added as needed.

WARN: %s accepts pointer to some char assuming it's a zero terminated string

size_t
nogcFormatTo
(
string fmt = "%s"
S
ARGS...
)
(
ref S sink
,
auto ref ARGS args
)

Parameters

fmt

The format string, much like in std.format

sink S

The sink where the full string should be written to, see section "Sink Types"

args ARGS

The arguments to fill the format string with

Return Value

Type: size_t

the length of the formatted string.

Examples

char[100] buf;
ubyte[3] data = [1, 2, 3];
immutable ret = nogcFormatTo!"hello %s %s %% world %d %x %p"(buf, data, "moshe", -567, 7, 7);
assert(ret == 53);
assert(buf[0..53] == "hello [1, 2, 3] moshe % world -567 7 0000000000000007");

Meta