VSQLite++ 0.3
Loading...
Searching...
No Matches
sqlite::v2 Namespace Reference

Namespaces

namespace  detail
namespace  json
namespace  fts

Classes

struct  backup
 backup is a class for representing SQLite backup operations An object of this class is not copyable More...
struct  named_parameter
struct  null_type
 null_type is an empty type used to represent NULL values More...
struct  command
 command is the base class of all sql command classes An object of this class is not copyable More...
struct  connection
 connection is used to open, close, attach and detach a database. Further it has to be passed to all classes since it represents the connection to the database and contains the internal needed handle, so you can see a connection object as handle to the database An object of this class is not copyable More...
class  connection_pool
 Thread-safe pool for leasing reusable SQLite connections. More...
struct  database_exception
 Generic runtime failure raised for most SQLite errors. More...
struct  database_exception_code
 Exception that carries the original SQLite error code and optional SQL snippet. More...
struct  buffer_too_small_exception
 Raised when a caller-provided buffer is too small to hold a blob/text payload. More...
struct  database_misuse_exception
 Used for programming errors such as double-closing or using invalidated resources. More...
struct  database_misuse_exception_code
 Logic-error flavour that also exposes the SQLite status code and SQL string. More...
struct  database_system_error
 Wraps system-level failures (e.g., file I/O) that bubble up from SQLite APIs. More...
struct  execute
 execute can be used for SQL commands which should executed the constructor is defined in a way that it can be used like a function An object of this class is not copyable More...
struct  unknown_t
struct  null_t
struct  filesystem_entry
 Result of probing a filesystem path that bundles status metadata and the failure code. More...
struct  filesystem_adapter
 Interface for querying and mutating filesystem paths before SQLite touches them. More...
class  default_filesystem_adapter
 Default adapter that simply forwards to std::filesystem. More...
struct  function_options
 Options passed alongside a callable when registering it with sqlite3_create_function_v2. More...
struct  private_accessor
 A internal used class, shall not be used from users. More...
struct  result_construct_params_private
struct  query
 query should be used to execute SQL queries An object of this class is not copyable More...
struct  result
 Forward-only cursor over the rows produced by a prepared statement. More...
struct  savepoint
 this is a helper class to handle transaction savepoints within SQLite More...
struct  session_options
 Configuration flags supplied when opening a new change session. More...
struct  session
 RAII wrapper around sqlite3_session. More...
struct  snapshot
 RAII wrapper around sqlite3_snapshot. More...
struct  statement_cache_config
 Configuration knobs for the built-in LRU statement cache. More...
class  statement_cache
 Tracks prepared statements by SQL text and hands them out on demand. More...
struct  transaction
 transaction is a helper class to start transactions within SQLite More...
struct  view
 view is used to create views. In SQLite a view can only be queried. INSERT, DELETE and UPDATE will fail on a view More...

Typedefs

typedef std::vector< std::uint8_t > blob_t
typedef std::shared_ptr< blob_tblob_ref_t
typedef std::variant< unknown_t, int, std::int64_t, long double, std::string, null_t, blob_ref_tvariant_t
using filesystem_adapter_ptr = std::shared_ptr<filesystem_adapter>
typedef std::shared_ptr< resultresult_type
 Shared-pointer alias used by legacy APIs that transfer result ownership.

Enumerations

enum class  open_mode { open_readonly , open_existing , open_or_create , always_create }
enum  type {
  unknown , null , integer , real ,
  text , blob
}
enum class  wal_mode {
  rollback , truncate , persist , memory ,
  wal , wal2
}
enum class  threading_mode { single_thread , multi_thread , serialized }
 Mirrors the sqlite3_config(SQLITE_CONFIG_*) threading options. More...
enum class  transaction_type { undefined , deferred , immediate , exclusive }
 Defines the kind of transaction to begin. More...

Functions

template<typename T>
named_parameter< std::decay_t< T > > named (std::string_view name, T &&value)
std::string append_sql_context (std::string message, std::string const &sql)
 Helper that appends [SQL: ...] context to an existing message.
template<typename Callable>
void create_function (connection &con, std::string_view name, Callable &&callable, function_options options={})
bool serialization_supported () noexcept
 Indicates whether the linked SQLite exposes the serialize/deserialise feature.
std::vector< unsigned char > serialize (connection &con, std::string_view schema="main", unsigned int flags=0)
 Copies the complete database image for schema into a byte vector.
void deserialize (connection &con, std::span< const unsigned char > image, std::string_view schema="main", bool read_only=false)
 Replaces the contents of schema with the supplied serialized image.
bool sessions_supported () noexcept
 Returns true when SQLite sessions API is available.
void apply_changeset (connection &con, std::span< const unsigned char > data)
 Applies a changeset produced by session::changeset onto con.
void apply_patchset (connection &con, std::span< const unsigned char > data)
 Applies a patchset produced by session::patchset onto con.
wal_mode set_wal_mode (connection &con, wal_mode mode)
 Force a specific WAL journal mode.
wal_mode enable_wal (connection &con, bool prefer_wal2=false)
 Enable WAL, optionally preferring WAL2 with transparent fallback.
wal_mode get_wal_mode (connection &con)
 Query the current journal mode for a connection.
std::string_view to_string (wal_mode mode)
 Convert wal_mode to the corresponding PRAGMA token.
bool snapshots_supported () noexcept
 Check if the linked SQLite library exposes snapshot helpers.
bool configure_threading (threading_mode mode)
 Calls sqlite3_config to switch SQLite into the requested threading mode.
threading_mode current_threading_mode ()
 Returns the currently configured threading_mode.

Variables

null_type nil
 nil is used instead of NULL within the operator % syntax in this wrapper

Typedef Documentation

◆ blob_ref_t

typedef std::shared_ptr<blob_t> sqlite::v2::blob_ref_t

Definition at line 49 of file variant.hpp.

◆ blob_t

typedef std::vector<std::uint8_t> sqlite::v2::blob_t

Definition at line 48 of file variant.hpp.

◆ filesystem_adapter_ptr

Definition at line 76 of file filesystem_adapter.hpp.

◆ result_type

typedef std::shared_ptr<result> sqlite::v2::result_type

Shared-pointer alias used by legacy APIs that transfer result ownership.

Definition at line 252 of file result.hpp.

◆ variant_t

typedef std::variant<unknown_t, int, std::int64_t, long double, std::string, null_t, blob_ref_t> sqlite::v2::variant_t

Definition at line 52 of file variant.hpp.

Enumeration Type Documentation

◆ open_mode

enum class sqlite::v2::open_mode
strong
Enumerator
open_readonly 

Opens an existing database for reads only or fails.

open_existing 

Opens an existing database; fails when it is missing.

open_or_create 

Opens an existing database or creates it on demand.

always_create 

Deletes any existing database file and recreates it.

Definition at line 51 of file connection.hpp.

◆ threading_mode

enum class sqlite::v2::threading_mode
strong

Mirrors the sqlite3_config(SQLITE_CONFIG_*) threading options.

Enumerator
single_thread 

No internal mutexing; callers must serialize all access.

multi_thread 

Connections are thread-safe, but individual database handles are not.

serialized 

Full mutexing that allows sharing a connection across threads.

Definition at line 46 of file threading.hpp.

◆ transaction_type

enum class sqlite::v2::transaction_type
strong

Defines the kind of transaction to begin.

See also
http://www.sqlite.org/lang_transaction.html for documentation about transaction kind.

When no transaction type is defined (undefined) the default behaviour is to create a deferred transaction, but the undefined constant is because maybe in future the default behaviour may change.

Note that for more type safety this needs Strongly Typed enums C++11 feature: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf

Enumerator
undefined 
deferred 
immediate 
exclusive 

