Function Row.peek
Returns the data of a column directly.
T peek(T)
(
size_t index
)
if (isBoolean!T || isIntegral!T || isSomeChar!T);
T peek(T)
(
size_t index
)
if (isFloatingPoint!T);
T peek(T, PeekMode mode = PeekMode .copy)
(
size_t index
)
if (isSomeString!T);
T peek(T, PeekMode mode = PeekMode .copy)
(
size_t index
)
if (isArray!T && !isSomeString!T);
T peek(T)
(
size_t index
)
if (isInstanceOf!(Nullable, T) && !isArray!(TemplateArgsOf!T[0]) && !isSomeString!(TemplateArgsOf!T[0]));
T peek(T, PeekMode mode = PeekMode .copy)
(
size_t index
)
if (isInstanceOf!(Nullable, T) && (isArray!(TemplateArgsOf!T[0]) || isSomeString!(TemplateArgsOf!T[0])));
T peek(T)
(
string columnName
);
Contrary to opIndex
, the peek
functions return the data directly, automatically cast to T,
without the overhead of using a wrapping type (ColumnData
).
When using peek
to retrieve an array or a string, you can use either:
Parameters
Name | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
T | The type of the returned data. T must be a boolean, a built-in numeric type, a
string, an array or a Nullable .
| ||||||||||||
index | The index of the column in the prepared statement or the name of the column, as specified in the prepared statement with an AS clause. The index of the first column is 0. |
Returns
A value of type T. The returned value results from SQLite's own conversion rules:
see http://www.sqlite.org/c3ref/column_blob.html and
http://www.sqlite.org/lang_expr.html#castexpr. It's then converted
to T using std
.
Warnings
When using PeekMode
, the data of the slice will be invalidated
when the next row is accessed. A copy of the data has to be made somehow for it to
outlive the next step on the same statement.
When using referring to the column by name, the names of all the columns are tested each time this function is called: use numeric indexing for better performance.