libsl3  1.12.2
C++ interface for sqlite3
Classes | Typedefs | Enumerations | Functions
sl3 Namespace Reference

Namespace of libSL3. More...

Classes

class  Columns
 Class to access data of query results. More...
 
class  Command
 A compiled SQL command. More...
 
class  Container
 Wrapper to provide begin, end and random access of a container. More...
 
class  Database
 represents a SQLite3 Database More...
 
class  Dataset
 A utility for processing the result queries. More...
 
class  DbValue
 This class models the duck typing sqlite uses. It supports int, real, text, blob and null values. More...
 
class  DbValues
 A row of DbValues. More...
 
class  Error
 Exception base type. More...
 
class  ErrType
 Object class representing an ErrCode. More...
 
class  ErrType< ErrCode::SQL3Error >
 packaging an error from sqlite3. This exception will be thrown if sqlite3 reports an error. More...
 
class  RowCallback
 Callback for SQL Select statements. More...
 
class  Types
 A Container holding sl3::Type values. More...
 
class  Value
 This class models the duck typing sqlite uses. It supports int, real, text, blob and null values. More...
 

Typedefs

using ErrNoConnection = ErrType< ErrCode::NoConnection >
 error that will be thrown if no open database was available but needed More...
 
using ErrOutOfRange = ErrType< ErrCode::OutOfRange >
 thrown if an index op is out of range More...
 
using ErrTypeMisMatch = ErrType< ErrCode::TypeMisMatch >
 thrown in case of an incorrect type usage More...
 
using ErrNullValueAccess = ErrType< ErrCode::NullValueAccess >
 thrown in case of accessing a Null value field/parameter More...
 
using ErrUnexpected = ErrType< ErrCode::UNEXPECTED >
 
using SQLite3Error = ErrType< ErrCode::SQL3Error >
 Shortcut. More...
 
using Blob = std::vector< char >
 

Enumerations

enum  ErrCode {
  ErrCode::SQL3Error = 1,
  ErrCode::NoConnection = 2,
  ErrCode::OutOfRange = 5,
  ErrCode::TypeMisMatch = 6,
  ErrCode::NullValueAccess = 7,
  ErrCode::UNEXPECTED = 99
}
 Error codes. More...
 
enum  Type {
  Type::Null = 0,
  Type::Int = 1,
  Type::Real = 2,
  Type::Text = 3,
  Type::Blob = 4,
  Type::Variant = 5
}
 

Functions

template<typename... VALS>
DbValues parameters (VALS &&... vals)
 Syntax sugar to create command parameters. More...
 
const char * sqliteCompiledVersion ()
 sqlite version string at compile time More...
 
int sqliteCompiledVersionNumber ()
 sqlite version number at compile time More...
 
const char * sqliteRuntimeVersion ()
 sqlite version string at runtime More...
 
int sqliteRuntimeVersionNumber ()
 sqlite version number at compile time More...
 
int sqliteThreadSafeCompileOption ()
 returns value of SQLITE_THREADSAFE compilation option More...
 
std::string getErrStr (int errcode)
 Wraps sqlite3_errstr() function. More...
 
LIBSL3_API std::ostream & operator<< (std::ostream &stm, const sl3::DbValue &v)
 Stream op for a DbValue. More...
 
bool dbval_type_eq (const DbValue &a, const DbValue &b) noexcept
 equality, including type info More...
 
bool dbval_type_lt (const DbValue &a, const DbValue &b) noexcept
 less than, including type info More...
 
bool dbval_eq (const DbValue &a, const DbValue &b) noexcept
 equality, ignoring type info More...
 
bool dbval_lt (const DbValue &a, const DbValue &b) noexcept
 less than, ignoring type info More...
 
void swap (DbValues &a, DbValues &b) noexcept
 DbValue specialized swap function. More...
 
constexpr const char * ErrCodeName (ErrCode ec)
 get textual representantion (the name) of an ErrCode More...
 
LIBSL3_API std::ostream & operator<< (std::ostream &os, const Error &e)
 overloaded stream operator More...
 
std::string typeName (Type)
 Get the type name as string. More...
 
std::ostream &LIBSL3_API operator<< (std::ostream &os, const Type &t)
 overloaded stream operator for sl3::Type More...
 
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...
 
void swap (Value &a, Value &b) noexcept
 Value specialized swap function. More...
 

Detailed Description

Namespace of libSL3.

The namespace where the library defines it's elements.

Typedef Documentation

◆ Blob

using sl3::Blob = typedef std::vector<char>

A type for binary data

◆ ErrNoConnection

error that will be thrown if no open database was available but needed

◆ ErrNullValueAccess

thrown in case of accessing a Null value field/parameter

◆ ErrOutOfRange

thrown if an index op is out of range

◆ ErrTypeMisMatch

thrown in case of an incorrect type usage

◆ ErrUnexpected

thrown if something unexpected happened, mostly used by test tools and in debug mode

◆ SQLite3Error

Shortcut.

Assign a name to an ErrType with ErrCode::SQL3Error.

Enumeration Type Documentation

◆ ErrCode

enum sl3::ErrCode
strong

Error codes.

These enum values used to create ErrType objects.

Each ErrCode becomes an ErrType object.

Enumerator
SQL3Error 

sqlite3 error happened

NoConnection 

no database

OutOfRange 

index op out of range

TypeMisMatch 

type cast problem

