libsl3
1.1.31001
The convenient C++11 interface for SQLite 3.x
|
This class models the duck typing sqlite uses. It supports int, real, text, blob and null values. More...
#include <sl3/dbvalue.hpp>
Public Member Functions | |
DbValue (Type type) noexcept | |
Constructor. More... | |
DbValue (int val, Type type=Type::Int) | |
Constructor. More... | |
DbValue (int64_t val, Type type=Type::Int) | |
Constructor. More... | |
DbValue (std::string val, Type type=Type::Text) | |
Constructor. More... | |
DbValue (double val, Type type=Type::Real) | |
Constructor. More... | |
DbValue (Blob val, Type type=Type::Blob) | |
Constructor. More... | |
~DbValue () noexcept=default | |
Destructor. More... | |
DbValue (const DbValue &) noexcept=default | |
Copy constructor. More... | |
DbValue (DbValue &&) noexcept=default | |
Move constructor. More... | |
DbValue & | operator= (const DbValue &val) |
Assignment. More... | |
DbValue & | operator= (DbValue &&val) |
Assignment. More... | |
DbValue & | operator= (int val) |
Assignment. More... | |
DbValue & | operator= (const int64_t &val) |
Assignment. More... | |
DbValue & | operator= (const double &val) |
Assignment. More... | |
DbValue & | operator= (const std::string &val) |
Assignment. More... | |
DbValue & | operator= (const char *val) |
Assignment. More... | |
DbValue & | operator= (const Blob &val) |
Assignment. More... | |
DbValue & | operator= (const Value &val) |
Assignment. More... | |
void | set (int val) |
Assignment. More... | |
void | set (int64_t val) |
Assignment. More... | |
void | set (const std::string &val) |
Assignment. More... | |
void | set (double val) |
Assignment. More... | |
void | set (const Blob &val) |
Assignment. More... | |
const Value & | getValue () const noexcept |
Value access. More... | |
const Value & | value () const noexcept |
Value access Just s shorter way tan getValue. More... | |
const int64_t & | getInt () const |
Value access. More... | |
const double & | getReal () const |
Value access. More... | |
const std::string & | getText () const |
Value access. More... | |
const Blob & | getBlob () const |
Value access. More... | |
int64_t | getInt (int64_t defval) const |
Value access with default for a NULL value. More... | |
double | getReal (double defval) const |
Value access with default for a NULL value.; More... | |
std::string | getText (const std::string &defval) const |
Value access with default for a NULL value.; More... | |
Blob | getBlob (const Blob &defval) const |
Value access with default for a NULL value.; More... | |
int64_t | get (int64_t defval) const |
Value access with default for a NULL and different type value. More... | |
int64_t | get (int defval) const |
Value access with default for a NULL and different type value.; More... | |
double | get (double defval) const |
Value access with default for a NULL and different type value.; More... | |
std::string | get (const std::string &defval) const |
Value access with default for a NULL and different type value.; More... | |
Blob | get (const Blob &defval) const |
Value access with default for a NULL and different type value.; More... | |
std::string | ejectText () |
Moves the current value into the return value. More... | |
Blob | ejectBlob () |
Moves the current value into the return value. More... | |
void | setNull () |
Set to NULL. More... | |
bool | isNull () const |
Check Null. More... | |
Type | dbtype () const |
The Type of the value. More... | |
Type | type () const |
Returns the type of the underlying Value. More... | |
bool | canAssign (const DbValue &other) const |
Check if assignment would be OK. More... | |
This class models the duck typing sqlite uses. It supports int, real, text, blob and null values.
The type can be a variant, to support all of the possible types, or it can be set explicit to a wanted type.
Using this type for communication with the database can ensure either type guarantee or give the flexibility of variant types.
If a type is of type variant, the storage type can be any of the supported types, otherwise, if the type is set to a specific type, it is guaranteed that the type will match, or an exception occurs.
|
noexcept |
Constructor.
Constructs a type and the value is null.
type | wanted storage type If Type::Null is given, the type will be a variant. |
Constructor.
This constructor takes a initialization value, and optionally a type which can only be Type::Variant or the default one.
sl3::ErrTypeMisMatch | if given type is incompatible |
val | initial value |
type | wanted type, default set to type but can be set to DbValue::Variant if waned |
Constructor.
This constructor takes a initialization value, and optionally a type which can only be Type::Variant or the default one.
sl3::ErrTypeMisMatch | if given type is incompatible |
val | initial value |
type | wanted type, default set to type but can be set to DbValue::Variant if waned |
|
explicit |
Constructor.
This constructor takes a initialization value, and optionally a type which can only be Type::Variant or the default one.
sl3::ErrTypeMisMatch | if given type is incompatible |
val | initial value |
type | wanted type, default set to type but can be set to DbValue::Variant if waned |
|
explicit |
Constructor.
This constructor takes a initialization value, and optionally a type which can only be Type::Variant or the default one.
sl3::ErrTypeMisMatch | if given type is incompatible |
val | initial value |
type | wanted type, default set to type but can be set to DbValue::Variant if waned |
|
explicit |
Constructor.
This constructor takes a initialization value, and optionally a type which can only be Type::Variant or the default one.
sl3::ErrTypeMisMatch | if given type is incompatible |
val | initial value |
type | wanted type, default set to type but can be set to DbValue::Variant if waned |
|
defaultnoexcept |
Destructor.
|
defaultnoexcept |
Copy constructor.
|
defaultnoexcept |
Move constructor.
bool sl3::DbValue::canAssign | ( | const DbValue & | other | ) | const |
Check if assignment would be OK.
If this function return true, the other value can be assign because it is type compatible.
other | value to check |
Type sl3::DbValue::dbtype | ( | ) | const |
Blob sl3::DbValue::ejectBlob | ( | ) |
Moves the current value into the return value.
After calling this function the value will be Null.
sl3::ErrTypeMisMatch | in case of wrong type. |
std::string sl3::DbValue::ejectText | ( | ) |
Moves the current value into the return value.
After calling this function the value will be Null.
sl3::ErrTypeMisMatch | in case of wrong type. |
Value access with default for a NULL and different type value.;
This method will not throw. If the actual value is null or of a different type, the fiven default value will be returned.
defval | default value to return |
std::string sl3::DbValue::get | ( | const std::string & | defval | ) | const |
Value access with default for a NULL and different type value.;
This method will not throw. If the actual value is null or of a different type, the fiven default value will be returned.
defval | default value to return |
double sl3::DbValue::get | ( | double | defval | ) | const |
Value access with default for a NULL and different type value.;
This method will not throw. If the actual value is null or of a different type, the fiven default value will be returned.
defval | default value to return |
int64_t sl3::DbValue::get | ( | int | defval | ) | const |
Value access with default for a NULL and different type value.;
This method will not throw. If the actual value is null or of a different type, the fiven default value will be returned.
defval | default value to return |
int64_t sl3::DbValue::get | ( | int64_t | defval | ) | const |
Value access with default for a NULL and different type value.
This method will not throw. If the actual value is null or of a different type, the fiven default value will be returned.
defval | default value to return |
const Blob& sl3::DbValue::getBlob | ( | ) | const |
Value access.
sl3::ErrNullValueAccess | if value is null. |
sl3::ErrTypeMisMatch | if getType is incorrect |
Value access with default for a NULL value.;
sl3::ErrTypeMisMatch | if getType is incorrect |
defval | default value to return if value is NULL |
const int64_t& sl3::DbValue::getInt | ( | ) | const |
Value access.
sl3::ErrNullValueAccess | if value is null. |
sl3::ErrTypeMisMatch | if getType is incorrect |
int64_t sl3::DbValue::getInt | ( | int64_t | defval | ) | const |
Value access with default for a NULL value.
sl3::ErrTypeMisMatch | if getType is incorrect |
defval | default value to return if value is NULL |
const double& sl3::DbValue::getReal | ( | ) | const |
Value access.
sl3::ErrNullValueAccess | if value is null. |
sl3::ErrTypeMisMatch | if getType is incorrect |
double sl3::DbValue::getReal | ( | double | defval | ) | const |
Value access with default for a NULL value.;
sl3::ErrTypeMisMatch | if getType is incorrect |
defval | default value to return if value is NULL |
const std::string& sl3::DbValue::getText | ( | ) | const |
Value access.
sl3::ErrNullValueAccess | if value is null. |
sl3::ErrTypeMisMatch | if getType is incorrect |
std::string sl3::DbValue::getText | ( | const std::string & | defval | ) | const |
Value access with default for a NULL value.;
sl3::ErrTypeMisMatch | if getType is incorrect |
defval | default value to return if value is NULL |
|
noexcept |
bool sl3::DbValue::isNull | ( | ) | const |
Check Null.
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
|
inline |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
DbValue& sl3::DbValue::operator= | ( | const double & | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
DbValue& sl3::DbValue::operator= | ( | const int64_t & | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
DbValue& sl3::DbValue::operator= | ( | const std::string & | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
DbValue& sl3::DbValue::operator= | ( | int | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::set | ( | const Blob & | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::set | ( | const std::string & | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::set | ( | double | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::set | ( | int | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::set | ( | int64_t | val | ) |
Assignment.
sl3::ErrTypeMisMatch | if getType is incompatible |
val | new value |
void sl3::DbValue::setNull | ( | ) |
Set to NULL.
Type sl3::DbValue::type | ( | ) | const |
Returns the type of the underlying Value.
If getType() is a Variant this property returns the actual type information, otherwise it will be the same as type or null.
|
inlinenoexcept |