LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Database.h
Go to the documentation of this file.
1//
2// c4Database.h
3//
4// Copyright 2015-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14#include "c4DatabaseTypes.h"
15
18
21
22
24
27
28
38
49
50// Deprecated in favor of c4_enableExtension
52
64CBL_CORE_API bool c4_enableExtension(C4String name, C4String extensionPath, C4Error* outError) C4API;
65
67
69
70
73
76
77
81 C4Error* C4NULLABLE outError) C4API;
82
87
98NODISCARD CBL_CORE_API bool c4db_copyNamed(C4String sourcePath, C4String destinationName,
99 const C4DatabaseConfig2* config, C4Error* C4NULLABLE error) C4API;
100
105
111
117
118
123 C4Error* C4NULLABLE outError) C4API;
124
128
129
133
134
139
143
147
151 C4UUID* C4NULLABLE privateUUID, C4Error* C4NULLABLE outError) C4API;
152
160
164
165
169
170
175 C4Error* C4NULLABLE outError) C4API;
176
177
181
182
187
193
197
198
201
202
204
205
208
213 C4Error* C4NULLABLE outError) C4API;
214
218 C4String body, C4Error* C4NULLABLE outError) C4API;
219
220// Store used for database metadata.
221#define kC4InfoStore C4STR("info")
222
223// Store used for local (non-replicated) documents.
224#define kC4LocalDocStore C4STR("_local")
225
227
228
#define NODISCARD
Definition CompilerSupport.h:63
#define CBL_CORE_API
Definition c4Compat.h:131
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:106
#define C4_RETURNS_NONNULL
Definition c4Compat.h:40
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:108
#define C4API_BEGIN_DECLS
Definition c4Compat.h:107
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
C4Slice C4String
Definition c4Base.h:51
C4SliceResult C4StringResult
Definition c4Base.h:53
struct C4Database C4Database
Opaque handle to an opened database.
Definition c4Base.h:135
NODISCARD CBL_CORE_API C4Database * c4db_openNamed(C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
Opens a database given its name (without the ".cblite2" extension) and directory.
CBL_CORE_API C4StringResult c4db_getPath(C4Database *)
Returns the path of the database.
NODISCARD CBL_CORE_API bool c4db_maintenance(C4Database *database, C4MaintenanceType type, C4Error *outError)
Performs database maintenance.
NODISCARD CBL_CORE_API bool c4db_deleteNamed(C4String dbName, C4String inDirectory, C4Error *outError)
Deletes the file(s) for the database with the given name in the given directory.
NODISCARD CBL_CORE_API bool c4db_delete(C4Database *database, C4Error *outError)
Closes the database and deletes the file/bundle.
NODISCARD CBL_CORE_API bool c4db_copyNamed(C4String sourcePath, C4String destinationName, const C4DatabaseConfig2 *config, C4Error *error)
Copies a prebuilt database from the given source path and places it in the destination directory,...
NODISCARD CBL_CORE_API bool c4key_setPassword(C4EncryptionKey *encryptionKey, C4String password, C4EncryptionAlgorithm alg)
Stores a password into a C4EncryptionKey, by using the key-derivation algorithm PBKDF2 to securely co...
NODISCARD CBL_CORE_API C4Database * c4db_openAgain(C4Database *db, C4Error *outError)
Opens a new handle to the same database file as db.
CBL_CORE_API const C4DatabaseConfig2 * c4db_getConfig2(C4Database *database)
Returns the configuration the database was opened with.
NODISCARD CBL_CORE_API bool c4_shutdown(C4Error *outError)
Closes down the storage engines.
NODISCARD CBL_CORE_API bool c4db_beginTransaction(C4Database *database, C4Error *outError)
Begins a transaction.
CBL_CORE_API bool c4db_isInTransaction(C4Database *database)
Is a transaction active?
NODISCARD CBL_CORE_API bool c4db_getUUIDs(C4Database *database, C4UUID *publicUUID, C4UUID *privateUUID, C4Error *outError)
Returns the database's public and/or private UUIDs.
C4MaintenanceType
Definition c4DatabaseTypes.h:111
C4EncryptionAlgorithm
Definition c4DatabaseTypes.h:47
NODISCARD CBL_CORE_API bool c4db_close(C4Database *database, C4Error *outError)
Closes the database.
CBL_CORE_API C4String c4db_getName(C4Database *)
Returns the name of the database, as given to c4db_openNamed.
CBL_CORE_API void c4_setExtensionPath(C4String path)
NODISCARD CBL_CORE_API bool c4key_setPasswordSHA1(C4EncryptionKey *encryptionKey, C4String password, C4EncryptionAlgorithm alg)
Stores a password into a C4EncryptionKey, by using the key-derivation algorithm PBKDF2 to securely co...
CBL_CORE_API void c4db_setExtraInfo(C4Database *database, C4ExtraInfo)
Associates an arbitrary pointer with this database instance, for client use.
NODISCARD CBL_CORE_API bool c4db_endTransaction(C4Database *database, bool commit, C4Error *outError)
Commits or aborts a transaction.
CBL_CORE_API bool c4_enableExtension(C4String name, C4String extensionPath, C4Error *outError)
Asks LiteCore to look for and validate the presence of an extension given the name of the extension a...
NODISCARD CBL_CORE_API bool c4db_rekey(C4Database *database, const C4EncryptionKey *newKey, C4Error *outError)
Changes a database's encryption key (removing encryption if it's NULL.)
CBL_CORE_API bool c4db_exists(C4String name, C4String inDirectory)
Returns true if a database with the given name exists in the directory.
CBL_CORE_API C4ExtraInfo c4db_getExtraInfo(C4Database *database)
Returns the C4ExtraInfo associated with this db reference.
NODISCARD CBL_CORE_API C4RawDocument * c4raw_get(C4Database *database, C4String storeName, C4String docID, C4Error *outError)
Reads a raw document from the database.
NODISCARD CBL_CORE_API bool c4raw_put(C4Database *database, C4String storeName, C4String key, C4String meta, C4String body, C4Error *outError)
Writes a raw document to the database, or deletes it if both meta and body are NULL.
Main database configuration struct (version 2) for use with c4db_openNamed etc.
Definition c4DatabaseTypes.h:65
Encryption key specified in a C4DatabaseConfig.
Definition c4DatabaseTypes.h:59
An error value.
Definition c4Error.h:133
Client-defined metadata that can be associated with some objects like C4Database.
Definition c4Base.h:106
Contents of a raw document.
Definition c4DatabaseTypes.h:151
Definition c4DatabaseTypes.h:79