9#ifndef SL3_DBVALUE_HPP_
10#define SL3_DBVALUE_HPP_
14#include <sl3/config.hpp>
15#include <sl3/error.hpp>
16#include <sl3/types.hpp>
17#include <sl3/value.hpp>
148 operator= (const
char* val)
150 return *
this = std::string{val};
180 void set (
const std::string& val);
202 value () const noexcept
245 std::string
getText (
const std::string& defval)
const;
261 int64_t
get (int64_t defval)
const;
266 int64_t
get (
int defval)
const;
271 double get (
double defval)
const;
276 std::string
get (
const std::string& defval)
const;
357 void assign (
const DbValue& other);
This class models the duck typing sqlite uses. It supports int, real, text, blob and null values.
Definition: dbvalue.hpp:43
void set(int val)
Assignment.
const Blob & getBlob() const
Value access.
const double & getReal() const
Value access.
void setNull()
Set to NULL.
DbValue(std::string val, Type type=Type::Text)
Constructor.
const Value & getValue() const noexcept
Value access.
void set(int64_t val)
Assignment.
std::string get(const std::string &defval) const
Value access with default for a NULL and different type value. ;
int64_t getInt(int64_t defval) const
Value access with default for a NULL value.
int64_t get(int64_t defval) const
Value access with default for a NULL and different type value.
DbValue(Type type) noexcept
Constructor.
int64_t get(int defval) const
Value access with default for a NULL and different type value. ;
double getReal(double defval) const
Value access with default for a NULL value. ;
void set(const Blob &val)
Assignment.
bool isNull() const
Check Null.
DbValue(Blob val, Type type=Type::Blob)
Constructor.
Blob get(const Blob &defval) const
Value access with default for a NULL and different type value. ;
Type dbtype() const
The Type of the value.
DbValue(double val, Type type=Type::Real)
Constructor.
void set(double val)
Assignment.
std::string getText(const std::string &defval) const
Value access with default for a NULL value. ;
double get(double defval) const
Value access with default for a NULL and different type value. ;
const std::string & getText() const
Value access.
Blob getBlob(const Blob &defval) const
Value access with default for a NULL value. ;
Type type() const
Returns the type of the underlying Value.
~DbValue() noexcept=default
Destructor.
void set(const std::string &val)
Assignment.
friend void swap(DbValue &a, DbValue &b) noexcept
Swap 2 DbValues.
std::string ejectText()
Moves the current value into the return value.
const int64_t & getInt() const
Value access.
Blob ejectBlob()
Moves the current value into the return value.
bool canAssign(const DbValue &other) const
Check if assignment would be OK.
DbValue(int val, Type type=Type::Int)
Constructor.
DbValue(int64_t val, Type type=Type::Int)
Constructor.
A row of DbValues.
Definition: dbvalues.hpp:30
This class models the duck typing sqlite uses. It supports int, real, text, blob and null values.
Definition: value.hpp:32
Namespace of libSL3.
Definition: columns.hpp:18
bool dbval_lt(const DbValue &a, const DbValue &b) noexcept
less than, ignoring type info
Type
Definition: types.hpp:30
LIBSL3_API std::ostream & operator<<(std::ostream &stm, const sl3::DbValue &v)
Stream op for a DbValue.
bool dbval_eq(const DbValue &a, const DbValue &b) noexcept
equality, ignoring type info
bool dbval_type_lt(const DbValue &a, const DbValue &b) noexcept
less than, including type info
bool dbval_type_eq(const DbValue &a, const DbValue &b) noexcept
equality, including type info
std::vector< std::byte > Blob
Definition: types.hpp:126