|
Couchbase Lite C++
Couchbase Lite C++ API
|
A reference to a binary data blob associated with a document. More...
#include <cbl++/Blob.hh>
Public Member Functions | |
| Blob (std::optional< std::string_view > contentType, slice contents) | |
| Creates a new blob, given its contents as a single block of data. | |
| Blob (std::optional< std::string_view > contentType, BlobWriteStream &writer) | |
| Creates a new blob from the data written to a CBLBlobWriteStream. | |
| Blob (fleece::Dict d) | |
| Creates a Blob instance on an existing blob reference in a document or query result. | |
| bool | blobEquals (const Blob &other) const |
| Compares whether this blob and another are equal based on their content. | |
| uint64_t | length () const |
| Returns the length in bytes of a blob's content (from its length property). | |
| std::string | contentType () const |
| Returns a blob's MIME type, if its metadata has a content_type property. | |
| std::string | digest () const |
| Returns the cryptographic digest of a blob's content (from its digest property). | |
| fleece::Dict | properties () const |
| Returns a blob's metadata. | |
| std::string | createJSON () const |
| Returns the JSON representation of the blob's metadata dictionary. | |
| operator fleece::Dict () const | |
| Implicit conversion to the blob's underlying Fleece dictionary. | |
| alloc_slice | loadContent () |
| Reads the blob's content into memory and returns it. | |
| BlobReadStream * | openContentStream () |
| Opens a stream for reading a blob's content. | |
| Blob () noexcept | |
| Constructs a null reference (one that points to no object). | |
| Blob & | operator= (std::nullptr_t) |
| Releases the underlying object and resets this to a null reference. | |
| bool | valid () const |
| Returns true if this references an object, or false if it is a null reference. | |
| operator bool () const | |
| Returns true if this references an object (same as valid). | |
| bool | operator== (const Blob &other) const |
| Returns true if both sides reference the same object, or are both null references. | |
| bool | operator!= (const Blob &other) const |
| Returns true if the two sides reference different objects. | |
| CBLBlob *_Nullable | ref () const |
| Returns a pointer to the underlying C object (CBLBlob), or NULL if this is a null reference. | |
| Blob (const Blob &other) noexcept | |
Copy constructor: creates another reference to the same object as other. | |
| Blob (Blob &&other) noexcept | |
Move constructor: takes over the reference from other, leaving it a null reference. | |
| Blob & | operator= (const Blob &other) noexcept |
Copy assignment: replaces this reference with a reference to other's object. | |
| Blob & | operator= (Blob &&other) noexcept |
Move assignment: replaces this reference with other's, leaving other a null reference. | |
Static Public Member Functions | |
| static bool | isBlob (fleece::Dict d) |
| Returns true if a dictionary in a document is a blob reference. | |
Protected Member Functions | |
| Blob (CBLBlob *_Nullable ref) | |
| (Internal) Constructs a reference wrapping, and retaining, a C object pointer. | |
Friends | |
| class | Database |
A reference to a binary data blob associated with a document.
A blob's persistent form is a special dictionary in the document properties. To work with a blob, you construct a Blob object with that dictionary.
|
inline |
Creates a new blob, given its contents as a single block of data.
| contentType | The MIME type (optional). |
| contents | The data's address and length. |
|
inline |
Creates a new blob from the data written to a CBLBlobWriteStream.
| contentType | The MIME type (optional). |
| writer | The blob-writing stream the data was written to. |
|
inline |
|
inlinenoexcept |
Constructs a null reference (one that points to no object).
|
inlineexplicitprotected |
(Internal) Constructs a reference wrapping, and retaining, a C object pointer.
|
inlinenoexcept |
Copy constructor: creates another reference to the same object as other.
|
inlinenoexcept |
Move constructor: takes over the reference from other, leaving it a null reference.
|
inline |
Compares whether this blob and another are equal based on their content.
|
inline |
Returns a blob's MIME type, if its metadata has a content_type property.
|
inline |
Returns the JSON representation of the blob's metadata dictionary.
|
inline |
Returns the cryptographic digest of a blob's content (from its digest property).
|
inlinestatic |
Returns true if a dictionary in a document is a blob reference.
|
inline |
Returns the length in bytes of a blob's content (from its length property).
|
inline |
Reads the blob's content into memory and returns it.
| cbl::Error | If the content cannot be read (for example, the blob's data is not available in the database). |
|
inline |
Opens a stream for reading a blob's content.
|
inlineexplicit |
Returns true if this references an object (same as valid).
|
inline |
Implicit conversion to the blob's underlying Fleece dictionary.
This lets a Blob be assigned to a mutable Dict/Array item, e.g. dict["foo"] = blob.
|
inline |
Returns true if the two sides reference different objects.
Move assignment: replaces this reference with other's, leaving other a null reference.
Copy assignment: replaces this reference with a reference to other's object.
|
inline |
Releases the underlying object and resets this to a null reference.
|
inline |
Returns true if both sides reference the same object, or are both null references.
|
inline |
Returns a blob's metadata.
This includes the digest, length, content_type, and @type properties, as well as any custom ones that may have been added.
|
inline |
Returns a pointer to the underlying C object (CBLBlob), or NULL if this is a null reference.
|
inline |
Returns true if this references an object, or false if it is a null reference.
|
friend |