Definition at line 64 of file transaction.hpp.

◆ type

Enumerator
unknown 
null 
integer 
real 
text 
blob 

Definition at line 44 of file variant.hpp.

◆ wal_mode

enum class sqlite::v2::wal_mode
strong
Enumerator
rollback 

DELETE/legacy rollback journal.

truncate 
persist 
memory 
wal 
wal2 

Definition at line 52 of file snapshot.hpp.

Function Documentation

◆ append_sql_context()

std::string sqlite::v2::append_sql_context ( std::string message,
std::string const & sql )
inline

Helper that appends [SQL: ...] context to an existing message.

Definition at line 54 of file database_exception.hpp.

Referenced by sqlite::v2::database_exception_code::database_exception_code(), and sqlite::v2::database_misuse_exception_code::database_misuse_exception_code().

◆ apply_changeset()

void sqlite::v2::apply_changeset ( connection & con,
std::span< const unsigned char > data )

Applies a changeset produced by session::changeset onto con.

◆ apply_patchset()

void sqlite::v2::apply_patchset ( connection & con,
std::span< const unsigned char > data )

Applies a patchset produced by session::patchset onto con.

◆ configure_threading()

bool sqlite::v2::configure_threading ( threading_mode mode)

Calls sqlite3_config to switch SQLite into the requested threading mode.

◆ create_function()

template<typename Callable>
void sqlite::v2::create_function ( connection & con,
std::string_view name,
Callable && callable,
function_options options = {} )

Definition at line 447 of file function.hpp.

◆ current_threading_mode()

threading_mode sqlite::v2::current_threading_mode ( )

Returns the currently configured threading_mode.

◆ deserialize()

void sqlite::v2::deserialize ( connection & con,
std::span< const unsigned char > image,
std::string_view schema = "main",
bool read_only = false )

Replaces the contents of schema with the supplied serialized image.

Parameters
conConnection that should host the deserialized database.
imageSerialized bytes previously produced by serialize or another SQLite source.
schemaLogical database name.
read_onlyWhen true the connection treats the schema as immutable.

◆ enable_wal()

wal_mode sqlite::v2::enable_wal ( connection & con,
bool prefer_wal2 = false )

Enable WAL, optionally preferring WAL2 with transparent fallback.

◆ get_wal_mode()

wal_mode sqlite::v2::get_wal_mode ( connection & con)

Query the current journal mode for a connection.

◆ named()

template<typename T>
named_parameter< std::decay_t< T > > sqlite::v2::named ( std::string_view name,
T && value )

Definition at line 63 of file command.hpp.

◆ serialization_supported()

bool sqlite::v2::serialization_supported ( )
noexcept

Indicates whether the linked SQLite exposes the serialize/deserialise feature.

◆ serialize()

std::vector< unsigned char > sqlite::v2::serialize ( connection & con,
std::string_view schema = "main",
unsigned int flags = 0 )

Copies the complete database image for schema into a byte vector.

Parameters
conOpen connection whose schema should be serialized.
schemaLogical database name (e.g. "main" or "temp").
flagsOptional SQLite serialization flags.
Exceptions
database_exceptionwhen serialization is unavailable or fails.

◆ sessions_supported()

bool sqlite::v2::sessions_supported ( )
noexcept

Returns true when SQLite sessions API is available.

◆ set_wal_mode()

wal_mode sqlite::v2::set_wal_mode ( connection & con,
wal_mode mode )

Force a specific WAL journal mode.

◆ snapshots_supported()

bool sqlite::v2::snapshots_supported ( )
noexcept

Check if the linked SQLite library exposes snapshot helpers.

◆ to_string()

std::string_view sqlite::v2::to_string ( wal_mode mode)

Convert wal_mode to the corresponding PRAGMA token.

Variable Documentation

◆ nil

null_type sqlite::v2::nil
extern

nil is used instead of NULL within the operator % syntax in this wrapper