ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
Loading...
Searching...
No Matches
blob Class Referencefinal

Access blob as a byte stream. More...

Inheritance diagram for blob:
handle< sqlite3_blob, blob >

Public Member Functions

 ~blob () noexcept
 Equivalent to sqlite3_blob_close.
 
void reopen (int64_t rowid)
 Move the object to a new row.
 
size_t bytes () const noexcept
 Returns the size of the blob.
 
void read (size_t offset, span< std::byte > dest) const
 Read data from the blob.
 
template<std::ranges::contiguous_range R>
requires (std::is_trivially_copyable_v<std::ranges::range_value_t<R>> && !std::is_const_v<std::remove_reference_t<std::ranges::range_reference_t<R>>>)
void read (size_t offset, R &range) const
 Read data from the blob.
 
void write (size_t offset, span< const std::byte > src)
 Write data to the blob.
 
void write (size_t offset, span< std::byte > src)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<std::ranges::contiguous_range R>
requires (std::is_trivially_copyable_v<std::ranges::range_value_t<R>>)
void write (size_t offset, R range) const
 Write data to the blob.
 
void operator delete (void *) noexcept
 Operator delete for a fake pointer is no-op.
 
sqlite3_blobc_ptr () const noexcept
 Access the real underlying SQLite type.
 

Static Public Member Functions

static blobfrom (sqlite3_blob *obj) noexcept
 Create fake pointer from the underlying SQLite one.
 

Detailed Description

Access blob as a byte stream.

This is a fake wrapper class for sqlite3_blob.

Use database::open_blob to create blob objects.

#include <thinsqlitepp/blob.hpp>

Member Function Documentation

◆ reopen()

void reopen ( int64_t rowid)
inline

Move the object to a new row.

Equivalent to sqlite3_blob_reopen

◆ bytes()

size_t bytes ( ) const
inlinenoexcept

Returns the size of the blob.

Equivalent to sqlite3_blob_bytes

◆ read() [1/2]

void read ( size_t offset,
span< std::byte > dest ) const
inline

Read data from the blob.

Equivalent to sqlite3_blob_read

◆ read() [2/2]

template<std::ranges::contiguous_range R>
requires (std::is_trivially_copyable_v<std::ranges::range_value_t<R>> && !std::is_const_v<std::remove_reference_t<std::ranges::range_reference_t<R>>>)
void read ( size_t offset,
R & range ) const
inline

Read data from the blob.

This overload is only available in C++20 and allows you to read into any compatible range.

Equivalent to sqlite3_blob_read

◆ write() [1/2]

void write ( size_t offset,
span< const std::byte > src )
inline

Write data to the blob.

This function may only modify the contents of the blob; it is not possible to increase the size of a blob using this API

Equivalent to sqlite3_blob_write

◆ write() [2/2]

template<std::ranges::contiguous_range R>
requires (std::is_trivially_copyable_v<std::ranges::range_value_t<R>>)
void write ( size_t offset,
R range ) const
inline

Write data to the blob.

This function may only modify the contents of the blob; it is not possible to increase the size of a blob using this API

This overload is only available in C++20 and allows you to write from any compatible range.

Equivalent to sqlite3_blob_write