libsl3 1.2.41002
A C++ interface for SQLite
Loading...
Searching...
No Matches
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
 
using ErrOutOfRange = ErrType< ErrCode::OutOfRange >
 thrown if an index op is out of range
 
using ErrTypeMisMatch = ErrType< ErrCode::TypeMisMatch >
 thrown in case of an incorrect type usage
 
using ErrNullValueAccess = ErrType< ErrCode::NullValueAccess >
 thrown in case of accessing a Null value field/parameter
 
using ErrUnexpected = ErrType< ErrCode::UNEXPECTED >
 
using SQLite3Error = ErrType< ErrCode::SQL3Error >
 Alias for ErrType<ErrCode::SQL3Error>
 
using Blob = std::vector< std::byte >
 

Enumerations

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

Functions

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

Detailed Description

Namespace of libSL3.

The namespace where the library defines it's elements.

Typedef Documentation

◆ Blob

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

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

Enumeration Type Documentation

◆ ErrCode

enum class 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 class 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)
constexpr

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]

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

overloaded stream operator

Parameters
osostream
ethe Error
Returns
the ostream

◆ operator<<() [2/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<<() [3/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

◆ operator<<() [4/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

◆ 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))
DbValues parameters(VALS &&... vals)
Syntax sugar to create command parameters.
Definition: command.hpp:254

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