| Home | Libraries | People | FAQ | More

##### row_view::reference

The reference type.

###### Synopsis

    using reference = field_view;

###### Member Functions

Name | Description
--- | ---
as_blob | Retrieves the underlying value as a blob or throws an exception.
as_date | Retrieves the underlying value as a `date` or throws an exception.
as_datetime | Retrieves the underlying value as a `datetime` or throws an exception.
as_double | Retrieves the underlying value as a `double` or throws an exception.
as_float | Retrieves the underlying value as a `float` or throws an exception.
as_int64 | Retrieves the underlying value as an `int64` or throws an exception.
as_string | Retrieves the underlying value as a string or throws an exception.
as_time | Retrieves the underlying value as a `time` or throws an exception.
as_uint64 | Retrieves the underlying value as an `uint64` or throws an exception.

field_view

Constructs a `field_view` holding NULL.
—
Constructs a `field_view` holding an `int64`.
—
Constructs a `field_view` holding an `int64`.
—
Constructs a `field_view` holding a `uint64`.
—
Constructs a `field_view` holding a `uint64`.
—
Constructors from character types would incorrectly construct a `field_view` holding an integer, so they are not allowed.
—
Constructors from character types would incorrectly construct a `field_view` holding an integer, so they are not allowed.
—
Constructs a `field_view` holding a string.
—
Constructs a `field_view` holding a blob.
—
Constructs a `field_view` holding a `float`.
—
Constructs a `field_view` holding a `double`.
—
Constructs a `field_view` holding a `date`.
—
Constructs a `field_view` holding a `datetime`.
—
Constructs a `field_view` holding a `time`.

get_blob | Retrieves the underlying value as a blob (unchecked access).
get_date | Retrieves the underlying value as a `date` (unchecked access).
get_datetime | Retrieves the underlying value as a `datetime` (unchecked access).
get_double | Retrieves the underlying value as a `double` (unchecked access).
get_float | Retrieves the underlying value as a `float` (unchecked access).
get_int64 | Retrieves the underlying value as an `int64` (unchecked access).
get_string | Retrieves the underlying value as a string (unchecked access).
get_time | Retrieves the underlying value as a `time` (unchecked access).
get_uint64 | Retrieves the underlying value as an `uint64` (unchecked access).
is_blob | Returns whether this `field_view` points to a binary blob.
is_date | Returns whether this `field_view` points to a `date` value.
is_datetime | Returns whether this `field_view` points to a `datetime` value.
is_double | Returns whether this `field_view` points to a `double` value.
is_float | Returns whether this `field_view` points to a `float` value.
is_int64 | Returns whether this `field_view` points to a `int64` value.
is_null | Returns whether this `field_view` points to a `NULL` value.
is_string | Returns whether this `field_view` points to a string value.
is_time | Returns whether this `field_view` points to a `time` value.
is_uint64 | Returns whether this `field_view` points to a `uint64` value.
kind | Returns the type of the value this `field_view` is pointing to.
operator== | Tests for equality.
operator!= | Tests for inequality.

###### Related Functions

Name | Description
--- | ---
operator<< | Streams a `field_view`.

This is a variant-like class, similar to `field`, but semi-owning and read-only. Values of this type are usually created by the library, not directly by the user. It's cheap to construct and copy, and it's the main library interface when reading values from MySQL.

Like a variant, at any point, a `field_view` always points to a value of certain type. You can query the type using `field_view::kind` and the `is_xxx` functions like `field_view::is_int64`. Use `as_xxx` and `get_xxx` for checked and unchecked value access, respectively. As opposed to `field`, these functions return values instead of references.

###### Object lifetimes

Depending on how it was constructed, `field_view` can have value or reference semantics:

- If it was created by the library, the `field_view` will have an associated `row`, `rows` or `results` object holding memory to which the `field_view` points. It will be valid as long as the memory allocated by that object is valid.
- If it was created from a `field` (by calling `operator field_view`), the `field_view` acts as a reference to that `field` object, and will be valid as long as the `field` is.
- If it was created from a scalar (null, integral, floating point, date, datetime or time), the `field_view` has value semnatics and will always be valid.
- If it was created from a string or blob type, the `field_view` acts as a `string_view` or `blob_view`, and will be valid as long as the original string/blob is.

Calling any member function on a `field_view` that has been invalidated results in undefined behavior.