A class representing a BLOB in a SQLite database.
More...
#include <Blob.h>
|
| ~Blob () noexcept |
|
| Blob (const Blob &)=delete |
|
| Blob (Blob &&) noexcept |
|
Blob & | operator= (const Blob &)=delete |
|
Blob & | operator= (Blob &&) noexcept |
|
int64_t | Size () const noexcept |
| Returns the size of the BLOB. More...
|
|
int64_t | Read (void *buffer, int64_t offset, int64_t bufferSize) const noexcept |
| Reads up to bufferSize bytes from the BLOB into the buffer at the given offset. More...
|
|
int64_t | Write (const void *buffer, int64_t offset, int64_t bufferSize) noexcept |
| Writes up to bufferSize bytes from the buffer into the BLOB at the given offset. More...
|
|
template<typename ContainerType > |
ContainerType | Read (int64_t offset=0, int64_t bufferSize=-1) const |
| Reads up to bufferSize bytes from the BLOB into a container at the given offset. More...
|
|
|
| Blob (sqlite3_blob *blob) noexcept |
|
A class representing a BLOB in a SQLite database.
Definition at line 17 of file Blob.h.
◆ Blob() [1/3]
audacity::sqlite::Blob::Blob |
( |
sqlite3_blob * |
blob | ) |
|
|
explicitprivatenoexcept |
Definition at line 17 of file Blob.cpp.
19{
20 assert(
mBlob !=
nullptr);
21}
◆ ~Blob()
audacity::sqlite::Blob::~Blob |
( |
| ) |
|
|
noexcept |
Definition at line 23 of file Blob.cpp.
24{
26 {
27 sqlite3_blob_close(
mBlob);
29 }
30}
References mBlob.
◆ Blob() [2/3]
audacity::sqlite::Blob::Blob |
( |
const Blob & |
| ) |
|
|
delete |
◆ Blob() [3/3]
audacity::sqlite::Blob::Blob |
( |
Blob && |
rhs | ) |
|
|
noexcept |
Definition at line 32 of file Blob.cpp.
33{
34 *this = std::move(rhs);
35}
◆ operator=() [1/2]
Blob & audacity::sqlite::Blob::operator= |
( |
Blob && |
rhs | ) |
|
|
noexcept |
◆ operator=() [2/2]
Blob & audacity::sqlite::Blob::operator= |
( |
const Blob & |
| ) |
|
|
delete |
◆ Read() [1/2]
template<typename ContainerType >
ContainerType audacity::sqlite::Blob::Read |
( |
int64_t |
offset = 0 , |
|
|
int64_t |
bufferSize = -1 |
|
) |
| const |
|
inline |
Reads up to bufferSize bytes from the BLOB into a container at the given offset.
If bufferSize is negative, the entire BLOB is read. ContainerType must have a resize() method and a data() method.
Definition at line 44 of file Blob.h.
45 {
46 if (bufferSize < 0)
47 bufferSize =
Size() - offset;
48
49 if (bufferSize <= 0)
50 return {};
51
52 ContainerType buffer;
53 buffer.resize(bufferSize);
54 const auto bytesRead =
Read(buffer.data(), offset, bufferSize);
55 buffer.resize(bytesRead);
56
57 return buffer;
58 }
int64_t Size() const noexcept
Returns the size of the BLOB.
int64_t Read(void *buffer, int64_t offset, int64_t bufferSize) const noexcept
Reads up to bufferSize bytes from the BLOB into the buffer at the given offset.
◆ Read() [2/2]
int64_t audacity::sqlite::Blob::Read |
( |
void * |
buffer, |
|
|
int64_t |
offset, |
|
|
int64_t |
bufferSize |
|
) |
| const |
|
noexcept |
Reads up to bufferSize bytes from the BLOB into the buffer at the given offset.
Definition at line 52 of file Blob.cpp.
53{
55 return 0;
56
57 const int readSize = std::min<int>(bufferSize,
Size() - offset);
58
59 if (bufferSize <= 0)
60 return 0;
61
62 if (
63 SQLITE_OK !=
64 sqlite3_blob_read(
mBlob, buffer, readSize,
static_cast<int>(offset)))
65 return 0;
66
67 return readSize;
68}
◆ Size()
int64_t audacity::sqlite::Blob::Size |
( |
| ) |
const |
|
noexcept |
Returns the size of the BLOB.
Definition at line 43 of file Blob.cpp.
44{
46 return 0;
47
48 return sqlite3_blob_bytes(
mBlob);
49}
References mBlob.
◆ Write()
int64_t audacity::sqlite::Blob::Write |
( |
const void * |
buffer, |
|
|
int64_t |
offset, |
|
|
int64_t |
bufferSize |
|
) |
| |
|
noexcept |
Writes up to bufferSize bytes from the buffer into the BLOB at the given offset.
Definition at line 71 of file Blob.cpp.
72{
74 return 0;
75
76 const int writeSize = std::min<int>(bufferSize,
Size() - offset);
77
78 if (bufferSize <= 0)
79 return 0;
80
81 if (
82 SQLITE_OK !=
83 sqlite3_blob_write(
mBlob, buffer, writeSize,
static_cast<int>(offset)))
84 return 0;
85
86 return writeSize;
87}
◆ Connection
◆ mBlob
sqlite3_blob* audacity::sqlite::Blob::mBlob {} |
|
private |
The documentation for this class was generated from the following files: