17# include "c4Document.hh"
34#define kC4GeneratedIDLength 23
43#ifndef C4_STRICT_COLLECTION_API
132 unsigned backToRevsCount)
C4API;
245#ifndef C4_STRICT_COLLECTION_API
289#ifndef C4_STRICT_COLLECTION_API
#define NODISCARD
Definition CompilerSupport.h:59
#define CBL_CORE_API
Definition c4Compat.h:134
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:114
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:116
#define C4API_BEGIN_DECLS
Definition c4Compat.h:115
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition c4Base.h:96
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition c4Base.h:91
struct C4Database C4Database
Opaque handle to an opened database.
Definition c4Base.h:136
NODISCARD CBL_CORE_API bool c4doc_loadRevisionBody(C4Document *doc, C4Error *outError)
Populates the body field of a doc's selected revision, if it was initially loaded without its body.
NODISCARD CBL_CORE_API bool c4doc_selectNextLeafRevision(C4Document *doc, bool includeDeleted, bool withBody, C4Error *outError)
Selects the next leaf revision; like selectNextRevision but skips over non-leaves.
CBL_CORE_API C4Document * c4doc_put(C4Database *database, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
A high-level Put operation, to insert a new or downloaded revision.
NODISCARD CBL_CORE_API bool c4doc_selectParentRevision(C4Document *doc)
Selects the parent of the selected revision, if it's known, else returns false.
CBL_CORE_API bool c4doc_setExpiration(C4Database *db, C4String docID, C4Timestamp timestamp, C4Error *outError)
Sets an expiration date on a document.
NODISCARD CBL_CORE_API bool c4doc_setRemoteAncestor(C4Document *doc, C4RemoteID remoteDatabase, C4String revID, C4Error *error)
Marks a revision as current for the given remote database.
CBL_CORE_API C4Document * c4doc_update(C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
Adds a revision to a document already in memory as a C4Document.
CBL_CORE_API char * c4doc_generateID(char *buffer, size_t bufferSize)
Generates a random 23-byte C string suitable for use as a unique new document ID.
CBL_CORE_API C4SliceResult c4doc_getSelectedRevIDGlobalForm(C4Document *doc)
Returns the selected revision's ID in a form that will make sense to another peer/server.
CBL_CORE_API unsigned c4rev_getGeneration(C4String revID)
Given a tree-based revision ID, returns its generation number (the decimal number before the hyphen),...
CBL_CORE_API bool c4db_purgeDoc(C4Database *database, C4String docID, C4Error *outError)
Removes all trace of a document and its revisions from the database.
CBL_CORE_API C4RemoteID c4db_getRemoteDBID(C4Database *db, C4String remoteAddress, bool canCreate, C4Error *outError)
Looks up or creates a numeric ID identifying a remote database, for use with c4doc_getRemoteAncestor(...
NODISCARD CBL_CORE_API bool c4doc_selectNextRevision(C4Document *doc)
Selects the next revision in priority order.
NODISCARD CBL_CORE_API bool c4doc_save(C4Document *doc, uint32_t maxRevTreeDepth, C4Error *outError)
Saves changes to a C4Document.
NODISCARD CBL_CORE_API int32_t c4doc_purgeRevision(C4Document *doc, C4String revID, C4Error *outError)
Removes a branch from a document's history.
CBL_CORE_API C4Document * c4doc_create(C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
NODISCARD CBL_CORE_API C4Document * c4doc_get(C4Database *database, C4String docID, bool mustExist, C4Error *outError)
Gets a document from the database given its ID (semi-deprecated).
CBL_CORE_API C4SliceResult c4doc_getRemoteAncestor(C4Document *doc, C4RemoteID remoteDatabase)
Returns the revision ID that has been marked as current for the given remote database.
CBL_CORE_API C4SliceResult c4db_getRemoteDBAddress(C4Database *db, C4RemoteID remoteID)
Given a remote database ID, returns its replication URL / unique identifier.
NODISCARD CBL_CORE_API C4Document * c4doc_getBySequence(C4Database *database, C4SequenceNumber, C4Error *outError)
Gets a document from the database given its sequence number.
CBL_CORE_API bool c4doc_hasRevisionBody(C4Document *doc)
Returns true if the body of the selected revision is available, i.e.
CBL_CORE_API bool c4doc_isRevRejected(C4Document *doc)
NODISCARD CBL_CORE_API bool c4doc_selectCommonAncestorRevision(C4Document *doc, C4String rev1ID, C4String rev2ID)
Selects the common ancestor of two revisions.
CBL_CORE_API bool c4rev_equal(C4Slice rev1, C4Slice rev2)
Returns true if two revision IDs are equivalent.
CBL_CORE_API bool c4doc_selectCurrentRevision(C4Document *doc)
Selects the current revision of a document.
NODISCARD CBL_CORE_API bool c4doc_resolveConflict(C4Document *doc, C4String winningRevID, C4String losingRevID, C4Slice mergedBody, C4RevisionFlags mergedFlags, C4Error *error)
Resolves a conflict between two leaf revisions, by deleting one of them and optionally adding a new m...
CBL_CORE_API C4Slice c4doc_getRevisionBody(C4Document *doc)
Returns the body (encoded Fleece data) of the selected revision, if available.
NODISCARD CBL_CORE_API C4Document * c4db_getDoc(C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the database given its ID.
C4DocContentLevel
Definition c4DocumentTypes.h:50
uint32_t C4RemoteID
Identifies a remote database being replicated with.
Definition c4DocumentTypes.h:46
CBL_CORE_API uint64_t c4rev_getTimestamp(C4String revID)
Given a revision ID that's a Version (of the form time@peer), returns its timestamp.
CBL_CORE_API C4SliceResult c4doc_getRevisionHistory(C4Document *doc, unsigned maxRevs, const C4String backToRevs[], unsigned backToRevsCount)
Returns a string encoding the selected revision's history, as comma-separate revision/version IDs in ...
NODISCARD CBL_CORE_API bool c4doc_selectRevision(C4Document *doc, C4String revID, bool withBody, C4Error *outError)
Selects a specific revision of a document (or no revision, if revID is NULL.)
C4RevisionFlags
Definition c4DocumentTypes.h:33
CBL_CORE_API C4Timestamp c4doc_getExpiration(C4Database *db, C4String docID, C4Error *outError)
Returns the expiration time of a document, if one has been set, else 0.
Parameters for adding a revision using c4doc_put.
Definition c4DocumentTypes.h:88
Describes a version-controlled document.
Definition c4DocumentStruct.h:32
An error value.
Definition c4Error.h:133
A simple reference to a block of memory.
Definition FLSlice.h:45
A heap-allocated block of memory returned from an API call.
Definition FLSlice.h:63