fromCsv

fnCsvResult!T fromCsv(T)(FieldView f) @safe nothrow @nogc

Convert a FieldView to the requested type T lazily, without allocations.

Supported targets:

  • Integral types (e.g., int, long, ubyte, ...)
  • Floating point types (float, double, real) — decimal with optional exponent
  • bool — accepts true/false (case-insensitive) and 1/0
  • enum types — by name (exact, case-sensitive) or by numeric value of the base type

On success returns CsvResult!T with isOk == true. On failure returns CsvResult!T with err.code == CsvErrorCode.INVALID_CONVERSION.

Examples

import ddn.data.csv;
FieldView a; a.data = "42";
auto ia = fromCsv!int(a);
assert(ia.isOk && ia.value == 42);

FieldView b; b.data = "3.14";
auto db = fromCsv!double(b);
assert(db.isOk && db.value > 3.0 && db.value < 3.2);

FieldView c; c.data = "TRUE";
auto bc = fromCsv!bool(c);
assert(bc.isOk && bc.value);