NullValueAccess 

accessing a value that is Null

UNEXPECTED 

for everything that happens unexpected

◆ Type

enum sl3::Type
strong

Enumeration of different value types

These are the types known by sqlite. They are used when reading from or writing to a database.

Enumerator
Null 

Null, no value.

Int 

Int value.

Real 

Real value.

Text 

Text value.

Blob 

Blob vale.

Variant 

takes any type

Function Documentation

◆ dbval_eq()

bool sl3::dbval_eq ( const DbValue a,
const DbValue b 
)
noexcept

equality, ignoring type info

Compares only the stored value for equality and ignores type information.

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

◆ dbval_lt()

bool sl3::dbval_lt ( const DbValue a,
const DbValue b 
)
noexcept

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

◆ dbval_type_eq()

bool sl3::dbval_type_eq ( const DbValue a,
const DbValue b 
)
noexcept

equality, including type info

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

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

◆ dbval_type_lt()

bool sl3::dbval_type_lt ( const DbValue a,
const DbValue b 
)
noexcept

less than, including type info

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

Parameters
afirst value to compare
bsecond value to compare
Returns
true if given DbValue a is less than given DbValue b

◆ ErrCodeName()

constexpr const char* sl3::ErrCodeName ( ErrCode  ec)

get textual representantion (the name) of an ErrCode

Parameters
ecwanted ErrCode name
Returns
the ErrCode name

◆ getErrStr()

std::string sl3::getErrStr ( int  errcode)

Wraps sqlite3_errstr() function.

The sqlite3_errstr() interface returns the English-language text that describes the result code, as UTF

Parameters
errcodeerr number
Returns
Count of changed rows

◆ operator<<() [1/4]

std::ostream& LIBSL3_API sl3::operator<< ( std::ostream &  os,
const Type t 
)

overloaded stream operator for sl3::Type

Parameters
osostream
tthe Type
Returns
the ostream

◆ operator<<() [2/4]

LIBSL3_API std::ostream& sl3::operator<< ( std::ostream &  os,
const Error e 
)

overloaded stream operator

Parameters
osostream
ethe Error
Returns
the ostream

◆ operator<<() [3/4]

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

Stream op for a Value.

Parameters
stman outstream
vthe value to stream
Returns
ostream

◆ operator<<() [4/4]

LIBSL3_API std::ostream& sl3::operator<< ( std::ostream &  stm,
const sl3::DbValue v 
)

Stream op for a DbValue.

Parameters
stman outstream
vthe value to stream
Returns
ostream

◆ parameters()

template<typename... VALS>
DbValues sl3::parameters ( VALS &&...  vals)

Syntax sugar to create command parameters.

Creates DbValues with types based on the given arguments.

cmd.execute(parameters(1,"foo",3.3))

Will create DbValues of Type::Int, Type::Text and Type::Real

Template Parameters
VALSvariadic argument types
Parameters
valsvariadic argument values
Returns
DbValues constructed by given arguments

◆ sqliteCompiledVersion()

const char* sl3::sqliteCompiledVersion ( )

sqlite version string at compile time

if this library was linked against an installed version of sqlite this function can be used to determinate if the system library has been updated.

See also
sqliteRuntimeVersion()
Returns
version string at compile time

◆ sqliteCompiledVersionNumber()

int sl3::sqliteCompiledVersionNumber ( )

sqlite version number at compile time

if this library was linked against an installed version of sqlite this function can be used to determinate if the system library has been updated.

See also
sqliteRuntimeVersionNumber()
Returns
version number at compile time

◆ sqliteRuntimeVersion()

const char* sl3::sqliteRuntimeVersion ( )

sqlite version string at runtime

if this library was linked against an installed version of sqlite this function can be used to determinate if the system library has been updated.

See also
sqliteCompiledVersion()
Returns
version string currently used

◆ sqliteRuntimeVersionNumber()

int sl3::sqliteRuntimeVersionNumber ( )

sqlite version number at compile time

if this library was linked against an installed version of sqlite this function can be used to determinate if the system library has been updated.

See also
sqliteCompiledVersionNumber()
Returns
sqlite version number currently used

◆ sqliteThreadSafeCompileOption()

int sl3::sqliteThreadSafeCompileOption ( )

returns value of SQLITE_THREADSAFE compilation option

see http://www.sqlite.org/compile.html about additional informations

Returns
0 or 1 or 2

◆ swap() [1/2]

void sl3::swap ( DbValues a,
DbValues b 
)
noexcept

DbValue specialized swap function.

Parameters
afirst value to swap with second value
bsecond value to swap with first value

This function call a.swap(b).

See also
DbValues::swap

◆ swap() [2/2]

void sl3::swap ( Value a,
Value b 
)
noexcept

Value specialized swap function.

Independent of the type, a Value is always swapable.

Parameters
afirst value to swap with second value
bsecond value to swap with first value

◆ typeName()

std::string sl3::typeName ( Type  )

Get the type name as string.

For example, in log messages a type "Real" is more verbose that a type 2.

Returns
the type name as string

◆ value_eq()

bool sl3::value_eq ( const Value a,
const Value b 
)
noexcept

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 sl3::value_lt ( const Value a,
const Value b 
)
noexcept

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 sl3::value_type_eq ( const Value a,
const Value b 
)
noexcept

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 sl3::value_type_lt ( const Value a,
const Value b 
)
noexcept

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