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>
149 operator= (const
char* val)
151 return *
this = std::string{val};
181 void set (
const std::string& val);
247 std::string
getText (
const std::string& defval)
const;
263 int64_t
get (int64_t defval)
const;
268 int64_t
get (
int defval)
const;
273 double get (
double defval)
const;
278 std::string
get (
const std::string& defval)
const;
359 friend class DbValues;
361 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
const Value & value() const noexcept
Value access Just a shorter way than getValue.
Definition dbvalue.hpp:204
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.
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
std::vector< std::byte > Blob
Definition types.hpp:90
Type
Definition types.hpp:30
@ Int
Int value.
Definition types.hpp:32
@ Real
Real value.
Definition types.hpp:33
@ Text
Text value.
Definition types.hpp:34
@ Blob
Blob value.
Definition types.hpp:35
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