Couchbase Lite C
Couchbase Lite C API
CBLBase.h
Go to the documentation of this file.
1//
2// CBLBase.h
3//
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18
19#pragma once
20#ifdef CMAKE
21#include "cbl_config.h"
22#endif
23
24#include "CBL_Edition.h"
25#include "CBL_Compat.h"
26#include "fleece/FLSlice.h"
27#include <stdbool.h>
28#include <stdint.h>
29
31
37typedef CBL_ENUM(uint8_t, CBLErrorDomain) {
44};
45
47typedef CBL_ENUM(int32_t, CBLErrorCode) {
78};
79
81typedef CBL_ENUM(int32_t, CBLNetworkErrorCode) {
97};
98
99
104typedef struct {
106 int code;
107 unsigned internal_info; // do not use or modify
108} CBLError;
109
113
123typedef int64_t CBLTimestamp;
124
125
128
151
156
161
164
168
169// Declares retain/release functions for TYPE. For internal use only.
170#define CBL_REFCOUNTED(TYPE, NAME) \
171 static inline const TYPE CBL##NAME##_Retain(const TYPE _cbl_nullable t) \
172 {return (const TYPE)CBL_Retain((CBLRefCounted*)t);} \
173 static inline void CBL##NAME##_Release(const TYPE _cbl_nullable t) {CBL_Release((CBLRefCounted*)t);}
174
197typedef struct CBLBlob CBLBlob;
203typedef struct CBLQuery CBLQuery;
204
215#ifdef COUCHBASE_ENTERPRISE
216
225#endif
226
260
263
264
#define CBLAPI
Definition: CBL_Compat.h:98
#define _cbl_nullable
Definition: CBL_Compat.h:86
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
struct CBLBlob CBLBlob
A binary data value associated with a CBLDocument.
Definition: CBLBase.h:197
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:191
struct CBLEncryptable CBLEncryptable
An encryptable value.
Definition: CBLBase.h:223
CBLNetworkErrorCode
Network error codes, in the CBLNetworkDomain.
Definition: CBLBase.h:81
CBLErrorDomain
Error domains, serving as namespaces for numeric error codes.
Definition: CBLBase.h:37
FLSliceResult CBLError_Message(const CBLError *_cbl_nullable outError)
Returns a message describing an error.
CBLErrorCode
Couchbase Lite error codes, in the CBLDomain.
Definition: CBLBase.h:47
@ kCBLNetErrTimeout
No response received before timeout.
Definition: CBLBase.h:84
@ kCBLNetErrTLSClientCertRequired
Server requires client to have a TLS certificate.
Definition: CBLBase.h:90
@ kCBLNetErrTooManyRedirects
HTTP redirect loop.
Definition: CBLBase.h:86
@ kCBLNetErrTLSCertNameMismatch
Server cert's name does not match DNS name.
Definition: CBLBase.h:96
@ kCBLNetErrTLSCertExpired
Server's TLS certificate has expired.
Definition: CBLBase.h:88
@ kCBLNetErrTLSCertRevoked
Server's cert has been revoked.
Definition: CBLBase.h:95
@ kCBLNetErrTLSHandshakeFailed
Low-level error establishing TLS.
Definition: CBLBase.h:87
@ kCBLNetErrUnknownHost
DNS server doesn't know the hostname.
Definition: CBLBase.h:83
@ kCBLNetErrTLSCertUntrusted
Cert isn't trusted for other reason.
Definition: CBLBase.h:89
@ kCBLNetErrInvalidURL
Invalid URL.
Definition: CBLBase.h:85
@ kCBLNetErrUnknown
Unknown networking error.
Definition: CBLBase.h:94
@ kCBLNetErrDNSFailure
DNS lookup failed.
Definition: CBLBase.h:82
@ kCBLNetErrTLSCertUnknownRoot
Self-signed cert, or unknown anchor cert.
Definition: CBLBase.h:92
@ kCBLNetErrTLSClientCertRejected
Server rejected my TLS client certificate.
Definition: CBLBase.h:91
@ kCBLNetErrInvalidRedirect
Attempted redirect to invalid URL.
Definition: CBLBase.h:93
@ kCBLWebSocketDomain
code is a WebSocket close code (1000...1015) or HTTP error (300..599)
Definition: CBLBase.h:43
@ kCBLFleeceDomain
code is a Fleece error; see "FleeceException.h"
Definition: CBLBase.h:41
@ kCBLPOSIXDomain
code is a POSIX errno; see "errno.h"
Definition: CBLBase.h:39
@ kCBLDomain
code is a Couchbase Lite error code; see CBLErrorCode
Definition: CBLBase.h:38
@ kCBLSQLiteDomain
code is a SQLite error; see "sqlite3.h"
Definition: CBLBase.h:40
@ kCBLNetworkDomain
code is a network error; see CBLNetworkErrorCode
Definition: CBLBase.h:42
@ kCBLErrorTransactionNotClosed
Database can't be closed while a transaction is open.
Definition: CBLBase.h:65
@ kCBLErrorCantUpgradeDatabase
Definition: CBLBase.h:77
@ kCBLErrorNotOpen
Database/KeyStore/index is not open.
Definition: CBLBase.h:53
@ kCBLErrorAssertionFailed
Internal assertion failure.
Definition: CBLBase.h:48
@ kCBLErrorDatabaseTooNew
Database file format is newer than what I can open.
Definition: CBLBase.h:75
@ kCBLErrorBusy
Database is busy/locked.
Definition: CBLBase.h:63
@ kCBLErrorCrypto
Encryption/decryption error.
Definition: CBLBase.h:69
@ kCBLErrorCorruptData
Data is corrupted.
Definition: CBLBase.h:62
@ kCBLErrorRemoteError
Unknown error from remote server.
Definition: CBLBase.h:73
@ kCBLErrorConflict
Document update conflict.
Definition: CBLBase.h:55
@ kCBLErrorCorruptRevisionData
Revision contains corrupted/unreadable data.
Definition: CBLBase.h:52
@ kCBLErrorUnexpectedError
Definition: CBLBase.h:57
@ kCBLErrorBadDocID
Invalid document ID.
Definition: CBLBase.h:76
@ kCBLErrorNotADatabaseFile
Definition: CBLBase.h:67
@ kCBLErrorUnimplemented
Oops, an unimplemented API call.
Definition: CBLBase.h:49
@ kCBLErrorNotFound
Document not found.
Definition: CBLBase.h:54
@ kCBLErrorDatabaseTooOld
Database file format is older than what I can open.
Definition: CBLBase.h:74
@ kCBLErrorMissingIndex
No such index, or query requires a nonexistent index.
Definition: CBLBase.h:71
@ kCBLErrorCantOpenFile
Internal unexpected C++ exception.
Definition: CBLBase.h:58
@ kCBLErrorBadRevisionID
Invalid revision ID syntax.
Definition: CBLBase.h:51
@ kCBLErrorInvalidQuery
Invalid query.
Definition: CBLBase.h:70
@ kCBLErrorInvalidQueryParam
Unknown query param name, or param number out of range.
Definition: CBLBase.h:72
@ kCBLErrorIOError
File I/O error.
Definition: CBLBase.h:59
@ kCBLErrorNotInTransaction
Function must be called while in a transaction.
Definition: CBLBase.h:64
@ kCBLErrorMemoryError
Memory allocation failed (out of memory?)
Definition: CBLBase.h:60
@ kCBLErrorUnsupportedEncryption
Unsupported encryption algorithm.
Definition: CBLBase.h:50
@ kCBLErrorNotWriteable
File is not writeable.
Definition: CBLBase.h:61
@ kCBLErrorInvalidParameter
Invalid function parameter or struct value.
Definition: CBLBase.h:56
@ kCBLErrorUnsupported
Operation not supported in this database.
Definition: CBLBase.h:66
@ kCBLErrorWrongFormat
File is not a database, or encryption key is wrong.
Definition: CBLBase.h:68
void CBLListener_Remove(CBLListenerToken *_cbl_nullable)
Removes a listener callback, given the token that was returned when it was added.
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
int64_t CBLTimestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: CBLBase.h:123
CBLTimestamp CBL_Now(void)
Returns the current time, in milliseconds since 1/1/1970.
struct CBLQuery CBLQuery
A compiled database query.
Definition: CBLBase.h:203
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:206
struct CBLRefCounted CBLRefCounted
Definition: CBLBase.h:150
void CBL_Release(CBLRefCounted *_cbl_nullable)
Decrements an object's reference-count, freeing the object if the count hits zero.
CBLRefCounted * CBL_Retain(CBLRefCounted *_cbl_nullable)
Increments an object's reference-count.
void CBL_DumpInstances(void)
Logs the class and address of each Couchbase Lite object.
unsigned CBL_InstanceCount(void)
Returns the total number of Couchbase Lite objects.
struct CBLReplicator CBLReplicator
A background task that syncs a CBLDatabase with a remote server or peer.
Definition: CBLBase.h:212
A struct holding information about an error.
Definition: CBLBase.h:104
int code
Error code, specific to the domain. 0 always means no error.
Definition: CBLBase.h:106
CBLErrorDomain domain
Domain of errors; a namespace for the code.
Definition: CBLBase.h:105
unsigned internal_info
Definition: CBLBase.h:107
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:64