Wt
4.11.1
|
Traits class for value types. More...
#include <Wt/Dbo/SqlTraits.h>
Static Public Member Functions | |
static const char * | type (SqlConnection *connection, int size) |
Returns the SQL type name. | |
static void | bind (const V &v, SqlStatement *statement, int index, int size) |
Binds a value to a statement parameter. | |
static bool | read (V &v, SqlStatement *statement, int column, int size) |
Reads a result from an executed query. |
Traits class for value types.
This traits class may be specialized for a custom type V
, to add dbo support for custom types. A value type has a one-to-one mapping to a single database column.
The library has built-in support for:
In <Wt/Dbo/WtSqlTraits.h>, traits classes are also provided for:
Example for an enum that is saved as a string rather than an int:
|
static |
Binds a value to a statement parameter.
The value v
must be bound to parameter with index index
in the statement
.
|
static |
Reads a result from an executed query.
The value v
must be read from result column column
in the statement
.
Returns true
if the value was not null
. This result may be used by the boost::optional<V> specialization to support fields that may have null
values.
|
static |
Returns the SQL type name.
The size
(for strings) is a hint and may be ignored by a back-end.
This will usually return a type ending with " not null" except for C++ types that support null
values. For a normal c++ value type T
, boost::optional<T> has been specialized to allow for null
values.