parseToken

Undocumented in source. Be warned that the author may not have intended to support it.
nothrow @nogc pure
int
parseToken
(
string ranges
alias next
string sseRanges = null
C
)
(
const(C)[] buffer
,
ref size_t i
)
if (
is(C == ubyte) ||
is(C == char)
)

Examples

size_t idx;
string buf = "foo\nbar";
auto ret = parseToken!("\0\037\177\377", "\r\n")(buf, idx);
assert(ret == 0); // no error
assert(idx == 3); // index of newline character

idx = 0;
ret = parseToken!("\0\037\177\377", "\r\n")(buf[0..3], idx);
assert(ret == -1); // not enough data to find next character
assert(idx == 3);

idx = 0;
buf = "foo\t\nbar";
ret = parseToken!("\0\037\177\377", "\r\n")(buf, idx);
assert(ret == -2); // invalid character '\t' found in token
assert(idx == 3); // invalid character on index 3

Meta