libsl3  1.12.2
C++ interface for sqlite3
Classes | Public Member Functions | Friends | List of all members
sl3::Value Class Reference

This class models the duck typing sqlite uses. It supports int, real, text, blob and null values. More...

#include <sl3/value.hpp>

Public Member Functions

 Value () noexcept
 Constructor. More...
 
 Value (int val) noexcept
 Constructor. More...
 
 Value (int64_t val) noexcept
 Constructor. More...
 
 Value (std::string val) noexcept
 Constructor. More...
 
 Value (const char *val)
 Constructor. More...
 
 Value (double val) noexcept
 Constructor. More...
 
 Value (Blob val) noexcept
 Constructor. More...
 
 ~Value () noexcept
 Destructor. More...
 
 Value (const Value &) noexcept
 Copy constructor. More...
 
 Value (Value &&) noexcept
 Move constructor. More...
 
Valueoperator= (const Value &val)
 Assignment. More...
 
Valueoperator= (Value &&val)
 Assignment. More...
 
Valueoperator= (int val)
 Assignment. More...
 
Valueoperator= (const int64_t &val)
 Assignment. More...
 
Valueoperator= (const double &val)
 Assignment. More...
 
Valueoperator= (const std::string &val)
 Assignment. More...
 
Valueoperator= (const Blob &val)
 Assignment. More...
 
 operator int () const
 Implicit conversion operator. More...
 
 operator int64_t () const
 Implicit conversion operator. More...
 
 operator double () const
 Implicit conversion operator. More...
 
 operator const std::string & () const
 Implicit conversion operator. More...
 
 operator const Blob & () const
 Implicit conversion operator. More...
 
const int64_t & int64 () const
 Access the value. More...
 
const double & real () const
 Access the value. More...
 
const std::string & text () const
 Access the value. More...
 
const Blobblob () const
 Access the 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 () noexcept
 Set to NULL. More...
 
bool isNull () const noexcept
 Check Null. More...
 
Type getType () const noexcept
 The Type of the value. More...
 
void swap (Value &other) noexcept
 swap function More...
 

Friends

std::ostream & operator<< (std::ostream &stm, const sl3::Value &v)
 Stream op for a Value. More...
 
bool value_type_eq (const Value &a, const Value &b) noexcept
 equality, including type info More...
 
bool value_type_lt (const Value &a, const Value &b) noexcept
 less than, including type info More...
 
bool value_eq (const Value &a, const Value &b) noexcept
 equality, ignoring type info More...
 
bool value_lt (const Value &a, const Value &b) noexcept
 less than, ignoring type info More...
 

Detailed Description

This class models the duck typing sqlite uses. It supports int, real, text, blob and null values.

The class has the current type info availalbe.

Constructor & Destructor Documentation

◆ Value() [1/9]

sl3::Value::Value ( )
noexcept

Constructor.

Creates a Null Value

◆ Value() [2/9]

sl3::Value::Value ( int  val)
explicitnoexcept

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ Value() [3/9]

sl3::Value::Value ( int64_t  val)
explicitnoexcept

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ Value() [4/9]

sl3::Value::Value ( std::string  val)
explicitnoexcept

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ Value() [5/9]

sl3::Value::Value ( const char *  val)
explicit

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ Value() [6/9]

sl3::Value::Value ( double  val)
explicitnoexcept

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ Value() [7/9]

sl3::Value::Value ( Blob  val)
explicitnoexcept

Constructor.

This constructor wiht an initialization value

Parameters
valinitial value

◆ ~Value()

sl3::Value::~Value ( )
noexcept

Destructor.

◆ Value() [8/9]

sl3::Value::Value ( const Value )
noexcept

Copy constructor.

◆ Value() [9/9]

sl3::Value::Value ( Value &&  )
noexcept

Move constructor.

Member Function Documentation

◆ blob()

const Blob& sl3::Value::blob ( ) const

Access the value.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif the current value has a different type.
Returns
reference to the value

◆ ejectBlob()

Blob sl3::Value::ejectBlob ( )

Moves the current value into the return value.

After calling this function the value will be Null.

Exceptions
sl3::ErrTypeMisMatchin case of wrong type.
Returns
The value

◆ ejectText()

std::string sl3::Value::ejectText ( )

Moves the current value into the return value.

After calling this function the value will be Null.

Exceptions
sl3::ErrTypeMisMatchin case of wrong type.
Returns
The value

◆ getType()

Type sl3::Value::getType ( ) const
noexcept

The Type of the value.

Returns
the type

◆ int64()

const int64_t& sl3::Value::int64 ( ) const

Access the value.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif the current value has a different type.
Returns
reference to the value

◆ isNull()

bool sl3::Value::isNull ( ) const
noexcept

Check Null.

Returns
if the value is null

◆ operator const Blob &()

sl3::Value::operator const Blob & ( ) const
explicit

Implicit conversion operator.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif getType is incompatible
Returns
the value

◆ operator const std::string &()

sl3::Value::operator const std::string & ( ) const
explicit

Implicit conversion operator.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif getType is incompatible
Returns
the value

◆ operator double()

sl3::Value::operator double ( ) const
explicit

Implicit conversion operator.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif getType is incompatible
sl3::ErrOutOfRangeis the stored value is an int64_t and out of the min or max double range.
Returns
the value

◆ operator int()

sl3::Value::operator int ( ) const
explicit

Implicit conversion operator.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif getType is incompatible
sl3::ErrOutOfRangeis the stored value is an int64_t
Returns
the value

◆ operator int64_t()

sl3::Value::operator int64_t ( ) const
explicit

Implicit conversion operator.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif getType is incompatible
Returns
the value

◆ operator=() [1/7]

Value& sl3::Value::operator= ( const Value val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [2/7]

Value& sl3::Value::operator= ( Value &&  val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [3/7]

Value& sl3::Value::operator= ( int  val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [4/7]

Value& sl3::Value::operator= ( const int64_t &  val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [5/7]

Value& sl3::Value::operator= ( const double &  val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [6/7]

Value& sl3::Value::operator= ( const std::string &  val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ operator=() [7/7]

Value& sl3::Value::operator= ( const Blob val)

Assignment.

Exceptions
sl3::ErrTypeMisMatchif getType is incompatible
Note
, only value assignment happens here, the type does not change, the storage type might change in case of type is a variant.
Parameters
valnew value
Returns
reference to this

◆ real()

const double& sl3::Value::real ( ) const

Access the value.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif the current value has a different type.
Returns
reference to the value

◆ setNull()

void sl3::Value::setNull ( )
noexcept

Set to NULL.

◆ swap()

void sl3::Value::swap ( Value other)
noexcept

swap function

Independent of the type, a Value is always swapable.

Parameters
othervalue to swap with

◆ text()

const std::string& sl3::Value::text ( ) const

Access the value.

Exceptions
sl3::ErrNullValueAccessif value is null.
sl3::ErrTypeMisMatchif the current value has a different type.
Returns
reference to the value

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stm,
const sl3::Value v 
)
friend

Stream op for a Value.

Parameters
stman outstream
vthe value to stream
Returns
ostream

◆ value_eq

bool value_eq ( const Value a,
const Value b 
)
friend

equality, ignoring type info

Compares only the stored value and ignores type information.

Parameters
afirst value to compare
bsecond value to compare
Returns
the comparison result

◆ value_lt

bool value_lt ( const Value a,
const Value b 
)
friend

less than, ignoring type info

Compares only the stored value and ignores type information.

Parameters
afirst value to compare
bsecond value to compare
Returns
the comparison result

◆ value_type_eq

bool value_type_eq ( const Value a,
const Value b 
)
friend

equality, including type info

Check if 2 Value instances are of the same type and of the same value.

Parameters
afirst element to compare
bsecond element to compare
Returns
true if the type and the current value are equal, false otherwise

◆ value_type_lt

bool value_type_lt ( const Value a,
const Value b 
)
friend

less than, including type info

Applies following rules which are equal to the sorting rules of sqlite.

Parameters
afirst element to compare
bsecond element to compare
Returns
true if given Value a is less than given Value b

The documentation for this class was generated from the following file: