diff --git a/C/Cpp_include/c4.hh b/C/Cpp_include/c4.hh index dea2b0e7d5..5820bd90ae 100644 --- a/C/Cpp_include/c4.hh +++ b/C/Cpp_include/c4.hh @@ -33,3 +33,4 @@ #include "c4Query.hh" #include "c4Replicator.hh" #include "c4Socket.hh" +#include "c4ConnectedClient.hh" diff --git a/C/Cpp_include/c4ConnectedClient.hh b/C/Cpp_include/c4ConnectedClient.hh new file mode 100644 index 0000000000..1dd88a9a68 --- /dev/null +++ b/C/Cpp_include/c4ConnectedClient.hh @@ -0,0 +1,125 @@ +// +// c4ConnectedClient.hh +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#pragma once +#include "c4Base.hh" +#include "Async.hh" +#include "c4ConnectedClientTypes.h" +#include "fleece/Fleece.h" + +C4_ASSUME_NONNULL_BEGIN + +struct C4ConnectedClient : public fleece::RefCounted, + public fleece::InstanceCountedIn, + C4Base +{ + /// Creates a new ConnectedClient + /// \note It will automatically starts the client, no need to call `start()`. + /// + /// @param params Connected Client parameters. + /// @result A new \ref C4ConnectedClient, or NULL on failure. + static Retained newClient(const C4ConnectedClientParameters ¶ms); + + /// The current connection status. + virtual litecore::actor::Async getStatus() const =0; + + /// The HTTP response headers. + virtual alloc_slice getResponseHeaders() const noexcept =0; + +#ifdef COUCHBASE_ENTERPRISE + /// The server's TLS certificate. + virtual C4Cert* C4NULLABLE getPeerTLSCertificate() const =0; +#endif + + /// Result of a successful `getDoc()` call. + struct DocResponse { + alloc_slice docID, revID, body; + bool deleted; + }; + + /// Gets the current revision of a document from the server. + /// You can set the `unlessRevID` parameter to avoid getting a redundant copy of a + /// revision you already have. + /// @param docID The document ID. + /// @param collectionID The name of the document's collection, or `nullslice` for default. + /// @param unlessRevID If non-null, and equal to the current server-side revision ID, + /// the server will return error {WebSocketDomain, 304}. + /// @param asFleece If true, the response's `body` field is Fleece; if false, it's JSON. + /// @result An async value that, when resolved, contains either a `DocResponse` struct + /// or a C4Error. + virtual litecore::actor::Async getDoc(slice docID, + slice collectionID, + slice unlessRevID, + bool asFleece)=0; + + /// Pushes a new document revision to the server. + /// @param docID The document ID. + /// @param collectionID The name of the document's collection, or `nullslice` for default. + /// @param parentRevID The ID of the parent revision on the server, + /// or `nullslice` if this is a new document. + /// @param revisionFlags Flags of this revision. + /// @param fleeceData The document body encoded as Fleece (without shared keys!) + /// @return An async value that, when resolved, contains new revisionID or the status as a C4Error + virtual litecore::actor::Async putDoc(slice docID, + slice collectionID, + slice parentRevID, + C4RevisionFlags revisionFlags, + slice fleeceData)=0; + + /// Callback for \ref getAllDocIDs. + /// @param ids A vector of docIDs; empty on the final call. + /// @param error NULL or a pointer to an error. + using AllDocsReceiver = std::function& ids, + const C4Error* C4NULLABLE error)>; + + /// Requests a list of all document IDs, or optionally only those matching a pattern. + /// The docIDs themselves are passed to a callback. + /// The callback will be called zero or more times with a non-empty vector of docIDs, + /// then once with an empty vector and an optional error. + /// @param collectionID The ID of the collection to observe. + /// @param globPattern Either `nullslice` or a glob-style pattern string (with `*` or + /// `?` wildcards) for docIDs to match. + /// @param callback The callback to receive the docIDs. + virtual void getAllDocIDs(slice collectionID, + slice globPattern, + AllDocsReceiver callback) =0; + + /// Callback for \ref query. + /// @param rowJSON A row of the result, encoded as a JSON object. + /// On the final call, will be `nullslice`. + /// @param rowDict The row parsed as a Fleece Dict, if you requested it. + /// @param error NULL or, on the final call, a pointer to an error. + using QueryReceiver = std::function; + + /// Runs a query on the server and gets the results. + /// The callback will be called one or more times; see its documentation for details. + /// @param name The name by which the query has been registered on the server; + /// or a full query string beginning with "SELECT " or "{". + /// @param parameters A Dict mapping query parameter names to values. + /// @param rowsAsFleece True if you want the rows to be Fleece-encoded, false for JSON. + /// @param receiver A callback that will be invoked for each row of the result, + /// and/or if there's an error. + virtual void query(slice name, + FLDict C4NULLABLE parameters, + bool rowsAsFleece, + QueryReceiver receiver) =0; + + /// Tells a connected client to start. + virtual void start()=0; + + /// Tells a replicator to stop. + virtual void stop()=0; +}; + +C4_ASSUME_NONNULL_END diff --git a/C/Cpp_include/c4Document.hh b/C/Cpp_include/c4Document.hh index 5a82ec968f..8d1a5cdca0 100644 --- a/C/Cpp_include/c4Document.hh +++ b/C/Cpp_include/c4Document.hh @@ -146,12 +146,6 @@ struct C4Document : public fleece::RefCounted, /// Returns the Document instance, if any, that contains the given Fleece value. static C4Document* C4NULLABLE containingValue(FLValue) noexcept; - static bool isOldMetaProperty(slice propertyName) noexcept; - static bool hasOldMetaProperties(FLDict) noexcept; - - static alloc_slice encodeStrippingOldMetaProperties(FLDict properties, - FLSharedKeys); - // Special property names & values: /** The Dict property that identifies it as a special type of object. diff --git a/C/Cpp_include/c4EnumUtil.hh b/C/Cpp_include/c4EnumUtil.hh index 8952a8ba28..9032500f07 100644 --- a/C/Cpp_include/c4EnumUtil.hh +++ b/C/Cpp_include/c4EnumUtil.hh @@ -11,6 +11,7 @@ // #pragma once +#include "c4Compat.h" #include /// Declares `++` and `--` functions for an `enum class`. diff --git a/C/Doxyfile b/C/Doxyfile index 6b231b3c25..3f909e3834 100644 --- a/C/Doxyfile +++ b/C/Doxyfile @@ -597,7 +597,7 @@ SORT_MEMBERS_CTORS_1ST = NO # appear in their defined order. # The default value is: NO. -SORT_GROUP_NAMES = NO +SORT_GROUP_NAMES = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will @@ -2039,6 +2039,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = DOXYGEN_PARSING=1 \ C4API= \ + C4API_BEGIN_DECLS= \ C4NULLABLE= \ C4NONNULL= \ C4_RETURNS_NONNULL= \ diff --git a/C/DoxygenDependencies.txt b/C/DoxygenDependencies.txt index 6ce57b9b12..4d683109ee 100644 --- a/C/DoxygenDependencies.txt +++ b/C/DoxygenDependencies.txt @@ -1,19 +1,27 @@ -$(SRCROOT)/../C/include/c4.h +$(SRCROOT)/../C/Doxyfile $(SRCROOT)/../C/include/c4Base.h $(SRCROOT)/../C/include/c4BlobStore.h +$(SRCROOT)/../C/include/c4BlobStoreTypes.h $(SRCROOT)/../C/include/c4Certificate.h +$(SRCROOT)/../C/include/c4CertificateTypes.h $(SRCROOT)/../C/include/c4Collection.h $(SRCROOT)/../C/include/c4Compat.h +$(SRCROOT)/../C/include/c4ConnectedClient.h +$(SRCROOT)/../C/include/c4ConnectedClientTypes.h $(SRCROOT)/../C/include/c4Database.h $(SRCROOT)/../C/include/c4DatabaseTypes.h $(SRCROOT)/../C/include/c4DocEnumerator.h $(SRCROOT)/../C/include/c4DocEnumeratorTypes.h $(SRCROOT)/../C/include/c4Document+Fleece.h $(SRCROOT)/../C/include/c4Document.h +$(SRCROOT)/../C/include/c4DocumentStruct.h $(SRCROOT)/../C/include/c4DocumentTypes.h +$(SRCROOT)/../C/include/c4Error.h $(SRCROOT)/../C/include/c4Index.h $(SRCROOT)/../C/include/c4IndexTypes.h $(SRCROOT)/../C/include/c4Listener.h +$(SRCROOT)/../C/include/c4ListenerTypes.h +$(SRCROOT)/../C/include/c4Log.h $(SRCROOT)/../C/include/c4Observer.h $(SRCROOT)/../C/include/c4PredictiveQuery.h $(SRCROOT)/../C/include/c4Query.h @@ -21,3 +29,4 @@ $(SRCROOT)/../C/include/c4QueryTypes.h $(SRCROOT)/../C/include/c4Replicator.h $(SRCROOT)/../C/include/c4ReplicatorTypes.h $(SRCROOT)/../C/include/c4Socket.h +$(SRCROOT)/../C/include/c4SocketTypes.h diff --git a/C/c4.exp b/C/c4.exp index d61706e233..b17fd8bba7 100644 --- a/C/c4.exp +++ b/C/c4.exp @@ -417,5 +417,11 @@ _FLDictIterator_End _FLValue_IsEqual _FLValue_ToJSON5 +_c4client_new +_c4client_getDoc +_c4client_start +_c4client_stop +_c4client_putDoc + # Apple specific _FLEncoder_WriteNSObject diff --git a/C/c4CAPI.cc b/C/c4CAPI.cc index cac104cb2a..ed47123d90 100644 --- a/C/c4CAPI.cc +++ b/C/c4CAPI.cc @@ -21,6 +21,7 @@ #include "c4Query.hh" #include "c4QueryImpl.hh" #include "c4Replicator.hh" +#include "LegacyAttachments.hh" #include "c4.h" #include "c4Private.h" @@ -1102,12 +1103,12 @@ FLSharedKeys c4db_getFLSharedKeys(C4Database *db) noexcept { bool c4doc_isOldMetaProperty(C4String prop) noexcept { - return C4Document::isOldMetaProperty(prop); + return legacy_attachments::isOldMetaProperty(prop); } bool c4doc_hasOldMetaProperties(FLDict doc) noexcept { - return C4Document::hasOldMetaProperties(doc); + return legacy_attachments::hasOldMetaProperties(doc); } @@ -1152,7 +1153,7 @@ bool c4doc_blobIsCompressible(FLDict blobDict) { C4SliceResult c4doc_encodeStrippingOldMetaProperties(FLDict doc, FLSharedKeys sk, C4Error *outError) noexcept { return tryCatch(outError, [&]{ - return C4SliceResult(C4Document::encodeStrippingOldMetaProperties(doc, sk)); + return C4SliceResult(legacy_attachments::encodeStrippingOldMetaProperties(doc, sk)); }); } diff --git a/C/c4Document.cc b/C/c4Document.cc index ca6473d52a..a06c31086b 100644 --- a/C/c4Document.cc +++ b/C/c4Document.cc @@ -361,19 +361,3 @@ C4RevisionFlags C4Document::revisionFlagsFromDocFlags(C4DocumentFlags docFlags) C4Document* C4Document::containingValue(FLValue value) noexcept { return C4Collection::documentContainingValue(value); } - - -bool C4Document::isOldMetaProperty(slice propertyName) noexcept { - return legacy_attachments::isOldMetaProperty(propertyName); -} - - -bool C4Document::hasOldMetaProperties(FLDict dict) noexcept { - return legacy_attachments::hasOldMetaProperties((const fleece::impl::Dict*)dict); -} - - -alloc_slice C4Document::encodeStrippingOldMetaProperties(FLDict properties, FLSharedKeys sk) { - return legacy_attachments::encodeStrippingOldMetaProperties((const fleece::impl::Dict*)properties, - (fleece::impl::SharedKeys*)sk); -} diff --git a/C/c4Error.cc b/C/c4Error.cc index 46d670c483..71943a9f96 100644 --- a/C/c4Error.cc +++ b/C/c4Error.cc @@ -225,31 +225,30 @@ C4Error C4Error::fromException(const exception &x) noexcept { __cold C4Error C4Error::fromCurrentException() noexcept { - // This rigamarole recovers the current exception being thrown... - auto xp = std::current_exception(); - if (xp) { - try { - std::rethrow_exception(xp); - } catch(const std::exception& x) { - // Now we have the exception, so we can record it in outError: - return C4Error::fromException(x); - } catch (...) { } + return fromException(error::convertCurrentException()); +} + + +static string getMessage(const C4Error &c4err) { + auto info = ErrorTable::instance().copy(c4err); + return info ? info->message : ""; +} + + +namespace litecore { + // Declared in Error.hh + error::error(const C4Error &c4err) + :error(error::Domain(c4err.domain), c4err.code, getMessage(c4err)) + { + if (auto info = ErrorTable::instance().copy(c4err)) + backtrace = info->backtrace; } - return ErrorTable::instance().makeError( - LiteCoreDomain, kC4ErrorUnexpectedError, - {"Unknown C++ exception", Backtrace::capture(1)}); } [[noreturn]] __cold void C4Error::raise() const { - if (auto info = ErrorTable::instance().copy(*this); info) { - error e(error::Domain(domain), code, info->message); - e.backtrace = info->backtrace; - throw e; - } else { - error::_throw(error::Domain(domain), code); - } + throw litecore::error(*this); } diff --git a/C/c4_ee.exp b/C/c4_ee.exp index b28b7484fc..157c55c93c 100644 --- a/C/c4_ee.exp +++ b/C/c4_ee.exp @@ -458,6 +458,12 @@ _FLDictIterator_End _FLValue_IsEqual _FLValue_ToJSON5 +_c4client_new +_c4client_getDoc +_c4client_start +_c4client_stop +_c4client_putDoc + _c4db_URINameFromPath diff --git a/C/include/c4.h b/C/include/c4.h index b8e262d2c3..2c3b517e52 100644 --- a/C/include/c4.h +++ b/C/include/c4.h @@ -25,3 +25,4 @@ #include "c4Query.h" #include "c4Replicator.h" #include "c4Socket.h" +#include "c4ConnectedClient.h" diff --git a/C/include/c4Base.h b/C/include/c4Base.h index 291f5f07b3..2ce613d088 100644 --- a/C/include/c4Base.h +++ b/C/include/c4Base.h @@ -27,10 +27,10 @@ C4API_BEGIN_DECLS // Corresponds to Couchbase Lite product version number, with 2 digits for minor and patch versions. // i.e. `10000 * MajorVersion + 100 * MinorVersion + PatchVersion` -#define LITECORE_VERSION 30000 +#define LITECORE_VERSION 30100 // This number has no absolute meaning but is bumped whenever the LiteCore public API changes. -#define LITECORE_API_VERSION 351 +#define LITECORE_API_VERSION 352 /** \defgroup Base Data Types and Base Functions @@ -117,6 +117,9 @@ typedef struct C4Cert C4Cert; /** Opaque handle to a namespace of documents in an opened database. */ typedef struct C4Collection C4Collection; +/** Opaque reference to a Connected Client. */ +typedef struct C4ConnectedClient C4ConnectedClient; + /** A collection-observer reference. */ typedef struct C4CollectionObserver C4CollectionObserver; @@ -182,6 +185,8 @@ static inline C4Cert* C4NULLABLE c4cert_retain(C4Cert* C4NULLABLE r) C4API {return (C4Cert*)c4base_retain(r);} static inline C4Collection* C4NULLABLE c4coll_retain(C4Collection* C4NULLABLE r) C4API {return (C4Collection*)c4base_retain(r);} +static inline C4ConnectedClient* C4NULLABLE + c4client_retain(C4ConnectedClient* C4NULLABLE r) C4API {return (C4ConnectedClient*)c4base_retain(r);} static inline C4Database* C4NULLABLE c4db_retain(C4Database* C4NULLABLE r) C4API {return (C4Database*)c4base_retain(r);} static inline C4KeyPair* C4NULLABLE @@ -197,6 +202,7 @@ CBL_CORE_API C4Socket* C4NULLABLE c4socket_retain(C4Socket* C4NULLABLE) C4API; static inline void c4cert_release (C4Cert* C4NULLABLE r) C4API {c4base_release(r);} +static inline void c4client_release (C4ConnectedClient* C4NULLABLE r) C4API {c4base_release(r);} static inline void c4coll_release (C4Collection* C4NULLABLE r) C4API {c4base_release(r);} static inline void c4db_release (C4Database* C4NULLABLE r) C4API {c4base_release(r);} static inline void c4keypair_release(C4KeyPair* C4NULLABLE r) C4API {c4base_release(r);} diff --git a/C/include/c4ConnectedClient.h b/C/include/c4ConnectedClient.h new file mode 100644 index 0000000000..781bbf0db4 --- /dev/null +++ b/C/include/c4ConnectedClient.h @@ -0,0 +1,85 @@ +// +// c4ConnectedClient.h +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#pragma once +#include "c4ConnectedClientTypes.h" + +C4_ASSUME_NONNULL_BEGIN +C4API_BEGIN_DECLS + +/** \defgroup ConnectedClient Connected Client (Remote Database) + @{ + The Connected Client API allows you to get and put documents, and listen for changes, + directly on a remote database server (Sync Gateway or a Couchbase Lite sync listener), + without any local database. */ + +/** Creates a new connected client and starts it automatically. + \note No need to call \ref c4client_start. + + @param params Connected Client parameters. + @param error Error will be written here if the function fails. + @result A new \ref C4ConnectedClient, or NULL on failure. */ +C4ConnectedClient* c4client_new(const C4ConnectedClientParameters* params, + C4Error* C4NULLABLE error) C4API; + +/** Gets the current revision of a document from the server. + You can set the `unlessRevID` parameter to avoid getting a redundant copy of a + revision you already have. + @param docID The document ID. + @param collectionID The name of the document's collection, or `nullslice` for default. + @param unlessRevID If non-null, and equal to the current server-side revision ID, + the server will return error {WebSocketDomain, 304}. + @param asFleece If true, the response's `body` field is Fleece; if false, it's JSON. + @param callback Callback for getting document. + @param context Client value passed to getDocument callback + @param outError On failure, the error info will be stored here. */ +bool c4client_getDoc(C4ConnectedClient*, + C4Slice docID, + C4Slice collectionID, + C4Slice unlessRevID, + bool asFleece, + C4ConnectedClientGetDocumentCallback callback, + void * C4NULLABLE context, + C4Error* C4NULLABLE outError) C4API; + +/** Pushes a new document revision to the server. + @param docID The document ID. + @param collectionID The name of the document's collection, or `nullslice` for default. + @param revID The ID of the parent revision on the server, + or `nullslice` if this is a new document. + @param revisionFlags Flags of this revision. + @param fleeceData The document body encoded as Fleece (without shared keys!) + @param callback Callback once the document is updated. + @param context Client value passed to updateDocument callback + @param outError On failure, the error info will be stored here. */ +bool c4client_putDoc(C4ConnectedClient* client, + C4Slice docID, + C4Slice collectionID, + C4Slice revID, + C4RevisionFlags revisionFlags, + C4Slice fleeceData, + C4ConnectedClientUpdateDocumentCallback callback, + void * C4NULLABLE context, + C4Error* C4NULLABLE outError) C4API; + +/** Tells a connected client to start. + \note This function is thread-safe.*/ +void c4client_start(C4ConnectedClient*) C4API; + +/** Tells a replicator to stop. + \note This function is thread-safe. */ +void c4client_stop(C4ConnectedClient*) C4API; + +/** @} */ + +C4API_END_DECLS +C4_ASSUME_NONNULL_END diff --git a/C/include/c4ConnectedClientTypes.h b/C/include/c4ConnectedClientTypes.h new file mode 100644 index 0000000000..59171ee7ae --- /dev/null +++ b/C/include/c4ConnectedClientTypes.h @@ -0,0 +1,72 @@ +// +// c4ConnectedClientTypes.h +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#pragma once +#include "c4ReplicatorTypes.h" + +C4_ASSUME_NONNULL_BEGIN +C4API_BEGIN_DECLS + +/** \defgroup ConnectedClient Connected Client (Remote Database) + @{ */ + +/** Result of a successful \ref c4client_getDoc call. */ +typedef struct C4DocResponse { + C4HeapSlice docID; ///< The document ID + C4HeapSlice revID; ///< The revision ID + C4HeapSlice body; ///< The document body (Fleece or JSON, as requested) + bool deleted; ///< True if the document is deleted +} C4DocResponse; + + +typedef C4ReplicatorStatus C4ConnectedClientStatus; + +/** Callback a client can register, to get status information. + This will be called on arbitrary background threads, and should not block. */ +typedef void (*C4ConnectedClientStatusChangedCallback)(C4ConnectedClient*, + C4ConnectedClientStatus, + void * C4NULLABLE context); + + +/** Parameters describing a connected client, used when creating a \ref C4ConnectedClient. */ +typedef struct C4ConnectedClientParameters { + C4Slice url; ///N1QL) + #define kC4ReplicatorOptionAllQueries "allQueries" ///< Allow any N1QL query? (bool) + // [1]: Auth dictionary keys: #define kC4ReplicatorAuthType "type" ///< Auth type; see [2] (string) #define kC4ReplicatorAuthUserName "username" ///< User name for basic auth (string) diff --git a/C/scripts/c4.txt b/C/scripts/c4.txt index 418d03c214..9e40a543f6 100644 --- a/C/scripts/c4.txt +++ b/C/scripts/c4.txt @@ -424,3 +424,9 @@ FLDictIterator_End FLValue_IsEqual FLValue_ToJSON5 + +c4client_new +c4client_getDoc +c4client_start +c4client_stop +c4client_putDoc diff --git a/C/tests/c4CppUtils.hh b/C/tests/c4CppUtils.hh index e65f460515..274896c84e 100644 --- a/C/tests/c4CppUtils.hh +++ b/C/tests/c4CppUtils.hh @@ -30,6 +30,7 @@ namespace c4 { static inline void releaseRef(C4Cert* c) noexcept {c4cert_release(c);} static inline void releaseRef(C4Database* c) noexcept {c4db_release(c);} static inline void releaseRef(C4CollectionObserver* c)noexcept {c4dbobs_free(c);} + static inline void releaseRef(C4ConnectedClient* c) noexcept {c4client_release(c);} static inline void releaseRef(C4DocEnumerator* c) noexcept {c4enum_free(c);} static inline void releaseRef(C4Document* c) noexcept {c4doc_release(c);} static inline void releaseRef(C4DocumentObserver* c) noexcept {c4docobs_free(c);} @@ -45,6 +46,7 @@ namespace c4 { // The functions the ref<> template calls to retain a reference. (Not all types can be retained) static inline C4Cert* retainRef(C4Cert* c) noexcept {return c4cert_retain(c);} + static inline C4ConnectedClient* retainRef(C4ConnectedClient* c) noexcept {return c4client_retain(c);} static inline C4Database* retainRef(C4Database* c) noexcept {return c4db_retain(c);} static inline C4Document* retainRef(C4Document* c) noexcept {return c4doc_retain(c);} static inline C4KeyPair* retainRef(C4KeyPair* c) noexcept {return c4keypair_retain(c);} diff --git a/C/tests/c4Test.cc b/C/tests/c4Test.cc index be87249b7a..df06b4e601 100644 --- a/C/tests/c4Test.cc +++ b/C/tests/c4Test.cc @@ -624,6 +624,7 @@ unsigned C4Test::importJSONLines(string path, C4Collection *collection, fleece::Stopwatch st; auto database = c4coll_getDatabase(collection); + uint64_t docCount = c4coll_getDocumentCount(collection); unsigned numDocs = 0; bool completed; { @@ -634,7 +635,7 @@ unsigned C4Test::importJSONLines(string path, C4Collection *collection, REQUIRE(body.buf); char docID[20]; - sprintf(docID, "%07u", numDocs+1); + sprintf(docID, "%07u", unsigned(docCount+1)); // Save document: C4DocPutRequest rq = {}; @@ -645,6 +646,7 @@ unsigned C4Test::importJSONLines(string path, C4Collection *collection, REQUIRE(doc != nullptr); c4doc_release(doc); ++numDocs; + ++docCount; if (numDocs % 1000 == 0 && timeout > 0.0 && st.elapsed() >= timeout) { C4Warn("Stopping JSON import after %.3f sec ", st.elapsed()); return false; @@ -657,7 +659,7 @@ unsigned C4Test::importJSONLines(string path, C4Collection *collection, } if (verbose) st.printReport("Importing", numDocs, "doc"); if (completed) - CHECK(c4coll_getDocumentCount(collection) == numDocs); + CHECK(c4coll_getDocumentCount(collection) == docCount); return numDocs; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 2df7cf282f..5f101600d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,7 @@ target_include_directories( Networking/HTTP Networking/WebSockets Replicator + Replicator/ConnectedClient REST vendor/SQLiteCpp/include vendor/sqlite3-unicodesn diff --git a/LiteCore/Database/DocumentFactory.hh b/LiteCore/Database/DocumentFactory.hh index 5690199005..dd1269222e 100644 --- a/LiteCore/Database/DocumentFactory.hh +++ b/LiteCore/Database/DocumentFactory.hh @@ -15,6 +15,7 @@ #include "c4DocumentTypes.h" #include "Record.hh" #include +#include "RevID.hh" C4_ASSUME_NONNULL_BEGIN @@ -40,7 +41,6 @@ namespace litecore { unsigned maxAncestors, bool mustHaveBodies, C4RemoteID remoteDBID) =0; - private: C4Collection* const _coll; // Unretained, to avoid ref-cycle }; diff --git a/LiteCore/Database/LegacyAttachments.cc b/LiteCore/Database/LegacyAttachments.cc index 658af9dcbd..329f55dbe9 100644 --- a/LiteCore/Database/LegacyAttachments.cc +++ b/LiteCore/Database/LegacyAttachments.cc @@ -17,6 +17,8 @@ #include #include +// Note: Some of the functions in LegacyAttachments.hh are implemented in LegacyAttachments2.cc. + namespace litecore { namespace legacy_attachments { using namespace std; using namespace fleece; @@ -29,8 +31,8 @@ namespace litecore { namespace legacy_attachments { // Returns true if a Fleece Dict contains any top-level keys that begin with an underscore. - bool hasOldMetaProperties(const Dict* root) { - for (Dict::iterator i(root); i; ++i) { + bool hasOldMetaProperties(FLDict root) { + for (Dict::iterator i((const Dict*)root); i; ++i) { if (isOldMetaProperty(i.keyString())) return true; } @@ -38,7 +40,9 @@ namespace litecore { namespace legacy_attachments { } - alloc_slice encodeStrippingOldMetaProperties(const Dict *root, SharedKeys *sk) { + alloc_slice encodeStrippingOldMetaProperties(FLDict fl_root, FLSharedKeys fl_sk) { + auto root = (const Dict*)fl_root; + auto sk = (SharedKeys*)fl_sk; if (!root) return {}; diff --git a/LiteCore/Database/LegacyAttachments.hh b/LiteCore/Database/LegacyAttachments.hh index 1b305065fd..d6c3a2d06a 100644 --- a/LiteCore/Database/LegacyAttachments.hh +++ b/LiteCore/Database/LegacyAttachments.hh @@ -11,34 +11,42 @@ // #pragma once -#include "c4Compat.h" +#include "c4Base.h" +#include "fleece/function_ref.hh" #include "fleece/slice.hh" +#include "fleece/Fleece.h" C4_ASSUME_NONNULL_BEGIN -namespace fleece::impl { - class Dict; - class SharedKeys; -} +/** Utilities for dealing with 'legacy' properties like _id, _rev, _deleted, _attachments. */ +namespace litecore::legacy_attachments { -namespace litecore { + /** Returns true if this is the name of a 1.x metadata property ("_id", "_rev", etc.) */ + bool isOldMetaProperty(fleece::slice key); - /** Utilities for dealing with 'legacy' properties like _id, _rev, _deleted, _attachments. */ - namespace legacy_attachments { + /** Returns true if the document contains 1.x metadata properties (at top level). */ + bool hasOldMetaProperties(FLDict root); - /** Returns true if this is the name of a 1.x metadata property ("_id", "_rev", etc.) */ - bool isOldMetaProperty(fleece::slice key); + /** Encodes to Fleece, without any 1.x metadata properties. + The _attachments property is treated specially, in that any entries in it that don't + appear elsewhere in the dictionary as blobs are preserved. */ + fleece::alloc_slice encodeStrippingOldMetaProperties(FLDict root, + FLSharedKeys C4NULLABLE); - /** Returns true if the document contains 1.x metadata properties (at top level). */ - bool hasOldMetaProperties(const fleece::impl::Dict* root); + using FindBlobCallback = fleece::function_ref; - /** Encodes to Fleece, without any 1.x metadata properties. - The _attachments property is treated specially, in that any entries in it that don't - appear elsewhere in the dictionary as blobs are preserved. */ - fleece::alloc_slice encodeStrippingOldMetaProperties(const fleece::impl::Dict* root, - fleece::impl::SharedKeys* C4NULLABLE); - } + /** Finds all blob references in the dict, at any depth. */ + void findBlobReferences(FLDict root, + bool unique, + const FindBlobCallback &callback, + bool attachmentsOnly =false); + /** Writes `root` to the encoder, transforming blobs into old-school `_attachments` dict */ + void encodeRevWithLegacyAttachments(FLEncoder enc, + FLDict root, + unsigned revpos); } C4_ASSUME_NONNULL_END diff --git a/LiteCore/Database/LegacyAttachments2.cc b/LiteCore/Database/LegacyAttachments2.cc new file mode 100644 index 0000000000..401760f151 --- /dev/null +++ b/LiteCore/Database/LegacyAttachments2.cc @@ -0,0 +1,134 @@ +// +// LegacyAttachments2.cc +// +// Copyright © 2022 Couchbase. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "LegacyAttachments.hh" +#include "c4BlobStore.hh" +#include "c4Document.hh" +#include "fleece/Fleece.hh" +#include + +// This source file is separate from LegacyAttachments.cc because, for historical reasons, those +// functions are implemented with the fleece::impl API while the ones here use the public Fleece +// API, and the two APIs don't mix well in a single source file. + +namespace litecore::legacy_attachments { + using namespace std; + using namespace fleece; + + + static bool isBlobOrAttachment(FLDeepIterator i, C4BlobKey *blobKey, bool attachmentsOnly) { + auto dict = FLValue_AsDict(FLDeepIterator_GetValue(i)); + if (!dict) + return false; + + // Get the digest: + if (auto key = C4Blob::keyFromDigestProperty(dict); key) + *blobKey = *key; + else + return false; + + // Check if it's a blob: + if (!attachmentsOnly && C4Blob::isBlob(dict)) { + return true; + } else { + // Check if it's an old-school attachment, i.e. in a top level "_attachments" dict: + FLPathComponent* path; + size_t depth; + FLDeepIterator_GetPath(i, &path, &depth); + return depth == 2 && path[0].key == C4Blob::kLegacyAttachmentsProperty; + } + } + + + void findBlobReferences(FLDict root, + bool unique, + const FindBlobCallback &callback, + bool attachmentsOnly) + { + unordered_set found; + FLDeepIterator i = FLDeepIterator_New(FLValue(root)); + for (; FLDeepIterator_GetValue(i); FLDeepIterator_Next(i)) { + C4BlobKey blobKey; + if (isBlobOrAttachment(i, &blobKey, attachmentsOnly)) { + if (!unique || found.emplace((const char*)&blobKey, sizeof(blobKey)).second) { + auto blob = Value(FLDeepIterator_GetValue(i)).asDict(); + callback(i, blob, blobKey); + } + FLDeepIterator_SkipChildren(i); + } + } + FLDeepIterator_Free(i); + } + + + void encodeRevWithLegacyAttachments(FLEncoder fl_enc, FLDict root, unsigned revpos) { + SharedEncoder enc(fl_enc); + enc.beginDict(); + + // Write existing properties except for _attachments: + Dict oldAttachments; + for (Dict::iterator i(root); i; ++i) { + slice key = i.keyString(); + if (key == C4Blob::kLegacyAttachmentsProperty) { + oldAttachments = i.value().asDict(); // remember _attachments dict for later + } else { + enc.writeKey(key); + enc.writeValue(i.value()); + } + } + + // Now write _attachments: + enc.writeKey(C4Blob::kLegacyAttachmentsProperty); + enc.beginDict(); + // First pre-existing legacy attachments, if any: + for (Dict::iterator i(oldAttachments); i; ++i) { + slice key = i.keyString(); + if (!key.hasPrefix("blob_"_sl)) { + // TODO: Should skip this entry if a blob with the same digest exists + enc.writeKey(key); + enc.writeValue(i.value()); + } + } + + // Then entries for blobs found in the document: + findBlobReferences(root, false, [&](FLDeepIterator di, FLDict blob, C4BlobKey blobKey) { + alloc_slice path(FLDeepIterator_GetJSONPointer(di)); + if (path.hasPrefix("/_attachments/"_sl)) + return; + string attName = string("blob_") + string(path); + enc.writeKey(slice(attName)); + enc.beginDict(); + for (Dict::iterator i(blob); i; ++i) { + slice key = i.keyString(); + if (key != C4Document::kObjectTypeProperty && key != "stub"_sl) { + enc.writeKey(key); + enc.writeValue(i.value()); + } + } + enc.writeKey("stub"_sl); + enc.writeBool(true); + enc.writeKey("revpos"_sl); + enc.writeInt(revpos); + enc.endDict(); + }); + enc.endDict(); + + enc.endDict(); + } + +} diff --git a/LiteCore/Database/TreeDocument.cc b/LiteCore/Database/TreeDocument.cc index 6fe2bb3ecf..ced4331efc 100644 --- a/LiteCore/Database/TreeDocument.cc +++ b/LiteCore/Database/TreeDocument.cc @@ -594,7 +594,9 @@ namespace litecore { if (!body) return false; - revidBuffer encodedNewRevID = generateDocRevID(body, _selected.revID, deletion); + revidBuffer encodedNewRevID = TreeDocumentFactory::generateDocRevID(body, + _selected.revID, + deletion); C4ErrorCode errorCode = {}; int httpStatus; @@ -645,24 +647,6 @@ namespace litecore { return true; } - - static revidBuffer generateDocRevID(slice body, slice parentRevID, bool deleted) { - // Get SHA-1 digest of (length-prefixed) parent rev ID, deletion flag, and revision body: - uint8_t revLen = (uint8_t)min((unsigned long)parentRevID.size, 255ul); - uint8_t delByte = deleted; - SHA1 digest = (SHA1Builder() << revLen << slice(parentRevID.buf, revLen) - << delByte << body) - .finish(); - // Derive new rev's generation #: - unsigned generation = 1; - if (parentRevID.buf) { - revidBuffer parentID(parentRevID); - generation = parentID.generation() + 1; - } - return revidBuffer(generation, slice(digest)); - } - - private: RevTreeRecord _revTree; const Rev *_selectedRev {nullptr}; @@ -764,5 +748,22 @@ namespace litecore { return asInternal(collection())->keyStore().withDocBodies(docIDs, callback); } + /*static*/ revidBuffer TreeDocumentFactory::generateDocRevID(slice body, + slice parentRevID, + bool deleted) { + // Get SHA-1 digest of (length-prefixed) parent rev ID, deletion flag, and revision body: + uint8_t revLen = (uint8_t)min((unsigned long)parentRevID.size, 255ul); + uint8_t delByte = deleted; + SHA1 digest = (SHA1Builder() << revLen << slice(parentRevID.buf, revLen) + << delByte << body) + .finish(); + // Derive new rev's generation #: + unsigned generation = 1; + if (parentRevID.buf) { + revidBuffer parentID(parentRevID); + generation = parentID.generation() + 1; + } + return revidBuffer(generation, slice(digest)); + } } // end namespace litecore diff --git a/LiteCore/Database/TreeDocument.hh b/LiteCore/Database/TreeDocument.hh index 4370f45ea9..b5ed4f32ce 100644 --- a/LiteCore/Database/TreeDocument.hh +++ b/LiteCore/Database/TreeDocument.hh @@ -31,6 +31,8 @@ namespace litecore { C4RemoteID remoteDBID) override; static C4Document* documentContaining(FLValue value); + + static revidBuffer generateDocRevID(slice body, slice parentRevID, bool deleted); }; } diff --git a/LiteCore/Support/Actor.cc b/LiteCore/Support/Actor.cc index 929bcee950..acaae1988d 100644 --- a/LiteCore/Support/Actor.cc +++ b/LiteCore/Support/Actor.cc @@ -11,11 +11,12 @@ // #include "Actor.hh" +#include "Async.hh" #include "Logging.hh" #include -namespace litecore { namespace actor { +namespace litecore::actor { void Actor::caughtException(const std::exception &x) { Warn("Caught exception in Actor %s: %s", actorName().c_str(), x.what()); @@ -41,5 +42,4 @@ namespace litecore { namespace actor { cond->notify_one(); } - -} } +} diff --git a/LiteCore/Support/Actor.hh b/LiteCore/Support/Actor.hh index fd97f12e2c..9a12cdac83 100644 --- a/LiteCore/Support/Actor.hh +++ b/LiteCore/Support/Actor.hh @@ -11,6 +11,7 @@ // #pragma once +#include "AsyncActorCommon.hh" #include "ThreadedMailbox.hh" #include "Logging.hh" #include @@ -28,15 +29,8 @@ #include "Stopwatch.hh" #endif -#ifdef ACTORS_SUPPORT_ASYNC -#include "Async.hh" -#endif - - -namespace litecore { namespace actor { - class Actor; - class AsyncContext; +namespace litecore::actor { //// Some support code for asynchronize(), from http://stackoverflow.com/questions/42124866 template @@ -55,11 +49,13 @@ namespace litecore { namespace actor { #define ACTOR_BIND_METHOD0(RCVR, METHOD) ^{ ((RCVR)->*METHOD)(); } #define ACTOR_BIND_METHOD(RCVR, METHOD, ARGS) ^{ ((RCVR)->*METHOD)(ARGS...); } #define ACTOR_BIND_FN(FN, ARGS) ^{ FN(ARGS...); } + #define ACTOR_BIND_FN0(FN) ^{ FN(); } #else using Mailbox = ThreadedMailbox; #define ACTOR_BIND_METHOD0(RCVR, METHOD) std::bind(METHOD, RCVR) #define ACTOR_BIND_METHOD(RCVR, METHOD, ARGS) std::bind(METHOD, RCVR, ARGS...) #define ACTOR_BIND_FN(FN, ARGS) std::bind(FN, ARGS...) + #define ACTOR_BIND_FN0(FN) (FN) #endif #define FUNCTION_TO_QUEUE(METHOD) #METHOD, &METHOD @@ -105,6 +101,14 @@ namespace litecore { namespace actor { ,_mailbox(this, name, parentMailbox) { } + /** Within an Actor method, `thisActor` evaluates to `this`. + (Outside of one, it calls the static function `thisActor` that returns nullptr.) */ + Actor* thisActor() {return this;} + const Actor* thisActor() const {return this;} + + /** Returns true if `this` is the currently running Actor. */ + bool isCurrentActor() const {return currentActor() == this;} + /** Schedules a call to a method. */ template void enqueue(const char* methodName, void (Rcvr::*fn)(Args...), Args... args) { @@ -135,45 +139,83 @@ namespace litecore { namespace actor { return _asynchronize(methodName, fn); } + /** Schedules a call to `fn` on the actor's thread. + The return type depends on `fn`s return type: + - `void` -- `asCurrentActor` will return `void`. + - `X` -- `asCurrentActor` will return `Async`, which will resolve after `fn` runs. + - `Async` -- `asCurrentActor` will return `Async`, which will resolve after `fn` + runs _and_ its returned async value resolves. */ + template + auto asCurrentActor(LAMBDA &&fn) { + using U = unwrap_async>; // return type w/o Async<> + return _asCurrentActor(std::forward(fn)); + } + + /** The scheduler calls this after every call to the Actor. */ virtual void afterEvent() { } + /** Called if an Actor method throws an exception. */ virtual void caughtException(const std::exception &x); virtual std::string loggingIdentifier() const { return actorName(); } + /** Writes statistics to the log. */ void logStats() { _mailbox.logStats(); } - -#ifdef ACTORS_SUPPORT_ASYNC - /** Body of an async method: Creates an Provider from the lambda given, - then returns an Async that refers to that provider. */ - template - Async _asyncBody(const LAMBDA &bodyFn) { - return Async(this, bodyFn); - } - - void wakeAsyncContext(AsyncContext *context) { - _mailbox.enqueue(ACTOR_BIND_METHOD0(context, &AsyncContext::next)); - } -#endif - private: friend class ThreadedMailbox; friend class GCDMailbox; - friend class AsyncContext; + friend class AsyncProviderBase; template friend class ActorBatcher; template friend class ActorCountBatcher; void _waitTillCaughtUp(std::mutex*, std::condition_variable*, bool*); + /** Calls a method on _some other object_ on my mailbox's queue. */ + template + void enqueueOther(const char* methodName, Rcvr* other, void (Rcvr::*fn)(Args...), Args... args) { + _mailbox.enqueue(methodName, ACTOR_BIND_METHOD(other, fn, args)); + } + + // Implementation of `asCurrentActor` where `fn` returns a non-async type `T`. + template + auto _asCurrentActor(std::function fn) { + auto provider = Async::makeProvider(); + asCurrentActor([fn,provider] { provider->setResultFromFunction(fn); }); + return provider->asyncValue(); + } + + // Implementation of `asCurrentActor` where `fn` itself returns an `Async`. + template + Async _asCurrentActor(std::function()> fn) { + auto provider = Async::makeProvider(); + asCurrentActor([fn,provider] { + fn().thenProvider([=](AsyncProvider &fnProvider) { + provider->setResult(std::move(fnProvider).result()); + }); + }); + return provider; + } + Mailbox _mailbox; }; + // Specialization of `asCurrentActor` where `fn` returns void. + template <> + inline auto Actor::_asCurrentActor(std::function fn) { + if (currentActor() == this) + fn(); + else + _mailbox.enqueue("asCurrentActor", ACTOR_BIND_FN0(fn)); + } + #undef ACTOR_BIND_METHOD +#undef ACTOR_BIND_METHOD0 #undef ACTOR_BIND_FN +#undef ACTOR_BIND_FN0 -} } +} diff --git a/LiteCore/Support/ActorProperty.cc b/LiteCore/Support/ActorProperty.cc deleted file mode 100644 index dd75005b9c..0000000000 --- a/LiteCore/Support/ActorProperty.cc +++ /dev/null @@ -1,36 +0,0 @@ -// -// ActorProperty.cc -// -// Copyright 2017-Present Couchbase, Inc. -// -// Use of this software is governed by the Business Source License included -// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified -// in that file, in accordance with the Business Source License, use of this -// software will be governed by the Apache License, Version 2.0, included in -// the file licenses/APL2.txt. -// - -#include "ActorProperty.hh" - -using namespace std; - -namespace litecore { namespace actor { - - template - PropertyImpl& PropertyImpl::operator= (const T &t) { - if (t != _value) { - _value = t; - for (auto &observer : _observers) { - observer(_value); - } - } - return *this; - } - - - template - void PropertyImpl::addObserver(Observer &observer) { - _observers.push_back(observer); - } - -} } diff --git a/LiteCore/Support/ActorProperty.hh b/LiteCore/Support/ActorProperty.hh deleted file mode 100644 index c6f6779dd9..0000000000 --- a/LiteCore/Support/ActorProperty.hh +++ /dev/null @@ -1,73 +0,0 @@ -// -// ActorProperty.hh -// -// Copyright 2017-Present Couchbase, Inc. -// -// Use of this software is governed by the Business Source License included -// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified -// in that file, in accordance with the Business Source License, use of this -// software will be governed by the Apache License, Version 2.0, included in -// the file licenses/APL2.txt. -// - -#pragma once -#include "Actor.hh" -#include -#include - -namespace litecore { namespace actor { - - template - class Observer; - - /** Implementation of an Actor property. This would be a private member variable of an Actor. */ - template - class PropertyImpl { - public: - explicit PropertyImpl(Actor *owner) :_owner(*owner) { } - explicit PropertyImpl(Actor *owner, T t):_owner(*owner), _value(t) { } - - T get() const {return _value;} - operator T() const {return _value;} - PropertyImpl& operator= (const T &t); - - void addObserver(Observer &observer); - - private: - Actor &_owner; - T _value {}; - std::vector> _observers; - }; - - - template - class ObservedProperty { - public: - ~ObservedProperty(); - - T get() const {return _value;} - operator T() const {return _value;} - private: - void receiveValue(T t) {_value = t;} - - Retained &_provider; - T _value; - }; - - - /** Public Actor property. This would be a public member variable of an Actor. */ - template - class Property { - public: - explicit Property(PropertyImpl &prop) :_impl(prop) { } - - using Observer = std::function; - - void addObserver(Observer &observer) {_impl.addObserver(observer);} - void removeObserver(Actor &a); - - private: - PropertyImpl &_impl; - }; - -} } diff --git a/LiteCore/Support/Async.cc b/LiteCore/Support/Async.cc index 522884b291..1cf35eb541 100644 --- a/LiteCore/Support/Async.cc +++ b/LiteCore/Support/Async.cc @@ -12,71 +12,108 @@ #include "Async.hh" #include "Actor.hh" +#include "c4Error.h" +#include "Logging.hh" +#include "betterassert.hh" -namespace litecore { namespace actor { +namespace litecore::actor { + using namespace std; +#pragma mark - ASYNC OBSERVER: - bool AsyncState::_asyncCall(const AsyncBase &a, int lineNo) { - _calling = a._context; - _continueAt = lineNo; - return !a.ready(); - } +#pragma mark - ASYNC PROVIDER BASE: -#if DEBUG - std::atomic_int AsyncContext::gInstanceCount; -#endif + AsyncProviderBase::AsyncProviderBase(bool ready) + :_ready(ready) + { } - AsyncContext::AsyncContext(Actor *actor) - :_actor(actor) - { -#if DEBUG - ++gInstanceCount; -#endif - } - AsyncContext::~AsyncContext() { -#if DEBUG - --gInstanceCount; -#endif + AsyncProviderBase::~AsyncProviderBase() { + if (!_ready) + WarnError("AsyncProvider %p deleted without ever getting a value!", (void*)this); } - void AsyncContext::setObserver(AsyncContext *p) { - assert(!_observer); - _observer = p; - } - void AsyncContext::start() { - _waitingSelf = this; - if (_actor && _actor != Actor::currentActor()) - _actor->wakeAsyncContext(this); // Start on my Actor's queue - else - next(); + void AsyncProviderBase::setObserver(Actor *actor, Observer observer) { + { + unique_lock _lock(_mutex); + precondition(!_observer); + // Presumably I wasn't ready when the caller decided to call `setObserver` on me; + // but I might have become ready in between then and now, so check for that. + if (!_ready) { + _observer = move(observer); + _observerActor = actor ? actor : Actor::currentActor(); + return; + } + } + // if I am ready, call the observer now: + notifyObserver(observer, actor); } - void AsyncContext::_wait() { - _waitingActor = Actor::currentActor(); // retain my actor while I'm waiting - _calling->setObserver(this); - } - void AsyncContext::wakeUp(AsyncContext *async) { - assert(async == _calling); - if (_waitingActor) { - fleece::Retained waitingActor = std::move(_waitingActor); - waitingActor->wakeAsyncContext(this); // queues the next() call on its Mailbox - } else { - next(); + void AsyncProviderBase::notifyObserver(Observer &observer, Actor *actor) { + try { + if (actor && actor != Actor::currentActor()) { + // Schedule a call on my Actor: + actor->asCurrentActor([observer, provider=fleece::retained(this)] { + observer(*provider); + }); + } else { + // ... or call it synchronously: + observer(*this); + } + } catch (...) { + // we do not want an exception from the observer to propagate + C4Error::warnCurrentException("AsyncProviderBase::notifyObserver"); } } - void AsyncContext::_gotResult() { + + void AsyncProviderBase::_gotResult(std::unique_lock& lock) { + // on entry, `_mutex` is locked by `lock` + precondition(!_ready); _ready = true; - auto observer = _observer; + auto observer = move(_observer); _observer = nullptr; + auto observerActor = move(_observerActor); + _observerActor = nullptr; + + lock.unlock(); + if (observer) - observer->wakeUp(this); - _waitingSelf = nullptr; + notifyObserver(observer, observerActor); + } + + +#pragma mark - ASYNC BASE: + + + bool AsyncBase::canCallNow() const { + return ready() && (_onActor == nullptr || _onActor == Actor::currentActor()); + } + + + void AsyncBase::blockUntilReady() { + if (!ready()) { + precondition(Actor::currentActor() == nullptr); // would deadlock if called by an Actor + mutex _mutex; + condition_variable _cond; + + _provider->setObserver(nullptr, [&](AsyncProviderBase &provider) { + unique_lock lock(_mutex); + _cond.notify_one(); + }); + + unique_lock lock(_mutex); + _cond.wait(lock, [&]{return ready();}); + } + } + + + void assertNoError(C4Error err) { + Assert(!err, "Unexpected error in Async value, %s", err.description().c_str()); } -} } +} diff --git a/LiteCore/Support/Async.hh b/LiteCore/Support/Async.hh index cd94daf4bc..069b7387bd 100644 --- a/LiteCore/Support/Async.hh +++ b/LiteCore/Support/Async.hh @@ -11,393 +11,410 @@ // #pragma once +#include "AsyncActorCommon.hh" +#include "Result.hh" #include "fleece/RefCounted.hh" +#include "fleece/InstanceCounted.hh" #include -#include #include +#include +#include #include +#include -namespace litecore { namespace actor { - class Actor; - - /* - Async represents a result of type T that may not be available yet. This concept is - also referred to as a "future". You can create one by first creating an AsyncProvider, - which is also known as a "promise", then calling its `asyncValue` method: - - Async getIntFromServer() { - Retained> intProvider = Async::provider(); - sendServerRequestFor(intProvider); - return intProvider->asyncValue(); - } - - You can simplify this somewhat: - - Async getIntFromServer() { - auto intProvider = Async::provider(); // `auto` is your friend - sendServerRequestFor(intProvider); - return intProvider; // implicit conversion to Async - } - - The AsyncProvider reference has to be stored somewhere until the result is available. - Then you call its setResult() method: - - int result = valueReceivedFromServer(); - intProvider.setResult(result); - - Async has a `ready` method that tells whether the result is available, and a `result` - method that returns the result (or aborts if it's not available.) However, it does not - provide any way to block and wait for the result. That's intentional: we don't want - blocking! Instead, the way you work with async results is within an _asynchronous - function_. - - ASYNCHRONOUS FUNCTIONS - - An asynchronous function is a function that can resolve Async values in a way that appears - synchronous, but without actually blocking. It always returns an Async result (or void), - since if the Async value it's resolving isn't available, the function itself has to return - without (yet) providing a result. Here's what one looks like: - - Async anAsyncFunction() { - BEGIN_ASYNC_RETURNING(T) - ... - return t; - END_ASYNC() - } - - If the function doesn't return a result, it looks like this: - - void aVoidAsyncFunction() { - BEGIN_ASYNC() - ... - END_ASYNC() - } - - In between BEGIN and END you can "unwrap" Async values, such as those returned by other - asynchronous functions, by calling asyncCall(). The first parameter is the variable to - assign the result to, and the second is the expression returning the async result: - - asyncCall(int n, someOtherAsyncFunction()); - - `asyncCall` is a macro that hides some very weird control flow. What happens is that, if - the Async value isn't yet available, `asyncCall` causes the enclosing function to return. - (Obviously it returns an unavailable Async value.) It also registers as an observer of - the value, so when its result does become available, the enclosing function _resumes_ - right where it left off, assigns the result to the variable, and continues. - - ASYNC CALLS AND VARIABLE SCOPE - - `asyncCall()` places some odd restrictions on your code. Most importantly, a variable declared - between the BEGIN/END cannot have a scope that extends across an `asyncCall`: - - int foo = ....; - asyncCall(int n, someOtherAsyncFunction()); // ERROR: Cannot jump from switch... - - This is because the macro expansion of `asyncCall()` includes a `switch` label, and it's not - possible to jump to that label (when resuming the async flow of control) skipping the variable - declaration. - - If you want to use a variable across `asyncCall` scopes, you must declare it _before_ the - BEGIN_ASYNC -- its scope then includes the entire async function: - - int foo; - BEGIN_ASYNC_RETURNING(T) - ... - foo = ....; - asyncCall(int n, someOtherAsyncFunction()); // OK! - foo += n; - - Or if the variable isn't used after the next `asyncCall`, just use braces to limit its scope: - - { - int foo = ....; - } - asyncCall(int n, someOtherAsyncFunction()); // OK! - - THREADING - - By default, an async method resumes immediately when the Async value it's waiting for becomes - available. That means when the provider's `setResult` method is called, or when the - async method returning that value finally returns a result. This is reasonable in single- - threaded code. - - `asyncCall` is aware of Actors, however. So if an async Actor method waits, it will be resumed - on that Actor's execution context. This ensures that the Actor's code runs single-threaded, as - expected. - - */ - -#define BEGIN_ASYNC_RETURNING(T) \ - return _asyncBody([=](AsyncState &_async_state_) mutable -> T { \ - switch (_async_state_.continueAt()) { \ - default: - -#define BEGIN_ASYNC() \ - _asyncBody([=](AsyncState &_async_state_) mutable -> void { \ - switch (_async_state_.continueAt()) { \ - default: - -#define asyncCall(VAR, CALL) \ - if (_async_state_._asyncCall(CALL, __LINE__)) return {}; \ - case __LINE__: \ - VAR = _async_state_.asyncResult(); _async_state_.reset(); - -#define END_ASYNC() \ - } \ - }); - +struct C4Error; +namespace litecore::actor { + using fleece::RefCounted; + using fleece::Retained; + class Actor; class AsyncBase; - class AsyncContext; + class AsyncProviderBase; template class Async; template class AsyncProvider; - /** The state data passed to the lambda of an async function. */ - class AsyncState { - public: - uint32_t continueAt() const {return _continueAt;} - - bool _asyncCall(const AsyncBase &a, int lineNo); + // *** For full documentation, read Networking/BLIP/docs/Async.md *** - template - T&& asyncResult() { - return ((AsyncProvider*)_calling.get())->extractResult(); - } - void reset() {_calling = nullptr;} + namespace { + struct voidPlaceholder; // Just a hack to avoid `void&` parameters in Async + template struct _ThenType { using type = T; using realType = T; }; + template <> struct _ThenType { using type = voidPlaceholder; }; + } - protected: - fleece::Retained _calling; // What I'm blocked awaiting - uint32_t _continueAt {0}; // label/line# to continue lambda at - }; +#pragma mark - ASYNCPROVIDER: // Maintains the context/state of an async operation and its observer. - // Abstract base class of AsyncProvider. - class AsyncContext : public fleece::RefCounted, protected AsyncState { + // Abstract base class of AsyncProvider + class AsyncProviderBase : public RefCounted, + public fleece::InstanceCountedIn + { public: bool ready() const {return _ready;} - void setObserver(AsyncContext *p); - void wakeUp(AsyncContext *async); - protected: - AsyncContext(Actor *actor); - ~AsyncContext(); - void start(); - void _wait(); - void _gotResult(); + using Observer = std::function; - virtual void next() =0; + void setObserver(Actor*, Observer); - bool _ready {false}; // True when result is ready - fleece::Retained _observer; // Dependent context waiting on me - Actor *_actor; // Owning actor, if any - fleece::Retained _waitingActor; // Actor that's waiting, if any - fleece::Retained _waitingSelf; // Keeps `this` from being freed + protected: + friend class AsyncBase; -#if DEBUG - public: - static std::atomic_int gInstanceCount; -#endif + explicit AsyncProviderBase(bool ready = false); + explicit AsyncProviderBase(Actor *actorOwningFn, const char *functionName); + ~AsyncProviderBase(); + void _gotResult(std::unique_lock&); + void notifyObserver(Observer &observer, Actor *actor); - template friend class Async; - friend class Actor; + std::mutex mutable _mutex; + private: + Observer _observer; + Retained _observerActor; // Actor the observer was running on + std::atomic _ready {false}; // True when result is ready }; - /** An asynchronously-provided result, seen from the producer side. */ + /** An asynchronously-provided result, seen from the producer's side. */ template - class AsyncProvider : public AsyncContext { + class AsyncProvider final : public AsyncProviderBase { public: - template - explicit AsyncProvider(Actor *actor, const LAMBDA body) - :AsyncContext(actor) - ,_body(body) - { } + using ResultType = Result; + using ThenType = typename _ThenType::type; // `ThenType` is `T` unless `T` is `void` - static fleece::Retained create() { - return new AsyncProvider; - } + /// Creates a new empty AsyncProvider. + static Retained create() {return new AsyncProvider;} - Async asyncValue() { - return Async(this); + /// Creates a new AsyncProvider that already has a result. + static Retained createReady(ResultType r) { + return new AsyncProvider(std::move(r)); } - void setResult(const T &result) { - _result = result; - _gotResult(); + /// Constructs a new empty AsyncProvider. + AsyncProvider() = default; + + /// Creates the client-side view of the result. + Async asyncValue() {return Async(this);} + + /// Resolves the value by storing a result (value or error) and waking any waiting clients. + template >> + void setResult(RESULT &&result) { + emplaceResult(std::forward(result)); } - const T& result() const { - assert(_ready); - return _result; + /// Equivalent to `setResult` but constructs the result directly inside the provider + /// from the constructor parameters given. + template >> + void emplaceResult(Args&&... args) { + std::unique_lock lock(_mutex); + precondition(!_result); + _result.emplace(args...); + _gotResult(lock); } - T&& extractResult() { - assert(_ready); - return std::move(_result); + /// Returns the result, a `Result` containing either a value or an error. + /// The result must be available, or an exception is thrown. + ResultType& result() & { + std::unique_lock _lock(_mutex); + precondition(_result); + return *_result; } - private: - AsyncProvider() - :AsyncContext(nullptr) - { } + const ResultType& result() const & {return const_cast(this)->result();} + ResultType result() && {return moveResult();} - void next() override { - _result = _body(*this); - if (_calling) - _wait(); - else - _gotResult(); + /// Extracts the result and returns it as a moveable direct value. + ResultType moveResult() { + std::unique_lock _lock(_mutex); + precondition(_result); + return *std::move(_result); } - std::function _body; // The async function body - T _result {}; // My result - }; + /// Sets the result to a C4Error. + void setError(const C4Error &error) {setResult(error);} + void setException(const std::exception &x) {setResult(x);} + bool hasError() const {return result().isError();} - // Specialization of AsyncProvider for use in functions with no return value (void). - template <> - class AsyncProvider : public AsyncContext { - public: - template - explicit AsyncProvider(Actor *actor, const LAMBDA &body) - :AsyncContext(actor) - ,_body(body) - { } - - static fleece::Retained create() { - return new AsyncProvider; + C4Error error() const { + if (auto x = result().errorPtr()) + return *x; + else + return {}; } private: - AsyncProvider() - :AsyncContext(nullptr) + friend class AsyncProviderBase; + friend class Async; + + explicit AsyncProvider(ResultType result) + :AsyncProviderBase(true) + ,_result(std::move(result)) { } - void next() override { - _body(*this); - if (_calling) - _wait(); - else - _gotResult(); + template + Async _now(std::function(ThenType&&)> &&callback) { + if (hasError()) + return Async(error()); + try { + return callback(moveResult()._value()); + } catch (const std::exception &x) { + return Async(C4Error::fromException(x)); + } } - std::function _body; // The async function body + std::optional _result; // My result }; +#pragma mark - ASYNC: + + // base class of Async class AsyncBase { public: - explicit AsyncBase(const fleece::Retained &context) - :_context(context) - { } + /// Sets which Actor the callback of a `then` call should run on. + AsyncBase& on(Actor *actor) {_onActor = actor; return *this;} + + /// Returns true once the result is available. + bool ready() const {return _provider->ready();} - bool ready() const {return _context->ready();} + /// Blocks the current thread (i.e. doesn't return) until the result is available. + /// \warning This is intended for use in unit tests. Please don't use it otherwise unless + /// absolutely necessary; use `then()` or `AWAIT()` instead. + void blockUntilReady(); protected: - fleece::Retained _context; // The AsyncProvider that owns my value + explicit AsyncBase(Retained &&provider) :_provider(std::move(provider)) { } + bool canCallNow() const; - friend class AsyncState; + Retained _provider; // The provider that owns my value + Actor* _onActor {nullptr}; // Actor that `then` should call on }; - /** An asynchronously-provided result, seen from the client side. */ + /** An asynchronously-provided result, seen from the consumer's side. */ template class Async : public AsyncBase { public: - using ResultType = T; + using ResultType = Result; + using ThenType = typename _ThenType::type; - Async(AsyncProvider *provider) - :AsyncBase(provider) - { } + /// Returns a new AsyncProvider. + static Retained> makeProvider() {return AsyncProvider::create();} - Async(const fleece::Retained> &provider) - :AsyncBase(provider) + /// Creates an Async value from its provider. + Async(AsyncProvider *provider) :AsyncBase(provider) { } + Async(Retained> &&provider) :AsyncBase(std::move(provider)) { } + + /// Creates an already-resolved Async with a result (success or error.) + Async(ResultType t) + :AsyncBase(AsyncProvider::createReady(std::move(t))) { } + template >> + Async(R &&r) :Async(ResultType(std::forward(r))) { } + + + /// Invokes the callback when the result is ready. + /// The callback should take a single parameter of type `T`, `T&` or `T&&`. + /// The callback's return type may be: + /// - `X` -- the `then` method will return `Async`, which will resolve to the callback's + /// return value after the callback returns. + /// - `Async` -- the `then` method will return `Async`. After the callback + /// returns, _and_ its returned async value becomes ready, the returned + /// async value will resolve to that value. + /// - `void` -- the `then` method will return `Async`, because you've handled the + /// result value (`T`) but not a potential error, so what's left is just the error. + /// You can chain `onError()` to handle the error. + /// + /// If the async operation fails, i.e. the result is an error not a `T`, your callback will + /// not be called. Instead the error is passed on to the `Async` value that was returned by + /// `then()`. + /// + /// By default the callback will be invoked either on the thread that set the result, + /// or if the result is already available, synchronously on the current thread + /// (before `then` returns.) + /// + /// If an Actor method is calling `then`, it should first call `on(this)` to specify that + /// it wants the callback to run on its event queue; e.g. `a.on(this).then(...)`. + /// + /// Examples: + /// - `a.then([](T) -> void { ... });` + /// - `Async x = a.then([](T) -> X { ... });` + /// - `Async x = a.then([](T) -> Async { ... });` + template , + typename = std::enable_if_t>> + [[nodiscard]] + auto then(LAMBDA &&callback) && { + // U is the return type of the lambda with any `Async<...>` removed + using U = unwrap_async; + return _then(std::function(std::forward(callback))); + } + + + /// `then()` with a callback that returns nothing (`void`). + /// The callback is called only if the async operation is successful. + /// The `then` method itself returns an `Async` which conveys the success/failure of + /// the operation -- you need to handle that value because you haven't handled the failure + /// case yet. Typically you'd chain an `onError(...)`. + /// + /// Also consider using the `then()` method that takes two parameters for success & failure. + [[nodiscard]] + Async then(std::function &&callback) { + auto result = Async::makeProvider(); + _provider->setObserver(_onActor, [=](AsyncProviderBase &providerBase) { + auto &provider = dynamic_cast&>(providerBase); + if (provider.hasError()) + result->setResult(provider.error()); + else { + callback(provider.moveResult()._value()); + result->setResult(Result()); + } + }); + return result->asyncValue(); + } + - template - Async(Actor *actor, const LAMBDA& bodyFn) - :Async( new AsyncProvider(actor, bodyFn) ) + /// Special `then()` for `Async` only. The callback takes a `C4Error` and returns + /// nothing. It's called on sucess or failure; on success, the C4Error will have `code` 0. + void then(std::function &&callback) { + static_assert(std::is_same_v, + "then(C4Error) is only allowed with Async; use onError()"); + _provider->setObserver(_onActor, [=](AsyncProviderBase &providerBase) { + auto &provider = dynamic_cast&>(providerBase); + callback(provider.error()); + }); + } + + + /// Version of `then` that takes _two_ callbacks, one for the result and one for an error. + /// There is a function `assertNoAsyncError` that can be passed as the second parameter if + /// you are certain there will be no error. + template + void then(LAMBDA &&callback, + std::function errorCallback) && { - _context->start(); + std::function fn = std::forward(callback); + _then(std::move(fn), std::move(errorCallback)); } - /** Returns a new AsyncProvider. */ - static fleece::Retained> provider() { - return AsyncProvider::create(); + + /// Invokes the callback when the result is ready, but only if it's an error. + /// A successful result is ignored. Normally chained after a `then` call to handle the + /// remaining error condition. + void onError(std::function callback) { + _provider->setObserver(_onActor, [=](AsyncProviderBase &providerBase) { + auto &provider = dynamic_cast&>(providerBase); + if (provider.hasError()) + callback(provider.error()); + }); } - const T& result() const {return ((AsyncProvider*)_context.get())->result();} - /** Invokes the callback when this Async's result becomes ready, - or immediately if it's ready now. */ - template - void wait(LAMBDA callback) { - if (ready()) - callback(result()); - else - (void) new AsyncWaiter(_context, callback); + /// Returns the result. (Throws an exception if the result is not yet available.) + /// If the result contains an error, throws that as an exception. + ResultType& result() & {return provider()->result();} + ResultType result() && {return provider()->result();} + + /// Move-returns the result. (Throws an exception if the result is not yet available.) + /// If the result contains an error, throws that as an exception. + ResultType moveResult() {return provider()->moveResult();} + + /// Blocks the current thread until the result is available, then returns it. + /// If the result contains an error, throws that as an exception. + /// \warning This is intended for use in unit tests. Please don't use it otherwise unless + /// absolutely necessary; use `then()` or `AWAIT()` instead. + ResultType& blockingResult() { + blockUntilReady(); + return result(); } + /// Returns the error. + C4Error error() const {return provider()->error();} - // Internal class used by wait(), above - class AsyncWaiter : public AsyncContext { - public: - template - AsyncWaiter(AsyncContext *context, LAMBDA callback) - :AsyncContext(nullptr) - ,_callback(callback) - { - _waitingSelf = this; - _calling = context; - _wait(); - } + private: + friend class Actor; + template friend class Async; - protected: - void next() override { - _callback(asyncResult()); - _waitingSelf = nullptr; - } + Async() :AsyncBase(makeProvider()) { } - private: - std::function _callback; - }; - }; + AsyncProvider* provider() {return (AsyncProvider*)_provider.get();} + AsyncProvider const* provider() const {return (const AsyncProvider*)_provider.get();} - // Specialization of Async<> for functions with no result - template <> - class Async : public AsyncBase { - public: - Async(AsyncProvider *provider) - :AsyncBase(provider) - { } + void thenProvider(std::function&)> callback) && { + _provider->setObserver(_onActor, [=](AsyncProviderBase &provider) { + callback(dynamic_cast&>(provider)); + }); + } + + + // Implements `then` where the lambda returns a regular type `U`. Returns `Async`. + template + [[nodiscard]] + Async _then(std::function &&callback) { + auto uProvider = Async::makeProvider(); + if (canCallNow()) { + // Result is available now, so call the callback: + uProvider->setResult(moveResult().then(callback)); + } else { + _provider->setObserver(_onActor, [=](AsyncProviderBase &providerBase) { + auto &provider = dynamic_cast&>(providerBase); + uProvider->setResult(provider.moveResult().then(callback)); + }); + } + return uProvider->asyncValue(); + } - Async(const fleece::Retained> &provider) - :AsyncBase(provider) - { } - static fleece::Retained> provider() { - return AsyncProvider::create(); + // Implements `then` where the lambda returns `Async`. + template + [[nodiscard]] + Async _then(std::function(ThenType&&)> &&callback) { + if (canCallNow()) { + // If I'm ready, just call the callback and pass on the Async it returns: + return provider()->_now(std::move(callback)); + } else { + // Otherwise wait for my result... + auto uProvider = Async::makeProvider(); + _provider->setObserver(_onActor, [=](AsyncProviderBase &provider) mutable { + // Invoke the callback, then wait to resolve the Async it returns: + auto &tProvider = dynamic_cast&>(provider); + auto asyncU = tProvider._now(std::move(callback)); + std::move(asyncU).thenProvider([uProvider](auto &provider) { + // Then finally resolve the async I returned: + uProvider->setResult(provider.result()); + }); + }); + return uProvider->asyncValue(); + } } - template - Async(Actor *actor, const LAMBDA& bodyFn) - :Async( new AsyncProvider(actor, bodyFn) ) + + // innards of the `then()` with two callbacks + template >> + void _then(std::function &&callback, + std::function &&errorCallback) { - _context->start(); + _provider->setObserver(_onActor, [=](AsyncProviderBase &providerBase) { + auto &provider = dynamic_cast&>(providerBase); + if (provider.hasError()) + errorCallback(provider.error()); + else + callback(provider.moveResult()._value()); + }); } + }; - /** Body of an async function: Creates an AsyncProvider from the lambda given, - then returns an Async that refers to that provider. */ - template - Async _asyncBody(const LAMBDA &bodyFn) { - return Async(nullptr, bodyFn); - } + /// You can use this as the error-handling callback to `void Async::then(onResult,onError)`. + /// It throws an assertion-failed exception if the C4Error's code is nonzero. + void assertNoError(C4Error); -} } +} diff --git a/LiteCore/Support/AsyncActorCommon.hh b/LiteCore/Support/AsyncActorCommon.hh new file mode 100644 index 0000000000..3dff63610c --- /dev/null +++ b/LiteCore/Support/AsyncActorCommon.hh @@ -0,0 +1,34 @@ +// +// AsyncActorCommon.hh +// +// Copyright © 2022 Couchbase. All rights reserved. +// + +#pragma once +#include + +namespace litecore::actor { + class Actor; + template class Async; + template class AsyncProvider; + + + /** Outside of an Actor method, `thisActor` evaluates to `nullptr`. + (Inside of one, it calls the Actor method `thisActor` that returns `this`.) */ + static inline Actor* thisActor() {return nullptr;} + + + // Compile-time utility that pulls the result type out of an Async type. + // If `T` is `Async`, or a reference thereto, then `async_result_type` is X. + template + using async_result_type = typename std::remove_reference_t::ResultType; + + + // Magic template gunk. `unwrap_async` removes a layer of `Async<...>` from a type: + // - `unwrap_async` is `string`. + // - `unwrap_async> is `string`. + template T _unwrap_async(T*); + template T _unwrap_async(Async*); + template using unwrap_async = decltype(_unwrap_async((T*)nullptr)); + +} diff --git a/LiteCore/Support/Error.cc b/LiteCore/Support/Error.cc index ffe9073442..7feb0232f6 100644 --- a/LiteCore/Support/Error.cc +++ b/LiteCore/Support/Error.cc @@ -466,6 +466,7 @@ namespace litecore { domain(d), code(getPrimaryCode(d, c)) { + DebugAssert(code != 0); if (sCaptureBacktraces) captureBacktrace(3); } @@ -578,6 +579,24 @@ namespace litecore { } + __cold + error error::convertCurrentException() { + // This rigamarole recovers the current exception being thrown... + auto xp = std::current_exception(); + if (xp) { + try { + std::rethrow_exception(xp); + } catch(const std::exception& x) { + // Now we have the exception, so we can record it in outError: + return convertException(x); + } catch (...) { } + } + auto e = error(error::LiteCore, error::UnexpectedError, "Unknown C++ exception"); + e.captureBacktrace(1); + return e; + } + + __cold bool error::isUnremarkable() const { if (code == 0) diff --git a/LiteCore/Support/Error.hh b/LiteCore/Support/Error.hh index 58b2362dae..ab66effe0f 100644 --- a/LiteCore/Support/Error.hh +++ b/LiteCore/Support/Error.hh @@ -20,6 +20,8 @@ #undef check +struct C4Error; + namespace fleece { class Backtrace; } @@ -93,6 +95,7 @@ namespace litecore { error (Domain, int code ); error(error::Domain, int code, const std::string &what); explicit error (LiteCoreError e) :error(LiteCore, e) {} + explicit error (const C4Error&); // This is implemented in c4Error.cc error& operator= (const error &e); @@ -110,6 +113,7 @@ namespace litecore { exception types like SQLite::Exception. */ static error convertRuntimeError(const std::runtime_error&); static error convertException(const std::exception&); + static error convertCurrentException(); /** Static version of the standard `what` method. */ static std::string _what(Domain, int code) noexcept; diff --git a/LiteCore/Support/QuietReporter.hh b/LiteCore/Support/QuietReporter.hh index d998f65555..2f1af77f1f 100644 --- a/LiteCore/Support/QuietReporter.hh +++ b/LiteCore/Support/QuietReporter.hh @@ -27,6 +27,7 @@ #include "CaseListReporter.hh" #include #include +#include #ifdef _MSC_VER #include @@ -67,6 +68,7 @@ struct QuietReporter: public CaseListReporter { //---- Catch overrides virtual void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override { + std::lock_guard lock(_mutex); c4log_setCallbackLevel(kC4LogWarning); c4log_warnOnErrors(true); _caseStartTime = litecore::LogIterator::now(); @@ -74,7 +76,16 @@ struct QuietReporter: public CaseListReporter { } + virtual void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override { + std::lock_guard lock(_mutex); + // Locking/unlocking the mutex merely so we block if a background thread is in + // dumpBinaryLogs due to an exception... + CaseListReporter::testCaseEnded(testCaseStats); + } + + virtual void sectionStarting( Catch::SectionInfo const& sectionInfo ) override { + std::lock_guard lock(_mutex); _caseStartTime = litecore::LogIterator::now(); CaseListReporter::sectionStarting(sectionInfo); } @@ -89,6 +100,7 @@ struct QuietReporter: public CaseListReporter { private: void dumpBinaryLogs() { + std::lock_guard lock(_mutex); fleece::alloc_slice logPath = c4log_binaryFilePath(); if (logPath && c4log_binaryFileLevel() < c4log_callbackLevel()) { c4log_flushLogFiles(); @@ -111,6 +123,7 @@ private: static inline QuietReporter* sInstance {nullptr}; + std::mutex _mutex; litecore::LogIterator::Timestamp _caseStartTime; }; diff --git a/LiteCore/Support/Result.hh b/LiteCore/Support/Result.hh new file mode 100644 index 0000000000..44e11f774b --- /dev/null +++ b/LiteCore/Support/Result.hh @@ -0,0 +1,255 @@ +// +// Result.hh +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#pragma once +#include "c4Error.h" +#include "Defer.hh" // for CONCATENATE() +#include "fleece/function_ref.hh" +#include +#include +#include + +namespace litecore { + template class Result; + + // !!! Documentation is at docs/Result.md !!! + + namespace { + // Magic template gunk. `unwrap_Result` removes a layer of `Result<...>` from type T + template T _unwrap_Result(T*); + template T _unwrap_Result(Result*); + template using unwrap_Result = decltype(_unwrap_Result((T*)nullptr)); + } + + + /// Represents the return value of a function that can fail. + /// It contains either a value of type T, or a C4Error. + template + class Result { + public: + /// Constructs a successful Result from a value. + Result(const T &val) noexcept :_result(val) { } + Result(T &&val) noexcept :_result(std::move(val)) { } + + /// Constructs a failure Result from an error. + /// The error must not be the empty/null/0 value. + Result(const C4Error &err) noexcept :_result(err) {precondition(err);} + Result(C4Error &&err) noexcept :_result(std::move(err)) {precondition(err);} + + /// True if successful. + bool ok() const noexcept {return _result.index() == 0;} + + /// True if not successful. + bool isError() const noexcept {return _result.index() != 0;} + + /// Returns the value. Or if there's an error, throws it as an exception(!) + T& value() & { + if (auto e = errorPtr(); _usuallyFalse(e != nullptr)) e->raise(); + return *std::get_if<0>(&_result); + } + + T value() && { + if (auto e = errorPtr(); _usuallyFalse(e != nullptr)) e->raise(); + return std::move(*std::get_if<0>(&_result)); + } + + /// Returns the error, or an empty C4Error with code==0 if none. + C4Error error() const noexcept {auto e = errorPtr(); return e ? *e : C4Error{};} + + /// Returns a pointer to the error, or `nullptr` if there is none. + const C4Error* errorPtr() const noexcept {return std::get_if<1>(&_result);} + + /// Transforms a `Result` to a `Result` by passing the value through a function. + /// - If I have a value, I pass it to `fn` and return its result. + /// * If `fn` throws an exception, it's caught and returned (thanks to `CatchResult()`.) + /// - If I have an error, `fn` is _not_ called, and I return my error. + /// @param fn A function/lambda that takes a `T&&` and returns `U` or `Result`. + /// @return The result of `fn`, or else my current error, as a `Result`. + template , + typename U = unwrap_Result> + [[nodiscard]] + Result then(LAMBDA fn) && noexcept { + return _then(fleece::function_ref(std::forward(fn))); + } + + /// Calls `fn` with the error, if there is one, else does nothing. + /// @param fn A function/lambda that takes a `C4Error` and returns `void`. + /// @return Always returns itself, `*this`. + template + [[nodiscard]] + Result& onError(LAMBDA fn) { + if (isError()) + fn(error()); + return *this; + } + + // `_value` is faster than `value`, but you MUST have preflighted or it'll deref NULL. + T& _value() & noexcept {return *std::get_if<0>(&_result);} + T _value() && noexcept {return std::move(*std::get_if<0>(&_result));} + + private: + template + Result _then(fleece::function_ref const& fn) noexcept; + template + Result _then(fleece::function_ref(T&&)> const& fn) noexcept; + + std::variant _result; + }; + + + // Specialization of `Result` when there is no value; it just represents success or an error. + // - The `success` constructor takes no arguments. Or you can construct with `kC4NoError`. + // - There is no `value` method. + // - The `then` callback takes no arguments. + template<> + class Result { + public: + Result() noexcept :_error{} { } + Result(const C4Error &err) noexcept :_error(err) { } + Result(C4Error &&err) noexcept :_error(std::move(err)) { } + + bool ok() const noexcept {return !_error;} + bool isError() const noexcept {return !!_error;} + const C4Error& error() const noexcept {return _error;} + const C4Error* errorPtr() const noexcept {return _error ? &_error : nullptr;} + + template , + typename U = unwrap_Result> + [[nodiscard]] + Result then(LAMBDA fn) && noexcept { + return _then(fleece::function_ref(std::forward(fn))); + } + + template + void onError(LAMBDA fn) { + if (isError()) + fn(error()); + } + + private: + template + Result _then(fleece::function_ref const& fn) noexcept; + template + Result _then(fleece::function_ref()> const& fn) noexcept; + + C4Error _error; + }; + + + /// Runs a function returning `T` in a try/catch block, + /// catching any exception and returning it as an error. Returns `Result`. + template + [[nodiscard]] + Result CatchResult(fleece::function_ref fn) noexcept { + try { + return fn(); + } catch (std::exception &x) { + return C4Error::fromException(x); + } + } + + + /// Runs a function returning `Result` in a try/catch block, + /// catching any exception and returning it as an error. Returns `Result`. + template + [[nodiscard]] + Result CatchResult(fleece::function_ref()> fn) noexcept { + try { + return fn(); + } catch (std::exception &x) { + return C4Error::fromException(x); + } + } + + + // (specialization needed for T=void) + template <> + [[nodiscard]] + inline Result CatchResult(fleece::function_ref fn) noexcept { + try { + fn(); + return {}; + } catch (std::exception &x) { + return C4Error::fromException(x); + } + } + + + // (this helps the compiler deduce T when CatchResult() is called with a lambda) + template , // return value + typename T = unwrap_Result> // RV with `Result<...>` stripped off + [[nodiscard]] + inline Result CatchResult(LAMBDA fn) noexcept { + return CatchResult(fleece::function_ref(std::move(fn))); + } + + + /// An approximation of Swift's `try` syntax for clean error propagation without exceptions. + /// First `EXPR` is evaluated. + /// - If the result is ok, the value is assigned to `VAR`, which may be an existing variable + /// name (`foo`) or a declaration (`int foo`). + /// - If the result is an error, that error is returned from the current function, which should + /// have a return type of `Result<>` or `C4Error`. + #define TRY(VAR, EXPR) \ + auto CONCATENATE(rslt, __LINE__) = (EXPR); \ + if (CONCATENATE(rslt, __LINE__).isError()) \ + return CONCATENATE(rslt, __LINE__).error(); \ + VAR = std::move(CONCATENATE(rslt, __LINE__))._value(); + // (`CONCATENATE(rslt, __LINE__)` is just a clumsy way to create a unique variable name.) + + + //---- Method implementations + + + template + template + [[nodiscard]] + Result Result::_then(fleece::function_ref const& fn) noexcept { + if (ok()) + return CatchResult([&]{return fn(std::move(_value()));}); + else + return error(); + } + + template + template + [[nodiscard]] + Result Result::_then(fleece::function_ref(T&&)> const& fn) noexcept { + if (ok()) + return CatchResult([&]{return fn(std::move(_value()));}); + else + return error(); + } + + + template + [[nodiscard]] + Result Result::_then(fleece::function_ref const& fn) noexcept { + if (ok()) + return CatchResult(fn); + else + return error(); + } + + template + [[nodiscard]] + Result Result::_then(fleece::function_ref()> const& fn) noexcept { + if (ok()) + return CatchResult(fn); + else + return error(); + } + +} diff --git a/LiteCore/Support/StringUtil.cc b/LiteCore/Support/StringUtil.cc index 6483f986ec..357fbf5097 100644 --- a/LiteCore/Support/StringUtil.cc +++ b/LiteCore/Support/StringUtil.cc @@ -16,6 +16,17 @@ #include #include +// For matchGlobPattern: +#ifdef _MSC_VER + #include + #include + #pragma comment(lib, "shlwapi.lib") + #undef min + #undef max +#else + #include // POSIX (?) +#endif + namespace litecore { using namespace std; @@ -140,6 +151,19 @@ namespace litecore { c = (char)tolower(c); } + + bool matchGlobPattern(const string &str, const string &pattern) { +#ifdef _MSC_VER + return PathMatchSpecA(name, pattern); +#else + return fnmatch(pattern.c_str(), str.c_str(), 0) == 0; +#endif + } + + +#pragma mark - UNICODE / UTF-8 FUNCTIONS + + // Based on utf8_check.c by Markus Kuhn, 2005 // https://www.cl.cam.ac.uk/~mgk25/ucs/utf8_check.c bool isValidUTF8(fleece::slice sl) noexcept diff --git a/LiteCore/Support/StringUtil.hh b/LiteCore/Support/StringUtil.hh index 8338fe99c8..7756f25f7f 100644 --- a/LiteCore/Support/StringUtil.hh +++ b/LiteCore/Support/StringUtil.hh @@ -95,6 +95,12 @@ namespace litecore { return str; } + /** Returns true if `str` matches the pattern `pattern`, which uses typical (Unix) shell + wildcard syntax: `?` matches a single character, `*` matches any number of characters, + `[...]` matches a specific character `\\` escapes the next character. + See for details.*/ + bool matchGlobPattern(const std::string &str, const std::string &pattern); + //////// UNICODE_AWARE FUNCTIONS: /** Returns true if the UTF-8 encoded slice contains no characters with code points < 32. */ diff --git a/LiteCore/tests/AsyncTest.cc b/LiteCore/tests/AsyncTest.cc new file mode 100644 index 0000000000..ba265e6eac --- /dev/null +++ b/LiteCore/tests/AsyncTest.cc @@ -0,0 +1,362 @@ +// +// AsyncTest.cc +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#include "Async.hh" +#include "Actor.hh" +#include "LiteCoreTest.hh" +#include "Logging.hh" + +using namespace std; +using namespace litecore::actor; + + +static Async downloader(string url) { + auto provider = Async::makeProvider(); + std::thread t([=] { + std::this_thread::sleep_for(1s); + provider->setResult("Contents of " + url); + }); + t.detach(); + return provider->asyncValue(); +} + + +class AsyncTest { +public: + Retained> _aProvider; + Retained> _bProvider; + + AsyncProvider* aProvider() { + if (!_aProvider) + _aProvider = Async::makeProvider(); + return _aProvider; + } + + AsyncProvider* bProvider() { + if (!_bProvider) + _bProvider = Async::makeProvider(); + return _bProvider; + } + + Async provideA() { + return aProvider()->asyncValue(); + } + + Async provideB() { + return bProvider()->asyncValue(); + } + + Async provideDouble() { + Log("provideSum: awaiting A"); + return provideA().then([=](string a) -> string { + return a + a; + }); + } + + + Async provideSum() { + Log("provideSum: awaiting A"); + return provideA().then([=](string a) { + Log("provideSum: awaiting B"); + return provideB().then([=](string b) { + Log("provideSum: returning"); + return a + b; + }); + }); + } + + + Async provideSumPlus() { + return provideSum().then([=](string a) { + return a + "!"; + }); + } + + + Async provideImmediately() { + return string("immediately"); + } + + + Async provideError() { + return provideA().then([](string a) -> Async { + if (a.empty()) + return C4Error::make(LiteCoreDomain, kC4ErrorInvalidParameter, "Empty!"); + else + return a; + }); + } + + + string provideNothingResult; + + Async provideNothing() { + return provideA().then([=](string a) { + Log("provideNothing: awaiting B"); + return provideB().then([=](string b) -> Async { + Log("provideNothing: got B"); + provideNothingResult = a + b; + return C4Error{}; + }); + }); + } + +}; + + +TEST_CASE_METHOD(AsyncTest, "Async", "[Async]") { + Async sum = provideSum(); + REQUIRE(!sum.ready()); + _aProvider->setResult("hi"); + REQUIRE(!sum.ready()); + _bProvider->setResult(" there"); + REQUIRE(sum.ready()); + REQUIRE(sum.result().value() == "hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async, other order", "[Async]") { + Async sum = provideSum(); + REQUIRE(!sum.ready()); + bProvider()->setResult(" there"); // this time provideB() finishes first + REQUIRE(!sum.ready()); + aProvider()->setResult("hi"); + REQUIRE(sum.ready()); + REQUIRE(sum.result().value() == "hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async, emplaceResult") { + auto p = Async::makeProvider(); + auto v = p->asyncValue(); + REQUIRE(!v.ready()); + p->setResult("******"); + REQUIRE(v.ready()); + CHECK(v.result().value() == "******"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async then", "[Async]") { + Async s = provideDouble(); + REQUIRE(!s.ready()); + _aProvider->setResult("Twice"); + REQUIRE(s.ready()); + CHECK(s.result().value() == "TwiceTwice"); +} + + +TEST_CASE_METHOD(AsyncTest, "AsyncWaiter", "[Async]") { + Async sum = provideSum(); + string result; + move(sum).then([&](string s) { + result = s; + }, assertNoError); + REQUIRE(!sum.ready()); + REQUIRE(result == ""); + _aProvider->setResult("hi"); + REQUIRE(!sum.ready()); + REQUIRE(result == ""); + _bProvider->setResult(" there"); + REQUIRE(sum.ready()); + REQUIRE(result == "hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async, 2 levels", "[Async]") { + Async sum = provideSumPlus(); + REQUIRE(!sum.ready()); + _aProvider->setResult("hi"); + REQUIRE(!sum.ready()); + _bProvider->setResult(" there"); + REQUIRE(sum.ready()); + REQUIRE(sum.result().value() == "hi there!"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async, immediately", "[Async]") { + Async im = provideImmediately(); + REQUIRE(im.ready()); + REQUIRE(im.result().value() == "immediately"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async void fn", "[Async]") { + provideNothing(); + REQUIRE(provideNothingResult == ""); + _aProvider->setResult("hi"); + REQUIRE(provideNothingResult == ""); + _bProvider->setResult(" there"); + REQUIRE(provideNothingResult == "hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async then returning void", "[Async]") { + optional result; + provideSum().then([&](string &&s) { + Log("--Inside then fn; s = \"%s\"", s.c_str()); + result = s; + }, assertNoError); + + Log("--Providing aProvider"); + _aProvider->setResult("hi"); + Log("--Providing bProvider"); + _bProvider->setResult(" there"); + CHECK(result == "hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async then returning T", "[Async]") { + Async size = provideSum().then([](string &&s) { + Log("--Inside then fn; s = \"%s\", returning %zu", s.c_str(), s.size()); + return s.size(); + }); + + Log("--Providing aProvider"); + _aProvider->setResult("hi"); + Log("--Providing bProvider"); + _bProvider->setResult(" there"); + CHECK(size.blockingResult().value() == 8); +} + + +TEST_CASE_METHOD(AsyncTest, "Async then returning async T", "[Async]") { + Async dl = provideSum().then([](string &&s) { + Log("--Inside then fn; s = \"%s\", returning %zu", s.c_str(), s.size()); + return downloader(s); + }); + + Log("--Providing aProvider"); + _aProvider->setResult("hi"); + Log("--Providing bProvider"); + _bProvider->setResult(" there"); + CHECK(dl.blockingResult().value() == "Contents of hi there"); +} + + +TEST_CASE_METHOD(AsyncTest, "Async Error", "[Async]") { + Async r = provideError(); + REQUIRE(!r.ready()); + SECTION("no error") { + _aProvider->setResult("hi"); + REQUIRE(r.ready()); + CHECK(!r.error()); + CHECK(r.result().value() == "hi"); + } + SECTION("error") { + _aProvider->setResult(""); + REQUIRE(r.ready()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } +} + + +TEST_CASE_METHOD(AsyncTest, "Async Error Then", "[Async]") { + optional theStr; + optional theError; + provideError().then([&](string str) -> void { + theStr = str; + }).onError([&](C4Error err) { + theError = err; + }); + REQUIRE(!theStr); + REQUIRE(!theError); + + SECTION("no error") { + _aProvider->setResult("hi"); + CHECK(!theError); + REQUIRE(theStr); + CHECK(*theStr == "hi"); + } + SECTION("error") { + _aProvider->setResult(""); + CHECK(!theStr); + REQUIRE(theError); + CHECK(*theError == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } +} + + +#pragma mark - WITH ACTORS: + + +class AsyncTestActor : public Actor { +public: + AsyncTestActor() :Actor(kC4Cpp_DefaultLog) { } + + Async download(string url) { + return asCurrentActor([=] { + CHECK(currentActor() == this); + return downloader(url).then([=](string contents) -> string { + // When `then` is used inside an Actor method, the lambda is called on its queue: + CHECK(currentActor() == this); + return contents; + }); + }); + } + + Async download(string url1, string url2) { + return asCurrentActor([=] { + CHECK(currentActor() == this); + return download(url1).then([=](string contents1) { + return download(url2).then([=](string contents2) { + CHECK(currentActor() == this); + return contents1 + " and " + contents2; + }); + }); + }); + } + + void testThen(string url) { + asCurrentActor([=] { + downloader(url).then([=](string &&s) { + assert(currentActor() == this); + testThenResult = move(s); + testThenReady = true; + }, assertNoError); + }); + } + + atomic testThenReady = false; + optional testThenResult; +}; + + +TEST_CASE("Async on thread", "[Async]") { + auto asyncContents = downloader("couchbase.com"); + string contents = asyncContents.blockingResult().value(); + CHECK(contents == "Contents of couchbase.com"); +} + + +TEST_CASE("Async Actor", "[Async]") { + auto actor = make_retained(); + auto asyncContents = actor->download("couchbase.org"); + string contents = asyncContents.blockingResult().value(); + CHECK(contents == "Contents of couchbase.org"); +} + + +TEST_CASE("Async Actor Twice", "[Async]") { + auto actor = make_retained(); + auto asyncContents = actor->download("couchbase.org", "couchbase.biz"); + string contents = asyncContents.blockingResult().value(); + CHECK(contents == "Contents of couchbase.org and Contents of couchbase.biz"); +} + +TEST_CASE("Async Actor with then", "[Async]") { + auto actor = make_retained(); + actor->testThen("couchbase.xxx"); + CHECK(!actor->testThenReady); + while (!actor->testThenReady) + this_thread::sleep_for(10ms); + CHECK(actor->testThenResult == "Contents of couchbase.xxx"); +} diff --git a/LiteCore/tests/CMakeLists.txt b/LiteCore/tests/CMakeLists.txt index 68200b54e2..f00fd0c7d2 100644 --- a/LiteCore/tests/CMakeLists.txt +++ b/LiteCore/tests/CMakeLists.txt @@ -50,13 +50,15 @@ file(GLOB FLEECE_FILES "../../vendor/fleece/Tests/*.json" "../../vendor/fleece/T file(COPY ${FLEECE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/vendor/fleece/Tests) add_executable( CppTests + LogEncoderTest.cc + ResultTest.cc c4BaseTest.cc c4DocumentTest_Internal.cc + AsyncTest.cc DataFileTest.cc DocumentKeysTest.cc FTSTest.cc LiteCoreTest.cc - LogEncoderTest.cc N1QLParserTest.cc PredictiveQueryTest.cc QueryParserTest.cc @@ -80,6 +82,7 @@ add_executable( ${TOP}vendor/fleece/Tests/SupportTests.cc ${TOP}vendor/fleece/Tests/ValueTests.cc ${TOP}vendor/fleece/Experimental/KeyTree.cc + ${TOP}Replicator/tests/ConnectedClientTest.cc ${TOP}Replicator/tests/DBAccessTestWrapper.cc ${TOP}Replicator/tests/PropertyEncryptionTests.cc ${TOP}Replicator/tests/ReplicatorLoopbackTest.cc diff --git a/LiteCore/tests/ResultTest.cc b/LiteCore/tests/ResultTest.cc new file mode 100644 index 0000000000..bd3cd08c9c --- /dev/null +++ b/LiteCore/tests/ResultTest.cc @@ -0,0 +1,220 @@ +// +// ResultTest.cc +// +// Copyright © 2022 Couchbase. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "Result.hh" +#include "LiteCoreTest.hh" + +using namespace std; +using namespace litecore; + + +static Result rfunc(int x) { + if (x > 0) + return to_string(x); + else if (x < 0) + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; + else + throw logic_error("I didn't expect a kind of Spanish Inquisition!"); +} + + +static Result rvfunc(int x) { + if (x > 0) + return {}; + else if (x < 0) + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; + else + throw logic_error("I didn't expect a kind of Spanish Inquisition!"); +} + + +static string xfunc(int x) { + if (x >= 0) + return to_string(x); + else + C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}.raise(); +} + + +TEST_CASE("Result", "[Result]") { + auto r = rfunc(1); + CHECK(r.ok()); + CHECK(r.value() == "1"); + CHECK(r.error() == kC4NoError); + CHECK(r.errorPtr() == nullptr); + + r = rfunc(-1); + CHECK(!r.ok()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + CHECK(r.errorPtr() != nullptr); + CHECK(*r.errorPtr() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); +} + + +// Test Result::then +TEST_CASE("Result then", "[Result]") { + SECTION("Success") { + Result r = rfunc(11).then([](string &&str) { return str.size();}); + REQUIRE(r.ok()); + CHECK(r.value() == 2); + } + SECTION("Error") { + Result r = rfunc(-1).then([](string &&str) { return str.size();}); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } + + SECTION("Success, returning Result") { + Result r = rfunc(11).then([](string &&str) -> Result { return str.size();}); + REQUIRE(r.ok()); + CHECK(r.value() == 2); + } + SECTION("Error, returning Result") { + Result r = rfunc(11).then([](string &&str) -> Result { + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; + }); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } +} + + +// Test Result::then() +TEST_CASE("Result void then", "[Result]") { + SECTION("Success") { + Result r = rvfunc(11).then([]() { return 2;}); + REQUIRE(r.ok()); + CHECK(r.value() == 2); + } + SECTION("Error") { + Result r = rvfunc(-1).then([]() { return 1;}); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } + + SECTION("Success, returning Result") { + Result r = rvfunc(11).then([]() -> Result { return 2;}); + REQUIRE(r.ok()); + CHECK(r.value() == 2); + } + SECTION("Error, returning Result") { + Result r = rvfunc(11).then([]() -> Result { + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; + }); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } +} + + +// Test Result.then(), where the fn returns void +TEST_CASE("Result then void", "[Result]") { + SECTION("Success") { + optional calledWith; + Result r = rfunc(11).then([&](string &&str) { calledWith = str; }); + REQUIRE(r.ok()); + CHECK(calledWith == "11"); + } + SECTION("Error") { + optional calledWith; + Result r = rfunc(-1).then([&](string &&str) { calledWith = str; }); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } + + SECTION("Success, returning Result") { + optional calledWith; + Result r = rfunc(11).then([&](string &&str) -> Result { + calledWith = str; return {}; + }); + REQUIRE(r.ok()); + CHECK(calledWith == "11"); + } + SECTION("Error, returning Result") { + optional calledWith; + Result r = rfunc(11).then([&](string &&str) -> Result { + calledWith = str; return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; + }); + REQUIRE(r.isError()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + CHECK(calledWith == "11"); + } +} + + +TEST_CASE("Result onError", "[Result]") { + SECTION("Success") { + optional calledWithErr; + Result r = rfunc(11).onError([&](C4Error err) {calledWithErr = err;}); + REQUIRE(r.ok()); + CHECK(r.value() == "11"); + CHECK(!calledWithErr); + } + SECTION("Error") { + optional calledWithErr; + Result r = rfunc(-1).onError([&](C4Error err) {calledWithErr = err;}); + REQUIRE(r.isError()); + CHECK(calledWithErr == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } +} + +TEST_CASE("CatchResult", "[Result]") { + SECTION("Success") { + auto r = CatchResult([]{ return xfunc(4);}); + CHECK(r.value() == "4"); + } + + SECTION("Exception") { + ExpectingExceptions x; + auto r = CatchResult([]{ return xfunc(-1);}); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } + + SECTION("Success when lambda returns Result") { + auto r = CatchResult([]{ return rfunc(4);}); + CHECK(r.value() == "4"); + } + + SECTION("Error when lambda returns Result") { + auto r = CatchResult([]{ return rfunc(-1);}); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); + } + + SECTION("Exception when lambda returns Result") { + ExpectingExceptions x; + auto r = CatchResult([]{ return rfunc(0);}); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorAssertionFailed}); + } +} + + +TEST_CASE("TRY", "[Result]") { + auto fn = [](int x) -> Result { + TRY(string str, rfunc(x)); + TRY(string str2, rfunc(x)); + return str.size(); + }; + + Result r = fn(1234); + REQUIRE(r.ok()); + CHECK(r.value() == 4); + + r = fn(-1); + REQUIRE(!r.ok()); + CHECK(r.error() == C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}); +} diff --git a/Networking/BLIP/BLIPConnection.cc b/Networking/BLIP/BLIPConnection.cc index 46b8f7efe4..3c8c3c2089 100644 --- a/Networking/BLIP/BLIPConnection.cc +++ b/Networking/BLIP/BLIPConnection.cc @@ -16,6 +16,7 @@ #include "WebSocketInterface.hh" #include "Actor.hh" #include "Batcher.hh" +#include "c4EnumUtil.hh" #include "Codec.hh" #include "Error.hh" #include "Logging.hh" @@ -37,6 +38,10 @@ using namespace litecore::websocket; namespace litecore { namespace blip { + // Allow some arithmetic on MessageNo: + DEFINE_ENUM_INC_DEC(MessageNo) + DEFINE_ENUM_ADD_SUB_INT(MessageNo) + static const size_t kDefaultFrameSize = 4096; // Default size of frame static const size_t kBigFrameSize = 16384; // Max size of frame @@ -102,7 +107,7 @@ namespace litecore { namespace blip { MessageQueue _icebox; bool _writeable {true}; MessageMap _pendingRequests, _pendingResponses; - atomic _lastMessageNo {0}; + MessageNo _lastMessageNo {0}; MessageNo _numRequestsReceived {0}; Deflater _outputCodec; Inflater _inputCodec; @@ -349,7 +354,7 @@ namespace litecore { namespace blip { break; // Assign the message number for new requests. - if (msg->_number == 0) + if (msg->_number == MessageNo(0)) msg->_number = ++_lastMessageNo; FrameFlags frameFlags; @@ -362,7 +367,7 @@ namespace litecore { namespace blip { if (!_frameBuf) _frameBuf.reset(new uint8_t[kMaxVarintLen64 + 1 + 4 + kBigFrameSize]); slice_ostream out(_frameBuf.get(), maxSize); - out.writeUVarInt(msg->_number); + out.writeUVarInt(messageno_t(msg->_number)); auto flagsPos = (FrameFlags*)out.next(); out.advance(1); @@ -428,17 +433,17 @@ namespace litecore { namespace blip { // Read the frame header: slice_istream payload = wsMessage->data; _totalBytesRead += payload.size; - uint64_t msgNo; + MessageNo msgNo; FrameFlags flags; { auto pMsgNo = payload.readUVarInt(), pFlags = payload.readUVarInt(); if (!pMsgNo || !pFlags) throw runtime_error("Illegal BLIP frame header"); - msgNo = *pMsgNo; + msgNo = MessageNo{*pMsgNo}; flags = (FrameFlags)*pFlags; } logVerbose("Received frame: %s #%" PRIu64 " %c%c%c%c, length %5ld", - kMessageTypeNames[flags & kTypeMask], msgNo, + kMessageTypeNames[flags & kTypeMask], messageno_t(msgNo), (flags & kMoreComing ? 'M' : '-'), (flags & kUrgent ? 'U' : '-'), (flags & kNoReply ? 'N' : '-'), @@ -577,7 +582,8 @@ namespace litecore { namespace blip { } } else { throw runtime_error(format("BLIP protocol error: Bad incoming RES #%" PRIu64 " (%s)", - msgNo, (msgNo <= _lastMessageNo ? "no request waiting" : "too high"))); + messageno_t(msgNo), + (msgNo <= _lastMessageNo ? "no request waiting" : "too high"))); } return msg; } @@ -623,7 +629,7 @@ namespace litecore { namespace blip { } bool beginning = (state == MessageIn::kBeginning); - auto profile = request->property("Profile"_sl); + auto profile = request->profile(); if (profile) { auto i = _requestHandlers.find({profile.asString(), beginning}); if (i != _requestHandlers.end()) { @@ -639,7 +645,7 @@ namespace litecore { namespace blip { _connection->delegate().onRequestReceived(request); } catch (...) { logError("Caught exception thrown from BLIP request handler"); - request->respondWithError({"BLIP"_sl, 501, "unexpected exception"_sl}); + request->respondWithError({kBLIPErrorDomain, 501, "unexpected exception"_sl}); } } @@ -686,13 +692,27 @@ namespace litecore { namespace blip { /** Public API to send a new request. */ - void Connection::sendRequest(MessageBuilder &mb) { - Retained message = new MessageOut(this, mb, 0); + void Connection::sendRequest(BuiltMessage &&mb) { + Retained message = new MessageOut(this, move(mb), MessageNo{0}); DebugAssert(message->type() == kRequestType); send(message); } + Connection::AsyncResponse Connection::sendAsyncRequest(BuiltMessage &&mb) { + auto asyncProvider = AsyncResponse::makeProvider(); + mb.onProgress = [asyncProvider, oldOnProgress=std::move(mb.onProgress)] + (MessageProgress progress) { + if (progress.state >= MessageProgress::kComplete) + asyncProvider->setResult(progress.reply); + if (oldOnProgress) + oldOnProgress(progress); + }; + sendRequest(move(mb)); + return asyncProvider; + } + + /** Internal API to send an outgoing message (a request, response, or ACK.) */ void Connection::send(MessageOut *msg) { if (_compressionLevel == 0) diff --git a/Networking/BLIP/BLIPConnection.hh b/Networking/BLIP/BLIPConnection.hh index e9cac498ac..d17ede4a52 100644 --- a/Networking/BLIP/BLIPConnection.hh +++ b/Networking/BLIP/BLIPConnection.hh @@ -11,6 +11,7 @@ // #pragma once +#include "Async.hh" #include "WebSocketInterface.hh" #include "Message.hh" #include "Logging.hh" @@ -20,6 +21,7 @@ namespace litecore { namespace blip { class BLIPIO; + class BuiltMessage; class ConnectionDelegate; class MessageOut; @@ -40,7 +42,7 @@ namespace litecore { namespace blip { using CloseStatus = websocket::CloseStatus; - /** WebSocket 'protocol' name for BLIP; use as value of kProtocolsOption option. */ + /** WebSocket 'protocol' name for BLIP; use as value of kC4SocketOptionWSProtocols. */ static constexpr const char *kWSProtocolName = "BLIP_3"; /** Option to set the 'deflate' compression level. Value must be an integer in the range @@ -65,7 +67,14 @@ namespace litecore { namespace blip { void terminate(); /** Sends a built message as a new request. */ - void sendRequest(MessageBuilder&); + void sendRequest(BuiltMessage&&); + + using AsyncResponse = actor::Async>; + + /** Sends a built message as a new request and returns an async value that can be used + to get the response when it arrives. + @note The response will immediately resolve to `nullptr` if the connection closes. */ + AsyncResponse sendAsyncRequest(BuiltMessage&&); typedef std::function RequestHandler; diff --git a/Networking/BLIP/BLIPProtocol.hh b/Networking/BLIP/BLIPProtocol.hh index e16bc1941c..a4d9041268 100644 --- a/Networking/BLIP/BLIPProtocol.hh +++ b/Networking/BLIP/BLIPProtocol.hh @@ -11,36 +11,61 @@ // #pragma once +#include "fleece/slice.hh" #include namespace litecore { namespace blip { // See "docs/BLIP Protocol.md" + /// The types of messages in BLIP. enum MessageType: uint8_t { - kRequestType = 0, // A message initiated by a peer - kResponseType = 1, // A response to a Request - kErrorType = 2, // A response indicating failure + kRequestType = 0, ///< A message initiated by a peer + kResponseType = 1, ///< A response to a Request + kErrorType = 2, ///< A response indicating failure kAckRequestType = 4, // Acknowledgement of data received from a Request (internal) kAckResponseType = 5, // Acknowledgement of data received from a Response (internal) }; - // Array mapping MessageType to a short mnemonic like "REQ". + /// Array mapping MessageType to a short mnemonic like "REQ", for logging purposes. extern const char* const kMessageTypeNames[8]; - + /// The flags at the start of a message frame, including the 3 bits containing the type. enum FrameFlags: uint8_t { - kTypeMask = 0x07, // These 3 bits hold a MessageType - kCompressed = 0x08, // Message payload is gzip-deflated - kUrgent = 0x10, // Message is given priority delivery - kNoReply = 0x20, // Request only: no response desired + kTypeMask = 0x07, ///< These 3 bits hold a MessageType + kCompressed = 0x08, ///< Message payload is gzip-deflated + kUrgent = 0x10, ///< Message is given priority delivery + kNoReply = 0x20, ///< Request only: no response desired kMoreComing = 0x40, // Used only in frames, not in messages }; - typedef uint64_t MessageNo; + using messageno_t = uint64_t; + + /// A message number. Each peer numbers messages it sends sequentially starting at 1. + /// Each peer's message numbers are independent. + enum class MessageNo : messageno_t { }; + + /// The size of a message. typedef uint64_t MessageSize; - // Implementation-imposed max encoded size of message properties (not part of protocol) + /// Implementation-imposed max encoded size of message properties (not part of protocol) constexpr uint64_t kMaxPropertiesSize = 100 * 1024; + + + static constexpr const char* kProfilePropertyStr = "Profile"; + /// The "Profile" property contains the message's type + static constexpr fleece::slice kProfileProperty(kProfilePropertyStr); + + /// Property in an error response giving a namespace for the error code. + /// If omitted the default value is `kBLIPErrorDomain`. + static constexpr fleece::slice kErrorDomainProperty = "Error-Domain"; + + /// Property in an error response giving a numeric error code. + static constexpr fleece::slice kErrorCodeProperty = "Error-Code"; + + /// The default error domain, for errors that are not app-specific. + /// By convention its error codes are based on HTTP's, i.e. 404 for "not found". + static constexpr fleece::slice kBLIPErrorDomain = "BLIP"; + } } diff --git a/Networking/BLIP/LoopbackProvider.hh b/Networking/BLIP/LoopbackProvider.hh index f8f4287633..215f454d80 100644 --- a/Networking/BLIP/LoopbackProvider.hh +++ b/Networking/BLIP/LoopbackProvider.hh @@ -262,7 +262,7 @@ namespace litecore { namespace websocket { } virtual void _close(int status, fleece::alloc_slice message) { - if (_state != State::unconnected) { + if (_state != State::unconnected && _state != State::closed) { Assert(_state == State::connecting || _state == State::connected); logInfo("CLOSE; status=%d", status); std::string messageStr(message); diff --git a/Networking/BLIP/Message.cc b/Networking/BLIP/Message.cc index 74bf12d6fd..f201753a88 100644 --- a/Networking/BLIP/Message.cc +++ b/Networking/BLIP/Message.cc @@ -66,7 +66,7 @@ namespace litecore { namespace blip { void Message::dumpHeader(std::ostream& out) { out << kMessageTypeNames[type()]; - out << " #" << _number << ' '; + out << " #" << messageno_t(_number) << ' '; if (_flags & kUrgent) out << 'U'; if (_flags & kNoReply) out << 'N'; if (_flags & kCompressed) out << 'Z'; @@ -74,7 +74,7 @@ namespace litecore { namespace blip { void Message::writeDescription(slice payload, std::ostream& out) { if (type() == kRequestType) { - const char *profile = findProperty(payload, "Profile"); + const char *profile = findProperty(payload, kProfilePropertyStr); if (profile) out << "'" << profile << "' "; } @@ -178,7 +178,7 @@ namespace litecore { namespace blip { if (!_in) { // First frame! // Update my flags and allocate the Writer: - DebugAssert(_number > 0); + DebugAssert(messageno_t(_number) > 0); _flags = (FrameFlags)(frameFlags & ~kMoreComing); _in.reset(new fleece::JSONEncoder); @@ -327,11 +327,11 @@ namespace litecore { namespace blip { return nullptr; } - _bodyAsFleece = FLData_ConvertJSON({_body.buf, _body.size}, nullptr); + _bodyAsFleece = Doc::fromJSON({_body.buf, _body.size}); if (!_bodyAsFleece && _body != "null"_sl) Warn("MessageIn::JSONBody: Body does not contain valid JSON: %.*s", SPLAT(_body)); } - return fleece::ValueFromData(_bodyAsFleece); + return _bodyAsFleece.root(); } @@ -383,7 +383,7 @@ namespace litecore { namespace blip { void MessageIn::notHandled() { - respondWithError({"BLIP"_sl, 404, "no handler for message"_sl}); + respondWithError({kBLIPErrorDomain, 404, "no handler for message"_sl}); } @@ -437,8 +437,8 @@ namespace litecore { namespace blip { Error MessageIn::getError() const { if (!isError()) return Error(); - return Error(property("Error-Domain"_sl), - (int) intProperty("Error-Code"_sl), + return Error(property(kErrorDomainProperty), + (int) intProperty(kErrorCodeProperty), body()); } diff --git a/Networking/BLIP/Message.hh b/Networking/BLIP/Message.hh index 077eaae718..801707516e 100644 --- a/Networking/BLIP/Message.hh +++ b/Networking/BLIP/Message.hh @@ -137,6 +137,9 @@ namespace litecore { namespace blip { long intProperty(slice property, long defaultValue =0) const; bool boolProperty(slice property, bool defaultValue =false) const; + /** The "Profile" property gives the message's application-level type name. */ + slice profile() const {return property(kProfileProperty);} + /** Returns information about an error (if this message is an error.) */ Error getError() const; @@ -162,9 +165,14 @@ namespace litecore { namespace blip { (The message must be complete.) */ void respond(); - /** Sends an error as a response. (The message must be complete.) */ + /** Sends an error as a response. (The MessageIn must be complete.) */ void respondWithError(Error); + /** Sends a BLIP-domain error as a response. (The MessageIn must be complete.) */ + void respondWithError(int blipErrorCode, slice message) { + respondWithError(Error{kBLIPErrorDomain, blipErrorCode, message}); + } + /** Responds with an error saying that the message went unhandled. Call this if you don't know what to do with a request. (The message must be complete.) */ @@ -206,7 +214,7 @@ namespace litecore { namespace blip { uint32_t _unackedBytes {0}; // # bytes received that haven't been ACKed yet alloc_slice _properties; // Just the (still encoded) properties alloc_slice _body; // Just the body - alloc_slice _bodyAsFleece; // Body re-encoded into Fleece [lazy] + fleece::Doc _bodyAsFleece; // Body re-encoded into Fleece [lazy] const MessageSize _outgoingSize {0}; bool _complete {false}; bool _responded {false}; diff --git a/Networking/BLIP/MessageBuilder.cc b/Networking/BLIP/MessageBuilder.cc index 9936d9808e..91935ba137 100644 --- a/Networking/BLIP/MessageBuilder.cc +++ b/Networking/BLIP/MessageBuilder.cc @@ -31,7 +31,7 @@ namespace litecore { namespace blip { MessageBuilder::MessageBuilder(slice profile) { if (profile) - addProperty("Profile"_sl, profile); + setProfile(profile); } @@ -51,6 +51,12 @@ namespace litecore { namespace blip { } + void MessageBuilder::setProfile(slice profile) { + Assert(!isResponse()); + addProperty(kProfileProperty, profile); + } + + MessageBuilder& MessageBuilder::addProperties(initializer_list properties) { for (const property &p : properties) addProperty(p.first, p.second); @@ -61,8 +67,8 @@ namespace litecore { namespace blip { void MessageBuilder::makeError(Error err) { DebugAssert(err.domain && err.code); type = kErrorType; - addProperty("Error-Domain"_sl, err.domain); - addProperty("Error-Code"_sl, err.code); + addProperty(kErrorDomainProperty, err.domain); + addProperty(kErrorCodeProperty, err.code); write(err.message); } @@ -135,4 +141,12 @@ namespace litecore { namespace blip { _wroteProperties = false; } + + BuiltMessage::BuiltMessage(MessageBuilder &builder) + :dataSource(std::move(builder.dataSource)) + ,onProgress(move(builder.onProgress)) + ,_flags(builder.flags()) + ,_payload(builder.finish()) + { } + } } diff --git a/Networking/BLIP/MessageBuilder.hh b/Networking/BLIP/MessageBuilder.hh index e643480488..d9e82fb2c9 100644 --- a/Networking/BLIP/MessageBuilder.hh +++ b/Networking/BLIP/MessageBuilder.hh @@ -19,18 +19,19 @@ #include namespace litecore { namespace blip { + class BuiltMessage; + /** A callback to provide data for an outgoing message. When called, it should copy data to the location in the `buf` parameter, with a maximum length of `capacity`. It should return the number of bytes written, or 0 on EOF, or a negative number on error. */ - //using MessageDataSource = std::function; class IMessageDataSource { public: virtual int operator() (void *buf, size_t capacity) =0; virtual ~IMessageDataSource() = default; }; - using MessageDataSource = std::unique_ptr; + using MessageDataSource = std::shared_ptr; /** A temporary object used to construct an outgoing message (request or response). @@ -43,13 +44,17 @@ namespace litecore { namespace blip { typedef std::pair property; /** Constructs a MessageBuilder for a request, optionally setting its Profile property. */ - MessageBuilder(slice profile = fleece::nullslice); + explicit MessageBuilder(slice profile = fleece::nullslice); /** Constructs a MessageBuilder for a request, with a list of properties. */ - MessageBuilder(std::initializer_list); + explicit MessageBuilder(std::initializer_list); /** Constructs a MessageBuilder for a response. */ - MessageBuilder(MessageIn *inReplyTo); + explicit MessageBuilder(MessageIn *inReplyTo); + + bool isResponse() const {return type != kRequestType;} + + void setProfile(slice profile); /** Adds a property. */ MessageBuilder& addProperty(slice name, slice value); @@ -98,7 +103,7 @@ namespace litecore { namespace blip { protected: friend class MessageIn; - friend class MessageOut; + friend class BuiltMessage; FrameFlags flags() const; alloc_slice finish(); @@ -114,4 +119,22 @@ namespace litecore { namespace blip { bool _wroteProperties {false}; // Have _properties been written to _out yet? }; + + /** Intermediate value produced by a MessageBuilder, to be passed to the Connection. + (Unlike MessageBuilder this class is copyable, so instances can be captured by + `std::function`. That makes it useable by async code.) */ + class BuiltMessage { + public: + BuiltMessage(MessageBuilder&); + + MessageDataSource dataSource; + MessageProgressCallback onProgress; + + protected: + friend class MessageOut; + + FrameFlags _flags; + fleece::alloc_slice _payload; + }; + } } diff --git a/Networking/BLIP/MessageOut.cc b/Networking/BLIP/MessageOut.cc index 988a86d6aa..afdb880a2a 100644 --- a/Networking/BLIP/MessageOut.cc +++ b/Networking/BLIP/MessageOut.cc @@ -36,6 +36,19 @@ namespace litecore { namespace blip { { } + MessageOut::MessageOut(Connection *connection, + BuiltMessage &&built, + MessageNo number) + :MessageOut(connection, + built._flags, + move(built._payload), + move(built.dataSource), + number) + { + _onProgress = move(built.onProgress); + } + + void MessageOut::nextFrameToSend(Codec &codec, slice_ostream &dst, FrameFlags &outFlags) { outFlags = flags(); if (isAck()) { diff --git a/Networking/BLIP/MessageOut.hh b/Networking/BLIP/MessageOut.hh index c612d61530..6962220142 100644 --- a/Networking/BLIP/MessageOut.hh +++ b/Networking/BLIP/MessageOut.hh @@ -33,13 +33,8 @@ namespace litecore { namespace blip { MessageNo number); MessageOut(Connection *connection, - MessageBuilder &builder, - MessageNo number) - :MessageOut(connection, (FrameFlags)0, builder.finish(), std::move(builder.dataSource), number) - { - _flags = builder.flags(); // finish() may update the flags, so set them after - _onProgress = std::move(builder.onProgress); - } + BuiltMessage &&built, + MessageNo number); void dontCompress() {_flags = (FrameFlags)(_flags & ~kCompressed);} void nextFrameToSend(Codec &codec, fleece::slice_ostream &dst, FrameFlags &outFlags); diff --git a/Networking/BLIP/cmake/platform_base.cmake b/Networking/BLIP/cmake/platform_base.cmake index 533bc57ff3..1226c17349 100644 --- a/Networking/BLIP/cmake/platform_base.cmake +++ b/Networking/BLIP/cmake/platform_base.cmake @@ -15,11 +15,10 @@ function(set_source_files_base) ${WEBSOCKETS_LOCATION}/WebSocketImpl.cc ${WEBSOCKETS_LOCATION}/WebSocketInterface.cc ${SUPPORT_LOCATION}/Actor.cc - ${SUPPORT_LOCATION}/ActorProperty.cc -# ${SUPPORT_LOCATION}/Async.cc + ${SUPPORT_LOCATION}/Async.cc ${SUPPORT_LOCATION}/Channel.cc ${SUPPORT_LOCATION}/Codec.cc ${SUPPORT_LOCATION}/Timer.cc PARENT_SCOPE ) -endfunction() \ No newline at end of file +endfunction() diff --git a/Networking/BLIP/docs/Async.md b/Networking/BLIP/docs/Async.md new file mode 100644 index 0000000000..9932c2f47b --- /dev/null +++ b/Networking/BLIP/docs/Async.md @@ -0,0 +1,299 @@ +# The Async API + +(Last updated March 2 2022 by Jens) + +**Async** is a major extension of LiteCore’s concurrency support, which should help us write clearer and safer multithreaded code in the future. It extends the functionality of Actors: so far, Actor methods have had to return `void` since they’re called asynchronously. Getting a value back from an Actor meant explicitly passing a callback function. + +The Async feature allows Actor methods to return values; it’s just that those values are themselves asynchronous, and can’t be accessed by the caller until the Actor method finishes and returns a value. This may seem constraining, but it’s actually very useful. And any class can take advantage of Async values, not just Actors. + +> If this sounds familiar: yes, this is an implementation of async/await as found in C#, JavaScript, Rust, etc. (C++ itself is getting this feature too, but not until C++20, and even then it’s only half-baked.) + +## 1. Asynchronous Values (Futures & Promises) + +`Async` represents a value of type `T` that may not be available until some future time. This concept is also referred to as a ["future"](https://en.wikipedia.org/wiki/Futures_and_promises). You can keep it around like a normal value type, but you can’t get the underlying value until it becomes available. + +> You can think of `Async` as sort of like `std::optional`, except you can’t store a value in it yourself, only wait until something else does ... but what? + +An `Async` has a matching object, `AsyncProvider`, that was created along with it and which belongs to whomever is responsible for producing that `T` value. (This is sometimes referred to as a “promise”.) The producer keeps it around, probably in a `Retained<>` wrapper, until such time as the result becomes available, then calls `setResult` on it to store the value into its matching `Async`. + +#### Example + +Here’s a rather dumbed-down example of sending a request to a server and getting a response: + +```c++ +static Retained> _curProvider; + +Async getIntFromServer() { + _curProvider = Async::makeProvider(); + sendServerRequest(); + return _curProvider->asyncValue(); +} +``` + +Internally, this uses an `AsyncProvider` reference to keep track of the current request (I told you this was dumbed down!), so when the response arrives it can store it into the provider and thereby into the caller’s `Async` value: + +```c++ +static void receivedResponseFromServer(int result) { + _curProvider.setResult(result); + _curProvider = nullptr; +} +``` + +On the calling side you can start the request, go on your merry way, and then later get the value once it’s ready: + +```c++ +Async request = getIntFromServer(); // returns immediately! +//... do other stuff ... + +//... later, when the response is available: +int i = request.result(); +cout << "Server says: " << i << "!\n"; +``` + +Only … when is “later”, exactly? How do you know? + +## 2. Getting The Result With `then` + +You can’t call `Async::result()` until the result is available, or else Bad Stuff happens, like a fatal exception. We don’t want anything to block; that’s the point of async! + +There’s a safe `ready()` method that returns `true` after the result is available. But obviously it would be a bad idea to do something like `while (!request.ready()) { }` … + +So how do you wait for the result? **You don’t.** Instead you let the Async call _you_, by registering a callback. `Async`'s `then` method takes a lambda function that will be called with the result when it’s available: + +```c++ +Async request = getIntFromServer(); +request.then([=](int i) { + std::cout << "The result is " << i << "!\n"; +}, assertNoError); +``` + +> (What’s that `assertNoError`? Ignore it for now; it’ll be explained in the error handling section.) + +What if you need that lambda to return a value? That value won’t be available until later when the lambda runs, so it too is returned as an `Async`: + +```c++ +Async message = getIntFromServer().then([=](int i) { + return "The result is " + std::stoi(i) + "!"; +}); +``` + +This works even if the inner lambda itself returns an `Async`: + +```c++ +extern Async storeIntOnServer(int); + +Async status = getIntFromServer().then([=](int i) { + return storeIntOnServer(i + 1); +}); +``` + +In this situation it can be useful to **chain multiple `then` calls:** + +```c++ +Async message = getIntFromServer().then([=](int i) { + return storeIntOnServer(i + 1); +}).then([=](Status s) { + return status == Ok ? "OK!" : "Failure"; +}); +``` + +### Async with no value (`Async`) + +Sometimes an asynchronous operation doesn’t need to return a value, but you still want to use `Async` with it so callers can be notified when it finishes. For that, use `Async`. For example: + +```c++ +Async slowOperation() { + _curProvider = Async::makeProvider(); + startOperationInBackground(); + return _curProvider->asyncValue(); +} + +static void operationFinished() { + _curProvider.setResult(kC4NoError); + _curProvider = nullptr; +} +``` + +Since there’s no actual result, you store a no-error value in the provider to indicate that it’s done. + +Similarly with a `then` call — if your callback returns nothing (`void`), the result will be an `Async` that merely indicates the completion of the callback: + +```c++ +Async done = getIntFromServer().then([=](int i) { + _currentInt = i; +}); +``` + +### Be Careful With Captures! + +It’s worth repeating the usual warnings about lambdas that can be called after the enclosing scope returns: **don’t capture by reference** (don’t use `[&]`) and **don’t capture pointers or `slice`s**. Here C++14’s capture-initializer syntax can be helpful: + +```c++ +slice str = .....; // slices are not safe to capture! +somethingAsync().then([str = alloc_slice(str)] // capture `str` as `alloc_slice` + (int i) { ... }); +``` + +One remaining problem is that **you can’t capture uncopyable types, like unique_ptr**. If you try you’ll get strange error messages from down in the standard library headers. The root problem is that `std::function` is copyable, so it requires that lambdas be copyable, which means their captured values have to be copyable. Facebook’s *folly* library has an alternative [Function](https://github.com/facebook/folly/blob/main/folly/docs/Function.md) class that avoids this problem, so if this turns out to be enough of a headache we could consider adopting that. + +## 3. Async and Actors + +### Running `then` on the Actor’s Thread + +By default, a `then()` callback is called immediately when the provider’s `setResult()` is called, i.e. on the same thread the provider is running on. + +But Actors want everything to run on their thread. For that case, `Async` has an `on(Actor*)` method that lets you specify that a subsequent `then()` should schedule its callback on the Actor’s thread. + +```c++ +Async MyActor::downloadInt() { + return getIntFromServer() .on(this) .then([=](int i) { + // This code runs on the Actor's thread + _myInt = i; + }); +} +``` + +### Implementing Async Actor Methods + +A public method of an Actor can be called on any thread, so normally it just enqueues a call to the real method, which is private and (by convention) has an “_” prefix on its name: + +```c++ +class MyActor : public Actor { +public: + void start() { enqueue(FUNCTION_TO_QUEUE(MyActor::_start)); } +private: + void _start() { /* This code runs on the Actor's thread */ } +``` + +A new addition to Actor provides a way to do this without having to have two methods. It also makes it easy to return an Async value from an Actor method. All you do is wrap the body of the method in a lambda passed to `asCurrentActor()`: + +```c++ +class MyActor : public Actor { +public: + void start() { + return asCurrentActor([=] { /* This code runs on the Actor's thread */ }); + } + + Async getStatus() { + return asCurrentActor([=] { + // This code runs on the Actor's thread + return _status; + }); + } +``` + +As a bonus, if `asCurrentActor` is called on the Actor’s thread, it just calls the function immediately without enqueuing it, which is faster. + +# Exceptions & C4Errors + +### Providing an Error Result + +Any Async value (regardless of its type parameter) can resolve to an error instead of a result. You can store one by calling `setError(C4Error)` on the provider. + + If the code producing the value throws an exception, you can catch it and set it as the result with `setError()`. + +```c++ +try { + ... + provider->setResult(result); +} catch (const std::exception &x) { + provider->setError(x)); +} +``` + +> Note: `asCurrentActor()` catches exceptions thrown by its lambda and returns them as an error on the returned Async. + +### The `Result` class + +By the way, as part of implementing this, I added a general purpose `Result` class (see `Result.hh`.) This simply holds either a value of type `T` or a `C4Error`. It’s similar to types found in Swift, Rust, etc. + +```c++ +Result squareRoot(double n) { + if (n >= 0) + return sqrt(n); + else + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; +} + +if (auto root = squareRoot(x); root.ok()) + cout << "√x = " << root.value() << endl; +else + cerr << "No square root: " << root.error().description() << endl; +``` + + + +### Handling An Error + +The regular `then` methods described earlier can’t tell their callback about an error, because their callbacks take a parameter of type `T`. So what happens if the result is an error? Consider this example from earlier: + +```c++ +Async incrementIntOnServer() { + return getIntFromServer().then([=](int i) { + return storeIntOnServer(i + 1); + }); +} +``` + +What happens if the async result of `getIntFromServer()` is an error? **The callback lambda is not called.** Instead, the error value is propagated to the `Async` , basically “passing the buck” to the caller of `incrementIntOnServer`. This is usually what you want. + +If you want to handle the result whether or not it’s an error, you can set the callback’s parameter type to `Result`: + +```c++ +getIntFromServer().then([=](Result i) { + if (i.ok()) + _latestInt = i.value(); + else + cerr << "Couldn't get int: " << i.error().description() << endl; +}); +``` + +Note that this form of `then()` does not return any value, because the callback completely handles the operation. + +Another way to do this is to pass **two callbacks** to `then`: + +```c++ +getIntFromServer().then([=](int i) { + _latestInt = i.value(); +}, [=](C4Error error) { + cerr << "Couldn't get int: " << error.description() << endl; +}); +``` + +This finally explains the reason for mysterious `assertNoError` in the first example of section 2: that’s a function declared in `Async.hh` that simply takes a `C4Error` and throws an exception if it’s non-zero. That example was calling this two-callback version of `then` but idiomatically asserting that there would be no error. + +### Returning an error from a `then` callback + +There are two ways that a `then` method’s callback can signal an error. + +1. The callback can throw an exception. This will be caught and converted into a `C4Error` result. +2. The callback can return a `C4Error` directly, by explicitly declaring a return type of `Result`. This works because `Result` can be initialized with either a value or an error. + +Here’s an example of the second form: + +```c++ +Async squareRootFromServer() { + return getIntFromServer().then([=](int i) -> Result { // explicit result type! + if (i >= 0) + return sqrt(i); + else + return C4Error{LiteCoreDomain, kC4ErrorRemoteError}; + }); +} +``` + +## Appendix: Design + +First off, I’m aware that C++ already has a `std::future` class. However, it uses blocking control flow: + +> The `get` member function waits until the `future` has a valid result and (depending on which template is used) retrieves it. It effectively calls `wait()` in order to wait for the result. ([\*](https://en.cppreference.com/w/cpp/thread/future/get)) + +`std::future` has no mechanism to observe the result or register a callback. This makes it unusable in our async-oriented concurrency system. + +The “async/await” mechanism that’s now available in many languages was an inspiration, but unfortunately it’s not possible to implement something like `await` in C++17 — it changes control flow fundamentally, turning the enclosing function into a coroutine. I did try to implement this using some [weird C(++) tricks](https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html) and macros, but it was too inflexible and had too many broken edge cases. We’ll have to wait until we can move to [C++20](https://en.cppreference.com/w/cpp/language/coroutines). + +You *can* do async without `await`; it just needs a “`then({...})`” idiom of chaining callback handlers. JavaScript did this before the `await` syntax was added in 2017. + +Two C++ libraries I took design ideas from were [Folly](https://engineering.fb.com/2015/06/19/developer-tools/futures-for-c-11-at-facebook/) (by Facebook) and [Cap’n Proto](https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#asynchronous-event-loop). I went with a different class name, though; Folly calls them `future` and Cap’n Proto calls them `Promise`. I just liked `Async` better. `¯\_(ツ)_/¯` + +I didn’t directly use either library because their async code is tied to their own implementations of event loops, while we need to tie in with our existing `Actor` and `Mailbox`. diff --git a/Networking/WebSockets/BuiltInWebSocket.cc b/Networking/WebSockets/BuiltInWebSocket.cc index afabcff3da..3989137464 100644 --- a/Networking/WebSockets/BuiltInWebSocket.cc +++ b/Networking/WebSockets/BuiltInWebSocket.cc @@ -323,7 +323,9 @@ namespace litecore { namespace websocket { alloc_slice BuiltInWebSocket::cookiesForRequest(const Address &addr) { - alloc_slice cookies(_database->getCookies(addr)); + alloc_slice cookies; + if (_database) + cookies = _database->getCookies(addr); slice cookiesOption = options()[kC4ReplicatorOptionCookies].asString(); if (cookiesOption) { @@ -341,7 +343,8 @@ namespace litecore { namespace websocket { void BuiltInWebSocket::setCookie(const Address &addr, slice cookieHeader) { - _database->setCookie(cookieHeader, addr.hostname, addr.path); + if (_database) + _database->setCookie(cookieHeader, addr.hostname, addr.path); } diff --git a/REST/RESTListener+Handlers.cc b/REST/RESTListener+Handlers.cc index 98700547e3..07d7c9baf7 100644 --- a/REST/RESTListener+Handlers.cc +++ b/REST/RESTListener+Handlers.cc @@ -20,6 +20,7 @@ #include "Server.hh" #include "StringUtil.hh" #include "c4ExceptionUtils.hh" +#include "LegacyAttachments.hh" #include "fleece/Expert.hh" #include @@ -280,7 +281,8 @@ namespace litecore { namespace REST { // Encode body as Fleece (and strip _id and _rev): alloc_slice encodedBody; if (body) - encodedBody = doc->encodeStrippingOldMetaProperties(body, coll->getDatabase()->getFleeceSharedKeys()); + encodedBody = legacy_attachments::encodeStrippingOldMetaProperties(body, + coll->getDatabase()->getFleeceSharedKeys()); // Save the revision: C4Slice history[1] = {revID}; diff --git a/Replicator/ConnectedClient/ConnectedClient.cc b/Replicator/ConnectedClient/ConnectedClient.cc new file mode 100644 index 0000000000..dbb02c829c --- /dev/null +++ b/Replicator/ConnectedClient/ConnectedClient.cc @@ -0,0 +1,664 @@ +// +// ConnectedClient.cc +// +// Copyright © 2022 Couchbase. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "ConnectedClient.hh" +#include "c4BlobStore.hh" +#include "c4Document.hh" +#include "c4SocketTypes.h" +#include "Headers.hh" +#include "LegacyAttachments.hh" +#include "MessageBuilder.hh" +#include "NumConversion.hh" +#include "PropertyEncryption.hh" +#include "slice_stream.hh" +#include "WebSocketInterface.hh" +#include "c4Internal.hh" +#include "fleece/Mutable.hh" +#include + + +#define _options DONT_USE_OPTIONS // inherited from Worker, but replicator-specific, not used here + +namespace litecore::client { + using namespace std; + using namespace fleece; + using namespace litecore::actor; + using namespace blip; + + + alloc_slice ConnectedClient::Delegate::getBlobContents(const C4BlobKey &, C4Error *error) { + Warn("ConnectedClient's delegate needs to override getBlobContents!"); + *error = C4Error::make(LiteCoreDomain, kC4ErrorNotFound); + return nullslice; + } + + + + ConnectedClient::ConnectedClient(websocket::WebSocket* webSocket, + Delegate& delegate, + const C4ConnectedClientParameters ¶ms) + :Worker(new Connection(webSocket, AllocedDict(params.optionsDictFleece), *this), + nullptr, nullptr, nullptr, "Client") + ,_delegate(&delegate) + ,_params(params) + ,_activityLevel(kC4Stopped) + { + _importance = 2; + } + + + void ConnectedClient::setStatus(ActivityLevel level) { + if (level != _activityLevel) { + _activityLevel = level; + + LOCK(_mutex); + if (_delegate) { + Status status = Worker::status(); + status.level = _activityLevel; + _delegate->clientStatusChanged(this, status); + } + } + } + + + Async ConnectedClient::status() { + return asCurrentActor([this]() {return C4ReplicatorStatus(Worker::status());}); + } + + + void ConnectedClient::start() { + Assert(_activityLevel == kC4Stopped); + setStatus(kC4Connecting); + asCurrentActor([=] { + logInfo("Connecting..."); + connection().start(); + registerHandler("getAttachment", &ConnectedClient::handleGetAttachment); + _selfRetain = this; // retain myself while the connection is open + }); + } + + void ConnectedClient::stop() { + asCurrentActor([=] { + _disconnect(websocket::kCodeNormal, {}); + }); + } + + + void ConnectedClient::_disconnect(websocket::CloseCode closeCode, slice message) { + if (connected()) { + logInfo("Disconnecting..."); + connection().close(closeCode, message); + setStatus(kC4Stopping); + } + } + + void ConnectedClient::terminate() { + LOCK(_mutex); + _delegate = nullptr; + } + + + ConnectedClient::ActivityLevel ConnectedClient::computeActivityLevel() const { + return _activityLevel; + } + + +#pragma mark - BLIP DELEGATE: + + + void ConnectedClient::onTLSCertificate(slice certData) { + LOCK(_mutex); + if (_delegate) + _delegate->clientGotTLSCertificate(this, certData); + } + + + void ConnectedClient::onHTTPResponse(int status, const websocket::Headers &headers) { + asCurrentActor([=] { + logVerbose("Got HTTP response from server, status %d", status); + { + LOCK(_mutex); + if (_delegate) + _delegate->clientGotHTTPResponse(this, status, headers); + } + + if (status == 101 && !headers["Sec-WebSocket-Protocol"_sl]) { + gotError(C4Error::make(WebSocketDomain, kWebSocketCloseProtocolError, + "Incompatible replication protocol " + "(missing 'Sec-WebSocket-Protocol' response header)"_sl)); + } + }); + } + + + void ConnectedClient::onConnect() { + asCurrentActor([=] { + logInfo("Connected!"); + if (_activityLevel != kC4Stopping) // skip this if stop() already called + setStatus(kC4Idle); + }); + } + + + void ConnectedClient::onClose(Connection::CloseStatus status, Connection::State state) { + asCurrentActor([=]() mutable { + logInfo("Connection closed with %-s %d: \"%.*s\" (state=%d)", + status.reasonName(), status.code, FMTSLICE(status.message), state); + + bool closedByPeer = (_activityLevel != kC4Stopping); + + _connectionClosed(); + + if (status.isNormal() && closedByPeer) { + logInfo("I didn't initiate the close; treating this as code 1001 (GoingAway)"); + status.code = websocket::kCodeGoingAway; + status.message = alloc_slice("WebSocket connection closed by peer"); + } + + static const C4ErrorDomain kDomainForReason[] = {WebSocketDomain, POSIXDomain, + NetworkDomain, LiteCoreDomain}; + + // If this was an unclean close, set my error property: + if (status.reason != websocket::kWebSocketClose || status.code != websocket::kCodeNormal) { + int code = status.code; + C4ErrorDomain domain; + if (status.reason < sizeof(kDomainForReason)/sizeof(C4ErrorDomain)) { + domain = kDomainForReason[status.reason]; + } else { + domain = LiteCoreDomain; + code = kC4ErrorRemoteError; + } + gotError(C4Error::make(domain, code, status.message)); + } + setStatus(kC4Stopped); + { + LOCK(_mutex); + if (_delegate) + _delegate->clientConnectionClosed(this, status); + } + + _selfRetain = nullptr; // balances the self-retain in start() + }); + } + + + // This only gets called if none of the registered handlers were triggered. + void ConnectedClient::onRequestReceived(MessageIn *msg) { + warn("Received unrecognized BLIP request #%" PRIu64 " with Profile '%.*s', %zu bytes", + msg->number(), FMTSLICE(msg->profile()), msg->body().size); + msg->notHandled(); + } + + +#pragma mark - REQUESTS: + + + // Returns the error status of a response (including a NULL response, i.e. disconnection) + C4Error ConnectedClient::responseError(MessageIn *response) { + C4Error error; + if (!response) { + // Disconnected! + error = Worker::status().error; + if (!error) + error = C4Error::make(LiteCoreDomain, kC4ErrorIOError, "network connection lost"); + // TODO: Use a better default error than the one above + } else if (response->isError()) { + error = blipToC4Error(response->getError()); + if (error.domain == WebSocketDomain) { + switch (error.code) { + case 404: error.domain = LiteCoreDomain; error.code = kC4ErrorNotFound; break; + case 409: error.domain = LiteCoreDomain; error.code = kC4ErrorConflict; break; + } + } + } else { + error = {}; + } + if (error) + logError("Connected Client got error response %s", error.description().c_str()); + return error; + } + + + Async ConnectedClient::getDoc(slice docID_, + slice collectionID_, + slice unlessRevID_, + bool asFleece) + { + // Not yet running on Actor thread... + logInfo("getDoc(\"%.*s\")", FMTSLICE(docID_)); + alloc_slice docID(docID_); + MessageBuilder req("getRev"); + req["id"] = docID; + req["ifNotRev"] = unlessRevID_; + + return sendAsyncRequest(req) + .then([=](Retained response) -> Async { + logInfo("...getDoc got response"); + + if (C4Error err = responseError(response)) + return err; + + return DocResponse { + docID, + alloc_slice(response->property("rev")), + processIncomingDoc(docID, response->body(), asFleece), + response->boolProperty("deleted") + }; + }); + } + + + // (This method's code is adapted from IncomingRev::parseAndInsert) + alloc_slice ConnectedClient::processIncomingDoc(slice docID, + alloc_slice jsonData, + bool asFleece) + { + if (!jsonData) + return jsonData; + + bool modified = false; + bool tryDecrypt = _params.propertyDecryptor && repl::MayContainPropertiesToDecrypt(jsonData); + + // Convert JSON to Fleece: + FLError flErr; + Doc fleeceDoc = Doc::fromJSON(jsonData, &flErr); + if (!fleeceDoc) + C4Error::raise(FleeceDomain, flErr, "Unparseable JSON response from server"); + alloc_slice fleeceData = fleeceDoc.allocedData(); + Dict root = fleeceDoc.asDict(); + + // Decrypt properties: + MutableDict decryptedRoot; + if (tryDecrypt) { + C4Error error; + decryptedRoot = repl::DecryptDocumentProperties({}, //TODO: Pass collection spec + docID, + root, + _params.propertyDecryptor, + _params.callbackContext, + &error); + if (decryptedRoot) { + root = decryptedRoot; + modified = true; + } else if (error) { + error.raise(); + } + } + + // Strip out any "_"-prefixed properties like _id, just in case, and also any + // attachments in _attachments that are redundant with blobs elsewhere in the doc. + // This also re-encodes, updating fleeceData, if `root` was modified by the decryptor. + if (modified || legacy_attachments::hasOldMetaProperties(root)) { + fleeceData = legacy_attachments::encodeStrippingOldMetaProperties(root, nullptr); + if (!fleeceData) + C4Error::raise(LiteCoreDomain, kC4ErrorRemoteError, + "Invalid legacy attachments received from server"); + //modified = true; + if (!asFleece) + jsonData = Doc(fleeceData, kFLTrusted).root().toJSON(); + } + + return asFleece ? fleeceData : jsonData; + } + + + Async ConnectedClient::getBlob(C4BlobKey blobKey, + bool compress) + { + // Not yet running on Actor thread... + auto digest = blobKey.digestString(); + logInfo("getAttachment(<%s>)", digest.c_str()); + MessageBuilder req("getAttachment"); + req["digest"] = digest; + if (compress) + req["compress"] = "true"; + + return sendAsyncRequest(req) + .then([=](Retained response) -> Async { + logInfo("...getAttachment got response"); + if (C4Error err = responseError(response)) + return err; + return response->body(); + }); + } + + + Async ConnectedClient::putDoc(slice docID_, + slice collectionID_, + slice revID_, + slice parentRevID_, + C4RevisionFlags revisionFlags, + slice fleeceData_) + { + // Not yet running on Actor thread... + logInfo("putDoc(\"%.*s\", \"%.*s\")", FMTSLICE(docID_), FMTSLICE(revID_)); + MessageBuilder req("putRev"); + req.compressed = true; + req["id"] = docID_; + req["rev"] = revID_; + req["history"] = parentRevID_; + if (revisionFlags & kRevDeleted) + req["deleted"] = "1"; + + if (fleeceData_.size > 0) { + processOutgoingDoc(docID_, revID_, fleeceData_, req.jsonBody()); + } else { + req.write("{}"); + } + + return sendAsyncRequest(req) + .then([=](Retained response) -> Async { + logInfo("...putDoc got response"); + return Async(responseError(response)); + }); + } + + + static inline bool MayContainBlobs(fleece::slice documentData) noexcept { + return documentData.find(C4Document::kObjectTypeProperty) + && documentData.find(C4Blob::kObjectType_Blob); + } + + + void ConnectedClient::processOutgoingDoc(slice docID, slice revID, + slice fleeceData, + JSONEncoder &enc) + { + Dict root = Value(FLValue_FromData(fleeceData, kFLUntrusted)).asDict(); + if (!root) + C4Error::raise(LiteCoreDomain, kC4ErrorCorruptRevisionData, + "Invalid Fleece data passed to ConnectedClient::putDoc"); + + // Encrypt any encryptable properties + MutableDict encryptedRoot; + if (repl::MayContainPropertiesToEncrypt(fleeceData)) { + logVerbose("Encrypting properties in doc '%.*s'", FMTSLICE(docID)); + C4Error c4err; + encryptedRoot = repl::EncryptDocumentProperties({}, // TODO: Pass collection spec + docID, root, + _params.propertyEncryptor, + _params.callbackContext, + &c4err); + if (encryptedRoot) + root = encryptedRoot; + else if (c4err) + c4err.raise(); + } + + if (_remoteNeedsLegacyAttachments && MayContainBlobs(fleeceData)) { + // Create shadow copies of blobs, in `_attachments`: + int revpos = C4Document::getRevIDGeneration(revID); + legacy_attachments::encodeRevWithLegacyAttachments(enc, root, revpos); + } else { + enc.writeValue(root); + } + } + + + void ConnectedClient::handleGetAttachment(Retained req) { + // Pass the buck to the delegate: + alloc_slice contents; + C4Error error = {}; + try { + if (auto blobKey = C4BlobKey::withDigestString(req->property("digest"_sl))) + contents = _delegate->getBlobContents(*blobKey, &error); + else + error = C4Error::make(WebSocketDomain, 400, "Invalid 'digest' property in request"); + } catch (...) { + error = C4Error::fromCurrentException(); + } + if (!contents) { + if (!error) + error = C4Error::make(LiteCoreDomain, kC4ErrorNotFound); + req->respondWithError(c4ToBLIPError(error)); + return; + } + + MessageBuilder reply(req); + reply.compressed = req->boolProperty("compress"_sl); + reply.write(contents); + req->respond(reply); + } + + + void ConnectedClient::getAllDocIDs(slice collectionID, + slice globPattern, + AllDocsReceiver receiver) + { + MessageBuilder req("allDocs"); + if (!globPattern.empty()) + req["idPattern"] = globPattern; + sendAsyncRequest(req) + .then([=](Retained response) { + logInfo("...allDocs got response"); + C4Error err = responseError(response); + if (!err) { + if (!receiveAllDocs(response, receiver)) + err = C4Error::make(LiteCoreDomain, kC4ErrorRemoteError, + "Invalid allDocs response"); + } + // Final call to receiver: + receiver({}, err ? &err : nullptr); + + }).onError([=](C4Error err) { + logInfo("...allDocs got error"); + receiver({}, &err); + }); + //OPT: If we stream the response we can call the receiver function on results as they arrive. + } + + + bool ConnectedClient::receiveAllDocs(blip::MessageIn *response, const AllDocsReceiver &receiver) { + Array body = response->JSONBody().asArray(); + if (!body) + return false; + if (body.empty()) + return true; + vector docIDs; + docIDs.reserve(body.count()); + for (Array::iterator i(body); i; ++i) { + slice docID = i->asString(); + if (!docID) + return false; + docIDs.push_back(docID); + } + receiver(docIDs, nullptr); + return true; + } + + + Async ConnectedClient::observeCollection(slice collectionID_, + CollectionObserver callback_) + { + return asCurrentActor([this, + collectionID = alloc_slice(collectionID_), + observe = !!callback_, + callback = move(callback_)] () -> Async { + logInfo("observeCollection(%.*s)", FMTSLICE(collectionID)); + + bool sameSubState = (observe == !!_observer); + _observer = move(callback); + if (sameSubState) + return C4Error{}; + + MessageBuilder req; + if (observe) { + if (!_registeredChangesHandler) { + registerHandler("changes", &ConnectedClient::handleChanges); + _registeredChangesHandler = true; + } + req.setProfile("subChanges"); + req["future"] = true; + req["continuous"] = true; + } else { + req.setProfile("unsubChanges"); + } + + return sendAsyncRequest(req) + .then([=](Retained response) { + logInfo("...observeCollection got response"); + return Async(responseError(response)); + }); + }); + } + + + void ConnectedClient::handleChanges(Retained req) { + // The code below is adapted from RevFinder::handleChangesNow and RevFinder::findRevs. + auto inChanges = req->JSONBody().asArray(); + if (!inChanges && req->body() != "null"_sl) { + warn("Invalid body of 'changes' message"); + req->respondWithError(400, "Invalid JSON body"_sl); + return; + } + + // "changes" expects a response with an array of which items we want "rev" messages for. + // We don't actually want any. An empty array will indicate that. + if (!req->noReply()) { + MessageBuilder response(req); + auto &enc = response.jsonBody(); + enc.beginArray(); + enc.endArray(); + req->respond(response); + } + + if (_observer && !inChanges.empty()) { + logInfo("Received %u doc changes from server", inChanges.count()); + // Convert the JSON change list into a vector: + vector outChanges; + outChanges.reserve(inChanges.count()); + for (auto item : inChanges) { + // "changes" entry: [sequence, docID, revID, deleted?, bodySize?] + auto inChange = item.asArray(); + slice docID = inChange[1].asString(); + slice revID = inChange[2].asString(); + if (validateDocAndRevID(docID, revID)) { + auto &outChange = outChanges.emplace_back(); + outChange.sequence = C4SequenceNumber{inChange[0].asUnsigned()}; + outChange.docID = docID; + outChange.revID = revID; + outChange.flags = 0; + int64_t deletion = inChange[3].asInt(); + outChange.bodySize = fleece::narrow_cast(inChange[4].asUnsigned()); + + // In SG 2.x "deletion" is a boolean flag, 0=normal, 1=deleted. + // SG 3.x adds 2=revoked, 3=revoked+deleted, 4=removal (from channel) + if (deletion & 0b001) + outChange.flags |= kRevDeleted; + if (deletion & 0b110) + outChange.flags |= kRevPurged; + } + } + + // Finally call the observer callback: + try { + _observer(outChanges); + } catch (...) { + logError("ConnectedClient observer threw exception: %s", + C4Error::fromCurrentException().description().c_str()); + } + } + } + + + bool ConnectedClient::validateDocAndRevID(slice docID, slice revID) { + bool valid; + if (!C4Document::isValidDocID(docID)) + valid = false; + else if (_remoteUsesVersionVectors) + valid = revID.findByte('@') && !revID.findByte('*'); // require absolute form + else + valid = revID.findByte('-'); + if (!valid) { + warn("Invalid docID/revID '%.*s' #%.*s in incoming change list", + FMTSLICE(docID), FMTSLICE(revID)); + } + return valid; + } + + + void ConnectedClient::query(slice name, + fleece::Dict parameters, + bool asFleece, + QueryReceiver receiver) + { + MessageBuilder req("query"); + if (name.hasPrefix("SELECT ") || name.hasPrefix("select ") || name.hasPrefix("{")) + req["src"] = name; + else + req["name"] = name; + if (parameters) { + req.jsonBody().writeValue(parameters); + } else { + req.jsonBody().beginDict(); + req.jsonBody().endDict(); + } + sendAsyncRequest(req) + .then([=](Retained response) { + logInfo("...query got response"); + C4Error err = responseError(response); + if (!err) { + if (!receiveQueryRows(response, receiver, asFleece)) + err = C4Error::make(LiteCoreDomain, kC4ErrorRemoteError, + "Couldn't parse server's response"); + } + // Final call to receiver: + receiver(nullslice, nullptr, err ? &err : nullptr); + + }).onError([=](C4Error err) { + logInfo("...query got error"); + receiver(nullslice, nullptr, &err); + }); + //OPT: If we stream the response we can call the receiver function on results as they arrive. + } + + +#if DEBUG + static constexpr bool kCheckJSON = true; +#else + static constexpr bool kCheckJSON = false; +#endif + + + // not currently used; keeping it in case we decide to change the response format to lines-of-JSON + bool ConnectedClient::receiveQueryRows(blip::MessageIn *response, + const QueryReceiver &receiver, + bool asFleece) + { + slice_istream body(response->body()); + while (!body.eof()) { + // Get next line of JSON, up to a newline: + slice rowData = body.readToDelimiterOrEnd("\n"); + if (!rowData.empty()) { + Dict rowDict; + Doc doc; + if (asFleece || kCheckJSON) { + doc = Doc::fromJSON(rowData); + rowDict = doc.asDict(); + if (!rowDict) + return false; + if (!asFleece) + rowDict = nullptr; + } + receiver(rowData, rowDict, nullptr); + } + } + return true; + } + +} diff --git a/Replicator/ConnectedClient/ConnectedClient.hh b/Replicator/ConnectedClient/ConnectedClient.hh new file mode 100644 index 0000000000..11c239e94e --- /dev/null +++ b/Replicator/ConnectedClient/ConnectedClient.hh @@ -0,0 +1,220 @@ +// +// ConnectedClient.hh +// +// Copyright © 2022 Couchbase. All rights reserved. +// + +#pragma once +#include "Worker.hh" +#include "Async.hh" +#include "BLIPConnection.hh" +#include "c4ConnectedClientTypes.h" +#include "c4Observer.hh" +#include "c4ReplicatorTypes.h" +#include "fleece/Fleece.hh" +#include +#include +#include + +namespace litecore::client { + + /** Result of a successful `ConnectedClient::getDoc()` call. */ + struct DocResponse { + alloc_slice docID, revID, body; + bool deleted; + }; + + + /** A callback invoked when one or more document IDs are received from a getAllDocIDs call. + @param ids A vector of document IDs. An empty vector indicates the result is complete. + @param err Points to the error, if any, else NULL. */ + using AllDocsReceiver = std::function& ids, const C4Error *err)>; + + + /** A callback invoked when one or more documents change on the server. */ + using CollectionObserver = std::function const&)>; + + + /** A callback invoked for every row of a query result. + @param rowJSON The row as a JSON-encoded object, or `nullslice` on the final call. + @param rowDict The row as a Fleece `Dict` object, if you requested it, or `nullptr`. + @param error Points to the error, else NULL. */ + using QueryReceiver = std::function; + + /** A live connection to Sync Gateway (or a CBL peer) that can do interactive CRUD operations. + No C4Database necessary! + Its API is somewhat similar to `Replicator`. */ + class ConnectedClient : public repl::Worker, + private blip::ConnectionDelegate + { + public: + class Delegate; + using CloseStatus = blip::Connection::CloseStatus; + using ActivityLevel = C4ReplicatorActivityLevel; + using Status = C4ReplicatorStatus; + + ConnectedClient(websocket::WebSocket* NONNULL, + Delegate&, + const C4ConnectedClientParameters&); + + /** ConnectedClient delegate API. (Similar to `Replicator::Delegate`) */ + class Delegate { + public: + virtual void clientGotHTTPResponse(ConnectedClient* NONNULL, + int status, + const websocket::Headers &headers) { } + virtual void clientGotTLSCertificate(ConnectedClient* NONNULL, + slice certData) =0; + virtual void clientStatusChanged(ConnectedClient* NONNULL, + const Status&) =0; + virtual void clientConnectionClosed(ConnectedClient* NONNULL, + const CloseStatus&) { } + + /** Returns the contents of a blob given its key (SHA-1 digest) as found in a blob in + a document being uploaded to the server. + + This method is called after the \ref putDoc method is called, but before its async + value resolves. It's not guaranteed to be called for every blob in the document, + only those that are not yet known to the server. + + You must override this method if you upload documents containing blobs. + The default implementation always returns a Not Found error, + which will cause the upload to fail. + @param blobKey The blob's binary digest. + @param error If you can't return the contents, store an error here. + @return The blob's contents, or `nullslice` if an error occurred. */ + virtual alloc_slice getBlobContents(const C4BlobKey &blobKey, C4Error *error); + + virtual ~Delegate() =default; + }; + + void start(); + + void stop(); + + void terminate(); + + actor::Async status(); + + //---- CRUD! + + /// Gets the current revision of a document from the server. + /// You can set the `unlessRevID` parameter to avoid getting a redundant copy of a + /// revision you already have. + /// @param docID The document ID. + /// @param collectionID The name of the document's collection, or `nullslice` for default. + /// @param unlessRevID If non-null, and equal to the current server-side revision ID, + /// the server will return error {WebSocketDomain, 304}. + /// @param asFleece If true, the response's `body` field is Fleece; if false, it's JSON. + /// @return An async value that, when resolved, contains either a `DocResponse` struct + /// or a C4Error. + actor::Async getDoc(slice docID, + slice collectionID, + slice unlessRevID, + bool asFleece = true); + + /// Downloads the contents of a blob given its digest. + /// @param blobKey The binary digest of the blob. + /// @param compress If true, a request that the server compress the blob's data during + /// transmission. (This does not affect the data you receive.) + /// @return An async value that, when resolved, contains either the blob body or a C4Error. + actor::Async getBlob(C4BlobKey blobKey, + bool compress); + + /// Pushes a new document revision to the server. + /// @note If the document body contains any blob references, your delegate must implement + /// the \ref getBlobContents method. + /// + /// @param docID The document ID. + /// @param collectionID The name of the document's collection, or `nullslice` for default. + /// @param revID The revision ID you're sending. + /// @param parentRevID The ID of the parent revision on the server, + /// or `nullslice` if this is a new document. + /// @param revisionFlags Flags of this revision. + /// @param fleeceData The document body encoded as Fleece (without shared keys!) + /// @return An async value that, when resolved, contains the status as a C4Error. + actor::Async putDoc(slice docID, + slice collectionID, + slice revID, + slice parentRevID, + C4RevisionFlags revisionFlags, + slice fleeceData); + + //---- All Documents + + /// Requests a list of all document IDs, or optionally only those matching a pattern. + /// The docIDs themselves are passed to a callback. + /// The callback will be called zero or more times with a non-empty vector of docIDs, + /// then once with an empty vector and an optional error. + /// @param collectionID The ID of the collection to observe. + /// @param globPattern Either `nullslice` or a glob-style pattern string (with `*` or + /// `?` wildcards) for docIDs to match. + /// @param callback The callback to receive the docIDs. + void getAllDocIDs(slice collectionID, + slice globPattern, + AllDocsReceiver callback); + + //---- Observer + + /// Registers a listener function that will be called when any document is changed. + /// @note To cancel, pass a null callback. + /// @param collectionID The ID of the collection to observe. + /// @param callback The function to call (on an arbitrary background thread!) + /// @return An async value that, when resolved, contains the status as a C4Error. + actor::Async observeCollection(slice collectionID, + CollectionObserver callback); + + //---- Query + + /// Runs a query on the server and gets the results. + /// @param name The name by which the query has been registered on the server; + /// or a full query string beginning with "SELECT " or "{". + /// @param parameters A Dict mapping query parameter names to values. + /// @param asFleece If true, rows will be parsed as Fleece dicts for the callback. + /// @param receiver A callback that will be invoked for each row of the result, + /// and/or if there's an error. + void query(slice name, + fleece::Dict parameters, + bool asFleece, + QueryReceiver receiver); + + // exposed for unit tests: + websocket::WebSocket* webSocket() const {return connection().webSocket();} + + protected: + std::string loggingClassName() const override {return "Client";} + ActivityLevel computeActivityLevel() const override; + void onHTTPResponse(int status, const websocket::Headers &headers) override; + void onTLSCertificate(slice certData) override; + void onConnect() override; + void onClose(blip::Connection::CloseStatus status, blip::Connection::State state) override; + void onRequestReceived(blip::MessageIn* request) override; + + void handleChanges(Retained); + void handleGetAttachment(Retained); + + private: + void setStatus(ActivityLevel); + C4Error responseError(blip::MessageIn *response); + void _disconnect(websocket::CloseCode closeCode, slice message); + bool validateDocAndRevID(slice docID, slice revID); + alloc_slice processIncomingDoc(slice docID, alloc_slice body, bool asFleece); + void processOutgoingDoc(slice docID, slice revID, slice fleeceData, fleece::JSONEncoder &enc); + bool receiveAllDocs(blip::MessageIn *, const AllDocsReceiver &); + bool receiveQueryRows(blip::MessageIn*, const QueryReceiver&, bool asFleece); + + Delegate* _delegate; // Delegate whom I report progress/errors to + C4ConnectedClientParameters _params; + ActivityLevel _activityLevel; + Retained _selfRetain; + CollectionObserver _observer; + mutable std::mutex _mutex; + bool _observing = false; + bool _registeredChangesHandler = false; + bool _remoteUsesVersionVectors = false; + bool _remoteNeedsLegacyAttachments = true; + }; + +} diff --git a/Replicator/ConnectedClient/QueryServer.cc b/Replicator/ConnectedClient/QueryServer.cc new file mode 100644 index 0000000000..362354bfc6 --- /dev/null +++ b/Replicator/ConnectedClient/QueryServer.cc @@ -0,0 +1,126 @@ +// +// QueryServer.cc +// +// Copyright © 2022 Couchbase. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "QueryServer.hh" +#include "Replicator.hh" +#include "DBAccess.hh" +#include "MessageBuilder.hh" +#include "StringUtil.hh" +#include "c4Query.hh" + +namespace litecore::repl { + + QueryServer::QueryServer(Replicator *replicator) + :Worker(replicator, "query") + { + registerHandler("query", &QueryServer::handleQuery); + } + + + static bool isJSONQuery(slice queryStr) { + return queryStr.hasPrefix("{"); + } + + + Retained QueryServer::compileQuery(slice queryStr) { + C4QueryLanguage language = (isJSONQuery(queryStr) ? kC4JSONQuery : kC4N1QLQuery); + return _db->useLocked()->newQuery(language, queryStr); + } + + + C4Query* QueryServer::getNamedQuery(const string &name) { + if (auto i = _queries.find(name); i != _queries.end()) + return i->second; + slice queryStr = _options->namedQueries()[name].asString(); + if (!queryStr) + return nullptr; + logInfo("Compiling query '%s' from %.*s", name.c_str(), FMTSLICE(queryStr)); + Retained query = compileQuery(queryStr); + if (query) + _queries.insert({name, query}); + return query; + } + + + void QueryServer::handleQuery(Retained request) { + try { + Retained query; + slice name = request->property("name"); + slice src = request->property("src"); + if (!name == !src) { + request->respondWithError(blip::Error("HTTP", 400, + "Exactly one of 'name' or 'src' must be given")); + return; + } + if (name) { + // Named query: + query = getNamedQuery(string(name)); + if (!query) { + request->respondWithError(blip::Error("HTTP", 404, "No such query")); + return; + } + logInfo("Running named query '%.*s'", FMTSLICE(name)); + } else { + if (!_options->allQueries()) { + request->respondWithError(blip::Error("HTTP", 403, + "Arbitrary queries are not allowed")); + return; + } + logInfo("Compiling requested query: %.*s", FMTSLICE(src)); + query = compileQuery(src); + if (!query) { + request->respondWithError(blip::Error("HTTP", 400, "Syntax error in query")); + return; + } + } + + if (!request->JSONBody().asDict()) { + request->respondWithError(blip::Error("HTTP", 400, "Invalid query parameter dict")); + return; + } + + // Now run the query: + blip::MessageBuilder reply(request); + JSONEncoder &enc = reply.jsonBody(); + _db->useLocked([&](C4Database*) { + Stopwatch st; + // Run the query: + query->setParameters(request->body()); + auto e = query->run(); + while (e.next()) { + enc.beginDict(); + unsigned col = 0; + for (Array::iterator i(e.columns()); i; ++i) { + enc.writeKey(query->columnTitle(col++)); + enc.writeValue(*i); + } + enc.endDict(); + enc.nextDocument(); // Writes a newline + } + logInfo("...query took %.1f ms", st.elapsedMS()); + }); + request->respond(reply); + + } catch (...) { + C4Error err = C4Error::fromCurrentException(); + WarnError("Exception while handling query: %s", err.description().c_str()); + request->respondWithError(c4ToBLIPError(err)); + } + } + +} diff --git a/Replicator/ConnectedClient/QueryServer.hh b/Replicator/ConnectedClient/QueryServer.hh new file mode 100644 index 0000000000..047ae03356 --- /dev/null +++ b/Replicator/ConnectedClient/QueryServer.hh @@ -0,0 +1,26 @@ +// +// QueryServer.hh +// +// Copyright © 2022 Couchbase. All rights reserved. +// + +#pragma once +#include "Worker.hh" +#include + +namespace litecore::repl { + + class QueryServer final : public Worker { + public: + QueryServer(Replicator *replicator NONNULL); + + C4Query* getNamedQuery(const std::string &name); + Retained compileQuery(slice queryStr); + + private: + void handleQuery(Retained request); + + std::unordered_map> _queries; + }; + +} diff --git a/Replicator/DBAccess.cc b/Replicator/DBAccess.cc index a3ac706eea..d5ed1a8454 100644 --- a/Replicator/DBAccess.cc +++ b/Replicator/DBAccess.cc @@ -20,6 +20,7 @@ #include "c4Document.hh" #include "c4DocEnumerator.hh" #include "c4Private.h" +#include "LegacyAttachments.hh" #include #include #include @@ -164,103 +165,18 @@ namespace litecore { namespace repl { } - static inline bool isBlobOrAttachment(FLDeepIterator i, C4BlobKey *blobKey, bool noBlobs) { - auto dict = FLValue_AsDict(FLDeepIterator_GetValue(i)); - if (!dict) - return false; - - // Get the digest: - if (auto key = C4Blob::keyFromDigestProperty(dict); key) - *blobKey = *key; - else - return false; - - // Check if it's a blob: - if (!noBlobs && C4Blob::isBlob(dict)) { - return true; - } else { - // Check if it's an old-school attachment, i.e. in a top level "_attachments" dict: - FLPathComponent* path; - size_t depth; - FLDeepIterator_GetPath(i, &path, &depth); - return depth == 2 && path[0].key == C4Blob::kLegacyAttachmentsProperty; - } - } - - void DBAccess::findBlobReferences(Dict root, bool unique, const FindBlobCallback &callback) { // This method is non-static because it references _disableBlobSupport, but it's // thread-safe. - set found; - FLDeepIterator i = FLDeepIterator_New(root); - for (; FLDeepIterator_GetValue(i); FLDeepIterator_Next(i)) { - C4BlobKey blobKey; - if (isBlobOrAttachment(i, &blobKey, _disableBlobSupport)) { - if (!unique || found.emplace((const char*)&blobKey, sizeof(blobKey)).second) { - auto blob = Value(FLDeepIterator_GetValue(i)).asDict(); - callback(i, blob, blobKey); - } - FLDeepIterator_SkipChildren(i); - } - } - FLDeepIterator_Free(i); + return legacy_attachments::findBlobReferences(root, unique, callback, _disableBlobSupport); } void DBAccess::encodeRevWithLegacyAttachments(fleece::Encoder& enc, Dict root, unsigned revpos) { - enc.beginDict(); - - // Write existing properties except for _attachments: - Dict oldAttachments; - for (Dict::iterator i(root); i; ++i) { - slice key = i.keyString(); - if (key == C4Blob::kLegacyAttachmentsProperty) { - oldAttachments = i.value().asDict(); // remember _attachments dict for later - } else { - enc.writeKey(key); - enc.writeValue(i.value()); - } - } - - // Now write _attachments: - enc.writeKey(C4Blob::kLegacyAttachmentsProperty); - enc.beginDict(); - // First pre-existing legacy attachments, if any: - for (Dict::iterator i(oldAttachments); i; ++i) { - slice key = i.keyString(); - if (!key.hasPrefix("blob_"_sl)) { - // TODO: Should skip this entry if a blob with the same digest exists - enc.writeKey(key); - enc.writeValue(i.value()); - } - } - - // Then entries for blobs found in the document: - findBlobReferences(root, false, [&](FLDeepIterator di, FLDict blob, C4BlobKey blobKey) { - alloc_slice path(FLDeepIterator_GetJSONPointer(di)); - if (path.hasPrefix("/_attachments/"_sl)) - return; - string attName = string("blob_") + string(path); - enc.writeKey(slice(attName)); - enc.beginDict(); - for (Dict::iterator i(blob); i; ++i) { - slice key = i.keyString(); - if (key != C4Document::kObjectTypeProperty && key != "stub"_sl) { - enc.writeKey(key); - enc.writeValue(i.value()); - } - } - enc.writeKey("stub"_sl); - enc.writeBool(true); - enc.writeKey("revpos"_sl); - enc.writeInt(revpos); - enc.endDict(); - }); - enc.endDict(); - - enc.endDict(); + Assert(!_disableBlobSupport); + legacy_attachments::encodeRevWithLegacyAttachments(enc, root, revpos); } diff --git a/Replicator/IncomingRev.cc b/Replicator/IncomingRev.cc index 3a330ac337..6e777dc985 100644 --- a/Replicator/IncomingRev.cc +++ b/Replicator/IncomingRev.cc @@ -18,6 +18,7 @@ #include "StringUtil.hh" #include "c4BlobStore.hh" #include "c4Document.hh" +#include "LegacyAttachments.hh" #include "Instrumentation.hh" #include "BLIP.hh" #include "fleece/Mutable.hh" @@ -234,10 +235,10 @@ namespace litecore { namespace repl { // Strip out any "_"-prefixed properties like _id, just in case, and also any attachments // in _attachments that are redundant with blobs elsewhere in the doc. // This also re-encodes the document if it was modified by the decryptor. - if ((C4Document::hasOldMetaProperties(root) && !_db->disableBlobSupport()) + if ((legacy_attachments::hasOldMetaProperties(root) && !_db->disableBlobSupport()) || decryptedRoot) { auto sk = fleeceDoc.sharedKeys(); - alloc_slice body = C4Document::encodeStrippingOldMetaProperties(root, sk); + alloc_slice body = legacy_attachments::encodeStrippingOldMetaProperties(root, sk); if (!body) { failWithError(WebSocketDomain, 500, "invalid legacy attachments"_sl); return; diff --git a/Replicator/Inserter.cc b/Replicator/Inserter.cc index 6528763323..45b2605809 100644 --- a/Replicator/Inserter.cc +++ b/Replicator/Inserter.cc @@ -22,6 +22,7 @@ #include "c4Private.h" #include "c4Document.hh" #include "c4ReplicatorTypes.h" +#include "LegacyAttachments.hh" #include "BLIP.hh" using namespace std; @@ -196,11 +197,11 @@ namespace litecore { namespace repl { // After applying the delta, remove legacy attachment properties and any other // "_"-prefixed top level properties: Dict root = doc.root().asDict(); - if (C4Document::hasOldMetaProperties(root)) { + if (legacy_attachments::hasOldMetaProperties(root)) { body = nullslice; try { FLSharedKeys sk = _db->insertionDB().useLocked()->getFleeceSharedKeys(); - body = C4Document::encodeStrippingOldMetaProperties(root, sk); + body = legacy_attachments::encodeStrippingOldMetaProperties(root, sk); } catchAndWarn(); if (!body) *outError = C4Error::make(WebSocketDomain, 500, "invalid legacy attachments"); diff --git a/Replicator/Puller.cc b/Replicator/Puller.cc index a0e3578a7a..982509968a 100644 --- a/Replicator/Puller.cc +++ b/Replicator/Puller.cc @@ -54,72 +54,75 @@ namespace litecore { namespace repl { _skipDeleted = _options->skipDeleted(); if (!passive() && _options->noIncomingConflicts()) warn("noIncomingConflicts mode is not compatible with active pull replications!"); + + if (_options->properties[kC4ReplicatorOptionAllowConnectedClient]) + registerHandler("putRev", &Puller::handlePutRev); } // Starting an active pull. - void Puller::_start(RemoteSequence sinceSequence) { - _lastSequence = sinceSequence; - _missingSequences.clear(sinceSequence); - alloc_slice sinceStr = _lastSequence.toJSON(); - logInfo("Starting pull from remote seq '%.*s'", SPLAT(sinceStr)); - - Signpost::begin(Signpost::blipSent); - MessageBuilder msg("subChanges"_sl); - if (sinceStr) - msg["since"_sl] = sinceStr; - if (_options->pull == kC4Continuous) - msg["continuous"_sl] = "true"_sl; - msg["batch"_sl] = tuning::kChangesBatchSize; - msg["versioning"] = _db->usingVersionVectors() ? "version-vectors" : "rev-trees"; - if (_skipDeleted) - msg["activeOnly"_sl] = "true"_sl; - if (_options->enableAutoPurge() || progressNotificationLevel() > 0) { - msg["revocations"] = "true"; // Enable revocation notification in "changes" (SG 3.0) - logInfo("msg[\"revocations\"]=\"true\" due to enableAutoPurge()=%d or progressNotificationLevel()=%d > 0", - _options->enableAutoPurge(), progressNotificationLevel()); - } + void Puller::start(RemoteSequence sinceSequence) { + asCurrentActor([=]() { + _lastSequence = sinceSequence; + _missingSequences.clear(sinceSequence); + alloc_slice sinceStr = _lastSequence.toJSON(); + logInfo("Starting pull from remote seq '%.*s'", SPLAT(sinceStr)); + + Signpost::begin(Signpost::blipSent); + MessageBuilder msg("subChanges"_sl); + if (sinceStr) + msg["since"_sl] = sinceStr; + if (_options->pull == kC4Continuous) + msg["continuous"_sl] = "true"_sl; + msg["batch"_sl] = tuning::kChangesBatchSize; + msg["versioning"] = _db->usingVersionVectors() ? "version-vectors" : "rev-trees"; + if (_skipDeleted) + msg["activeOnly"_sl] = "true"_sl; + if (_options->enableAutoPurge() || progressNotificationLevel() > 0) { + msg["revocations"] = "true"; // Enable revocation notification in "changes" (SG 3.0) + logInfo("msg[\"revocations\"]=\"true\" due to enableAutoPurge()=%d or progressNotificationLevel()=%d > 0", + _options->enableAutoPurge(), progressNotificationLevel()); + } - auto channels = _options->channels(); - if (channels) { - stringstream value; - unsigned n = 0; - for (Array::iterator i(channels); i; ++i) { - slice name = i.value().asString(); - if (name) { - if (n++) - value << ","; - value << name.asString(); + auto channels = _options->channels(); + if (channels) { + stringstream value; + unsigned n = 0; + for (Array::iterator i(channels); i; ++i) { + slice name = i.value().asString(); + if (name) { + if (n++) + value << ","; + value << name.asString(); + } + } + msg["filter"_sl] = "sync_gateway/bychannel"_sl; + msg["channels"_sl] = value.str(); + } else { + slice filter = _options->filter(); + if (filter) { + msg["filter"_sl] = filter; + for (Dict::iterator i(_options->filterParams()); i; ++i) + msg[i.keyString()] = i.value().asString(); } } - msg["filter"_sl] = "sync_gateway/bychannel"_sl; - msg["channels"_sl] = value.str(); - } else { - slice filter = _options->filter(); - if (filter) { - msg["filter"_sl] = filter; - for (Dict::iterator i(_options->filterParams()); i; ++i) - msg[i.keyString()] = i.value().asString(); - } - } - auto docIDs = _options->docIDs(); - if (docIDs) { - auto &enc = msg.jsonBody(); - enc.beginDict(); - enc.writeKey("docIDs"_sl); - enc.writeValue(docIDs); - enc.endDict(); - } - - sendRequest(msg, [=](blip::MessageProgress progress) { - //... After request is sent: - if (progress.reply && progress.reply->isError()) { - gotError(progress.reply); - _fatalError = true; + auto docIDs = _options->docIDs(); + if (docIDs) { + auto &enc = msg.jsonBody(); + enc.beginDict(); + enc.writeKey("docIDs"_sl); + enc.writeValue(docIDs); + enc.endDict(); } - if (progress.state == MessageProgress::kComplete) + + sendAsyncRequest(msg).then([this](Retained reply) { + if (reply && reply->isError()) { + gotError(reply); + _fatalError = true; + } Signpost::end(Signpost::blipSent); + }, actor::assertNoError); }); } @@ -191,6 +194,14 @@ namespace litecore { namespace repl { } + // Received a "putRev" message from a connected client (not part of replication) + void Puller::handlePutRev(Retained msg) { + Retained inc = makeIncomingRev(); + if (inc) + inc->handleRev(msg, msg->body().size); // ... will call _revWasHandled when it's finished + } + + // Actually process an incoming "rev" now: void Puller::startIncomingRev(MessageIn *msg) { _revFinder->revReceived(); diff --git a/Replicator/Puller.hh b/Replicator/Puller.hh index efb3bc3a12..134fc368e2 100644 --- a/Replicator/Puller.hh +++ b/Replicator/Puller.hh @@ -32,7 +32,7 @@ namespace litecore { namespace repl { void setSkipDeleted() {_skipDeleted = true;} // Starts an active pull - void start(RemoteSequence sinceSequence) {enqueue(FUNCTION_TO_QUEUE(Puller::_start), sinceSequence);} + void start(RemoteSequence sinceSequence); // Called only by IncomingRev void revWasProvisionallyHandled() {_provisionallyHandledRevs.add(1);} @@ -54,11 +54,11 @@ namespace litecore { namespace repl { void activityLevelChanged(ActivityLevel level); private: - void _start(RemoteSequence sinceSequence); void _expectSequences(std::vector); void _documentsRevoked(std::vector>); void handleRev(Retained); void handleNoRev(Retained); + void handlePutRev(Retained); Retained makeIncomingRev(); void startIncomingRev(blip::MessageIn* NONNULL); void maybeStartIncomingRevs(); diff --git a/Replicator/Pusher+Attachments.cc b/Replicator/Pusher+Attachments.cc index 9510458e28..63671266e2 100644 --- a/Replicator/Pusher+Attachments.cc +++ b/Replicator/Pusher+Attachments.cc @@ -78,23 +78,33 @@ namespace litecore::repl { slice &digestStr, Replicator::BlobProgress &progress) { + C4Error error = {}; try { - digestStr = req->property("digest"_sl); - progress = {Dir::kPushing}; - if (auto key = C4BlobKey::withDigestString(digestStr); key) - progress.key = *key; - else - C4Error::raise(LiteCoreDomain, kC4ErrorInvalidParameter, "Missing or invalid 'digest'"); auto blobStore = _db->blobStore(); - if (int64_t size = blobStore->getSize(progress.key); size >= 0) - progress.bytesTotal = size; - else - C4Error::raise(LiteCoreDomain, kC4ErrorNotFound, "No such blob"); - return make_unique(*blobStore, progress.key); + do { + digestStr = req->property("digest"_sl); + progress = {Dir::kPushing}; + if (auto key = C4BlobKey::withDigestString(digestStr); key) + progress.key = *key; + else { + error = C4Error::make(LiteCoreDomain, kC4ErrorInvalidParameter, + "Missing or invalid 'digest'"); + break; + } + if (int64_t size = blobStore->getSize(progress.key); size >= 0) + progress.bytesTotal = size; + else { + error = C4Error::make(LiteCoreDomain, kC4ErrorNotFound, "No such blob"); + break; + } + } while (false); + if (!error) + return make_unique(*blobStore, progress.key); } catch (...) { - req->respondWithError(c4ToBLIPError(C4Error::fromCurrentException())); - return nullptr; + error = C4Error::fromCurrentException(); } + req->respondWithError(c4ToBLIPError(error)); + return nullptr; } @@ -115,7 +125,7 @@ namespace litecore::repl { if (progressNotificationLevel() >= 2) repl->onBlobProgress(progress); - reply.dataSource = make_unique(this, move(blob), progress); + reply.dataSource = make_shared(this, move(blob), progress); req->respond(reply); } @@ -139,7 +149,7 @@ namespace litecore::repl { // First digest the length-prefixed nonce: slice nonce = request->body(); if (nonce.size == 0 || nonce.size > 255) { - request->respondWithError({"BLIP"_sl, 400, "Missing nonce"_sl}); + request->respondWithError(400, "Missing nonce"_sl); return; } sha << (nonce.size & 0xFF) << nonce; diff --git a/Replicator/Pusher+Revs.cc b/Replicator/Pusher+Revs.cc index 80a25d1984..d481fd8a5e 100644 --- a/Replicator/Pusher+Revs.cc +++ b/Replicator/Pusher+Revs.cc @@ -19,6 +19,7 @@ #include "Increment.hh" #include "StringUtil.hh" #include "c4Document.hh" +#include "c4DocEnumeratorTypes.h" #include "fleece/Mutable.hh" #include @@ -44,33 +45,31 @@ namespace litecore::repl { } - // Send a "rev" message containing a revision body. - void Pusher::sendRevision(Retained request) { - if (!connected()) - return; - - logVerbose("Sending rev '%.*s' #%.*s (seq #%" PRIu64 ") [%d/%d]", - SPLAT(request->docID), SPLAT(request->revID), (uint64_t)request->sequence, - _revisionsInFlight, tuning::kMaxRevsInFlight); - - // Get the document & revision: + // Creates a revision message from a RevToSend. Used by `sendRevision` and `handleGetRev`. + bool Pusher::buildRevisionMessage(RevToSend *request, + C4Document *doc, + MessageBuilder &msg, + C4Error *outError) + { + // Select the revision and get its properties: C4Error c4err = {}; Dict root; - Retained doc = _db->getDoc(request->docID, kDocGetAll); if (doc) { if (doc->selectRevision(request->revID, true)) root = doc->getProperties(); - if (root) + if (root) { request->flags = doc->selectedRev().flags; - else + } else { revToSendIsObsolete(*request, &c4err); + doc = nullptr; + } } else { c4err = C4Error::make(LiteCoreDomain, kC4ErrorNotFound); } // Encrypt any encryptable properties MutableDict encryptedRoot; - if (root && MayContainPropertiesToEncrypt(doc->getRevisionBody())) { + if (doc && MayContainPropertiesToEncrypt(doc->getRevisionBody())) { logVerbose("Encrypting properties in doc '%.*s'", SPLAT(request->docID)); encryptedRoot = EncryptDocumentProperties(request->collectionSpec, request->docID, root, @@ -80,21 +79,22 @@ namespace litecore::repl { if (encryptedRoot) root = encryptedRoot; else if (c4err) { - root = nullptr; + doc = nullptr; finishedDocumentWithError(request, c4err, false); } } auto fullRevID = alloc_slice(_db->convertVersionToAbsolute(request->revID)); - // Now send the BLIP message. Normally it's "rev", but if this is an error we make it - // "norev" and include the error code: - MessageBuilder msg(root ? "rev"_sl : "norev"_sl); + // Now populate the BLIP message fields, whether or not this is an error msg.compressed = true; msg["id"_sl] = request->docID; msg["rev"_sl] = fullRevID; msg["sequence"_sl] = uint64_t(request->sequence); - if (root) { + + if (doc) { + if (!msg.isResponse()) + msg.setProfile("rev"); if (request->noConflicts) msg["noconflicts"_sl] = true; auto revisionFlags = doc->selectedRev().flags; @@ -130,15 +130,37 @@ namespace litecore::repl { else bodyEncoder.writeValue(root); } + logVerbose("Transmitting 'rev' message with '%.*s' #%.*s", + SPLAT(request->docID), SPLAT(request->revID)); + return true; + + } else { + if (outError) *outError = c4err; + return false; + } + } + + + // Send a "rev" message containing a revision body. + void Pusher::sendRevision(Retained request) { + if (!connected()) + return; + + logVerbose("Sending rev '%.*s' #%.*s (seq #%" PRIu64 ") [%d/%d]", + SPLAT(request->docID), SPLAT(request->revID), (uint64_t)request->sequence, + _revisionsInFlight, tuning::kMaxRevsInFlight); + + MessageBuilder msg; + C4Error c4err; + Retained doc = _db->getDoc(request->docID, kDocGetAll); + if (buildRevisionMessage(request, doc, msg, &c4err)) { logVerbose("Transmitting 'rev' message with '%.*s' #%.*s", SPLAT(request->docID), SPLAT(request->revID)); sendRequest(msg, [this, request](MessageProgress progress) { onRevProgress(request, progress); }); increment(_revisionsInFlight); - } else { - // Send an error if we couldn't get the revision: int blipError; if (c4err.domain == WebSocketDomain) blipError = c4err.code; @@ -150,6 +172,7 @@ namespace litecore::repl { c4err.description().c_str()); blipError = 500; } + msg.setProfile("norev"); msg["error"_sl] = blipError; msg.noreply = true; sendRequest(msg); @@ -362,4 +385,40 @@ namespace litecore::repl { } } + + // Handles "getRev", which is sent not by the replicator but by ConnectedClient. + void Pusher::handleGetRev(Retained req) { + alloc_slice docID(req->property("id")); + slice ifNotRev = req->property("ifNotRev"); + MessageBuilder response(req); + Retained rev; + C4Error c4err; + bool ok = false; + + Retained doc = _db->getDoc(docID, kDocGetCurrentRev); + if (!doc || (doc->flags() & kDocDeleted)) { + c4err = C4Error::make(LiteCoreDomain, kC4ErrorNotFound, "Deleted"_sl); + } else if (doc->revID() == ifNotRev) { + c4err = C4Error::make(WebSocketDomain, 304, "Not Changed"_sl); + } else { + C4DocumentInfo info = {}; + info.docID = docID; + info.revID = doc->revID(); + info.sequence = doc->sequence(); + info.flags = doc->flags(); + rev = make_retained(info); + ok = buildRevisionMessage(rev, doc, response, &c4err); + } + + if (ok) { + logVerbose("Responding to getRev('%.*s') with rev #%.*s", + SPLAT(docID), SPLAT(rev->revID)); + req->respond(response); + } else { + logInfo("Responding to getRev('%.*s') with error %s", + SPLAT(docID), c4err.description().c_str()); + req->respondWithError(c4ToBLIPError(c4err)); + } + } + } diff --git a/Replicator/Pusher.cc b/Replicator/Pusher.cc index 5ccd7fade3..7b82834b42 100644 --- a/Replicator/Pusher.cc +++ b/Replicator/Pusher.cc @@ -19,6 +19,7 @@ #include "StringUtil.hh" #include "BLIP.hh" #include "HTTPTypes.hh" +#include "c4DocEnumerator.hh" #include "c4ExceptionUtils.hh" #include @@ -51,6 +52,11 @@ namespace litecore { namespace repl { registerHandler("subChanges", &Pusher::handleSubChanges); registerHandler("getAttachment", &Pusher::handleGetAttachment); registerHandler("proveAttachment", &Pusher::handleProveAttachment); + + if (_options->properties[kC4ReplicatorOptionAllowConnectedClient]) { + registerHandler("allDocs", &Pusher::handleAllDocs); + registerHandler("getRev", &Pusher::handleGetRev); + } } @@ -80,7 +86,11 @@ namespace litecore { namespace repl { return; } - auto since = C4SequenceNumber(max(req->intProperty("since"_sl), 0l)); + C4SequenceNumber since = {}; + if (req->boolProperty("future", false)) + since = _db->useLocked()->getLastSequence(); // "future:true" means no past changes + else + since = C4SequenceNumber(max(req->intProperty("since"_sl), 0l)); _continuous = req->boolProperty("continuous"_sl); _changesFeed.setContinuous(_continuous); _changesFeed.setSkipDeletedDocs(req->boolProperty("activeOnly"_sl)); @@ -176,7 +186,7 @@ namespace litecore { namespace repl { // Send the "changes" request: auto changeCount = changes.revs.size(); - sendChanges(changes.revs); + sendChanges(move(changes.revs)); if (!changes.askAgain) { // ChangesFeed says there are not currently any more changes, i.e. we've caught up. @@ -188,8 +198,7 @@ namespace litecore { namespace repl { if (changeCount > 0 && passive()) { // The protocol says catching up is signaled by an empty changes list, so send // one if we didn't already: - RevToSendList empty; - sendChanges(empty); + sendChanges(RevToSendList{}); } } } else if (_continuous) { @@ -222,23 +231,34 @@ namespace litecore { namespace repl { #pragma mark - SENDING A "CHANGES" MESSAGE & HANDLING RESPONSE: + void Pusher::encodeRevID(Encoder &enc, slice revID) { + if (_db->usingVersionVectors() && revID.findByte('*')) + enc << _db->convertVersionToAbsolute(revID); + else + enc << revID; + } + + // Sends a "changes" or "proposeChanges" message. - void Pusher::sendChanges(RevToSendList &changes) { - MessageBuilder req(_proposeChanges ? "proposeChanges"_sl : "changes"_sl); - if(_proposeChanges) { + void Pusher::sendChanges(RevToSendList &&in_changes) { + bool const proposedChanges = _proposeChanges; + auto changes = make_shared(move(in_changes)); + + MessageBuilder req(proposedChanges ? "proposeChanges"_sl : "changes"_sl); + if(proposedChanges) { req[kConflictIncludesRevProperty] = "true"_sl; } req.urgent = tuning::kChangeMessagesAreUrgent; - req.compressed = !changes.empty(); + req.compressed = !changes->empty(); // Generate the JSON array of changes: auto &enc = req.jsonBody(); enc.beginArray(); - for (RevToSend *change : changes) { + for (RevToSend *change : *changes) { // Write the info array for this change: enc.beginArray(); - if (_proposeChanges) { + if (proposedChanges) { enc << change->docID; encodeRevID(enc, change->revID); slice remoteAncestorRevID = change->remoteAncestorRevID; @@ -263,100 +283,85 @@ namespace litecore { namespace repl { } enc.endArray(); - if (changes.empty()) { + if (changes->empty()) { // Empty == just announcing 'caught up', so no need to get a reply req.noreply = true; sendRequest(req); return; } - bool proposedChanges = _proposeChanges; - increment(_changeListsInFlight); - sendRequest(req, [this,changes=move(changes),proposedChanges](MessageProgress progress) mutable { - if (progress.state == MessageProgress::kComplete) - handleChangesResponse(changes, progress.reply, proposedChanges); - }); - } - - - void Pusher::encodeRevID(Encoder &enc, slice revID) { - if (_db->usingVersionVectors() && revID.findByte('*')) - enc << _db->convertVersionToAbsolute(revID); - else - enc << revID; - } + //---- SEND REQUEST AND WAIT FOR REPLY ---- + sendAsyncRequest(req).then([=](Retained reply) -> void { + if (!reply) + return; - // Handles the peer's response to a "changes" or "proposeChanges" message: - void Pusher::handleChangesResponse(RevToSendList &changes, - MessageIn *reply, - bool proposedChanges) - { - // Got reply to the "changes" or "proposeChanges": - if (!changes.empty()) { - logInfo("Got response for %zu local changes (sequences from %" PRIu64 ")", - changes.size(), (uint64_t)changes.front()->sequence); - } - decrement(_changeListsInFlight); - _changesFeed.setFindForeignAncestors(getForeignAncestors()); - if (!proposedChanges && reply->isError()) { - auto err = reply->getError(); - if (err.code == 409 && (err.domain == "BLIP"_sl || err.domain == "HTTP"_sl)) { - if (!_proposeChanges && !_proposeChangesKnown) { - // Caller is in no-conflict mode, wants 'proposeChanges' instead; retry - logInfo("Server requires 'proposeChanges'; retrying..."); - _proposeChanges = true; - _changesFeed.setFindForeignAncestors(getForeignAncestors()); - sendChanges(changes); - } else { - logError("Server does not allow '%s'; giving up", - (_proposeChanges ? "proposeChanges" : "changes")); - for(RevToSend* change : changes) - doneWithRev(change, false, false); - gotError(C4Error::make(LiteCoreDomain, kC4ErrorRemoteError, - "Incompatible with server replication protocol (changes)"_sl)); + // Got reply to the "changes" or "proposeChanges": + if (!changes->empty()) { + logInfo("Got response for %zu local changes (sequences from %" PRIu64 ")", + changes->size(), (uint64_t)changes->front()->sequence); + } + decrement(_changeListsInFlight); + _changesFeed.setFindForeignAncestors(getForeignAncestors()); + if (!proposedChanges && reply->isError()) { + auto err = reply->getError(); + if (err.code == 409 && (err.domain == kBLIPErrorDomain || err.domain == "HTTP"_sl)) { + if (!_proposeChanges && !_proposeChangesKnown) { + // Caller is in no-conflict mode, wants 'proposeChanges' instead; retry + logInfo("Server requires 'proposeChanges'; retrying..."); + _proposeChanges = true; + _changesFeed.setFindForeignAncestors(getForeignAncestors()); + sendChanges(move(*changes)); + } else { + logError("Server does not allow '%s'; giving up", + (_proposeChanges ? "proposeChanges" : "changes")); + for(RevToSend* change : *changes) + doneWithRev(change, false, false); + gotError(C4Error::make(LiteCoreDomain, kC4ErrorRemoteError, + "Incompatible with server replication protocol (changes)"_sl)); + } + return; } - return; } - } - _proposeChangesKnown = true; + _proposeChangesKnown = true; - // Request another batch of changes from the db: - maybeGetMoreChanges(); + // Request another batch of changes from the db: + maybeGetMoreChanges(); - if (reply->isError()) { - for(RevToSend* change : changes) - doneWithRev(change, false, false); - gotError(reply); - return; - } + if (reply->isError()) { + for(RevToSend* change : *changes) + doneWithRev(change, false, false); + gotError(reply); + return; + } - // OK, now look at the successful response: - int maxHistory = (int)max(1l, reply->intProperty("maxHistory"_sl, - tuning::kDefaultMaxHistory)); - bool legacyAttachments = !reply->boolProperty("blobs"_sl); - if (!_deltasOK && reply->boolProperty("deltas"_sl) - && !_options->properties[kC4ReplicatorOptionDisableDeltas].asBool()) - _deltasOK = true; - - // The response body consists of an array that parallels the `changes` array I sent: - Array::iterator iResponse(reply->JSONBody().asArray()); - for (RevToSend *change : changes) { - change->maxHistory = maxHistory; - change->legacyAttachments = legacyAttachments; - change->deltaOK = _deltasOK; - bool queued = proposedChanges ? handleProposedChangeResponse(change, *iResponse) - : handleChangeResponse(change, *iResponse); - if (queued) { - logVerbose("Queueing rev '%.*s' #%.*s (seq #%" PRIu64 ") [%zu queued]", - SPLAT(change->docID), SPLAT(change->revID), (uint64_t)change->sequence, - _revQueue.size()); + // OK, now look at the successful response: + int maxHistory = (int)max(1l, reply->intProperty("maxHistory"_sl, + tuning::kDefaultMaxHistory)); + bool legacyAttachments = !reply->boolProperty("blobs"_sl); + if (!_deltasOK && reply->boolProperty("deltas"_sl) + && !_options->properties[kC4ReplicatorOptionDisableDeltas].asBool()) + _deltasOK = true; + + // The response body consists of an array that parallels the `changes` array I sent: + Array::iterator iResponse(reply->JSONBody().asArray()); + for (RevToSend *change : *changes) { + change->maxHistory = maxHistory; + change->legacyAttachments = legacyAttachments; + change->deltaOK = _deltasOK; + bool queued = proposedChanges ? handleProposedChangeResponse(change, *iResponse) + : handleChangeResponse(change, *iResponse); + if (queued) { + logVerbose("Queueing rev '%.*s' #%.*s (seq #%" PRIu64 ") [%zu queued]", + SPLAT(change->docID), SPLAT(change->revID), (uint64_t)change->sequence, + _revQueue.size()); + } + if (iResponse) + ++iResponse; } - if (iResponse) - ++iResponse; - } - maybeSendMoreRevs(); + maybeSendMoreRevs(); + }, actor::assertNoError); } @@ -414,8 +419,7 @@ namespace litecore { namespace repl { if (shouldRetryConflictWithNewerAncestor(change, serverRevID)) { // I have a newer revision to send in its place: - RevToSendList changes = {change}; - sendChanges(changes); + sendChanges(RevToSendList{change}); return true; } else if (_options->pull <= kC4Passive) { C4Error error = C4Error::make(WebSocketDomain, 409, @@ -548,8 +552,7 @@ namespace litecore { namespace repl { if (!passive()) _checkpointer.addPendingSequence(change->sequence); addProgress({0, change->bodySize}); - RevToSendList changes = {change}; - sendChanges(changes); + sendChanges(RevToSendList{change}); } @@ -635,4 +638,28 @@ namespace litecore { namespace repl { } } + + // Connected Client `allDocs` request handler: + void Pusher::handleAllDocs(Retained req) { + string pattern( req->property("idPattern") ); + logInfo("Handling allDocs; pattern=`%s`", pattern.c_str()); + + MessageBuilder response(req); + response.compressed = true; + auto &enc = response.jsonBody(); + enc.beginArray(); + + _db->useLocked([&](C4Database *db) { + C4DocEnumerator docEnum(db, {kC4Unsorted | kC4IncludeNonConflicted}); + while (docEnum.next()) { + C4DocumentInfo info = docEnum.documentInfo(); + if (pattern.empty() || matchGlobPattern(string(info.docID), pattern)) + enc.writeString(info.docID); + } + }); + + enc.endArray(); + req->respond(response); + } + } } diff --git a/Replicator/Pusher.hh b/Replicator/Pusher.hh index 855cd5792b..fa7e9ad962 100644 --- a/Replicator/Pusher.hh +++ b/Replicator/Pusher.hh @@ -59,8 +59,8 @@ namespace litecore { namespace repl { void handleSubChanges(Retained req); void gotOutOfOrderChange(RevToSend* NONNULL); void encodeRevID(Encoder &enc, slice revID); - void sendChanges(RevToSendList&); - void handleChangesResponse(RevToSendList&, blip::MessageIn*, bool proposedChanges); + void sendChanges(RevToSendList&&); + void handleChangesResponse(const RevToSendList&, blip::MessageIn*, bool proposedChanges); bool handleChangeResponse(RevToSend *change, Value response); bool handleProposedChangeResponse(RevToSend *change, Value response); bool handlePushConflict(RevToSend *change); @@ -72,6 +72,7 @@ namespace litecore { namespace repl { bool shouldRetryConflictWithNewerAncestor(RevToSend* NONNULL, slice receivedRevID); void _docRemoteAncestorChanged(alloc_slice docID, alloc_slice remoteAncestorRevID); bool getForeignAncestors() const {return _proposeChanges || !_proposeChangesKnown;} + void handleAllDocs(Retained); // Pusher+Attachments.cc: void handleGetAttachment(Retained); @@ -83,6 +84,7 @@ namespace litecore { namespace repl { // Pusher+Revs.cc: void maybeSendMoreRevs(); void retryRevs(RevToSendList, bool immediate); + bool buildRevisionMessage(RevToSend*, C4Document*, blip::MessageBuilder&, C4Error*); void sendRevision(Retained); void onRevProgress(Retained rev, const blip::MessageProgress&); void couldntSendRevision(RevToSend* NONNULL); @@ -91,6 +93,7 @@ namespace litecore { namespace repl { fleece::Dict root, size_t revSize, bool sendLegacyAttachments); void revToSendIsObsolete(const RevToSend &request, C4Error *c4err =nullptr); + void handleGetRev(Retained req); using DocIDToRevMap = std::unordered_map>; diff --git a/Replicator/Replicator.cc b/Replicator/Replicator.cc index 352da0778f..66326224e6 100644 --- a/Replicator/Replicator.cc +++ b/Replicator/Replicator.cc @@ -15,6 +15,7 @@ #include "ReplicatorTuning.hh" #include "Pusher.hh" #include "Puller.hh" +#include "QueryServer.hh" #include "Checkpoint.hh" #include "DBAccess.hh" #include "Delimiter.hh" @@ -51,7 +52,7 @@ namespace litecore { namespace repl { }; - std::string Replicator::ProtocolName() { + std::string Replicator::protocolName() { stringstream result; delimiter delim(","); for (auto &name : kCompatProtocols) @@ -103,6 +104,10 @@ namespace litecore { namespace repl { registerHandler("getCheckpoint", &Replicator::handleGetCheckpoint); registerHandler("setCheckpoint", &Replicator::handleSetCheckpoint); + + if (!_options->namedQueries().empty() || _options->allQueries()) { + _queryServer = new QueryServer(this); + } } @@ -188,6 +193,7 @@ namespace litecore { namespace repl { connection().terminate(); _pusher = nullptr; _puller = nullptr; + _queryServer = nullptr; } // CBL-1061: This used to be inside the connected(), but static analysis shows @@ -349,6 +355,7 @@ namespace litecore { namespace repl { DebugAssert(!connected()); // must already have gotten _onClose() delegate callback _pusher = nullptr; _puller = nullptr; + _queryServer = nullptr; _db->close(); Signpost::end(Signpost::replication, uintptr_t(this)); } @@ -492,7 +499,7 @@ namespace litecore { namespace repl { // This only gets called if none of the registered handlers were triggered. void Replicator::_onRequestReceived(Retained msg) { warn("Received unrecognized BLIP request #%" PRIu64 " with Profile '%.*s', %zu bytes", - msg->number(), SPLAT(msg->property("Profile"_sl)), msg->body().size); + msg->number(), SPLAT(msg->profile()), msg->body().size); msg->notHandled(); } @@ -542,14 +549,21 @@ namespace litecore { namespace repl { MessageBuilder msg("getCheckpoint"_sl); msg["client"_sl] = _remoteCheckpointDocID; Signpost::begin(Signpost::blipSent); - sendRequest(msg, [this, refresh](MessageProgress progress) { + + _remoteCheckpointRequested = true; + + // If there's no local checkpoint, we know we're starting from zero and don't need to + // wait for the remote one before getting started: + if (!refresh && !_hadLocalCheckpoint) + startReplicating(); + + sendAsyncRequest(msg).then([=](Retained response) { // ...after the checkpoint is received: - if (progress.state != MessageProgress::kComplete) - return; Signpost::end(Signpost::blipSent); - MessageIn *response = progress.reply; Checkpoint remoteCheckpoint; + if (!response) + return; if (response->isError()) { auto err = response->getError(); if (!(err.domain == "HTTP"_sl && err.code == 404)) @@ -576,14 +590,7 @@ namespace litecore { namespace repl { if (_checkpointJSONToSave) saveCheckpointNow(); // _saveCheckpoint() was waiting for _remoteCheckpointRevID - }); - - _remoteCheckpointRequested = true; - - // If there's no local checkpoint, we know we're starting from zero and don't need to - // wait for the remote one before getting started: - if (!refresh && !_hadLocalCheckpoint) - startReplicating(); + }, actor::assertNoError); } @@ -598,6 +605,8 @@ namespace litecore { namespace repl { void Replicator::saveCheckpointNow() { + alloc_slice json = move(_checkpointJSONToSave); + // Switch to the permanent checkpoint ID: alloc_slice checkpointID = _checkpointer.checkpointID(); if (checkpointID != _remoteCheckpointDocID) { @@ -605,8 +614,6 @@ namespace litecore { namespace repl { _remoteCheckpointRevID = nullslice; } - alloc_slice json = move(_checkpointJSONToSave); - logVerbose("Saving remote checkpoint '%.*s' over rev='%.*s': %.*s ...", SPLAT(_remoteCheckpointDocID), SPLAT(_remoteCheckpointRevID), SPLAT(json)); Assert(_remoteCheckpointReceived); @@ -617,12 +624,12 @@ namespace litecore { namespace repl { msg["rev"_sl] = _remoteCheckpointRevID; msg << json; Signpost::begin(Signpost::blipSent); - sendRequest(msg, [=](MessageProgress progress) { - if (progress.state != MessageProgress::kComplete) - return; + + sendAsyncRequest(msg).then([this,json](Retained response) -> void { Signpost::end(Signpost::blipSent); - MessageIn *response = progress.reply; - if (response->isError()) { + if (!response) + return; + else if (response->isError()) { Error responseErr = response->getError(); if (responseErr.domain == "HTTP"_sl && responseErr.code == 409) { // On conflict, read the remote checkpoint to get the real revID: @@ -654,7 +661,7 @@ namespace litecore { namespace repl { } _checkpointer.saveCompleted(); } - }); + }, actor::assertNoError); } @@ -710,7 +717,7 @@ namespace litecore { namespace repl { if (checkpointID) logInfo("Request to %s peer checkpoint '%.*s'", whatFor, SPLAT(checkpointID)); else - request->respondWithError({"BLIP"_sl, 400, "missing checkpoint ID"_sl}); + request->respondWithError(400, "missing checkpoint ID"); return checkpointID; } diff --git a/Replicator/Replicator.hh b/Replicator/Replicator.hh index d72c16224f..6b96f8c6c9 100644 --- a/Replicator/Replicator.hh +++ b/Replicator/Replicator.hh @@ -25,6 +25,7 @@ namespace litecore { namespace repl { class Pusher; class Puller; + class QueryServer; class ReplicatedRev; static const array kCompatProtocols = {{ @@ -63,7 +64,7 @@ namespace litecore { namespace repl { using DocumentsEnded = std::vector>; - static std::string ProtocolName(); + static std::string protocolName(); /** Replicator delegate; receives progress & error notifications. */ class Delegate { @@ -176,6 +177,7 @@ namespace litecore { namespace repl { Delegate* _delegate; // Delegate whom I report progress/errors to Retained _pusher; // Object that manages outgoing revs Retained _puller; // Object that manages incoming revs + Retained _queryServer; // Object that runs query requests (listener) blip::Connection::State _connectionState; // Current BLIP connection state Status _pushStatus {}; // Current status of Pusher diff --git a/Replicator/ReplicatorOptions.hh b/Replicator/ReplicatorOptions.hh index 8a49f206b7..09e37c521f 100644 --- a/Replicator/ReplicatorOptions.hh +++ b/Replicator/ReplicatorOptions.hh @@ -111,6 +111,14 @@ namespace litecore { namespace repl { return uniqueID ? uniqueID : remoteURL; } + fleece::Dict namedQueries() const { + return dictProperty(kC4ReplicatorOptionNamedQueries); + } + + bool allQueries() const { + return boolProperty(kC4ReplicatorOptionAllQueries); + } + fleece::Array arrayProperty(const char *name) const { return properties[name].asArray(); } diff --git a/Replicator/ReplicatorTypes.cc b/Replicator/ReplicatorTypes.cc index f8a997accb..039fd597e5 100644 --- a/Replicator/ReplicatorTypes.cc +++ b/Replicator/ReplicatorTypes.cc @@ -38,6 +38,12 @@ namespace litecore { namespace repl { } + void RevToSend::setRevID(slice id) { + Assert(revID.empty()); + const_cast(revID) = id; + } + + void RevToSend::addRemoteAncestor(slice revID) { if (!revID) return; diff --git a/Replicator/ReplicatorTypes.hh b/Replicator/ReplicatorTypes.hh index 5c553ac36b..92867e1072 100644 --- a/Replicator/ReplicatorTypes.hh +++ b/Replicator/ReplicatorTypes.hh @@ -68,6 +68,7 @@ namespace litecore { namespace repl { void addRemoteAncestor(slice revID); bool hasRemoteAncestor(slice revID) const; + void setRevID(slice id); Dir dir() const override {return Dir::kPushing;} void trim() override; diff --git a/Replicator/RevFinder.cc b/Replicator/RevFinder.cc index c029b8d0f6..28700a3393 100644 --- a/Replicator/RevFinder.cc +++ b/Replicator/RevFinder.cc @@ -57,7 +57,7 @@ namespace litecore::repl { handleChangesNow(req); } else { logVerbose("Queued '%.*s' REQ#%" PRIu64 " (now %zu)", - SPLAT(req->property("Profile"_sl)), req->number(), + SPLAT(req->profile()), req->number(), _waitingChangesMessages.size() + 1); Signpost::begin(Signpost::handlingChanges, (uintptr_t)req->number()); _waitingChangesMessages.push_back(move(req)); @@ -85,7 +85,7 @@ namespace litecore::repl { // Actually handle a "changes" (or "proposeChanges") message: void RevFinder::handleChangesNow(MessageIn *req) { try { - slice reqType = req->property("Profile"_sl); + slice reqType = req->profile(); bool proposed = (reqType == "proposeChanges"_sl); logVerbose("Handling '%.*s' REQ#%" PRIu64, SPLAT(reqType), req->number()); @@ -93,11 +93,11 @@ namespace litecore::repl { auto nChanges = changes.count(); if (!changes && req->body() != "null"_sl) { warn("Invalid body of 'changes' message"); - req->respondWithError({"BLIP"_sl, 400, "Invalid JSON body"_sl}); + req->respondWithError(400, "Invalid JSON body"_sl); } else if ((!proposed && _mustBeProposed) || (proposed && _db->usingVersionVectors())) { // In conflict-free mode plus rev-trees the protocol requires the pusher send // "proposeChanges" instead. But with version vectors, always use "changes". - req->respondWithError({"BLIP"_sl, 409}); + req->respondWithError({kBLIPErrorDomain, 409}); } else if (nChanges == 0) { // Empty array indicates we've caught up. (This may have been sent no-reply) logInfo("Caught up with remote changes"); @@ -157,7 +157,7 @@ namespace litecore::repl { req->respond(response); logInfo("Responded to '%.*s' REQ#%" PRIu64 " w/request for %u revs in %.6f sec", - SPLAT(req->property("Profile"_sl)), req->number(), requested, st.elapsed()); + SPLAT(req->profile()), req->number(), requested, st.elapsed()); } } catch (...) { auto error = C4Error::fromCurrentException(); diff --git a/Replicator/Worker.cc b/Replicator/Worker.cc index 17f9d20b1e..325f8ca510 100644 --- a/Replicator/Worker.cc +++ b/Replicator/Worker.cc @@ -125,6 +125,27 @@ namespace litecore { namespace repl { } + Worker::AsyncResponse Worker::sendAsyncRequest(blip::BuiltMessage &&built) { + if (isCurrentActor()) { + increment(_pendingResponseCount); + built.onProgress = [=](MessageProgress progress) { + if (progress.state >= MessageProgress::kComplete) + enqueue(FUNCTION_TO_QUEUE(Worker::_endAsyncRequest)); + }; + return connection().sendAsyncRequest(move(built)); + } else { + return asCurrentActor([this, built=move(built)]() mutable { + return sendAsyncRequest(move(built)); + }); + } + } + + + void Worker::_endAsyncRequest() { + decrement(_pendingResponseCount); + } + + #pragma mark - ERRORS: diff --git a/Replicator/Worker.hh b/Replicator/Worker.hh index 7465fcf955..7829c9be88 100644 --- a/Replicator/Worker.hh +++ b/Replicator/Worker.hh @@ -12,6 +12,7 @@ #pragma once #include "Actor.hh" +#include "Async.hh" #include "ReplicatorOptions.hh" #include "BLIPConnection.hh" #include "Message.hh" @@ -98,7 +99,7 @@ namespace litecore { namespace repl { /// @param namePrefix Prepended to the Actor name. Worker(blip::Connection *connection NONNULL, Worker *parent, - const Options* options NONNULL, + const Options* options, std::shared_ptr db, const char *namePrefix NONNULL); @@ -151,6 +152,13 @@ namespace litecore { namespace repl { void sendRequest(blip::MessageBuilder& builder, blip::MessageProgressCallback onProgress = nullptr); + using AsyncResponse = actor::Async>; + + /// Sends a BLIP request, like `sendRequest` but returning the response asynchronously. + /// This method does not need to be called on the Worker's thread. + /// Note: The response object will be nullptr if the connection closed. + AsyncResponse sendAsyncRequest(blip::BuiltMessage&&); + /// The number of BLIP responses I'm waiting for. int pendingResponseCount() const {return _pendingResponseCount;} @@ -200,6 +208,8 @@ namespace litecore { namespace repl { /// or this Actor has pending events in its queue, else `kC4Idle`. virtual ActivityLevel computeActivityLevel() const; + void _endAsyncRequest(); + #pragma mark - INSTANCE DATA: protected: RetainedConst _options; // The replicator options diff --git a/Replicator/c4ConnectedClient.cc b/Replicator/c4ConnectedClient.cc new file mode 100644 index 0000000000..b8e0d958cb --- /dev/null +++ b/Replicator/c4ConnectedClient.cc @@ -0,0 +1,22 @@ +// +// c4ConnectedClient.cc +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#include "c4Base.hh" +#include "c4ConnectedClient.hh" +#include "c4ConnectedClientImpl.hh" + +using namespace litecore::client; +using namespace fleece; + +/*static*/ Retained C4ConnectedClient::newClient(const C4ConnectedClientParameters ¶ms) { + return new C4ConnectedClientImpl(params); +} diff --git a/Replicator/c4ConnectedClientImpl.hh b/Replicator/c4ConnectedClientImpl.hh new file mode 100644 index 0000000000..329a3a3770 --- /dev/null +++ b/Replicator/c4ConnectedClientImpl.hh @@ -0,0 +1,197 @@ +// +// ConnectedClientImpl.hh +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#pragma once + +#include "c4Base.h" +#include "ConnectedClient.hh" +#include "c4ConnectedClient.hh" +#include "c4Socket+Internal.hh" +#include "c4Internal.hh" +#include "Headers.hh" +#include "Replicator.hh" +#include "RevTree.hh" +#include "TreeDocument.hh" + +#ifdef COUCHBASE_ENTERPRISE +#include "c4Certificate.hh" +#endif + +namespace litecore::client { + + using namespace litecore::websocket; + using namespace litecore::actor; + using namespace std; + + struct C4ConnectedClientImpl final: public C4ConnectedClient, public ConnectedClient::Delegate { + + public: + C4ConnectedClientImpl(const C4ConnectedClientParameters ¶ms) + :_onStatusChanged(params.onStatusChanged) + ,_callbackContext(params.callbackContext) + { + if (params.socketFactory) { + // Keep a copy of the C4SocketFactory struct in case original is invalidated: + _socketFactory = *params.socketFactory; + } + + auto webSocket = repl::CreateWebSocket(effectiveURL(params.url), + socketOptions(params), + nullptr, + (_socketFactory ? &*_socketFactory : nullptr)); + _client = new ConnectedClient(webSocket, *this, params); + _client->start(); + } + + Async getStatus() const override { + return _client->status(); + } + + alloc_slice getResponseHeaders() const noexcept override { + return _responseHeaders; + } + +#ifdef COUCHBASE_ENTERPRISE + C4Cert* getPeerTLSCertificate() const override { + LOCK(_mutex); + if (!_peerTLSCertificate && _peerTLSCertificateData) { + _peerTLSCertificate = C4Cert::fromData(_peerTLSCertificateData); + _peerTLSCertificateData = nullptr; + } + return _peerTLSCertificate; + } +#endif + + +#pragma mark - ConnectedClient Delegate + + protected: + virtual void clientGotHTTPResponse(ConnectedClient* client, + int status, + const websocket::Headers &headers) override + { + _responseHeaders = headers.encode(); + } + + virtual void clientGotTLSCertificate(ConnectedClient* client, + slice certData) override + { +#ifdef COUCHBASE_ENTERPRISE + LOCK(_mutex); + _peerTLSCertificateData = certData; + _peerTLSCertificate = nullptr; +#endif + } + + virtual void clientStatusChanged(ConnectedClient* client, + const ConnectedClient::Status &status) override + { + if (_onStatusChanged) + _onStatusChanged(this, status, _callbackContext); + } + + virtual void clientConnectionClosed(ConnectedClient*, const CloseStatus& status) override { + // (do we need to do anything here?) + } + +#pragma mark - + Async getDoc(slice docID, + slice collectionID, + slice unlessRevID, + bool asFleece) override { + return _client->getDoc(docID, + collectionID, + unlessRevID, + asFleece).then([](auto a) -> DocResponse { + return { a.docID, a.revID, a.body, a.deleted }; + }); + } + + Async putDoc(slice docID, + slice collectionID, + slice parentRevisionID, + C4RevisionFlags flags, + slice fleeceData) override { + bool deletion = (flags & kRevDeleted) != 0; + revidBuffer generatedRev = TreeDocumentFactory::generateDocRevID(fleeceData, + parentRevisionID, + deletion); + auto provider = Async::makeProvider(); + _client->putDoc(docID, + collectionID, + revid(generatedRev).expanded(), + parentRevisionID, + flags, + fleeceData).then([=](Result i) { + if (i.ok()) { + auto revID = revid(generatedRev).expanded(); + provider->setResult(revID.asString()); + } else + provider->setError(i.error()); + }); + return provider->asyncValue(); + } + + void getAllDocIDs(slice collectionID, slice pattern, AllDocsReceiver callback) override { + _client->getAllDocIDs(collectionID, pattern, callback); + } + + void query(slice name, FLDict params, bool asFleece, QueryReceiver rcvr) override { + _client->query(name, params, asFleece, rcvr); + } + + virtual void start() override { + LOCK(_mutex); + _client->start(); + } + + virtual void stop() override { + LOCK(_mutex); + _client->stop(); + } + + private: + ~C4ConnectedClientImpl() { + if (_client) + _client->terminate(); + + _client = nullptr; + } + + alloc_slice effectiveURL(slice url) { + string newPath(url); + if (!url.hasSuffix("/")) + newPath += "/"; + newPath += "_blipsync"; + return alloc_slice(newPath); + } + + alloc_slice socketOptions(const C4ConnectedClientParameters ¶ms) { + // Use a temporary repl::Options object, + // because it has the handy ability to add properties to an existing Fleece dict. + repl::Options opts(kC4Disabled, kC4Disabled, params.optionsDictFleece); + opts.setProperty(kC4SocketOptionWSProtocols, repl::Replicator::protocolName().c_str()); + return opts.properties.data(); + } + + mutable std::mutex _mutex; + Retained _client; + optional _socketFactory; + C4ConnectedClientStatusChangedCallback _onStatusChanged; + void* _callbackContext; + alloc_slice _responseHeaders; +#ifdef COUCHBASE_ENTERPRISE + mutable alloc_slice _peerTLSCertificateData; + mutable Retained _peerTLSCertificate; +#endif + }; +} diff --git a/Replicator/c4ConnectedClient_CAPI.cc b/Replicator/c4ConnectedClient_CAPI.cc new file mode 100644 index 0000000000..1b98f3cfdd --- /dev/null +++ b/Replicator/c4ConnectedClient_CAPI.cc @@ -0,0 +1,80 @@ +// +// c4ConnectedClient_CAPI.cc +// +// Copyright 2022-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. +// + +#include "c4ConnectedClient.h" +#include "c4ConnectedClient.hh" +#include "c4Socket+Internal.hh" +#include "c4ExceptionUtils.hh" +#include "Async.hh" + +using namespace litecore::repl; +using namespace litecore; +using namespace fleece; + +C4ConnectedClient* c4client_new(const C4ConnectedClientParameters* params, C4Error *outError) noexcept { + try { + return C4ConnectedClient::newClient(*params).detach(); + } catchError(outError); + return nullptr; +} + +bool c4client_getDoc(C4ConnectedClient* client, + C4Slice docID, + C4Slice collectionID, + C4Slice unlessRevID, + bool asFleece, + C4ConnectedClientGetDocumentCallback callback, + void* C4NULLABLE context, + C4Error* C4NULLABLE outError) noexcept { + try { + auto res = client->getDoc(docID, collectionID, unlessRevID, asFleece); + res.then([=](const C4ConnectedClient::DocResponse &r) { + C4DocResponse cResponse = {r.docID, r.revID, r.body, r.deleted}; + return callback(client, &cResponse, nullptr, context); + }).onError([=](C4Error err) { + return callback(client, nullptr, &err, context); + }); + return true; + } catchError(outError); + return false; +} + +void c4client_start(C4ConnectedClient* client) noexcept { + client->start(); +} + +void c4client_stop(C4ConnectedClient* client) noexcept { + client->stop(); +} + +bool c4client_putDoc(C4ConnectedClient* client, + C4Slice docID, + C4Slice collectionID, + C4Slice revID, + C4RevisionFlags revisionFlags, + C4Slice fleeceData, + C4ConnectedClientUpdateDocumentCallback callback, + void* C4NULLABLE context, + C4Error* C4NULLABLE outError) noexcept { + try { + auto res = client->putDoc(docID, collectionID, revID, revisionFlags, fleeceData); + res.then([=](string result) { + callback(client, alloc_slice(result), nullptr, context); + }).onError([=](C4Error err) { + callback(client, FLHeapSlice(), &err, context); + }); + return true; + } catchError(outError); + + return false; +} + diff --git a/Replicator/c4RemoteReplicator.hh b/Replicator/c4RemoteReplicator.hh index 7b6dfe0cce..754c2d0a9a 100644 --- a/Replicator/c4RemoteReplicator.hh +++ b/Replicator/c4RemoteReplicator.hh @@ -243,7 +243,7 @@ namespace litecore { // Options to pass to the C4Socket alloc_slice socketOptions() const { Replicator::Options opts(kC4Disabled, kC4Disabled, _options->properties); - opts.setProperty(kC4SocketOptionWSProtocols, Replicator::ProtocolName().c_str()); + opts.setProperty(kC4SocketOptionWSProtocols, Replicator::protocolName().c_str()); return opts.properties.data(); } diff --git a/Replicator/c4Socket+Internal.hh b/Replicator/c4Socket+Internal.hh index 8a6a6c6a44..f6cf71630f 100644 --- a/Replicator/c4Socket+Internal.hh +++ b/Replicator/c4Socket+Internal.hh @@ -22,7 +22,7 @@ namespace litecore { namespace repl { // Main factory function to create a WebSocket. fleece::Retained CreateWebSocket(websocket::URL, fleece::alloc_slice options, - C4Database* NONNULL, + C4Database*, const C4SocketFactory*, void *nativeHandle =nullptr); diff --git a/Replicator/tests/ConnectedClientTest.cc b/Replicator/tests/ConnectedClientTest.cc new file mode 100644 index 0000000000..d7303b8dd0 --- /dev/null +++ b/Replicator/tests/ConnectedClientTest.cc @@ -0,0 +1,554 @@ +// +// ConnectedClientTest.cc +// +// Copyright © 2022 Couchbase. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "ConnectedClientTest.hh" +#include "fleece/Mutable.hh" + + +#pragma mark - GET: + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + Log("++++ Calling ConnectedClient::getDoc()..."); + auto asyncResult1 = _client->getDoc("0000001", nullslice, nullslice); + auto asyncResult99 = _client->getDoc("0000099", nullslice, nullslice); + + auto rev = waitForResponse(asyncResult1); + CHECK(rev.docID == "0000001"); + CHECK(rev.revID == "1-4cbe54d79c405e368613186b0bc7ac9ee4a50fbb"); + CHECK(rev.deleted == false); + Doc doc(rev.body); + CHECK(doc.asDict()["birthday"].asString() == "1983-09-18"); + + rev = waitForResponse(asyncResult99); + CHECK(rev.docID == "0000099"); + CHECK(rev.revID == "1-94baf6e4e4a1442aa6d8e9aab87955b8b7f4817a"); + CHECK(rev.deleted == false); + doc = Doc(rev.body); + CHECK(doc.asDict()["birthday"].asString() == "1958-12-20"); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev Conditional Match", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + auto match = _client->getDoc("0000002", nullslice, + "1-1fdf9d4bdae09f6651938d9ec1d47177280f5a77"); + CHECK(waitForErrorResponse(match) == C4Error{WebSocketDomain, 304}); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev Conditional No Match", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + auto match = _client->getDoc("0000002", nullslice, + "1-beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"); + auto rev = waitForResponse(match); + CHECK(rev.docID == "0000002"); + CHECK(rev.revID == "1-1fdf9d4bdae09f6651938d9ec1d47177280f5a77"); + CHECK(rev.deleted == false); + auto doc = Doc(rev.body); + CHECK(doc.asDict()["birthday"].asString() == "1989-04-29"); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev NotFound", "[ConnectedClient]") { + start(); + auto asyncResultX = _client->getDoc("bogus", nullslice, nullslice); + CHECK(waitForErrorResponse(asyncResultX) == C4Error{LiteCoreDomain, kC4ErrorNotFound}); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getBlob", "[ConnectedClient]") { + vector attachments = {"Hey, this is an attachment!", "So is this", ""}; + vector blobKeys; + { + TransactionHelper t(db); + blobKeys = addDocWithAttachments("att1"_sl, attachments, "text/plain"); + } + start(); + + auto asyncResult1 = _client->getDoc("att1", nullslice, nullslice); + auto rev = waitForResponse(asyncResult1); + CHECK(rev.docID == "att1"); + auto doc = Doc(rev.body); + auto digest = C4Blob::keyFromDigestProperty(doc.asDict()["attached"].asArray()[0].asDict()); + REQUIRE(digest); + CHECK(*digest == blobKeys[0]); + + auto asyncBlob1 = _client->getBlob(blobKeys[0], true); + auto asyncBlob2 = _client->getBlob(blobKeys[1], false); + auto asyncBadBlob = _client->getBlob(C4BlobKey{}, false); + + alloc_slice blob1 = waitForResponse(asyncBlob1); + CHECK(blob1 == slice(attachments[0])); + + alloc_slice blob2 = waitForResponse(asyncBlob2); + CHECK(blob2 == slice(attachments[1])); + + CHECK(waitForErrorResponse(asyncBadBlob) == C4Error{LiteCoreDomain, kC4ErrorNotFound}); +} + + +#pragma mark - PUT: + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "putDoc", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + Encoder enc; + enc.beginDict(); + enc["connected"] = "client"; + enc.endDict(); + auto docBody = enc.finish(); + + auto rq1 = _client->putDoc("0000001", nullslice, + "2-2222", + "1-4cbe54d79c405e368613186b0bc7ac9ee4a50fbb", + C4RevisionFlags{}, + docBody); + auto rq2 = _client->putDoc("frob", nullslice, + "1-1111", + nullslice, + C4RevisionFlags{}, + docBody); + rq1.blockUntilReady(); + REQUIRE(rq1.error() == C4Error()); + c4::ref doc1 = c4db_getDoc(db, "0000001"_sl, true, kDocGetCurrentRev, ERROR_INFO()); + REQUIRE(doc1); + CHECK(doc1->revID == "2-2222"_sl); + + rq2.blockUntilReady(); + REQUIRE(rq2.error() == C4Error()); + c4::ref doc2 = c4db_getDoc(db, "frob"_sl, true, kDocGetCurrentRev, ERROR_INFO()); + REQUIRE(doc2); + CHECK(doc2->revID == "1-1111"_sl); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "putDoc Failure", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + Encoder enc; + enc.beginDict(); + enc["connected"] = "client"; + enc.endDict(); + auto docBody = enc.finish(); + + auto rq1 = _client->putDoc("0000001", nullslice, + "2-2222", + "1-d00d", + C4RevisionFlags{}, + docBody); + rq1.blockUntilReady(); + REQUIRE(rq1.error() == C4Error{LiteCoreDomain, kC4ErrorConflict}); +} + + +#pragma mark - OBSERVE: + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "observeCollection", "[ConnectedClient]") { + { + // Start with a single doc that should not be sent to the observer + TransactionHelper t(db); + createFleeceRev(db, "doc1"_sl, "1-1111"_sl, R"({"name":"Puddin' Tane"})"_sl); + } + start(); + + mutex m; + condition_variable cond; + vector allChanges; + + _client->observeCollection(nullslice, [&](vector const& changes) { + // Observer callback: + unique_lock lock(m); + Log("+++ Observer got %zu changes!", changes.size()); + allChanges.insert(allChanges.end(), changes.begin(), changes.end()); + cond.notify_one(); + }).then([&](C4Error error) { + // Async callback when the observer has started: + unique_lock lock(m); + REQUIRE(error == C4Error{}); + Log("+++ Importing docs..."); + importJSONLines(sFixturesDir + "names_100.json"); + }); + + Log("+++ Waiting for 100 changes to arrive..."); + unique_lock lock(m); + cond.wait(lock, [&]{return allChanges.size() >= 100;}); + + Log("+++ Checking the changes"); + REQUIRE(allChanges.size() == 100); + C4SequenceNumber expectedSeq = 2; + for (auto &change : allChanges) { + CHECK(change.docID.size == 7); + CHECK(change.flags == 0); + CHECK(change.sequence == expectedSeq++); + } +} + + +#pragma mark - LEGACY ATTACHMENTS: + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev Blobs Legacy Mode", "[ConnectedClient][blob]") { + static constexpr slice kJSON5WithAttachments = + "{_attachments:{'blob_/attached/0':{content_type:'text/plain',digest:'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=',length:27,revpos:1,stub:true}," + "'blob_/attached/1':{content_type:'text/plain',digest:'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=',length:10,revpos:1,stub:true}," + "empty:{content_type:'text/plain',digest:'sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=',length:0,revpos:1,stub:true}}," + "attached:[{'@type':'blob',content_type:'text/plain',digest:'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=',length:27}," + "{'@type':'blob',content_type:'text/plain',digest:'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=',length:10}]}"; + static constexpr slice kJSON5WithoutAttachments = + "{_attachments:{empty:{content_type:'text/plain',digest:'sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=',length:0,revpos:1,stub:true}}," + "attached:[{'@type':'blob',content_type:'text/plain',digest:'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=',length:27}," + "{'@type':'blob',content_type:'text/plain',digest:'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=',length:10}]}"; + + createFleeceRev(db, "att1"_sl, "1-1111"_sl, slice(json5(kJSON5WithAttachments))); + + // Ensure the 'server' (LiteCore replicator) will not strip the `_attachments` property: + _serverOptions->setProperty("disable_blob_support"_sl, true); + start(); + + auto asyncResult = _client->getDoc("att1", nullslice, nullslice); + auto rev = waitForResponse(asyncResult); + CHECK(rev.docID == "att1"); + Doc doc(rev.body); + Dict props = doc.asDict(); + string json(props.toJSON5()); + replace(json, '"', '\''); + CHECK(slice(json) == kJSON5WithoutAttachments); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "putDoc Blobs Legacy Mode", "[ConnectedClient][blob]") { + // Ensure the 'server' (LiteCore replicator) will not strip the `_attachments` property: + _serverOptions->setProperty("disable_blob_support"_sl, true); + start(); + + // Register the blobs with the ConnectedClient delegate, by digest: + _blobs["sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck="] = alloc_slice("Hey, this is an attachment!"); + _blobs["sha1-rATs731fnP+PJv2Pm/WXWZsCw48="] = alloc_slice("So is this"); + _blobs["sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk="] = alloc_slice(""); + + // Construct the document body, and PUT it: + string json = "{'attached':[{'@type':'blob','content_type':'text/plain','digest':'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=','length':27}," + "{'@type':'blob','content_type':'text/plain','digest':'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=','length':10}," + "{'@type':'blob','content_type':'text/plain','digest':'sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=','length':0}]}"; + replace(json, '\'', '"'); + auto rq = _client->putDoc("att1", nullslice, + "1-1111", + nullslice, + C4RevisionFlags{}, + Doc::fromJSON(json).data()); + rq.blockUntilReady(); + + // All blobs should have been requested by the server and removed from the map: + CHECK(_blobs.empty()); + + // Now read the doc from the server's database: + json = getDocJSON(db, "att1"_sl); + replace(json, '"', '\''); + CHECK(json == + "{'_attachments':{'blob_/attached/0':{'content_type':'text/plain','digest':'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=','length':27,'revpos':1,'stub':true}," + "'blob_/attached/1':{'content_type':'text/plain','digest':'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=','length':10,'revpos':1,'stub':true}," + "'blob_/attached/2':{'content_type':'text/plain','digest':'sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=','length':0,'revpos':1,'stub':true}}," + "'attached':[{'@type':'blob','content_type':'text/plain','digest':'sha1-ERWD9RaGBqLSWOQ+96TZ6Kisjck=','length':27}," + "{'@type':'blob','content_type':'text/plain','digest':'sha1-rATs731fnP+PJv2Pm/WXWZsCw48=','length':10}," + "{'@type':'blob','content_type':'text/plain','digest':'sha1-2jmj7l5rSw0yVb/vlWAYkK/YBwk=','length':0}]}"); + +} + + +#pragma mark - ALL-DOCS: + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "allDocs from connected client", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + start(); + + mutex mut; + condition_variable cond; + unique_lock lock(mut); + + vector results; + + _client->getAllDocIDs(nullslice, nullslice, [&](const vector &docIDs, const C4Error *error) { + unique_lock lock(mut); + if (!docIDs.empty()) { + Log("*** Got %zu docIDs", docIDs.size()); + CHECK(!error); + for (slice id : docIDs) + results.emplace_back(id); + } else { + Log("*** Got final row"); + if (error) + results.push_back("Error: " + error->description()); + cond.notify_one(); + } + }); + + Log("Waiting for docIDs..."); + cond.wait(lock); + Log("docIDs ready"); + CHECK(results.size() == 100); +} + + +#pragma mark - ENCRYPTION: + + +C4UNUSED static constexpr slice + kEncryptedDocJSON = R"({"encrypted$SSN":{"alg":"CB_MOBILE_CUSTOM","ciphertext":"IzIzNC41Ni43ODk6Iw=="}})", + kDecryptedDocJSON = R"({"SSN":{"@type":"encryptable","value":"123-45-6789"}})"; + + +// Make sure there's no error if no decryption callback is given +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "getRev encrypted no callback", "[ConnectedClient]") { + createFleeceRev(db, "seekrit"_sl, "1-1111"_sl, kEncryptedDocJSON); + start(); + + Log("++++ Calling ConnectedClient::getDoc()..."); + auto asyncResult1 = _client->getDoc("seekrit", nullslice, nullslice); + auto rev = waitForResponse(asyncResult1); + Doc doc(rev.body); + CHECK(doc.root().toJSONString() == string(kEncryptedDocJSON)); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "putDoc encrypted no callback", "[ConnectedClient]") { + start(); + + Doc doc = Doc::fromJSON(kDecryptedDocJSON); + + Log("++++ Calling ConnectedClient::putDoc()..."); + C4Error error = {}; + try { + ExpectingExceptions x; + auto rq1 = _client->putDoc("seekrit", nullslice, + "1-1111", + nullslice, + C4RevisionFlags{}, + doc.data()); + } catch(const exception &x) { + error = C4Error::fromCurrentException(); + } + CHECK(error == C4Error{LiteCoreDomain, kC4ErrorCrypto}); +} + + +#ifdef COUCHBASE_ENTERPRISE + +class ConnectedClientEncryptedLoopbackTest : public ConnectedClientLoopbackTest { +public: + ConnectedClientEncryptedLoopbackTest() { + _params.propertyEncryptor = &encryptor; + _params.propertyDecryptor = &decryptor; + _params.callbackContext = &_encryptorContext; + } + + static alloc_slice unbreakableEncryption(slice cleartext, int8_t delta) { + alloc_slice ciphertext(cleartext); + for (size_t i = 0; i < ciphertext.size; ++i) + (uint8_t&)ciphertext[i] += delta; // "I've got patent pending on that!" --Wallace + return ciphertext; + } + + struct TestEncryptorContext { + slice docID; + slice keyPath; + bool called = false; + }; + + TestEncryptorContext _encryptorContext; + + static C4SliceResult encryptor(void* rawCtx, + C4CollectionSpec collection, + C4String documentID, + FLDict properties, + C4String keyPath, + C4Slice input, + C4StringResult* outAlgorithm, + C4StringResult* outKeyID, + C4Error* outError) + { + auto context = (TestEncryptorContext*)rawCtx; + context->called = true; + CHECK(documentID == context->docID); + CHECK(keyPath == context->keyPath); + return C4SliceResult(unbreakableEncryption(input, 1)); + } + + static C4SliceResult decryptor(void* rawCtx, + C4CollectionSpec collection, + C4String documentID, + FLDict properties, + C4String keyPath, + C4Slice input, + C4String algorithm, + C4String keyID, + C4Error* outError) + { + auto context = (TestEncryptorContext*)rawCtx; + context->called = true; + CHECK(documentID == context->docID); + CHECK(keyPath == context->keyPath); + return C4SliceResult(unbreakableEncryption(input, -1)); + } + +}; + + +TEST_CASE_METHOD(ConnectedClientEncryptedLoopbackTest, "getRev encrypted", "[ConnectedClient]") { + createFleeceRev(db, "seekrit"_sl, "1-1111"_sl, kEncryptedDocJSON); + start(); + + _encryptorContext.docID = "seekrit"; + _encryptorContext.keyPath = "SSN"; + + Log("++++ Calling ConnectedClient::getDoc()..."); + auto asyncResult1 = _client->getDoc("seekrit", nullslice, nullslice); + auto rev = waitForResponse(asyncResult1); + CHECK(_encryptorContext.called); + Doc doc(rev.body); + CHECK(doc.root().toJSON() == kDecryptedDocJSON); +} + + +TEST_CASE_METHOD(ConnectedClientEncryptedLoopbackTest, "putDoc encrypted", "[ConnectedClient]") { + start(); + + Doc doc = Doc::fromJSON(kDecryptedDocJSON); + + Log("++++ Calling ConnectedClient::getDoc()..."); + _encryptorContext.docID = "seekrit"; + _encryptorContext.keyPath = "SSN"; + auto rq1 = _client->putDoc("seekrit", nullslice, + "1-1111", + nullslice, + C4RevisionFlags{}, + doc.data()); + rq1.blockUntilReady(); + CHECK(_encryptorContext.called); + + // Read the doc from the database to make sure it was encrypted. + // Note that the replicator has no decryption callback so it will not decrypt the doc! + c4::ref savedDoc = c4db_getDoc(db, "seekrit"_sl, true, + kDocGetAll, ERROR_INFO()); + REQUIRE(savedDoc); + alloc_slice json = c4doc_bodyAsJSON(savedDoc, true, ERROR_INFO()); + CHECK(json == kEncryptedDocJSON); +} + +#endif // COUCHBASE_ENTERPRISE + + +#pragma mark - QUERIES: + + +static constexpr slice kQueryStr = "SELECT name.first, name.last FROM _ WHERE gender='male' and contact.address.state=$STATE"; + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "named query from connected client", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + + MutableDict queries = fleece::MutableDict::newDict(); + queries["guysIn"] = kQueryStr; + _serverOptions->setProperty(kC4ReplicatorOptionNamedQueries, queries); + + start(); + + mutex mut; + condition_variable cond; + + vector jsonResults, fleeceResults; + + MutableDict params = fleece::MutableDict::newDict(); + params["STATE"] = "CA"; + _client->query("guysIn", params, true, [&](slice json, fleece::Dict row, const C4Error *error) { + if (row) { + CHECK(!error); + Log("*** Got query row: %s", row.toJSONString().c_str()); + jsonResults.push_back(string(json)); + fleeceResults.push_back(row.toJSONString()); + } else { + Log("*** Got final row"); + if (error) + fleeceResults.push_back("Error: " + error->description()); + unique_lock lock(mut); + cond.notify_one(); + } + }); + + Log("Waiting for query..."); + unique_lock lock(mut); + cond.wait(lock); + Log("Query complete"); + vector expectedResults { + R"({"first":"Cleveland","last":"Bejcek"})", + R"({"first":"Rico","last":"Hoopengardner"})"}; + CHECK(fleeceResults == expectedResults); + CHECK(jsonResults == expectedResults); +} + + +TEST_CASE_METHOD(ConnectedClientLoopbackTest, "n1ql query from connected client", "[ConnectedClient]") { + importJSONLines(sFixturesDir + "names_100.json"); + + _serverOptions->setProperty(kC4ReplicatorOptionAllQueries, true); + + start(); + + mutex mut; + condition_variable cond; + + vector jsonResults, fleeceResults; + + MutableDict params = fleece::MutableDict::newDict(); + params["STATE"] = "CA"; + _client->query(kQueryStr, params, true, [&](slice json, fleece::Dict row, const C4Error *error) { + if (row) { + CHECK(!error); + Log("*** Got query row: %s", row.toJSONString().c_str()); + jsonResults.push_back(string(json)); + fleeceResults.push_back(row.toJSONString()); + } else { + Log("*** Got final row"); + if (error) + fleeceResults.push_back("Error: " + error->description()); + unique_lock lock(mut); + cond.notify_one(); + } + }); + + Log("Waiting for query..."); + unique_lock lock(mut); + cond.wait(lock); + Log("Query complete"); + vector expectedResults { + R"({"first":"Cleveland","last":"Bejcek"})", + R"({"first":"Rico","last":"Hoopengardner"})"}; + CHECK(fleeceResults == expectedResults); + CHECK(jsonResults == expectedResults); +} diff --git a/Replicator/tests/ConnectedClientTest.hh b/Replicator/tests/ConnectedClientTest.hh new file mode 100644 index 0000000000..56b39846dd --- /dev/null +++ b/Replicator/tests/ConnectedClientTest.hh @@ -0,0 +1,185 @@ +// +// ConnectedClientTest.hh +// +// Copyright © 2022 Couchbase. All rights reserved. +// + +#pragma once +#include "c4Test.hh" +#include "ConnectedClient.hh" +#include "Replicator.hh" +#include "LoopbackProvider.hh" +#include "StringUtil.hh" +#include "fleece/Fleece.hh" +#include + + +using namespace std; +using namespace fleece; +using namespace litecore; +using namespace litecore::websocket; + + +/// Test class for Connected Client unit tests. Runs a LiteCore replicator in passive mode. +class ConnectedClientLoopbackTest : public C4Test, + public repl::Replicator::Delegate, + public client::ConnectedClient::Delegate +{ +public: + + ConnectedClientLoopbackTest() { + _serverOptions = make_retained(kC4Passive,kC4Passive); + _serverOptions->setProperty(kC4ReplicatorOptionAllowConnectedClient, true); + _serverOptions->setProperty(kC4ReplicatorOptionNoIncomingConflicts, true); + } + + ~ConnectedClientLoopbackTest() { + stop(); + } + + void start() { + std::unique_lock lock(_mutex); + Assert(!_serverRunning && !_clientRunning); + + c4::ref serverDB = c4db_openAgain(db, ERROR_INFO()); + REQUIRE(serverDB); + _server = new repl::Replicator(serverDB, + new LoopbackWebSocket(alloc_slice("ws://srv/"), + Role::Server, {}), + *this, _serverOptions); + + _client = new client::ConnectedClient(new LoopbackWebSocket(alloc_slice("ws://cli/"), + Role::Client, {}), + *this, + _params); + + Headers headers; + headers.add("Set-Cookie"_sl, "flavor=chocolate-chip"_sl); + LoopbackWebSocket::bind(_server->webSocket(), _client->webSocket(), headers); + + _clientRunning = _serverRunning = true; + _server->start(); + _client->start(); + } + + + void stop() { + std::unique_lock lock(_mutex); + if (_server) { + _server->stop(); + _server = nullptr; + } + if (_client) { + _client->stop(); + _client = nullptr; + } + + Log("+++ Waiting for client & replicator to stop..."); + _cond.wait(lock, [&]{return !_clientRunning && !_serverRunning;}); + } + + + template + auto waitForResponse(actor::Async &asyncResult) { + asyncResult.blockUntilReady(); + + Log("++++ Async response available!"); + if (auto err = asyncResult.error()) + FAIL("Response returned an error " << err); + return asyncResult.result().value(); + } + + + template + C4Error waitForErrorResponse(actor::Async &asyncResult) { + asyncResult.blockUntilReady(); + + Log("++++ Async response available!"); + auto err = asyncResult.error(); + if (!err) + FAIL("Response did not return an error"); + return err; + } + + + //---- ConnectedClient delegate: + + alloc_slice getBlobContents(const C4BlobKey &blobKey, C4Error *error) override { + string digestString = blobKey.digestString(); + if (auto i = _blobs.find(digestString); i != _blobs.end()) { + alloc_slice blob = i->second; + _blobs.erase(i); // remove blob after it's requested + return blob; + } else { + WarnError("getBlobContents called on unknown blob %s", digestString.c_str()); + *error = C4Error::make(LiteCoreDomain, kC4ErrorNotFound); + return nullslice; + } + } + + + void clientGotHTTPResponse(client::ConnectedClient* NONNULL, + int status, + const websocket::Headers &headers) override + { + Log("+++ Client got HTTP response"); + } + + void clientGotTLSCertificate(client::ConnectedClient* NONNULL, + slice certData) override + { + Log("+++ Client got TLS certificate"); + } + + void clientStatusChanged(client::ConnectedClient* NONNULL, + client::ConnectedClient::Status const& status) override + { + Log("+++ Client status changed: %d", int(status.level)); + if (status.level == kC4Stopped) { + std::unique_lock lock(_mutex); + _clientRunning = false; + if (!_clientRunning && !_serverRunning) + _cond.notify_all(); + } + } + + void clientConnectionClosed(client::ConnectedClient* NONNULL, + const CloseStatus &close) override { + Log("+++ Client connection closed: reason=%d, code=%d, message=%.*s", + int(close.reason), close.code, FMTSLICE(close.message)); + } + + + //---- Replicator delegate: + + void replicatorGotHTTPResponse(repl::Replicator* NONNULL, + int status, + const websocket::Headers &headers) override { } + void replicatorGotTLSCertificate(slice certData) override { } + void replicatorStatusChanged(repl::Replicator* NONNULL, + const repl::Replicator::Status &status) override { + if (status.level == kC4Stopped) { + std::unique_lock lock(_mutex); + _serverRunning = false; + if (!_clientRunning && !_serverRunning) + _cond.notify_all(); + } + } + void replicatorConnectionClosed(repl::Replicator* NONNULL, + const CloseStatus&) override { } + void replicatorDocumentsEnded(repl::Replicator* NONNULL, + const repl::Replicator::DocumentsEnded&) override { } + void replicatorBlobProgress(repl::Replicator* NONNULL, + const repl::Replicator::BlobProgress&) override { } + + + C4ConnectedClientParameters _params {}; + Retained _server; + Retained _serverOptions; + Retained _client; + mutex _mutex; + condition_variable _cond; + unordered_map _blobs; + bool _clientRunning = false; + bool _serverRunning = false; +}; diff --git a/Xcode/LiteCore.xcodeproj/project.pbxproj b/Xcode/LiteCore.xcodeproj/project.pbxproj index b2264cf689..569627fd21 100644 --- a/Xcode/LiteCore.xcodeproj/project.pbxproj +++ b/Xcode/LiteCore.xcodeproj/project.pbxproj @@ -26,6 +26,9 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1A5726B227D74A8900A9B412 /* c4ConnectedClient.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A5726B127D74A8900A9B412 /* c4ConnectedClient.cc */; }; + 1AE26CC727D9C432003C3043 /* c4ConnectedClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE26CC327D9C42B003C3043 /* c4ConnectedClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1AE26CC927D9C488003C3043 /* c4ConnectedClient_CAPI.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1AE26CC827D9C488003C3043 /* c4ConnectedClient_CAPI.cc */; }; 2700BB53216FF2DB00797537 /* CoreML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2700BB4D216FF2DA00797537 /* CoreML.framework */; }; 2700BB5B217005A900797537 /* CoreMLPredictiveModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2700BB5A217005A900797537 /* CoreMLPredictiveModel.mm */; }; 2700BB75217905FE00797537 /* libLiteCore-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27EF81121917EEC600A327B9 /* libLiteCore-static.a */; }; @@ -181,6 +184,8 @@ 275067DC230B6AD500FA23B2 /* c4Listener.cc in Sources */ = {isa = PBXBuildFile; fileRef = 275A74D51ED3AA11008CB57B /* c4Listener.cc */; }; 275067E2230B6C5400FA23B2 /* libLiteCoreREST-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27FC81E81EAAB0D90028E38E /* libLiteCoreREST-static.a */; }; 27513A5D1A687EF80055DC40 /* sqlite3_unicodesn_tokenizer.c in Sources */ = {isa = PBXBuildFile; fileRef = 27513A591A687E770055DC40 /* sqlite3_unicodesn_tokenizer.c */; }; + 2752C6B727BC41DC001C1B76 /* ConnectedClient.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2752C6B627BC41DC001C1B76 /* ConnectedClient.cc */; }; + 2752C7A727BF18F2001C1B76 /* ConnectedClientTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2752C7A627BF18F2001C1B76 /* ConnectedClientTest.cc */; }; 275313392065844800463E74 /* RESTSyncListener_stub.cc in Sources */ = {isa = PBXBuildFile; fileRef = 270BEE1D20647E8A005E8BE8 /* RESTSyncListener_stub.cc */; }; 2753AF721EBD190600C12E98 /* LogDecoder.cc in Sources */ = {isa = PBXBuildFile; fileRef = 270C6B871EBA2CD600E73415 /* LogDecoder.cc */; }; 2753AF7D1EBD1BE300C12E98 /* Logging_Stub.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2753AF7C1EBD1BE300C12E98 /* Logging_Stub.cc */; }; @@ -205,6 +210,7 @@ 276683B81DC7DD2E00E3F187 /* SequenceTracker.hh in Headers */ = {isa = PBXBuildFile; fileRef = 276683B51DC7DD2E00E3F187 /* SequenceTracker.hh */; }; 2769438C1DCD502A00DB2555 /* c4Observer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2769438B1DCD502A00DB2555 /* c4Observer.cc */; }; 2769438F1DD0ED3F00DB2555 /* c4ObserverTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2769438E1DD0ED3F00DB2555 /* c4ObserverTest.cc */; }; + 27697DDC27D2B32D006F5BB5 /* ResultTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27697DDB27D2B32D006F5BB5 /* ResultTest.cc */; }; 276993E625390C3300FDF699 /* VectorRecord.cc in Sources */ = {isa = PBXBuildFile; fileRef = 276993E525390C3300FDF699 /* VectorRecord.cc */; }; 276CE6832267991500B681AC /* n1ql.cc in Sources */ = {isa = PBXBuildFile; fileRef = 276CE67C2267991400B681AC /* n1ql.cc */; settings = {COMPILER_FLAGS = "-Wno-unreachable-code"; }; }; 276D152B1DFB878800543B1B /* c4DocumentTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27E0CA9D1DBEAA130089A9C0 /* c4DocumentTest.cc */; }; @@ -220,6 +226,8 @@ 27727C55230F279D0082BCC9 /* HTTPLogic.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27727C53230F279D0082BCC9 /* HTTPLogic.cc */; }; 27766E161982DA8E00CAA464 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27766E151982DA8E00CAA464 /* Security.framework */; }; 2776AA272087FF6B004ACE85 /* LegacyAttachments.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2776AA252087FF6B004ACE85 /* LegacyAttachments.cc */; }; + 277C5C4627AB1EB4001BE212 /* AsyncTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277C5C4527AB1EB4001BE212 /* AsyncTest.cc */; }; + 277C5C4727AB1F02001BE212 /* Async.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2744B336241854F2005A194D /* Async.cc */; }; 2783DF991D27436700F84E6E /* c4ThreadingTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2783DF981D27436700F84E6E /* c4ThreadingTest.cc */; }; 2787EB271F4C91B000DB97B0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27766E151982DA8E00CAA464 /* Security.framework */; }; 2787EB291F4C929C00DB97B0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27766E151982DA8E00CAA464 /* Security.framework */; }; @@ -322,6 +330,7 @@ 27BF024B1FB62726003D5BB8 /* LibC++Debug.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27BF023C1FB61F5F003D5BB8 /* LibC++Debug.cc */; }; 27C319EE1A143F5D00A89EDC /* KeyStore.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27C319EC1A143F5D00A89EDC /* KeyStore.cc */; }; 27C77302216FCF5400D5FB44 /* c4PredictiveQueryTest+CoreML.mm in Sources */ = {isa = PBXBuildFile; fileRef = 27C77301216FCF5400D5FB44 /* c4PredictiveQueryTest+CoreML.mm */; }; + 27CA3D6D27FE510C006918A7 /* LegacyAttachments2.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27CA3D6C27FE510C006918A7 /* LegacyAttachments2.cc */; }; 27CCD4AE2315DB03003DEB99 /* CookieStore.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2761F3EE1EE9CC58006D4BB8 /* CookieStore.cc */; }; 27CCD4AF2315DB11003DEB99 /* Address.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27CE4CF02077F51000ACA225 /* Address.cc */; }; 27CCD4B22315DBD3003DEB99 /* Address.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27CE4CF02077F51000ACA225 /* Address.cc */; }; @@ -445,6 +454,7 @@ 27F0426C2196264900D7C6FA /* SQLiteDataFile+Indexes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27F0426B2196264900D7C6FA /* SQLiteDataFile+Indexes.cc */; }; 27F2BEA0221DF1A0006C13EE /* DBAccess.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27F2BE9F221DF1A0006C13EE /* DBAccess.cc */; }; 27F6F51D1BAA0482003FD798 /* c4Test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27F6F51B1BAA0482003FD798 /* c4Test.cc */; }; + 27F7177A2808E20E000CEA5B /* QueryServer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27F717792808E20E000CEA5B /* QueryServer.cc */; }; 27F7A1351D61F7EB00447BC6 /* LiteCoreTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2708FE5A1CF4D3370022F721 /* LiteCoreTest.cc */; }; 27F7A1431D61F8B700447BC6 /* c4Test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 27F6F51B1BAA0482003FD798 /* c4Test.cc */; }; 27F7A1441D61F8B700447BC6 /* c4DatabaseTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 274D04001BA75C0400FF7C35 /* c4DatabaseTest.cc */; }; @@ -827,6 +837,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1A5726AF27D7474900A9B412 /* c4ConnectedClient.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = c4ConnectedClient.hh; sourceTree = ""; }; + 1A5726B127D74A8900A9B412 /* c4ConnectedClient.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = c4ConnectedClient.cc; sourceTree = ""; }; + 1AE26CC327D9C42B003C3043 /* c4ConnectedClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c4ConnectedClient.h; sourceTree = ""; }; + 1AE26CC827D9C488003C3043 /* c4ConnectedClient_CAPI.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c4ConnectedClient_CAPI.cc; sourceTree = ""; }; + 1AE26CCA27D9D456003C3043 /* c4ConnectedClientImpl.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = c4ConnectedClientImpl.hh; sourceTree = ""; }; 2700BB4D216FF2DA00797537 /* CoreML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreML.framework; path = System/Library/Frameworks/CoreML.framework; sourceTree = SDKROOT; }; 2700BB59217005A900797537 /* CoreMLPredictiveModel.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CoreMLPredictiveModel.hh; sourceTree = ""; }; 2700BB5A217005A900797537 /* CoreMLPredictiveModel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreMLPredictiveModel.mm; sourceTree = ""; }; @@ -1002,7 +1017,6 @@ 2744B331241854F2005A194D /* WebSocketImpl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketImpl.cc; sourceTree = ""; }; 2744B332241854F2005A194D /* WebSocketProtocol.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WebSocketProtocol.hh; sourceTree = ""; }; 2744B334241854F2005A194D /* Codec.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Codec.cc; sourceTree = ""; }; - 2744B335241854F2005A194D /* ActorProperty.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ActorProperty.hh; sourceTree = ""; }; 2744B336241854F2005A194D /* Async.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Async.cc; sourceTree = ""; }; 2744B337241854F2005A194D /* Actor.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Actor.cc; sourceTree = ""; }; 2744B338241854F2005A194D /* ThreadedMailbox.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadedMailbox.hh; sourceTree = ""; }; @@ -1012,7 +1026,6 @@ 2744B33C241854F2005A194D /* Batcher.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Batcher.hh; sourceTree = ""; }; 2744B33D241854F2005A194D /* ThreadUtil.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadUtil.hh; sourceTree = ""; }; 2744B33E241854F2005A194D /* Codec.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Codec.hh; sourceTree = ""; }; - 2744B33F241854F2005A194D /* ActorProperty.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActorProperty.cc; sourceTree = ""; }; 2744B340241854F2005A194D /* Actor.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Actor.hh; sourceTree = ""; }; 2744B341241854F2005A194D /* Async.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Async.hh; sourceTree = ""; }; 2744B342241854F2005A194D /* Channel.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Channel.cc; sourceTree = ""; }; @@ -1100,6 +1113,9 @@ 27513A591A687E770055DC40 /* sqlite3_unicodesn_tokenizer.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sqlite3_unicodesn_tokenizer.c; sourceTree = ""; }; 27513A5C1A687EA70055DC40 /* sqlite3_unicodesn_tokenizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sqlite3_unicodesn_tokenizer.h; sourceTree = ""; }; 2752C6AC27BC3A2E001C1B76 /* replication-protocol.adoc */ = {isa = PBXFileReference; lastKnownFileType = text; name = "replication-protocol.adoc"; path = "../../modules/docs/pages/replication-protocol.adoc"; sourceTree = ""; }; + 2752C6B527BC41DC001C1B76 /* ConnectedClient.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConnectedClient.hh; sourceTree = ""; }; + 2752C6B627BC41DC001C1B76 /* ConnectedClient.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectedClient.cc; sourceTree = ""; }; + 2752C7A627BF18F2001C1B76 /* ConnectedClientTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectedClientTest.cc; sourceTree = ""; }; 2753AF7C1EBD1BE300C12E98 /* Logging_Stub.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logging_Stub.cc; sourceTree = ""; }; 2754B0C01E5F49AA00A05FD0 /* StringUtil.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringUtil.cc; sourceTree = ""; }; 2754B0C11E5F49AA00A05FD0 /* StringUtil.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StringUtil.hh; sourceTree = ""; }; @@ -1161,6 +1177,8 @@ 2764ED3623870F15007F020F /* c4Database.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = c4Database.hh; sourceTree = ""; }; 2764ED3723873B9E007F020F /* c4.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = c4.txt; path = scripts/c4.txt; sourceTree = ""; }; 2764ED3823873B9E007F020F /* c4_exp.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = c4_exp.txt; path = scripts/c4_exp.txt; sourceTree = ""; }; + 276592A02804B6700037DD04 /* ConnectedClientTest.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConnectedClientTest.hh; sourceTree = ""; }; + 276592A42804DB810037DD04 /* ConnectedClientProtocol.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = ConnectedClientProtocol.md; sourceTree = ""; }; 276683B41DC7DD2E00E3F187 /* SequenceTracker.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SequenceTracker.cc; sourceTree = ""; }; 276683B51DC7DD2E00E3F187 /* SequenceTracker.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SequenceTracker.hh; sourceTree = ""; }; 2766F9E51E64CC03008FC9E5 /* SequenceSet.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SequenceSet.hh; sourceTree = ""; }; @@ -1168,6 +1186,8 @@ 276943881DCD4AAD00DB2555 /* c4Observer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = c4Observer.h; sourceTree = ""; }; 2769438B1DCD502A00DB2555 /* c4Observer.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c4Observer.cc; sourceTree = ""; }; 2769438E1DD0ED3F00DB2555 /* c4ObserverTest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c4ObserverTest.cc; sourceTree = ""; }; + 27697DD727D19B25006F5BB5 /* Result.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Result.md; sourceTree = ""; }; + 27697DDB27D2B32D006F5BB5 /* ResultTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ResultTest.cc; sourceTree = ""; }; 276993E125390C3300FDF699 /* VectorRecord.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VectorRecord.hh; sourceTree = ""; }; 276993E525390C3300FDF699 /* VectorRecord.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VectorRecord.cc; sourceTree = ""; }; 276CE67C2267991400B681AC /* n1ql.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = n1ql.cc; sourceTree = ""; }; @@ -1201,6 +1221,8 @@ 2776AA262087FF6B004ACE85 /* LegacyAttachments.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = LegacyAttachments.hh; sourceTree = ""; }; 2777146C1C5D6BDB003C0287 /* static_lib.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = static_lib.xcconfig; sourceTree = ""; }; 2779CC6E1E85E4FC00F0D251 /* ReplicatorTypes.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ReplicatorTypes.hh; sourceTree = ""; }; + 277C5C4527AB1EB4001BE212 /* AsyncTest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncTest.cc; sourceTree = ""; }; + 277C5C4827AC4E0E001BE212 /* Async.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Async.md; sourceTree = ""; }; 277CB6251D0DED5E00702E56 /* Fleece.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Fleece.xcodeproj; path = fleece/Fleece.xcodeproj; sourceTree = ""; }; 277D19C9194E295B008E91EB /* Error.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Error.hh; sourceTree = ""; }; 277FEE5721ED10FA00B60E3C /* ReplicatorSGTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ReplicatorSGTest.cc; sourceTree = ""; }; @@ -1346,6 +1368,8 @@ 27C319EC1A143F5D00A89EDC /* KeyStore.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyStore.cc; sourceTree = ""; }; 27C319ED1A143F5D00A89EDC /* KeyStore.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyStore.hh; sourceTree = ""; }; 27C77301216FCF5400D5FB44 /* c4PredictiveQueryTest+CoreML.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "c4PredictiveQueryTest+CoreML.mm"; sourceTree = ""; }; + 27CA3D6827FE3D12006918A7 /* c4ConnectedClientTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = c4ConnectedClientTypes.h; sourceTree = ""; }; + 27CA3D6C27FE510C006918A7 /* LegacyAttachments2.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyAttachments2.cc; sourceTree = ""; }; 27CCC7D61E52613C00CE1989 /* Replicator.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Replicator.cc; sourceTree = ""; }; 27CCC7D71E52613C00CE1989 /* Replicator.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Replicator.hh; sourceTree = ""; }; 27CCC7DE1E526CCC00CE1989 /* Puller.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Puller.cc; sourceTree = ""; }; @@ -1527,6 +1551,8 @@ 27F4F48323070C7F0075D7CB /* tls_context.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tls_context.h; sourceTree = ""; }; 27F6F51B1BAA0482003FD798 /* c4Test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c4Test.cc; sourceTree = ""; }; 27F6F51C1BAA0482003FD798 /* c4Test.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = c4Test.hh; sourceTree = ""; }; + 27F717782808E20E000CEA5B /* QueryServer.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = QueryServer.hh; sourceTree = ""; }; + 27F717792808E20E000CEA5B /* QueryServer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = QueryServer.cc; sourceTree = ""; }; 27F7A0BD1D5E2BAB00447BC6 /* DatabaseImpl.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DatabaseImpl.hh; sourceTree = ""; }; 27FA09D31D70EDBF005888AA /* Catch_Tests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Catch_Tests.mm; sourceTree = ""; }; 27FA568324AD0E9300B2F1F8 /* Pusher+Attachments.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "Pusher+Attachments.cc"; sourceTree = ""; }; @@ -1629,6 +1655,8 @@ 27FDF13E1DA84EE70087B4E6 /* SQLiteFleeceUtil.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SQLiteFleeceUtil.hh; sourceTree = ""; }; 27FDF1421DAC22230087B4E6 /* SQLiteFunctionsTest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteFunctionsTest.cc; sourceTree = ""; }; 27FDF1A21DAD79450087B4E6 /* LiteCore-dylib_Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "LiteCore-dylib_Release.xcconfig"; sourceTree = ""; }; + 27FF5CAF27C83A8F00CFFA43 /* AsyncActorCommon.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AsyncActorCommon.hh; sourceTree = ""; }; + 27FF5CB027C96EC500CFFA43 /* Result.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Result.hh; sourceTree = ""; }; 42B6B0DD25A6A9D9004B20A7 /* URLTransformer.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = URLTransformer.hh; sourceTree = ""; }; 42B6B0E125A6A9D9004B20A7 /* URLTransformer.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLTransformer.cc; sourceTree = ""; }; 720EA3F51BA7EAD9002B8416 /* libLiteCore.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libLiteCore.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1818,6 +1846,7 @@ children = ( 275FF6D11E4947E1005F90DD /* c4BaseTest.cc */, 274D18EC2617DFE40018D39C /* c4DocumentTest_Internal.cc */, + 277C5C4527AB1EB4001BE212 /* AsyncTest.cc */, 277015081D523E2E008BADD7 /* DataFileTest.cc */, 27E0CA9F1DBEB0BA0089A9C0 /* DocumentKeysTest.cc */, 272B1BEA1FB1513100F56620 /* FTSTest.cc */, @@ -1829,6 +1858,7 @@ 2771991B2272498300B18E0A /* QueryParserTest.hh */, 27E6737C1EC78144008F50C4 /* QueryTest.cc */, 2723410F211B5FC400DA9437 /* QueryTest.hh */, + 27697DDB27D2B32D006F5BB5 /* ResultTest.cc */, 27456AFC1DC9507D00A38B20 /* SequenceTrackerTest.cc */, 27FDF1421DAC22230087B4E6 /* SQLiteFunctionsTest.cc */, 272850B41E9BE361009CA22F /* UpgraderTest.cc */, @@ -2003,6 +2033,7 @@ 2758DFD225F161CD007C7487 /* c4BlobStore.hh */, 274D181826165AFB0018D39C /* c4Certificate.hh */, 27229268260D171D00A3A41F /* c4Collection.hh */, + 1A5726AF27D7474900A9B412 /* c4ConnectedClient.hh */, 2764ED3623870F15007F020F /* c4Database.hh */, 2758DFE425F197B9007C7487 /* c4Document.hh */, 2758E09825F3026F007C7487 /* c4DocEnumerator.hh */, @@ -2061,20 +2092,19 @@ 2744B36124185D24005A194D /* Actors */ = { isa = PBXGroup; children = ( - 2744B335241854F2005A194D /* ActorProperty.hh */, - 2744B336241854F2005A194D /* Async.cc */, + 2744B340241854F2005A194D /* Actor.hh */, 2744B337241854F2005A194D /* Actor.cc */, 2744B338241854F2005A194D /* ThreadedMailbox.hh */, 2744B339241854F2005A194D /* GCDMailbox.hh */, 2744B33A241854F2005A194D /* ThreadedMailbox.cc */, 2744B33B241854F2005A194D /* GCDMailbox.cc */, - 2744B33F241854F2005A194D /* ActorProperty.cc */, - 2744B340241854F2005A194D /* Actor.hh */, - 2744B341241854F2005A194D /* Async.hh */, 2744B342241854F2005A194D /* Channel.cc */, 2744B344241854F2005A194D /* Channel.hh */, 274C1DC325C4A79C00B0EEAC /* ChannelManifest.cc */, 274C1DC425C4A79C00B0EEAC /* ChannelManifest.hh */, + 2744B341241854F2005A194D /* Async.hh */, + 2744B336241854F2005A194D /* Async.cc */, + 27FF5CAF27C83A8F00CFFA43 /* AsyncActorCommon.hh */, ); name = Actors; sourceTree = ""; @@ -2098,6 +2128,7 @@ isa = PBXGroup; children = ( 2745B7CB26825F970012A17A /* index.html */, + 27697DD727D19B25006F5BB5 /* Result.md */, 2745B7CC26825F970012A17A /* overview */, ); name = docs; @@ -2118,6 +2149,7 @@ 2745B7D126825F970012A17A /* Class Diagram.diagrams */, 2745B7D726825F970012A17A /* Class Diagram.pdf */, 2745B7D626825F970012A17A /* Class Diagram.png */, + 276592A42804DB810037DD04 /* ConnectedClientProtocol.md */, 2745B7D026825F970012A17A /* Replicator Diagram.svg */, 2745B7CD26825F970012A17A /* Replicator Diagram.t2d */, ); @@ -2250,6 +2282,7 @@ 2762A01F22EF641900F9AB18 /* Defer.hh */, 27393A861C8A353A00829C9B /* Error.cc */, 277D19C9194E295B008E91EB /* Error.hh */, + 27FF5CB027C96EC500CFFA43 /* Result.hh */, 27E89BA41D679542002C32B3 /* FilePath.cc */, 27E89BA51D679542002C32B3 /* FilePath.hh */, 27700DFD1FB642B80005D48E /* Increment.hh */, @@ -2295,6 +2328,17 @@ name = "Supporting Files"; sourceTree = ""; }; + 2752C6B127BC417E001C1B76 /* ConnectedClient */ = { + isa = PBXGroup; + children = ( + 2752C6B627BC41DC001C1B76 /* ConnectedClient.cc */, + 2752C6B527BC41DC001C1B76 /* ConnectedClient.hh */, + 27F717792808E20E000CEA5B /* QueryServer.cc */, + 27F717782808E20E000CEA5B /* QueryServer.hh */, + ); + path = ConnectedClient; + sourceTree = ""; + }; 2754616A22F21F3900DF87B0 /* Crypto */ = { isa = PBXGroup; children = ( @@ -2385,6 +2429,7 @@ 273D25F52564666A008643D2 /* VectorDocument.cc */, 273D25F42564666A008643D2 /* VectorDocument.hh */, 2776AA252087FF6B004ACE85 /* LegacyAttachments.cc */, + 27CA3D6C27FE510C006918A7 /* LegacyAttachments2.cc */, 2776AA262087FF6B004ACE85 /* LegacyAttachments.hh */, 27DD1511193CD005009A367D /* RevID.cc */, 27DD1512193CD005009A367D /* RevID.hh */, @@ -2427,6 +2472,8 @@ 277FEE5721ED10FA00B60E3C /* ReplicatorSGTest.cc */, 2761F3F61EEA00C3006D4BB8 /* CookieStoreTest.cc */, 27A83D53269E3E69002B7EBA /* PropertyEncryptionTests.cc */, + 2752C7A627BF18F2001C1B76 /* ConnectedClientTest.cc */, + 276592A02804B6700037DD04 /* ConnectedClientTest.hh */, ); path = tests; sourceTree = ""; @@ -2613,6 +2660,9 @@ 27D9652B23303B0C00F4A51C /* c4IncomingReplicator.hh */, 278BD6891EEB6756000DBF41 /* DatabaseCookies.cc */, 278BD68A1EEB6756000DBF41 /* DatabaseCookies.hh */, + 1AE26CCA27D9D456003C3043 /* c4ConnectedClientImpl.hh */, + 1A5726B127D74A8900A9B412 /* c4ConnectedClient.cc */, + 1AE26CC827D9C488003C3043 /* c4ConnectedClient_CAPI.cc */, ); name = "API implementation"; sourceTree = ""; @@ -2806,6 +2856,7 @@ 275E9904238360B200EA516B /* Checkpointer.hh */, 275E4CD22241C701006C5B71 /* Pull */, 275E4CD32241C726006C5B71 /* Push */, + 2752C6B127BC417E001C1B76 /* ConnectedClient */, 277B9567224597E1005B7E79 /* Support */, 277B956122459796005B7E79 /* API implementation */, 275CE0FC1E5B78570084E014 /* tests */, @@ -2915,6 +2966,7 @@ isa = PBXGroup; children = ( 27DF3BC326867F2600A57A1E /* Actors.md */, + 277C5C4827AC4E0E001BE212 /* Async.md */, 27DF3BC426867F2600A57A1E /* logo.png */, 27DF3BC526867F2600A57A1E /* BLIP Protocol.md */, ); @@ -3079,6 +3131,7 @@ 2722504A1D7884110006D5A5 /* c4BlobStore.h */, 27469D03233D488C00A1EE1A /* c4Certificate.h */, 274D166C2612906B0018D39C /* c4Collection.h */, + 1AE26CC327D9C42B003C3043 /* c4ConnectedClient.h */, 2757DE571B9FC3C9002EE261 /* c4Database.h */, 274A69881BED288D00D16D37 /* c4Document.h */, 27F370821DC02C3D0096F717 /* c4Document+Fleece.h */, @@ -3094,6 +3147,7 @@ 27491C9A1E7B1001001DC54B /* c4Socket.h */, 27175AF1261B80E70045F3AC /* c4BlobStoreTypes.h */, 274D181C26165BDA0018D39C /* c4CertificateTypes.h */, + 27CA3D6827FE3D12006918A7 /* c4ConnectedClientTypes.h */, 2743E32625F853D4006F696D /* c4DatabaseTypes.h */, 2743E1DA25F69D58006F696D /* c4DocumentTypes.h */, 274D17A22614E7220018D39C /* c4DocumentStruct.h */, @@ -3242,6 +3296,7 @@ 27B649542069723900FC12F7 /* c4Query.h in Headers */, 27B649552069723900FC12F7 /* c4Replicator.h in Headers */, 27B649562069723900FC12F7 /* c4Socket.h in Headers */, + 1AE26CC727D9C432003C3043 /* c4ConnectedClient.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3820,7 +3875,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = "/bin/sh -e"; - shellScript = "if which doxygen >/dev/null\nthen\n cd $SRCROOT/../C\n doxygen\nfi\n"; + shellScript = "if [[ \"$CONFIGURATION\" == Release* ]]\n then\n if which doxygen >/dev/null\n then\n cd $SRCROOT/../C\n doxygen\n fi\nfi\n"; }; 275BF36C1F5F67940051374A /* Generate repo_version.h */ = { isa = PBXShellScriptBuildPhase; @@ -3928,12 +3983,15 @@ 2708FE5B1CF4D3370022F721 /* LiteCoreTest.cc in Sources */, 272850ED1E9D4C79009CA22F /* c4Test.cc in Sources */, 275FF6D31E494860005F90DD /* c4BaseTest.cc in Sources */, + 2752C7A727BF18F2001C1B76 /* ConnectedClientTest.cc in Sources */, 27431BC7258A8AB0009E3EC5 /* QuietReporter.hh in Sources */, 270C6B981EBA3AD200E73415 /* LogEncoderTest.cc in Sources */, 275067DC230B6AD500FA23B2 /* c4Listener.cc in Sources */, 274D17C22615445B0018D39C /* DBAccessTestWrapper.cc in Sources */, 27FA09A01D6FA380005888AA /* DataFileTest.cc in Sources */, + 27697DDC27D2B32D006F5BB5 /* ResultTest.cc in Sources */, 27E0CAA01DBEB0BA0089A9C0 /* DocumentKeysTest.cc in Sources */, + 277C5C4627AB1EB4001BE212 /* AsyncTest.cc in Sources */, 27505DDD256335B000123115 /* VersionVectorTest.cc in Sources */, 27456AFD1DC9507D00A38B20 /* SequenceTrackerTest.cc in Sources */, 274EDDFA1DA322D4003AD158 /* QueryParserTest.cc in Sources */, @@ -4193,6 +4251,7 @@ buildActionMask = 2147483647; files = ( 2771B01A1FB2817800C6B794 /* SQLiteKeyStore+Indexes.cc in Sources */, + 1AE26CC927D9C488003C3043 /* c4ConnectedClient_CAPI.cc in Sources */, 27393A871C8A353A00829C9B /* Error.cc in Sources */, 27B699DB1F27B50000782145 /* SQLiteN1QLFunctions.cc in Sources */, 2744B36224186142005A194D /* BuiltInWebSocket.cc in Sources */, @@ -4234,6 +4293,7 @@ 275E9905238360B200EA516B /* Checkpointer.cc in Sources */, 275B35A5234E753800FE9CF0 /* Housekeeper.cc in Sources */, 271AB0162374AD09007B0319 /* IndexSpec.cc in Sources */, + 2752C6B727BC41DC001C1B76 /* ConnectedClient.cc in Sources */, 27FA568424AD0E9300B2F1F8 /* Pusher+Attachments.cc in Sources */, 93CD01101E933BE100AFB3FA /* Checkpoint.cc in Sources */, 27D74A6F1D4D3DF500D806E0 /* SQLiteDataFile.cc in Sources */, @@ -4273,9 +4333,11 @@ 274EDDEC1DA2F488003AD158 /* SQLiteKeyStore.cc in Sources */, 27FC8DBD22135BDA0083B033 /* RevFinder.cc in Sources */, 27D74A7C1D4D3F2300D806E0 /* Column.cpp in Sources */, + 1A5726B227D74A8900A9B412 /* c4ConnectedClient.cc in Sources */, 2763011B1F32A7FD004A1592 /* UnicodeCollator_Stub.cc in Sources */, 93CD010D1E933BE100AFB3FA /* Replicator.cc in Sources */, 273855AF25B790B1009D746E /* DatabaseImpl+Upgrade.cc in Sources */, + 27CA3D6D27FE510C006918A7 /* LegacyAttachments2.cc in Sources */, 2716F91F248578D000BE21D9 /* mbedSnippets.cc in Sources */, 27229215260AB89900A3A41F /* BlobStreams.cc in Sources */, 272F00F62273D45000E62F72 /* LiveQuerier.cc in Sources */, @@ -4292,6 +4354,7 @@ 27D74A7E1D4D3F2300D806E0 /* Database.cpp in Sources */, 27ADA79B1F2BF64100D9DE25 /* UnicodeCollator.cc in Sources */, 27BF024B1FB62726003D5BB8 /* LibC++Debug.cc in Sources */, + 27F7177A2808E20E000CEA5B /* QueryServer.cc in Sources */, 2712F5AF25D5A9AB0082D526 /* c4Error.cc in Sources */, 93CD010E1E933BE100AFB3FA /* Puller.cc in Sources */, 274EDDF61DA30B43003AD158 /* QueryParser.cc in Sources */, @@ -4311,6 +4374,7 @@ 27D74A7A1D4D3F2300D806E0 /* Backup.cpp in Sources */, 276683B61DC7DD2E00E3F187 /* SequenceTracker.cc in Sources */, 27F0426C2196264900D7C6FA /* SQLiteDataFile+Indexes.cc in Sources */, + 277C5C4727AB1F02001BE212 /* Async.cc in Sources */, 27FA568924AD0F8E00B2F1F8 /* Pusher+Revs.cc in Sources */, 278963621D7A376900493096 /* EncryptedStream.cc in Sources */, 72A3AF891F424EC0001E16D4 /* PrebuiltCopier.cc in Sources */, diff --git a/Xcode/LiteCore.xcodeproj/xcshareddata/xcschemes/LiteCore C++ Tests.xcscheme b/Xcode/LiteCore.xcodeproj/xcshareddata/xcschemes/LiteCore C++ Tests.xcscheme index 9f0be23a65..20f3bf84a1 100644 --- a/Xcode/LiteCore.xcodeproj/xcshareddata/xcschemes/LiteCore C++ Tests.xcscheme +++ b/Xcode/LiteCore.xcodeproj/xcshareddata/xcschemes/LiteCore C++ Tests.xcscheme @@ -65,7 +65,26 @@ argument = "--break" isEnabled = "YES"> + + + + + + + + + + + +src:*/LogEncoder.cc +src:*/Logging.cc diff --git a/Xcode/xcconfigs/Project_Debug.xcconfig b/Xcode/xcconfigs/Project_Debug.xcconfig index a85b5424e7..9d6b6c46b4 100644 --- a/Xcode/xcconfigs/Project_Debug.xcconfig +++ b/Xcode/xcconfigs/Project_Debug.xcconfig @@ -13,3 +13,12 @@ GCC_OPTIMIZATION_LEVEL = 0 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1 _LIBCPP_DEBUG=0 ENABLE_TESTABILITY = YES MTL_ENABLE_DEBUG_INFO = YES + +// This flag turns off the Address Sanitizer for the files or functions listed in the .txt file. +// I added this to speed up logging, so it doesn't introduce as much of a slowdown which can +// perturb test results and prevent some timing-sensitive race conditions from showing up. +// +// However, this compiler flag wasn't added until Xcode 13(?); at least, the version of Xcode +// currently on Jenkins doesn't support it, so I'm commenting this out for now. --Jens +// TODO: Re-enable this when Jenkins is upgraded. +//OTHER_CFLAGS = $(inherited) -fsanitize-ignorelist=$(SRCROOT)/sanitizer-ignore-list.txt diff --git a/build_cmake/scripts/build_unix_all.sh b/build_cmake/scripts/build_unix_all.sh new file mode 100755 index 0000000000..8a162ff981 --- /dev/null +++ b/build_cmake/scripts/build_unix_all.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright 2017-Present Couchbase, Inc. +# +# Use of this software is governed by the Business Source License included in +# the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +# file, in accordance with the Business Source License, use of this software +# will be governed by the Apache License, Version 2.0, included in the file +# licenses/APL2.txt. + +set -e + +SCRIPT_DIR=`dirname $0` +cd $SCRIPT_DIR/.. +mkdir -p unix +cd unix +core_count=`getconf _NPROCESSORS_ONLN` + +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. +make -j `expr $core_count + 1` diff --git a/cmake/platform_base.cmake b/cmake/platform_base.cmake index 0c9cf1a42f..d975569387 100644 --- a/cmake/platform_base.cmake +++ b/cmake/platform_base.cmake @@ -38,6 +38,7 @@ function(set_litecore_source_base) LiteCore/Database/DatabaseImpl+Upgrade.cc LiteCore/Database/Housekeeper.cc LiteCore/Database/LegacyAttachments.cc + LiteCore/Database/LegacyAttachments2.cc LiteCore/Database/LiveQuerier.cc LiteCore/Database/PrebuiltCopier.cc LiteCore/Database/SequenceTracker.cc @@ -108,6 +109,10 @@ function(set_litecore_source_base) Replicator/RevFinder.cc Replicator/URLTransformer.cc Replicator/Worker.cc + Replicator/c4ConnectedClient_CAPI.cc + Replicator/c4ConnectedClient.cc + Replicator/ConnectedClient/ConnectedClient.cc + Replicator/ConnectedClient/QueryServer.cc LiteCore/Support/Logging.cc LiteCore/Support/DefaultLogger.cc LiteCore/Support/Error.cc diff --git a/docs/C/html/_compiler_support_8h.html b/docs/C/html/_compiler_support_8h.html index 2c7f17bae3..6eb429f77d 100644 --- a/docs/C/html/_compiler_support_8h.html +++ b/docs/C/html/_compiler_support_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: CompilerSupport.h File Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
CompilerSupport.h File Reference
+
CompilerSupport.h File Reference

Go to the source code of this file.

- @@ -127,7 +127,7 @@

+

Macros

#define _FLEECE_COMPILER_SUPPORT_H
 
 

Macro Definition Documentation

- +

◆ __cold

@@ -141,7 +141,7 @@

+

◆ __has_attribute

@@ -159,7 +159,7 @@

+

◆ __has_builtin

@@ -177,7 +177,7 @@

+

◆ __has_extension

@@ -195,7 +195,7 @@

+

◆ __has_feature

@@ -213,7 +213,7 @@

+

◆ __hot

@@ -227,7 +227,7 @@

+

◆ __optimize

@@ -245,7 +245,7 @@

+

◆ _FLEECE_COMPILER_SUPPORT_H

@@ -259,7 +259,7 @@

+

◆ _usuallyFalse

@@ -277,7 +277,7 @@

+

◆ _usuallyTrue

@@ -295,7 +295,7 @@

+

◆ COLDLEVEL

@@ -309,7 +309,7 @@

+

◆ FL_ASSUME_NONNULL_BEGIN

@@ -323,7 +323,7 @@

+

◆ FL_ASSUME_NONNULL_END

@@ -337,7 +337,7 @@

+

◆ FL_NONNULL

@@ -351,7 +351,7 @@

+

◆ FL_NULLABLE

@@ -365,7 +365,7 @@

+

◆ FL_RETURNS_NONNULL

@@ -379,7 +379,7 @@

+

◆ FLCONST

@@ -393,7 +393,7 @@

+

◆ FLPURE

@@ -407,7 +407,7 @@

+

◆ HOTLEVEL

@@ -421,7 +421,7 @@

+

◆ MUST_USE_RESULT

@@ -435,7 +435,7 @@

+

◆ NONNULL

@@ -449,7 +449,7 @@

+

◆ RETURNS_NONNULL

@@ -463,7 +463,7 @@

+

◆ STEPOVER

@@ -477,7 +477,7 @@

+

◆ WINAPI_FAMILY_PARTITION

@@ -498,7 +498,7 @@

diff --git a/docs/C/html/_compiler_support_8h_source.html b/docs/C/html/_compiler_support_8h_source.html index 6110e63717..7470126bd7 100644 --- a/docs/C/html/_compiler_support_8h_source.html +++ b/docs/C/html/_compiler_support_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: CompilerSupport.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CompilerSupport.h
+
CompilerSupport.h
-Go to the documentation of this file.
1 //
-
2 // CompilerSupport.h
-
3 //
-
4 // Copyright 2018-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 #ifndef _FLEECE_COMPILER_SUPPORT_H
-
15 #define _FLEECE_COMPILER_SUPPORT_H
-
16 
-
17 // The __has_xxx() macros are only(?) implemented by Clang. (Except GCC has __has_attribute...)
-
18 // Define them to return 0 on other compilers.
-
19 // https://clang.llvm.org/docs/AttributeReference.html
-
20 // https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
-
21 
-
22 #ifndef __has_attribute
-
23  #define __has_attribute(x) 0
-
24 #endif
-
25 
-
26 #ifndef __has_builtin
-
27  #define __has_builtin(x) 0
-
28 #endif
-
29 
-
30 #ifndef __has_feature
-
31  #define __has_feature(x) 0
-
32 #endif
-
33 
-
34 #ifndef __has_extension
-
35  #define __has_extension(x) 0
-
36 #endif
-
37 
-
38 
-
39 #if defined(__clang__) || defined(__GNUC__)
-
40  // Tells the optimizer that a function's return value is never NULL.
-
41  #define RETURNS_NONNULL __attribute__((returns_nonnull))
-
42 
-
43  // Triggers a compile error if a call to the function ignores the returned value.
-
44  // Typically this is because the return value is something that must be released/freed.
-
45  #define MUST_USE_RESULT __attribute__((warn_unused_result))
-
46 
-
47  // These have no effect on behavior, but they hint to the optimizer which branch of an 'if'
-
48  // statement to make faster.
-
49  #define _usuallyTrue(VAL) __builtin_expect(VAL, true)
-
50  #define _usuallyFalse(VAL) __builtin_expect(VAL, false)
-
51 #else
-
52  #define RETURNS_NONNULL
-
53  #define MUST_USE_RESULT
-
54 
-
55  #define _usuallyTrue(VAL) (VAL)
-
56  #define _usuallyFalse(VAL) (VAL)
-
57 #endif
-
58 
-
59 
-
60 // Nullability annotations, for function parameters and struct fields.
-
61 // In between FL_ASSUME_NONNULL_BEGIN and FL_ASSUME_NONNULL_END, all pointer declarations implicitly
-
62 // disallow NULL values, unless annotated with FL_NULLABLE (which must come after the `*`.)
-
63 // (FL_NONNULL is occasionally necessary when there are multiple levels of pointers.)
-
64 // NOTE: Only supported in Clang, so far.
-
65 #if __has_feature(nullability)
-
66 # define FL_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
-
67 # define FL_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
-
68 # define FL_NULLABLE _Nullable
-
69 # define FL_NONNULL _Nonnull
-
70 # define FL_RETURNS_NONNULL __attribute__((returns_nonnull))
-
71 #else
-
72 # define FL_ASSUME_NONNULL_BEGIN
-
73 # define FL_ASSUME_NONNULL_END
-
74 # define FL_NULLABLE
-
75 # define FL_NONNULL
-
76 # define FL_RETURNS_NONNULL
-
77 #endif
-
78 
-
79 
-
80 // Declares that a parameter must not be NULL. The compiler can sometimes detect violations
-
81 // of this at compile time, if the parameter value is a literal.
-
82 // The Clang Undefined-Behavior Sanitizer will detect all violations at runtime.
-
83 // GCC also has an attribute with this name, but it's incompatible: it can't be applied to a
-
84 // parameter, it has to come after the function and list parameters by number. Oh well.
-
85 // TODO: Replace this with the better nullability annotations above.
-
86 #ifdef __clang__
-
87  #define NONNULL __attribute__((nonnull))
-
88 #else
-
89  #define NONNULL
-
90 #endif
-
91 
-
92 
-
93 // FLPURE functions are _read-only_. They cannot write to memory (in a way that's detectable),
-
94 // and they cannot access volatile data or do I/O.
-
95 //
-
96 // Calling an FLPURE function twice in a row with the same arguments must return the same result.
-
97 //
-
98 // "Many functions have no effects except the return value, and their return value depends only on
-
99 // the parameters and/or global variables. Such a function can be subject to common subexpression
-
100 // elimination and loop optimization just as an arithmetic operator would be. These functions
-
101 // should be declared with the attribute pure."
-
102 // "The pure attribute prohibits a function from modifying the state of the program that is
-
103 // observable by means other than inspecting the function’s return value. However, functions
-
104 // declared with the pure attribute can safely read any non-volatile objects, and modify the value
-
105 // of objects in a way that does not affect their return value or the observable state of the
-
106 // program." -- GCC manual
-
107 #if defined(__GNUC__) || __has_attribute(__pure__)
-
108  #define FLPURE __attribute__((__pure__))
-
109 #else
-
110  #define FLPURE
-
111 #endif
-
112 
-
113 // FLCONST is even stricter than FLPURE. The function cannot access memory at all (except for
-
114 // reading immutable values like constants.) The return value can only depend on the parameters.
-
115 //
-
116 // Calling an FLCONST function with the same arguments must _always_ return the same result.
-
117 //
-
118 // "Calls to functions whose return value is not affected by changes to the observable state of the
-
119 // program and that have no observable effects on such state other than to return a value may lend
-
120 // themselves to optimizations such as common subexpression elimination. Declaring such functions
-
121 // with the const attribute allows GCC to avoid emitting some calls in repeated invocations of the
-
122 // function with the same argument values."
-
123 // "Note that a function that has pointer arguments and examines the data pointed to must not be
-
124 // declared const if the pointed-to data might change between successive invocations of the
-
125 // function.
-
126 // "In general, since a function cannot distinguish data that might change from data that cannot,
-
127 // const functions should never take pointer or, in C++, reference arguments. Likewise, a function
-
128 // that calls a non-const function usually must not be const itself." -- GCC manual
-
129 #if defined(__GNUC__) || __has_attribute(__const__)
-
130  #define FLCONST __attribute__((__const__))
-
131 #else
-
132  #define FLCONST
-
133 #endif
-
134 
-
135 
-
136 // `constexpr14` is for uses of `constexpr` that are valid in C++14 but not earlier.
-
137 // In constexpr functions this includes `if`, `for`, `while` statements; or multiple `return`s.
-
138 // The macro expands to `constexpr` in C++14 or later, otherwise to nothing.
-
139 #ifdef __cplusplus
-
140  #if __cplusplus >= 201400L || _MSVC_LANG >= 201400L
-
141  #define constexpr14 constexpr
-
142  #else
-
143  #define constexpr14
-
144  #endif
-
145 #endif // __cplusplus
-
146 
-
147 
-
148 // STEPOVER is for trivial little glue functions that are annoying to step into in the debugger
-
149 // on the way to the function you _do_ want to step into. Examples are RefCounted's operator->,
-
150 // or slice constructors. Suppressing debug info for those functions means the debugger
-
151 // will continue through them when stepping in.
-
152 // (It probably also makes the debug-symbol file smaller.)
-
153 #if __has_attribute(nodebug)
-
154  #define STEPOVER __attribute((nodebug))
-
155 #else
-
156  #define STEPOVER
-
157 #endif
-
158 
-
159 
-
160 // Note: Code below adapted from libmdbx source code.
-
161 
-
162 // `__optimize` is used by the macros below -- you should probably not use it directly, instead
-
163 // use `__hot` or `__cold`. It applies a specific compiler optimization level to a function,
-
164 // e.g. __optimize("O3") or __optimize("Os"). Has no effect in an unoptimized build.
-
165 #ifndef __optimize
-
166 # if defined(__OPTIMIZE__)
-
167 # if defined(__clang__) && !__has_attribute(__optimize__)
-
168 # define __optimize(ops)
-
169 # elif defined(__GNUC__) || __has_attribute(__optimize__)
-
170 # define __optimize(ops) __attribute__((__optimize__(ops)))
-
171 # else
-
172 # define __optimize(ops)
-
173 # endif
-
174 # else
-
175 # define __optimize(ops)
-
176 # endif
-
177 #endif /* __optimize */
-
178 
-
179 #if defined(__clang__)
-
180  #define HOTLEVEL "Ofast"
-
181  #define COLDLEVEL "Oz"
-
182 #else
-
183  #define HOTLEVEL "O3"
-
184  #define COLDLEVEL "Os"
-
185 #endif
-
186 
-
187 // `__hot` marks a function as being a hot-spot. Optimizes it for speed and may move it to a common
-
188 // code section for hot functions. Has no effect in an unoptimized build.
-
189 #ifndef __hot
-
190 # if defined(__OPTIMIZE__)
-
191 # if defined(__clang__) && !__has_attribute(__hot__) \
-
192  && __has_attribute(__section__) && (defined(__linux__) || defined(__gnu_linux__))
-
193  /* just put frequently used functions in separate section */
-
194 # define __hot __attribute__((__section__("text.hot"))) __optimize(HOTLEVEL)
-
195 # elif defined(__GNUC__) || __has_attribute(__hot__)
-
196 # define __hot __attribute__((__hot__)) __optimize(HOTLEVEL)
-
197 # else
-
198 # define __hot __optimize(HOTLEVEL)
-
199 # endif
-
200 # else
-
201 # define __hot
-
202 # endif
-
203 #endif /* __hot */
-
204 
-
205 // `__cold` marks a function as being rarely used (e.g. error handling.) Optimizes it for size and
-
206 // moves it to a common code section for cold functions. Has no effect in an unoptimized build.
-
207 #ifndef __cold
-
208 # if defined(__OPTIMIZE__)
-
209 # if defined(__clang__) && !__has_attribute(__cold__) \
-
210  && __has_attribute(__section__) && (defined(__linux__) || defined(__gnu_linux__))
-
211  /* just put infrequently used functions in separate section */
-
212 # define __cold __attribute__((__section__("text.unlikely"))) __optimize(COLDLEVEL)
-
213 # elif defined(__GNUC__) || __has_attribute(__cold__)
-
214 # define __cold __attribute__((__cold__)) __optimize(COLDLEVEL)
-
215 # else
-
216 # define __cold __optimize(COLDLEVEL)
-
217 # endif
-
218 # else
-
219 # define __cold
-
220 # endif
-
221 #endif /* __cold */
-
222 
-
223 
-
224 #ifndef _MSC_VER
-
225  #define WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 0
-
226 #endif
-
227 
-
228 
-
229 #else // _FLEECE_COMPILER_SUPPORT_H
-
230 #warn "Compiler is not honoring #pragma once"
-
231 #endif
+Go to the documentation of this file.
1//
+
2// CompilerSupport.h
+
3//
+
4// Copyright 2018-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#ifndef _FLEECE_COMPILER_SUPPORT_H
+
15#define _FLEECE_COMPILER_SUPPORT_H
+
16
+
17// The __has_xxx() macros are only(?) implemented by Clang. (Except GCC has __has_attribute...)
+
18// Define them to return 0 on other compilers.
+
19// https://clang.llvm.org/docs/AttributeReference.html
+
20// https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+
21
+
22#ifndef __has_attribute
+
23 #define __has_attribute(x) 0
+
24#endif
+
25
+
26#ifndef __has_builtin
+
27 #define __has_builtin(x) 0
+
28#endif
+
29
+
30#ifndef __has_feature
+
31 #define __has_feature(x) 0
+
32#endif
+
33
+
34#ifndef __has_extension
+
35 #define __has_extension(x) 0
+
36#endif
+
37
+
38
+
39#if defined(__clang__) || defined(__GNUC__)
+
40 // Tells the optimizer that a function's return value is never NULL.
+
41 #define RETURNS_NONNULL __attribute__((returns_nonnull))
+
42
+
43 // Triggers a compile error if a call to the function ignores the returned value.
+
44 // Typically this is because the return value is something that must be released/freed.
+
45 #define MUST_USE_RESULT __attribute__((warn_unused_result))
+
46
+
47 // These have no effect on behavior, but they hint to the optimizer which branch of an 'if'
+
48 // statement to make faster.
+
49 #define _usuallyTrue(VAL) __builtin_expect(VAL, true)
+
50 #define _usuallyFalse(VAL) __builtin_expect(VAL, false)
+
51#else
+
52 #define RETURNS_NONNULL
+
53 #define MUST_USE_RESULT
+
54
+
55 #define _usuallyTrue(VAL) (VAL)
+
56 #define _usuallyFalse(VAL) (VAL)
+
57#endif
+
58
+
59
+
60// Nullability annotations, for function parameters and struct fields.
+
61// In between FL_ASSUME_NONNULL_BEGIN and FL_ASSUME_NONNULL_END, all pointer declarations implicitly
+
62// disallow NULL values, unless annotated with FL_NULLABLE (which must come after the `*`.)
+
63// (FL_NONNULL is occasionally necessary when there are multiple levels of pointers.)
+
64// NOTE: Only supported in Clang, so far.
+
65#if __has_feature(nullability)
+
66# define FL_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
+
67# define FL_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
+
68# define FL_NULLABLE _Nullable
+
69# define FL_NONNULL _Nonnull
+
70# define FL_RETURNS_NONNULL __attribute__((returns_nonnull))
+
71#else
+
72# define FL_ASSUME_NONNULL_BEGIN
+
73# define FL_ASSUME_NONNULL_END
+
74# define FL_NULLABLE
+
75# define FL_NONNULL
+
76# define FL_RETURNS_NONNULL
+
77#endif
+
78
+
79
+
80// Declares that a parameter must not be NULL. The compiler can sometimes detect violations
+
81// of this at compile time, if the parameter value is a literal.
+
82// The Clang Undefined-Behavior Sanitizer will detect all violations at runtime.
+
83// GCC also has an attribute with this name, but it's incompatible: it can't be applied to a
+
84// parameter, it has to come after the function and list parameters by number. Oh well.
+
85// TODO: Replace this with the better nullability annotations above.
+
86#ifdef __clang__
+
87 #define NONNULL __attribute__((nonnull))
+
88#else
+
89 #define NONNULL
+
90#endif
+
91
+
92
+
93// FLPURE functions are _read-only_. They cannot write to memory (in a way that's detectable),
+
94// and they cannot access volatile data or do I/O.
+
95//
+
96// Calling an FLPURE function twice in a row with the same arguments must return the same result.
+
97//
+
98// "Many functions have no effects except the return value, and their return value depends only on
+
99// the parameters and/or global variables. Such a function can be subject to common subexpression
+
100// elimination and loop optimization just as an arithmetic operator would be. These functions
+
101// should be declared with the attribute pure."
+
102// "The pure attribute prohibits a function from modifying the state of the program that is
+
103// observable by means other than inspecting the function’s return value. However, functions
+
104// declared with the pure attribute can safely read any non-volatile objects, and modify the value
+
105// of objects in a way that does not affect their return value or the observable state of the
+
106// program." -- GCC manual
+
107#if defined(__GNUC__) || __has_attribute(__pure__)
+
108 #define FLPURE __attribute__((__pure__))
+
109#else
+
110 #define FLPURE
+
111#endif
+
112
+
113// FLCONST is even stricter than FLPURE. The function cannot access memory at all (except for
+
114// reading immutable values like constants.) The return value can only depend on the parameters.
+
115//
+
116// Calling an FLCONST function with the same arguments must _always_ return the same result.
+
117//
+
118// "Calls to functions whose return value is not affected by changes to the observable state of the
+
119// program and that have no observable effects on such state other than to return a value may lend
+
120// themselves to optimizations such as common subexpression elimination. Declaring such functions
+
121// with the const attribute allows GCC to avoid emitting some calls in repeated invocations of the
+
122// function with the same argument values."
+
123// "Note that a function that has pointer arguments and examines the data pointed to must not be
+
124// declared const if the pointed-to data might change between successive invocations of the
+
125// function.
+
126// "In general, since a function cannot distinguish data that might change from data that cannot,
+
127// const functions should never take pointer or, in C++, reference arguments. Likewise, a function
+
128// that calls a non-const function usually must not be const itself." -- GCC manual
+
129#if defined(__GNUC__) || __has_attribute(__const__)
+
130 #define FLCONST __attribute__((__const__))
+
131#else
+
132 #define FLCONST
+
133#endif
+
134
+
135
+
136// `constexpr14` is for uses of `constexpr` that are valid in C++14 but not earlier.
+
137// In constexpr functions this includes `if`, `for`, `while` statements; or multiple `return`s.
+
138// The macro expands to `constexpr` in C++14 or later, otherwise to nothing.
+
139#ifdef __cplusplus
+
140 #if __cplusplus >= 201400L || _MSVC_LANG >= 201400L
+
141 #define constexpr14 constexpr
+
142 #else
+
143 #define constexpr14
+
144 #endif
+
145#endif // __cplusplus
+
146
+
147
+
148// STEPOVER is for trivial little glue functions that are annoying to step into in the debugger
+
149// on the way to the function you _do_ want to step into. Examples are RefCounted's operator->,
+
150// or slice constructors. Suppressing debug info for those functions means the debugger
+
151// will continue through them when stepping in.
+
152// (It probably also makes the debug-symbol file smaller.)
+
153#if __has_attribute(nodebug)
+
154 #define STEPOVER __attribute((nodebug))
+
155#else
+
156 #define STEPOVER
+
157#endif
+
158
+
159
+
160// Note: Code below adapted from libmdbx source code.
+
161
+
162// `__optimize` is used by the macros below -- you should probably not use it directly, instead
+
163// use `__hot` or `__cold`. It applies a specific compiler optimization level to a function,
+
164// e.g. __optimize("O3") or __optimize("Os"). Has no effect in an unoptimized build.
+
165#ifndef __optimize
+
166# if defined(__OPTIMIZE__)
+
167# if defined(__clang__) && !__has_attribute(__optimize__)
+
168# define __optimize(ops)
+
169# elif defined(__GNUC__) || __has_attribute(__optimize__)
+
170# define __optimize(ops) __attribute__((__optimize__(ops)))
+
171# else
+
172# define __optimize(ops)
+
173# endif
+
174# else
+
175# define __optimize(ops)
+
176# endif
+
177#endif /* __optimize */
+
178
+
179#if defined(__clang__)
+
180 #define HOTLEVEL "Ofast"
+
181 #define COLDLEVEL "Oz"
+
182#else
+
183 #define HOTLEVEL "O3"
+
184 #define COLDLEVEL "Os"
+
185#endif
+
186
+
187// `__hot` marks a function as being a hot-spot. Optimizes it for speed and may move it to a common
+
188// code section for hot functions. Has no effect in an unoptimized build.
+
189#ifndef __hot
+
190# if defined(__OPTIMIZE__)
+
191# if defined(__clang__) && !__has_attribute(__hot__) \
+
192 && __has_attribute(__section__) && (defined(__linux__) || defined(__gnu_linux__))
+
193 /* just put frequently used functions in separate section */
+
194# define __hot __attribute__((__section__("text.hot"))) __optimize(HOTLEVEL)
+
195# elif defined(__GNUC__) || __has_attribute(__hot__)
+
196# define __hot __attribute__((__hot__)) __optimize(HOTLEVEL)
+
197# else
+
198# define __hot __optimize(HOTLEVEL)
+
199# endif
+
200# else
+
201# define __hot
+
202# endif
+
203#endif /* __hot */
+
204
+
205// `__cold` marks a function as being rarely used (e.g. error handling.) Optimizes it for size and
+
206// moves it to a common code section for cold functions. Has no effect in an unoptimized build.
+
207#ifndef __cold
+
208# if defined(__OPTIMIZE__)
+
209# if defined(__clang__) && !__has_attribute(__cold__) \
+
210 && __has_attribute(__section__) && (defined(__linux__) || defined(__gnu_linux__))
+
211 /* just put infrequently used functions in separate section */
+
212# define __cold __attribute__((__section__("text.unlikely"))) __optimize(COLDLEVEL)
+
213# elif defined(__GNUC__) || __has_attribute(__cold__)
+
214# define __cold __attribute__((__cold__)) __optimize(COLDLEVEL)
+
215# else
+
216# define __cold __optimize(COLDLEVEL)
+
217# endif
+
218# else
+
219# define __cold
+
220# endif
+
221#endif /* __cold */
+
222
+
223
+
224#ifndef _MSC_VER
+
225 #define WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 0
+
226#endif
+
227
+
228
+
229#else // _FLEECE_COMPILER_SUPPORT_H
+
230#warn "Compiler is not honoring #pragma once"
+
231#endif
diff --git a/docs/C/html/_f_l_base_8h.html b/docs/C/html/_f_l_base_8h.html index e4a5932150..5080856583 100644 --- a/docs/C/html/_f_l_base_8h.html +++ b/docs/C/html/_f_l_base_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLBase.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
FLBase.h File Reference
+
FLBase.h File Reference

#include "CompilerSupport.h"
@@ -79,14 +79,14 @@

Go to the source code of this file.

-

+

Macros

#define _FLBASE_H
 
#define FLEECE_PUBLIC
 
- @@ -116,7 +116,7 @@

+

Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
 A reference to a shared-keys mapping. More...
 
-

+

Enumerations

enum  FLError {
  kFLNoError = 0 @@ -144,8 +144,8 @@
 
- @@ -164,7 +164,7 @@

Timestamps

Fleece does not have a native type for dates or times; like JSON, they are represented as strings in ISO-8601 format, which look like "2008-08-07T05:18:51.589Z".

-

They can also be represented more compactly as numbers, interpreted as milliseconds since the Unix epoch (midnight at January 1 1970, UTC.)

+

Fleece does not have a native type for dates or times; like JSON, they are represented as strings in ISO-8601 format, which look like "2008-08-07T05:18:51.589Z".

+

They can also be represented more compactly as numbers, interpreted as milliseconds since the Unix epoch (midnight at January 1 1970, UTC.)

#define FLTimestampNone   INT64_MIN
 A value representing a missing timestamp; returned when a date cannot be parsed. More...
 

Macro Definition Documentation

- +

◆ _FLBASE_H

@@ -178,7 +178,7 @@

+

◆ FLEECE_PUBLIC

@@ -195,7 +195,7 @@

diff --git a/docs/C/html/_f_l_base_8h_source.html b/docs/C/html/_f_l_base_8h_source.html index 4f3add2ad6..0d6b64d237 100644 --- a/docs/C/html/_f_l_base_8h_source.html +++ b/docs/C/html/_f_l_base_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLBase.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLBase.h
+
FLBase.h
-Go to the documentation of this file.
1 //
-
2 // FLBase.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLBASE_H
-
15 #define _FLBASE_H
-
16 
-
17 #include "CompilerSupport.h"
-
18 #include "FLSlice.h"
-
19 
-
20 // On Windows, FLEECE_PUBLIC marks symbols as being exported from the shared library.
-
21 // However, this is not the whole list of things that are exported. The API methods
-
22 // are exported using a definition list, but it is not possible to correctly include
-
23 // initialized global variables, so those need to be marked (both in the header and
-
24 // implementation) with FLEECE_PUBLIC. See kFLNullValue below and in Fleece.cc
-
25 // for an example.
-
26 #if defined(_MSC_VER)
-
27 #ifdef FLEECE_EXPORTS
-
28 #define FLEECE_PUBLIC __declspec(dllexport)
-
29 #else
-
30 #define FLEECE_PUBLIC __declspec(dllimport)
-
31 #endif
-
32 #else
-
33 #define FLEECE_PUBLIC
-
34 #endif
-
35 
- -
37 
-
38 #ifdef __cplusplus
-
39 extern "C" {
-
40 #endif
-
41 
-
42  // This is the C API! For the C++ API, see Fleece.hh.
-
43 
-
44 
-
45  //====== BASIC TYPES
-
46 
-
50 #ifndef FL_IMPL
-
51  typedef const struct _FLValue* FLValue;
-
52  typedef const struct _FLArray* FLArray;
-
53  typedef const struct _FLDict* FLDict;
-
54  typedef struct _FLSlot* FLSlot;
-
55  typedef struct _FLArray* FLMutableArray;
-
56  typedef struct _FLDict* FLMutableDict;
-
57  typedef struct _FLEncoder* FLEncoder;
-
58  typedef struct _FLDoc* FLDoc;
-
59  typedef struct _FLSharedKeys* FLSharedKeys;
-
60 #endif
-
61 
-
62 
-
64  typedef enum {
- -
66  kFLMemoryError, // Out of memory, or allocation failed
-
67  kFLOutOfRange, // Array index or iterator out of range
-
68  kFLInvalidData, // Bad input data (NaN, non-string key, etc.)
-
69  kFLEncodeError, // Structural error encoding (missing value, too many ends, etc.)
-
70  kFLJSONError, // Error parsing JSON
-
71  kFLUnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?)
-
72  kFLInternalError, // Something that shouldn't happen
-
73  kFLNotFound, // Key not found
-
74  kFLSharedKeysStateError, // Misuse of shared keys (not in transaction, etc.)
- -
76  kFLUnsupported, // Operation is unsupported
-
77  } FLError;
-
78 
-
79 
-
81  typedef enum {
- - - -
93 
-
94 
-
95  //====== TIMESTAMPS
-
96 
-
97 
-
108  typedef int64_t FLTimestamp;
-
109 
-
111  #define FLTimestampNone INT64_MIN
-
112 
- -
115 
- -
123 
- -
128 
-
133 #ifdef __cplusplus
-
134 }
-
135 #endif
-
136 
- -
138 
-
139 #endif // _FLBASE_H
+Go to the documentation of this file.
1//
+
2// FLBase.h
+
3//
+
4// Copyright 2016-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#ifndef _FLBASE_H
+
15#define _FLBASE_H
+
16
+
17#include "CompilerSupport.h"
+
18#include "FLSlice.h"
+
19
+
20// On Windows, FLEECE_PUBLIC marks symbols as being exported from the shared library.
+
21// However, this is not the whole list of things that are exported. The API methods
+
22// are exported using a definition list, but it is not possible to correctly include
+
23// initialized global variables, so those need to be marked (both in the header and
+
24// implementation) with FLEECE_PUBLIC. See kFLNullValue below and in Fleece.cc
+
25// for an example.
+
26#if defined(_MSC_VER)
+
27#ifdef FLEECE_EXPORTS
+
28#define FLEECE_PUBLIC __declspec(dllexport)
+
29#else
+
30#define FLEECE_PUBLIC __declspec(dllimport)
+
31#endif
+
32#else
+
33#define FLEECE_PUBLIC
+
34#endif
+
35
+ +
37
+
38#ifdef __cplusplus
+
39extern "C" {
+
40#endif
+
41
+
42 // This is the C API! For the C++ API, see Fleece.hh.
+
43
+
44
+
45 //====== BASIC TYPES
+
46
+
50#ifndef FL_IMPL
+
51 typedef const struct _FLValue* FLValue;
+
52 typedef const struct _FLArray* FLArray;
+
53 typedef const struct _FLDict* FLDict;
+
54 typedef struct _FLSlot* FLSlot;
+
55 typedef struct _FLArray* FLMutableArray;
+
56 typedef struct _FLDict* FLMutableDict;
+
57 typedef struct _FLEncoder* FLEncoder;
+
58 typedef struct _FLDoc* FLDoc;
+
59 typedef struct _FLSharedKeys* FLSharedKeys;
+
60#endif
+
61
+
62
+
64 typedef enum {
+ +
66 kFLMemoryError, // Out of memory, or allocation failed
+
67 kFLOutOfRange, // Array index or iterator out of range
+
68 kFLInvalidData, // Bad input data (NaN, non-string key, etc.)
+
69 kFLEncodeError, // Structural error encoding (missing value, too many ends, etc.)
+
70 kFLJSONError, // Error parsing JSON
+
71 kFLUnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?)
+
72 kFLInternalError, // Something that shouldn't happen
+
73 kFLNotFound, // Key not found
+
74 kFLSharedKeysStateError, // Misuse of shared keys (not in transaction, etc.)
+ +
76 kFLUnsupported, // Operation is unsupported
+
77 } FLError;
+
78
+
79
+
81 typedef enum {
+ + + +
93
+
94
+
95 //====== TIMESTAMPS
+
96
+
97
+
108 typedef int64_t FLTimestamp;
+
109
+
111 #define FLTimestampNone INT64_MIN
+
112
+ +
115
+ +
123
+ +
128
+
133#ifdef __cplusplus
+
134}
+
135#endif
+
136
+ +
138
+
139#endif // _FLBASE_H
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
@@ -210,7 +210,7 @@
diff --git a/docs/C/html/_f_l_collections_8h.html b/docs/C/html/_f_l_collections_8h.html index a5043a50d4..b0b86db024 100644 --- a/docs/C/html/_f_l_collections_8h.html +++ b/docs/C/html/_f_l_collections_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLCollections.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Functions | Variables
-
-
FLCollections.h File Reference
+
FLCollections.h File Reference

#include "FLBase.h"

Go to the source code of this file.

- @@ -91,12 +91,12 @@

+

Data Structures

struct  FLArrayIterator
 Opaque array iterator. More...
 Opaque key for a dictionary. More...
 
-

+

Macros

#define _FLCOLLECTIONS_H
 
- @@ -123,13 +123,13 @@ - -

+

Functions

uint32_t FLArray_Count (FLArray FL_NULLABLE) FLPURE
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 Looks up a key in a dictionary, returning its value. More...
 
Array iteration

Iterating an array typically looks like this:

-
-
FLArrayIterator_Begin(theArray, &iter);
-
FLValue value;
-
while (NULL != (value = FLArrayIterator_GetValue(&iter))) {
+

Iterating an array typically looks like this:

+
+
FLArrayIterator_Begin(theArray, &iter);
+
FLValue value;
+
while (NULL != (value = FLArrayIterator_GetValue(&iter))) {
// ...
- +
}
void FLArrayIterator_Begin(FLArray FL_NULLABLE, FLArrayIterator *)
Initializes a FLArrayIterator struct to iterate over an array.
bool FLArrayIterator_Next(FLArrayIterator *)
Advances the iterator to the next value, or returns false if at the end.
@@ -153,14 +153,14 @@
 Advances the iterator to the next value, or returns false if at the end. More...
 
Dict iteration

Iterating a dictionary typically looks like this:

-
-
FLDictIterator_Begin(theDict, &iter);
-
FLValue value;
-
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
- +

Iterating a dictionary typically looks like this:

+
+
FLDictIterator_Begin(theDict, &iter);
+
FLValue value;
+
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
+
// ...
- +
}
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
FLValue FL_NULLABLE FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
@@ -201,7 +201,7 @@
 Looks up a key in a dictionary using an FLDictKey. More...
 
- @@ -211,7 +211,7 @@

+

Variables

FLEECE_PUBLIC const FLArray kFLEmptyArray
 A constant empty array value. More...
 

Macro Definition Documentation

- +

◆ _FLCOLLECTIONS_H

@@ -228,7 +228,7 @@

diff --git a/docs/C/html/_f_l_collections_8h_source.html b/docs/C/html/_f_l_collections_8h_source.html index 330a25c454..bfb0b06dd0 100644 --- a/docs/C/html/_f_l_collections_8h_source.html +++ b/docs/C/html/_f_l_collections_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLCollections.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLCollections.h
+
FLCollections.h
-Go to the documentation of this file.
1 //
-
2 // FLCollections.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLCOLLECTIONS_H
-
15 #define _FLCOLLECTIONS_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27  //====== ARRAY
-
28 
-
29 
-
41  FLEECE_PUBLIC extern const FLArray kFLEmptyArray;
-
42 
- -
45 
- -
49 
- -
52 
- -
55 
-
73  typedef struct {
-
74 #if !DOXYGEN_PARSING
-
75  void* _private1;
-
76  uint32_t _private2;
-
77  bool _private3;
-
78  void* _private4;
-
79 #endif
- -
81 
- -
85 
- -
88 
- -
91 
- -
94 
- -
97 
-
102  //====== DICT
-
103 
-
104 
-
109  FLEECE_PUBLIC extern const FLDict kFLEmptyDict;
-
110 
- -
113 
- -
117 
- -
120 
- -
124 
-
125 
-
144  typedef struct {
-
145 #if !DOXYGEN_PARSING
-
146  void* _private1;
-
147  uint32_t _private2;
-
148  bool _private3;
-
149  void *_private4, *_private5, *_private6, *_private7;
-
150  int _private8;
-
151 #endif
-
152  } FLDictIterator;
-
153 
- -
158 
- -
161 
- -
164 
- -
167 
- -
170 
- -
173 
- -
177 
-
178 
-
187  typedef struct {
-
188 #if !DOXYGEN_PARSING
-
189  FLSlice _private1;
-
190  void* _private2;
-
191  uint32_t _private3, private4;
-
192  bool private5;
-
193 #endif
-
194  } FLDictKey;
-
195 
- -
202 
- -
205 
- -
209 
-
210 
-
214 #ifdef __cplusplus
-
215 }
-
216 #endif
-
217 
- -
219 
-
220 #endif // _FLCOLLECTIONS_H
+Go to the documentation of this file.
1//
+
2// FLCollections.h
+
3//
+
4// Copyright 2016-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#ifndef _FLCOLLECTIONS_H
+
15#define _FLCOLLECTIONS_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27 //====== ARRAY
+
28
+
29
+ +
42
+ +
45
+ +
49
+ +
52
+ +
55
+
73 typedef struct {
+
74#if !DOXYGEN_PARSING
+
75 void* _private1;
+
76 uint32_t _private2;
+
77 bool _private3;
+
78 void* _private4;
+
79#endif
+ +
81
+ +
85
+ +
88
+ +
91
+ +
94
+ +
97
+
102 //====== DICT
+
103
+
104
+
109 FLEECE_PUBLIC extern const FLDict kFLEmptyDict;
+
110
+ +
113
+ +
117
+ +
120
+ +
124
+
125
+
144 typedef struct {
+
145#if !DOXYGEN_PARSING
+
146 void* _private1;
+
147 uint32_t _private2;
+
148 bool _private3;
+
149 void *_private4, *_private5, *_private6, *_private7;
+
150 int _private8;
+
151#endif
+ +
153
+ +
158
+ +
161
+ +
164
+ +
167
+ +
170
+ +
173
+ +
177
+
178
+
187 typedef struct {
+
188#if !DOXYGEN_PARSING
+
189 FLSlice _private1;
+
190 void* _private2;
+
191 uint32_t _private3, private4;
+
192 bool private5;
+
193#endif
+
194 } FLDictKey;
+
195
+ +
202
+ +
205
+ +
209
+
210
+
214#ifdef __cplusplus
+
215}
+
216#endif
+
217
+ +
219
+
220#endif // _FLCOLLECTIONS_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FLPURE
Definition: CompilerSupport.h:110
@@ -234,7 +234,7 @@
diff --git a/docs/C/html/_f_l_deep_iterator_8h.html b/docs/C/html/_f_l_deep_iterator_8h.html index 5c2ff527cc..680ca42ff1 100644 --- a/docs/C/html/_f_l_deep_iterator_8h.html +++ b/docs/C/html/_f_l_deep_iterator_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDeepIterator.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Typedefs | Functions
-
-
FLDeepIterator.h File Reference
+
FLDeepIterator.h File Reference
#include "FLBase.h"

Go to the source code of this file.

-

+

Data Structures

struct  FLPathComponent
 
-

+

Macros

#define _FLDEEPITERATOR_H
 
-

+

Typedefs

typedef struct _FLDeepIterator * FLDeepIterator
 A reference to a deep iterator. More...
 
- @@ -134,7 +134,7 @@

+

Functions

FLDeepIterator FLDeepIterator_New (FLValue FL_NULLABLE)
 Creates a FLDeepIterator to iterate over a dictionary. More...
 

Macro Definition Documentation

- +

◆ _FLDEEPITERATOR_H

@@ -151,7 +151,7 @@

diff --git a/docs/C/html/_f_l_deep_iterator_8h_source.html b/docs/C/html/_f_l_deep_iterator_8h_source.html index 0ffb3c4e3a..22cae0db95 100644 --- a/docs/C/html/_f_l_deep_iterator_8h_source.html +++ b/docs/C/html/_f_l_deep_iterator_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDeepIterator.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLDeepIterator.h
+
FLDeepIterator.h
-Go to the documentation of this file.
1 //
-
2 // FLDeepIterator.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLDEEPITERATOR_H
-
15 #define _FLDEEPITERATOR_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
-
33 #ifndef FL_IMPL
-
34  typedef struct _FLDeepIterator* FLDeepIterator;
-
35 #endif
-
36 
- -
41 
- -
43 
- -
46 
- -
49 
- -
52 
- -
55 
- -
58 
- -
61 
- -
64 
-
65  typedef struct {
- -
67  uint32_t index;
- -
69 
- - -
73  size_t* outDepth) FLAPI;
-
74 
- -
77 
- -
80 
-
83 #ifdef __cplusplus
-
84 }
-
85 #endif
-
86 
- -
88 
-
89 #endif // _FLDEEPITERATOR_H
+Go to the documentation of this file.
1//
+
2// FLDeepIterator.h
+
3//
+
4// Copyright 2016-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#ifndef _FLDEEPITERATOR_H
+
15#define _FLDEEPITERATOR_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+
33#ifndef FL_IMPL
+
34 typedef struct _FLDeepIterator* FLDeepIterator;
+
35#endif
+
36
+ +
41
+ +
43
+ +
46
+ +
49
+ +
52
+ +
55
+ +
58
+ +
61
+ +
64
+
65 typedef struct {
+ +
67 uint32_t index;
+ +
69
+ + +
73 size_t* outDepth) FLAPI;
+
74
+ +
77
+ +
80
+
83#ifdef __cplusplus
+
84}
+
85#endif
+
86
+ +
88
+
89#endif // _FLDEEPITERATOR_H
#define FL_NONNULL
Definition: CompilerSupport.h:75
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
@@ -167,7 +167,7 @@
diff --git a/docs/C/html/_f_l_doc_8h.html b/docs/C/html/_f_l_doc_8h.html index 17f251ccd0..87f9cc5dbf 100644 --- a/docs/C/html/_f_l_doc_8h.html +++ b/docs/C/html/_f_l_doc_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDoc.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLDoc.h File Reference
+
FLDoc.h File Reference
#include "FLBase.h"

Go to the source code of this file.

-

+

Macros

#define _FLDOC_H
 
- - @@ -113,12 +113,12 @@ - - - + + +

+

Functions

FLDoc

An FLDoc points to (and often owns) Fleece-encoded data and provides access to its Fleece values.

+

An FLDoc points to (and often owns) Fleece-encoded data and provides access to its Fleece values.

FLDoc FLDoc_FromResultData (FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
 Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other API. More...
bool FLDoc_SetAssociated (FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
 Associates an arbitrary pointer value with a document, and thus its contained values. More...
 
void * FLDoc_GetAssociated (FLDoc FL_NULLABLE doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 
void * FLDoc_GetAssociated (FLDoc FL_NULLABLE doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 

Macro Definition Documentation

- +

◆ _FLDOC_H

@@ -135,7 +135,7 @@

diff --git a/docs/C/html/_f_l_doc_8h_source.html b/docs/C/html/_f_l_doc_8h_source.html index 2e711da6ec..4217938d65 100644 --- a/docs/C/html/_f_l_doc_8h_source.html +++ b/docs/C/html/_f_l_doc_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDoc.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLDoc.h
+
FLDoc.h
-Go to the documentation of this file.
1 //
-
2 // FLDoc.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLDOC_H
-
15 #define _FLDOC_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
- - -
42 
- -
45 
- -
49 
- -
52 
- -
55 
- -
58 
- -
61 
- -
65 
- -
81  void * FL_NULLABLE pointer,
-
82  const char *type) FLAPI;
-
83 
-
92  void* FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLAPI FLPURE;
-
93 
-
94 
-
98 #ifdef __cplusplus
-
99 }
-
100 #endif
-
101 
- -
103 
-
104 #endif // _FLDOC_H
+Go to the documentation of this file.
1//
+
2// FLDoc.h
+
3//
+
4// Copyright 2016-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#ifndef _FLDOC_H
+
15#define _FLDOC_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+ + +
42
+ +
45
+ +
49
+ +
52
+ +
55
+ +
58
+ +
61
+ +
65
+ +
81 void * FL_NULLABLE pointer,
+
82 const char *type) FLAPI;
+
83
+
92 void* FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLAPI FLPURE;
+
93
+
94
+
98#ifdef __cplusplus
+
99}
+
100#endif
+
101
+ +
103
+
104#endif // _FLDOC_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FLPURE
Definition: CompilerSupport.h:110
@@ -136,11 +136,11 @@
#define FLAPI
Definition: FLSlice.h:31
FLDoc FL_NULLABLE FLValue_FindDoc(FLValue FL_NULLABLE) FLPURE
Looks up the Doc containing the Value, or NULL if there is none.
FLSlice FLDoc_GetData(FLDoc FL_NULLABLE) FLPURE
Returns the encoded Fleece data backing the document.
+
void * FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLPURE
Returns the pointer associated with the document.
FLDoc FLDoc_FromResultData(FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other...
FLSharedKeys FLDoc_GetSharedKeys(FLDoc FL_NULLABLE) FLPURE
Returns the FLSharedKeys used by this FLDoc, as specified when it was created.
FLValue FLDoc_GetRoot(FLDoc FL_NULLABLE) FLPURE
Returns the root value in the FLDoc, usually an FLDict.
void FLDoc_Release(FLDoc FL_NULLABLE)
Releases a reference to an FLDoc.
-
void * FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLPURE
Returns the pointer associated with the document.
FLDoc FLDoc_Retain(FLDoc FL_NULLABLE)
Adds a reference to an FLDoc.
bool FLDoc_SetAssociated(FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
Associates an arbitrary pointer value with a document, and thus its contained values.
FLSliceResult FLDoc_GetAllocedData(FLDoc FL_NULLABLE) FLPURE
Returns the FLSliceResult data owned by the document, if any, else a null slice.
@@ -153,7 +153,7 @@
diff --git a/docs/C/html/_f_l_encoder_8h.html b/docs/C/html/_f_l_encoder_8h.html index 8895f2dece..a5880e949e 100644 --- a/docs/C/html/_f_l_encoder_8h.html +++ b/docs/C/html/_f_l_encoder_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLEncoder.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLEncoder.h File Reference
+
FLEncoder.h File Reference
#include "FLBase.h"
@@ -77,12 +77,12 @@

Go to the source code of this file.

-

+

Macros

#define _FLENCODER_H
 
- - - - + + +

+

Functions

Writing to the encoder
Note
The functions that write to the encoder do not return error codes, just a 'false' result on error. The actual error is attached to the encoder and can be accessed by calling FLEncoder_GetError or FLEncoder_End.
@@ -153,9 +153,9 @@
FLError FLEncoder_GetError (FLEncoder)
 Returns the error code of an encoder, or NoError (0) if there's no error. More...
 
const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
- - - + + + @@ -193,7 +193,7 @@

Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece @@ -182,9 +182,9 @@
void FLEncoder_SetExtraInfo (FLEncoder, void *FL_NULLABLE info)
 Associates an arbitrary user-defined value with the encoder. More...
 
void * FLEncoder_GetExtraInfo (FLEncoder)
 Returns the user-defined value associated with the encoder; NULL by default. More...
 
void * FLEncoder_GetExtraInfo (FLEncoder)
 Returns the user-defined value associated with the encoder; NULL by default. More...
 
void FLEncoder_Reset (FLEncoder)
 Resets the state of an encoder without freeing it. More...
 
 

Macro Definition Documentation

- +

◆ _FLENCODER_H

@@ -210,7 +210,7 @@

diff --git a/docs/C/html/_f_l_encoder_8h_source.html b/docs/C/html/_f_l_encoder_8h_source.html index 85c73b26b1..f475130d56 100644 --- a/docs/C/html/_f_l_encoder_8h_source.html +++ b/docs/C/html/_f_l_encoder_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLEncoder.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLEncoder.h
+
FLEncoder.h
-Go to the documentation of this file.
1 //
-
2 // FLEncoder.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLENCODER_H
-
15 #define _FLENCODER_H
-
16 
-
17 #include "FLBase.h"
-
18 #include <stdio.h>
-
19 
- -
21 
-
22 #ifdef __cplusplus
-
23 extern "C" {
-
24 #endif
-
25 
-
26  // This is the C API! For the C++ API, see Fleece.hh.
-
27 
-
28 
-
43  typedef enum {
- - - - -
48 
-
49 
- -
52 
- -
61  size_t reserveSize,
-
62  bool uniqueStrings) FLAPI;
-
63 
-
65  FLEncoder FLEncoder_NewWritingToFile(FILE*, bool uniqueStrings) FLAPI;
-
66 
- -
69 
- -
72 
- -
75 
- -
78 
-
79 
- -
83 
- -
86 
- -
101 
- -
107 
- -
110 
- -
115 
- -
120 
- -
127 
- -
133 
- -
138 
-
146  bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC) FLAPI;
-
147 
- -
152 
- -
155 
-
156 
-
162  bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount) FLAPI;
-
163 
- -
166 
-
167 
-
176  bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount) FLAPI;
-
177 
- -
180 
- -
184 
- -
187 
-
188 
- -
194 
- - -
206 
- - -
211 
- -
220 
- -
223 
-
227 #ifdef __cplusplus
-
228 }
-
229 #endif
-
230 
- -
232 
-
233 #endif // _FLENCODER_H
+Go to the documentation of this file.
1//
+
2// FLEncoder.h
+
3//
+
4// Copyright 2016-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#ifndef _FLENCODER_H
+
15#define _FLENCODER_H
+
16
+
17#include "FLBase.h"
+
18#include <stdio.h>
+
19
+ +
21
+
22#ifdef __cplusplus
+
23extern "C" {
+
24#endif
+
25
+
26 // This is the C API! For the C++ API, see Fleece.hh.
+
27
+
28
+
43 typedef enum {
+ + + + +
48
+
49
+ +
52
+ +
61 size_t reserveSize,
+
62 bool uniqueStrings) FLAPI;
+
63
+
65 FLEncoder FLEncoder_NewWritingToFile(FILE*, bool uniqueStrings) FLAPI;
+
66
+ +
69
+ +
72
+ +
75
+ +
78
+
79
+ +
83
+ +
86
+ +
101
+ +
107
+ +
110
+ +
115
+ +
120
+ +
127
+ +
133
+ +
138
+ +
147
+ +
152
+ +
155
+
156
+
162 bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount) FLAPI;
+
163
+ +
166
+
167
+
176 bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount) FLAPI;
+
177
+ +
180
+ +
184
+ +
187
+
188
+ +
194
+ + +
206
+ + +
211
+ +
220
+ +
223
+
227#ifdef __cplusplus
+
228}
+
229#endif
+
230
+ +
232
+
233#endif // _FLENCODER_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
@@ -189,17 +189,16 @@
#define FLAPI
Definition: FLSlice.h:31
bool FLEncoder_WriteUInt(FLEncoder, uint64_t)
Writes an unsigned integer to an encoder.
-
const char *FL_NULLABLE FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
FLEncoder FLEncoder_NewWritingToFile(FILE *, bool uniqueStrings)
Creates a new Fleece encoder that writes to a file, not to memory.
MUST_USE_RESULT FLSliceResult FLEncoder_Finish(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded data, else null.
bool FLEncoder_WriteKey(FLEncoder, FLString)
Specifies the key for the next value to be written to the current dictionary.
FLEncoder FLEncoder_New(void)
Creates a new encoder, for generating Fleece data.
-
void * FLEncoder_GetExtraInfo(FLEncoder)
Returns the user-defined value associated with the encoder; NULL by default.
bool FLEncoder_WriteInt(FLEncoder, int64_t)
Writes an integer to an encoder.
bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount)
Begins writing an array value to an encoder.
bool FLEncoder_WriteUndefined(FLEncoder)
Writes an undefined value to an encoder.
bool FLEncoder_WriteFloat(FLEncoder, float)
Writes a 32-bit floating point number to an encoder.
bool FLEncoder_WriteBool(FLEncoder, bool)
Writes a boolean value (true or false) to an encoder.
+
void * FLEncoder_GetExtraInfo(FLEncoder)
Returns the user-defined value associated with the encoder; NULL by default.
bool FLEncoder_WriteDouble(FLEncoder, double)
Writes a 64-bit floating point number to an encoder.
bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC)
Writes a timestamp to an encoder, as an ISO-8601 date string.
bool FLEncoder_WriteNull(FLEncoder)
Writes a null value to an encoder.
@@ -217,6 +216,7 @@
FLEncoder FLEncoder_NewWithOptions(FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
Creates a new encoder, allowing some options to be customized.
FLError FLEncoder_GetError(FLEncoder)
Returns the error code of an encoder, or NoError (0) if there's no error.
void FLEncoder_SetExtraInfo(FLEncoder, void *FL_NULLABLE info)
Associates an arbitrary user-defined value with the encoder.
+
const char *FL_NULLABLE FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
bool FLEncoder_EndArray(FLEncoder)
Ends writing an array value; pops back the previous encoding state.
bool FLEncoder_WriteRaw(FLEncoder, FLSlice)
Writes raw data directly to the encoded output.
MUST_USE_RESULT FLDoc FL_NULLABLE FLEncoder_FinishDoc(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc.
@@ -234,7 +234,7 @@
diff --git a/docs/C/html/_f_l_expert_8h.html b/docs/C/html/_f_l_expert_8h.html index 7c6b9278d8..00f86cab9e 100644 --- a/docs/C/html/_f_l_expert_8h.html +++ b/docs/C/html/_f_l_expert_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLExpert.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLExpert.h File Reference
+
FLExpert.h File Reference
#include "FLValue.h"

Go to the source code of this file.

-

+

Macros

#define _FLOBSCURE_H
 
- - @@ -137,20 +137,20 @@ - - - - - - + + + + + +

+

Functions

Delta Compression

These functions implement a fairly-efficient "delta" encoding that encapsulates the changes needed to transform one Fleece value into another.

-

The delta is expressed in JSON form.

-

A delta can be stored or transmitted as an efficient way to produce the second value, when the first is already present. Deltas are frequently used in version-control systems and efficient network protocols.

+

These functions implement a fairly-efficient "delta" encoding that encapsulates the changes needed to transform one Fleece value into another.

+

The delta is expressed in JSON form.

+

A delta can be stored or transmitted as an efficient way to produce the second value, when the first is already present. Deltas are frequently used in version-control systems and efficient network protocols.

FLSliceResult FLCreateJSONDelta (FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
 Returns JSON that encodes the changes to turn the value old into nuu. More...
 Finishes encoding the current item, and returns its offset in the output data. More...
 
Debugging Functions
const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that parses Fleece data and returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that parses Fleece data and returns a C string of JSON. More...
 
FLStringResult FLData_Dump (FLSlice data)
 Produces a human-readable dump of Fleece-encoded data. More...
 
- @@ -199,7 +199,7 @@

Shared Keys

FLSharedKeys represents a mapping from short strings to small integers in the range [0...2047].

-

It's used by FLDict to abbreviate dictionary keys. A shared key can be stored in a fixed two bytes and is faster to compare against. However, the same mapping has to be used when encoding and when accessing the Dict.

-

To use shared keys: Call FLSharedKeys_New to create a new empty mapping. After creating an FLEncoder, call FLEncoder_SetSharedKeys so dictionary keys will be added to the mapping and written in integer form. When loading Fleece data, use FLDoc_FromResultData and pass the FLSharedKeys as a parameter. Save the mapping somewhere by calling FLSharedKeys_GetStateData or FLSharedKeys_WriteState. You can later reconstitute the mapping by calling FLSharedKeys_LoadStateData or FLSharedKeys_LoadState on a new empty instance.

+

FLSharedKeys represents a mapping from short strings to small integers in the range [0...2047].

+

It's used by FLDict to abbreviate dictionary keys. A shared key can be stored in a fixed two bytes and is faster to compare against. However, the same mapping has to be used when encoding and when accessing the Dict.

+

To use shared keys: Call FLSharedKeys_New to create a new empty mapping. After creating an FLEncoder, call FLEncoder_SetSharedKeys so dictionary keys will be added to the mapping and written in integer form. When loading Fleece data, use FLDoc_FromResultData and pass the FLSharedKeys as a parameter. Save the mapping somewhere by calling FLSharedKeys_GetStateData or FLSharedKeys_WriteState. You can later reconstitute the mapping by calling FLSharedKeys_LoadStateData or FLSharedKeys_LoadState on a new empty instance.

typedef bool(* FLSharedKeysReadCallback) (void *FL_NULLABLE context, FLSharedKeys)
 
 

Macro Definition Documentation

- +

◆ _FLOBSCURE_H

@@ -216,7 +216,7 @@

diff --git a/docs/C/html/_f_l_expert_8h_source.html b/docs/C/html/_f_l_expert_8h_source.html index d37e6affb2..42ab9c09b7 100644 --- a/docs/C/html/_f_l_expert_8h_source.html +++ b/docs/C/html/_f_l_expert_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLExpert.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLExpert.h
+
FLExpert.h
-Go to the documentation of this file.
1 //
-
2 // FLExpert.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLOBSCURE_H
-
15 #define _FLOBSCURE_H
-
16 
-
17 #include "FLValue.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
- - -
50 
- -
59  FLValue FL_NULLABLE nuu,
-
60  FLEncoder jsonEncoder) FLAPI;
-
61 
-
62 
- -
72  FLSlice jsonDelta,
-
73  FLError* FL_NULLABLE outError) FLAPI;
-
74 
- -
85  FLSlice jsonDelta,
-
86  FLEncoder encoder) FLAPI;
- -
111 
-
112  typedef bool (*FLSharedKeysReadCallback)(void* FL_NULLABLE context, FLSharedKeys);
-
113 
- -
115  void* FL_NULLABLE context) FLAPI;
-
116 
- -
119 
- -
122 
- -
126 
- -
130 
- -
137 
- -
140 
- -
144 
- -
147 
- -
150 
- -
153 
-
154 
-
155  typedef struct _FLSharedKeyScope* FLSharedKeyScope;
-
156 
- -
160 
- -
163 
- -
182 
- -
204  FLStringResult* FL_NULLABLE outErrorMessage,
-
205  size_t* FL_NULLABLE outErrorPos,
-
206  FLError* FL_NULLABLE outError) FLAPI;
-
207 
- -
211 
- -
233  bool reuseStrings, bool externPointers) FLAPI;
-
234 
- -
237 
- -
241 
- -
245 
- -
250 
-
254  void FLEncoder_WriteValueAgain(FLEncoder, intptr_t preWrittenValue) FLAPI;
-
255 
- -
261 
- -
264 
- -
274 
-
277  const char* FL_NULLABLE FLDumpData(FLSlice data) FLAPI;
-
278 
- -
282 
-
288 #ifdef __cplusplus
-
289 }
-
290 #endif
-
291 
- -
293 
-
294 #endif // _FLOBSCURE_H
+Go to the documentation of this file.
1//
+
2// FLExpert.h
+
3//
+
4// Copyright 2016-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#ifndef _FLOBSCURE_H
+
15#define _FLOBSCURE_H
+
16
+
17#include "FLValue.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+ + +
50
+ + +
60 FLEncoder jsonEncoder) FLAPI;
+
61
+
62
+ +
72 FLSlice jsonDelta,
+
73 FLError* FL_NULLABLE outError) FLAPI;
+
74
+ +
85 FLSlice jsonDelta,
+
86 FLEncoder encoder) FLAPI;
+ +
111
+
112 typedef bool (*FLSharedKeysReadCallback)(void* FL_NULLABLE context, FLSharedKeys);
+
113
+ +
115 void* FL_NULLABLE context) FLAPI;
+
116
+ +
119
+ +
122
+ +
126
+ +
130
+ +
137
+ +
140
+ +
144
+ +
147
+ +
150
+ +
153
+
154
+
155 typedef struct _FLSharedKeyScope* FLSharedKeyScope;
+
156
+ +
160
+ +
163
+ +
182
+ +
204 FLStringResult* FL_NULLABLE outErrorMessage,
+
205 size_t* FL_NULLABLE outErrorPos,
+
206 FLError* FL_NULLABLE outError) FLAPI;
+
207
+ +
211
+ +
233 bool reuseStrings, bool externPointers) FLAPI;
+
234
+ +
237
+ +
241
+ +
245
+ +
250
+
254 void FLEncoder_WriteValueAgain(FLEncoder, intptr_t preWrittenValue) FLAPI;
+
255
+ +
261
+ +
264
+ +
274
+ +
278
+ +
282
+
288#ifdef __cplusplus
+
289}
+
290#endif
+
291
+ +
293
+
294#endif // _FLOBSCURE_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FLPURE
Definition: CompilerSupport.h:110
@@ -199,11 +199,9 @@
int FLSharedKeys_Encode(FLSharedKeys, FLString, bool add)
Maps a key string to a number in the range [0...2047], or returns -1 if it isn't mapped.
FLSliceResult FLCreateJSONDelta(FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
Returns JSON that encodes the changes to turn the value old into nuu.
FLSliceResult FLSharedKeys_GetStateData(FLSharedKeys)
Returns a data blob containing the current state (all the keys and their integers....
-
const char *FL_NULLABLE FLDump(FLValue FL_NULLABLE)
Debugging function that returns a C string of JSON.
void FLEncoder_SuppressTrailer(FLEncoder)
Tells the encoder not to write the two-byte Fleece trailer at the end of the data.
FLSliceResult FLData_ConvertJSON(FLSlice json, FLError *FL_NULLABLE outError)
Directly converts JSON data to Fleece-encoded data.
void FLSharedKeys_WriteState(FLSharedKeys, FLEncoder)
Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed...
-
const char *FL_NULLABLE FLDumpData(FLSlice data)
Debugging function that parses Fleece data and returns a C string of JSON.
FLSlice FLEncoder_GetBase(FLEncoder)
Returns the base value passed to FLEncoder_Amend.
bool FLSharedKeys_LoadState(FLSharedKeys, FLValue)
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_Wr...
FLSharedKeys FLSharedKeys_NewWithRead(FLSharedKeysReadCallback, void *FL_NULLABLE context)
@@ -212,12 +210,14 @@
size_t FLEncoder_GetNextWritePos(FLEncoder)
Returns the byte offset in the encoded data where the next value will be written.
FLSliceResult FLEncoder_Snip(FLEncoder)
Returns the data written so far as a standalone Fleece document, whose root is the last value written...
void FLEncoder_Amend(FLEncoder e, FLSlice base, bool reuseStrings, bool externPointers)
Tells the encoder to logically append to the given Fleece document, rather than making a standalone d...
+
const char *FL_NULLABLE FLDump(FLValue FL_NULLABLE)
Debugging function that returns a C string of JSON.
intptr_t FLEncoder_LastValueWritten(FLEncoder)
Returns an opaque reference to the last complete value written to the encoder, if possible.
void FLSharedKeys_RevertToCount(FLSharedKeys, unsigned oldCount)
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount.
FLStringResult FLData_Dump(FLSlice data)
Produces a human-readable dump of Fleece-encoded data.
FLSharedKeys FLSharedKeys_New(void)
Creates a new empty FLSharedKeys object, which must eventually be released.
size_t FLEncoder_FinishItem(FLEncoder)
Finishes encoding the current item, and returns its offset in the output data.
FLStringResult FLJSON5_ToJSON(FLString json5, FLStringResult *FL_NULLABLE outErrorMessage, size_t *FL_NULLABLE outErrorPos, FLError *FL_NULLABLE outError)
Converts valid JSON5 https://json5.org to JSON.
+
const char *FL_NULLABLE FLDumpData(FLSlice data)
Debugging function that parses Fleece data and returns a C string of JSON.
unsigned FLSharedKeys_Count(FLSharedKeys)
Returns the number of keys in the mapping.
bool FLSharedKeys_LoadStateData(FLSharedKeys, FLSlice)
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData.
bool(* FLSharedKeysReadCallback)(void *FL_NULLABLE context, FLSharedKeys)
Definition: FLExpert.h:112
@@ -235,7 +235,7 @@
diff --git a/docs/C/html/_f_l_j_s_o_n_8h.html b/docs/C/html/_f_l_j_s_o_n_8h.html index dd08cef3c8..c34713e80f 100644 --- a/docs/C/html/_f_l_j_s_o_n_8h.html +++ b/docs/C/html/_f_l_j_s_o_n_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLJSON.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLJSON.h File Reference
+
FLJSON.h File Reference
#include "FLBase.h"

Go to the source code of this file.

-

+

Macros

#define _FLJSON_H
 
- - @@ -111,7 +111,7 @@

+

Functions

Converting to JSON

These are convenience functions that directly return a JSON representation of a value.

-

For more control over the encoding, use an Fleece Encoders with format kFLEncodeJSON.

+

These are convenience functions that directly return a JSON representation of a value.

+

For more control over the encoding, use an Fleece Encoders with format kFLEncodeJSON.

FLStringResult FLValue_ToJSON (FLValue FL_NULLABLE)
 Encodes a Fleece value as JSON (or a JSON fragment.) More...
 

Macro Definition Documentation

- +

◆ _FLJSON_H

- +

◆ FLEncoder_ConvertJSON()

- +

◆ FLMutableArray_NewFromJSON()

- +

◆ FLMutableDict_NewFromJSON()

- +

◆ FLValue_ToJSON()

- +

◆ FLValue_ToJSONX()

@@ -341,7 +341,7 @@

diff --git a/docs/C/html/_f_l_j_s_o_n_8h_source.html b/docs/C/html/_f_l_j_s_o_n_8h_source.html index ea78008dde..29359609d1 100644 --- a/docs/C/html/_f_l_j_s_o_n_8h_source.html +++ b/docs/C/html/_f_l_j_s_o_n_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLJSON.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLJSON.h
+
FLJSON.h
-Go to the documentation of this file.
1 //
-
2 // FLJSON.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLJSON_H
-
15 #define _FLJSON_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
- -
37 
- -
42 
- -
50  bool json5,
-
51  bool canonicalForm) FLAPI;
-
52 
- -
63 
- -
67 
- -
71 
- -
76 
-
80 #ifdef __cplusplus
-
81 }
-
82 #endif
-
83 
- -
85 
-
86 #endif // _FLJSON_H
+Go to the documentation of this file.
1//
+
2// FLJSON.h
+
3//
+
4// Copyright 2016-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#ifndef _FLJSON_H
+
15#define _FLJSON_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+ +
37
+ +
42
+ +
50 bool json5,
+
51 bool canonicalForm) FLAPI;
+
52
+ +
63
+ +
67
+ +
71
+ +
76
+
80#ifdef __cplusplus
+
81}
+
82#endif
+
83
+ +
85
+
86#endif // _FLJSON_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
@@ -142,7 +142,7 @@
diff --git a/docs/C/html/_f_l_key_path_8h.html b/docs/C/html/_f_l_key_path_8h.html index 2af5d4ae8f..712b52d03e 100644 --- a/docs/C/html/_f_l_key_path_8h.html +++ b/docs/C/html/_f_l_key_path_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLKeyPath.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Typedefs | Functions
-
-
FLKeyPath.h File Reference
+
FLKeyPath.h File Reference
#include "FLBase.h"

Go to the source code of this file.

-

+

Macros

#define _FLKEYPATH_H
 
-

+

Typedefs

typedef struct _FLKeyPath * FLKeyPath
 A reference to a key path. More...
 
- @@ -114,7 +114,7 @@

+

Functions

FLKeyPath FL_NULLABLE FLKeyPath_New (FLSlice specifier, FLError *FL_NULLABLE outError)
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 

Macro Definition Documentation

- +

◆ _FLKEYPATH_H

@@ -131,7 +131,7 @@

diff --git a/docs/C/html/_f_l_key_path_8h_source.html b/docs/C/html/_f_l_key_path_8h_source.html index 0f684fa85e..95095a11df 100644 --- a/docs/C/html/_f_l_key_path_8h_source.html +++ b/docs/C/html/_f_l_key_path_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLKeyPath.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLKeyPath.h
+
FLKeyPath.h
-Go to the documentation of this file.
1 //
-
2 // FLKeyPath.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLKEYPATH_H
-
15 #define _FLKEYPATH_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
-
44 #ifndef FL_IMPL
-
45  typedef struct _FLKeyPath* FLKeyPath;
-
46 #endif
-
47 
- -
50  FLError* FL_NULLABLE outError) FLAPI;
-
51 
- -
54 
- -
57  FLValue root) FLAPI;
-
58 
- -
63  FLError* FL_NULLABLE outError) FLAPI;
-
64 
- -
67 
- -
70 
- -
73  size_t i,
-
74  FLSlice *outDictKey,
-
75  int32_t *outArrayIndex) FLAPI;
-
76 
-
79 #ifdef __cplusplus
-
80 }
-
81 #endif
-
82 
- -
84 
-
85 #endif // _FLKEYPATH_H
+Go to the documentation of this file.
1//
+
2// FLKeyPath.h
+
3//
+
4// Copyright 2016-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#ifndef _FLKEYPATH_H
+
15#define _FLKEYPATH_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+
44#ifndef FL_IMPL
+
45 typedef struct _FLKeyPath* FLKeyPath;
+
46#endif
+
47
+ +
50 FLError* FL_NULLABLE outError) FLAPI;
+
51
+ +
54
+ +
57 FLValue root) FLAPI;
+
58
+ +
63 FLError* FL_NULLABLE outError) FLAPI;
+
64
+ +
67
+ +
70
+ +
73 size_t i,
+
74 FLSlice *outDictKey,
+
75 int32_t *outArrayIndex) FLAPI;
+
76
+
79#ifdef __cplusplus
+
80}
+
81#endif
+
82
+ +
84
+
85#endif // _FLKEYPATH_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
@@ -148,7 +148,7 @@
diff --git a/docs/C/html/_f_l_mutable_8h.html b/docs/C/html/_f_l_mutable_8h.html index ad7a0bb06b..64df8e5de1 100644 --- a/docs/C/html/_f_l_mutable_8h.html +++ b/docs/C/html/_f_l_mutable_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLMutable.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
FLMutable.h File Reference
+
FLMutable.h File Reference
#include "FLValue.h"

Go to the source code of this file.

-

+

Macros

#define _FLMUTABLE_H
 
-

+

Enumerations

enum  FLCopyFlags { kFLDefaultCopy = 0 , kFLDeepCopy = 1 @@ -93,7 +93,7 @@
 Option flags for making mutable copies of values. More...
 
- @@ -314,7 +314,7 @@

+

Functions

MUST_USE_RESULT FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
 Returns an FLSlot that refers to the given index of the given array. More...
 

Macro Definition Documentation

- +

◆ _FLMUTABLE_H

@@ -331,7 +331,7 @@

diff --git a/docs/C/html/_f_l_mutable_8h_source.html b/docs/C/html/_f_l_mutable_8h_source.html index e825295999..05eecebfd9 100644 --- a/docs/C/html/_f_l_mutable_8h_source.html +++ b/docs/C/html/_f_l_mutable_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLMutable.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLMutable.h
+
FLMutable.h
-Go to the documentation of this file.
1 //
-
2 // FLMutable.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLMUTABLE_H
-
15 #define _FLMUTABLE_H
-
16 
-
17 #include "FLValue.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
-
33  typedef enum {
- - - - -
38  } FLCopyFlags;
-
39 
-
40 
-
41  //====== MUTABLE ARRAY
-
42 
-
43 
- - -
60 
- -
64 
- - -
68  }
- - -
72  }
-
73 
- -
76 
- -
79 
- -
82  bool changed) FLAPI;
-
83 
- -
89  uint32_t firstIndex,
-
90  uint32_t count) FLAPI;
-
91 
- -
97  uint32_t firstIndex,
-
98  uint32_t count) FLAPI;
-
99 
- -
104  uint32_t size) FLAPI;
-
105 
- -
112  uint32_t index) FLAPI;
-
113 
- -
120  uint32_t index) FLAPI;
-
121 
-
122 
-
124  static inline void FLMutableArray_SetNull(FLMutableArray, uint32_t index);
-
126  static inline void FLMutableArray_SetBool(FLMutableArray, uint32_t index, bool);
-
128  static inline void FLMutableArray_SetInt(FLMutableArray, uint32_t index, int64_t);
-
132  static inline void FLMutableArray_SetUInt(FLMutableArray, uint32_t index, uint64_t);
-
134  static inline void FLMutableArray_SetFloat(FLMutableArray, uint32_t index, float);
-
136  static inline void FLMutableArray_SetDouble(FLMutableArray, uint32_t index, double);
-
138  static inline void FLMutableArray_SetString(FLMutableArray, uint32_t index, FLString);
-
140  static inline void FLMutableArray_SetData(FLMutableArray, uint32_t index, FLSlice);
-
142  static inline void FLMutableArray_SetValue(FLMutableArray, uint32_t index, FLValue);
-
144  static inline void FLMutableArray_SetArray(FLMutableArray, uint32_t index, FLArray);
-
146  static inline void FLMutableArray_SetDict(FLMutableArray, uint32_t index, FLDict);
-
147 
-
149  static inline void FLMutableArray_AppendNull(FLMutableArray);
-
151  static inline void FLMutableArray_AppendBool(FLMutableArray, bool);
-
153  static inline void FLMutableArray_AppendInt(FLMutableArray, int64_t);
-
157  static inline void FLMutableArray_AppendUInt(FLMutableArray, uint64_t);
-
159  static inline void FLMutableArray_AppendFloat(FLMutableArray, float);
-
161  static inline void FLMutableArray_AppendDouble(FLMutableArray, double);
- -
165  static inline void FLMutableArray_AppendData(FLMutableArray, FLSlice);
- - -
171  static inline void FLMutableArray_AppendDict(FLMutableArray, FLDict);
-
172 
-
176  //====== MUTABLE DICT
-
177 
-
178 
- -
193 
- -
197 
- - -
201  }
-
202 
- - -
206  }
-
207 
- -
210 
- -
213 
- -
216 
- -
219 
- -
222 
- -
229 
- -
236 
-
237 
-
239  static inline void FLMutableDict_SetNull(FLMutableDict, FLString key);
-
241  static inline void FLMutableDict_SetBool(FLMutableDict, FLString key, bool);
-
243  static inline void FLMutableDict_SetInt(FLMutableDict, FLString key, int64_t);
-
247  static inline void FLMutableDict_SetUInt(FLMutableDict, FLString key, uint64_t);
-
249  static inline void FLMutableDict_SetFloat(FLMutableDict, FLString key, float);
-
251  static inline void FLMutableDict_SetDouble(FLMutableDict, FLString key, double);
-
253  static inline void FLMutableDict_SetString(FLMutableDict, FLString key, FLString);
-
255  static inline void FLMutableDict_SetData(FLMutableDict, FLString key, FLSlice);
-
257  static inline void FLMutableDict_SetValue(FLMutableDict, FLString key, FLValue);
-
259  static inline void FLMutableDict_SetArray(FLMutableDict, FLString key, FLArray);
-
261  static inline void FLMutableDict_SetDict(FLMutableDict, FLString key, FLDict);
-
262 
-
266  //====== NEWSTRING, NEWDATA
-
267 
-
268 
- -
276 
- -
281 
-
285  //====== VALUE SLOTS
-
286 
-
287 
- - -
308 
- - -
315 
- - -
322 
-
323 
- - -
326  void FLSlot_SetInt(FLSlot, int64_t) FLAPI;
-
327  void FLSlot_SetUInt(FLSlot, uint64_t) FLAPI;
-
328  void FLSlot_SetFloat(FLSlot, float) FLAPI;
-
329  void FLSlot_SetDouble(FLSlot, double) FLAPI;
- - - -
333 
-
334  static inline void FLSlot_SetArray(FLSlot slot, FLArray array) {
-
335  FLSlot_SetValue(slot, (FLValue)array);
-
336  }
-
337 
-
338  static inline void FLSlot_SetDict(FLSlot slot, FLDict dict) {
-
339  FLSlot_SetValue(slot, (FLValue)dict);
-
340  }
-
341 
-
342 
-
343  // implementations of the inline methods declared earlier:
-
344 
-
345  static inline void FLMutableArray_SetNull(FLMutableArray a, uint32_t index) {
- -
347  }
-
348  static inline void FLMutableArray_SetBool(FLMutableArray a, uint32_t index, bool val) {
-
349  FLSlot_SetBool(FLMutableArray_Set(a, index), val);
-
350  }
-
351  static inline void FLMutableArray_SetInt(FLMutableArray a, uint32_t index, int64_t val) {
-
352  FLSlot_SetInt(FLMutableArray_Set(a, index), val);
-
353  }
-
354  static inline void FLMutableArray_SetUInt(FLMutableArray a, uint32_t index, uint64_t val) {
-
355  FLSlot_SetUInt(FLMutableArray_Set(a, index), val);
-
356  }
-
357  static inline void FLMutableArray_SetFloat(FLMutableArray a, uint32_t index, float val) {
-
358  FLSlot_SetFloat(FLMutableArray_Set(a, index), val);
-
359  }
-
360  static inline void FLMutableArray_SetDouble(FLMutableArray a, uint32_t index, double val) {
-
361  FLSlot_SetDouble(FLMutableArray_Set(a, index), val);
-
362  }
-
363  static inline void FLMutableArray_SetString(FLMutableArray a, uint32_t index, FLString val) {
-
364  FLSlot_SetString(FLMutableArray_Set(a, index), val);
-
365  }
-
366  static inline void FLMutableArray_SetData(FLMutableArray a, uint32_t index, FLSlice val) {
-
367  FLSlot_SetData(FLMutableArray_Set(a, index), val);
-
368  }
-
369  static inline void FLMutableArray_SetValue(FLMutableArray a, uint32_t index, FLValue val) {
-
370  FLSlot_SetValue(FLMutableArray_Set(a, index), val);
-
371  }
-
372  static inline void FLMutableArray_SetArray(FLMutableArray a, uint32_t index, FLArray val) {
-
373  FLSlot_SetValue(FLMutableArray_Set(a, index), (FLValue)val);
-
374  }
-
375  static inline void FLMutableArray_SetDict(FLMutableArray a, uint32_t index, FLDict val) {
-
376  FLSlot_SetValue(FLMutableArray_Set(a, index), (FLValue)val);
-
377  }
-
378 
- - -
381  }
-
382  static inline void FLMutableArray_AppendBool(FLMutableArray a, bool val) {
- -
384  }
-
385  static inline void FLMutableArray_AppendInt(FLMutableArray a, int64_t val) {
- -
387  }
-
388  static inline void FLMutableArray_AppendUInt(FLMutableArray a, uint64_t val) {
- -
390  }
-
391  static inline void FLMutableArray_AppendFloat(FLMutableArray a, float val) {
- -
393  }
-
394  static inline void FLMutableArray_AppendDouble(FLMutableArray a, double val) {
- -
396  }
- - -
399  }
-
400  static inline void FLMutableArray_AppendData(FLMutableArray a, FLSlice val) {
- -
402  }
-
403  static inline void FLMutableArray_AppendValue(FLMutableArray a, FLValue val) {
- -
405  }
-
406  static inline void FLMutableArray_AppendArray(FLMutableArray a, FLArray val) {
- -
408  }
-
409  static inline void FLMutableArray_AppendDict(FLMutableArray a, FLDict val) {
- -
411  }
-
412 
-
413  static inline void FLMutableDict_SetNull(FLMutableDict d, FLString key) {
- -
415  }
-
416  static inline void FLMutableDict_SetBool(FLMutableDict d, FLString key, bool val) {
-
417  FLSlot_SetBool(FLMutableDict_Set(d, key), val);
-
418  }
-
419  static inline void FLMutableDict_SetInt(FLMutableDict d, FLString key, int64_t val) {
-
420  FLSlot_SetInt(FLMutableDict_Set(d, key), val);
-
421  }
-
422  static inline void FLMutableDict_SetUInt(FLMutableDict d, FLString key, uint64_t val) {
-
423  FLSlot_SetUInt(FLMutableDict_Set(d, key), val);
-
424  }
-
425  static inline void FLMutableDict_SetFloat(FLMutableDict d, FLString key, float val) {
-
426  FLSlot_SetFloat(FLMutableDict_Set(d, key), val);
-
427  }
-
428  static inline void FLMutableDict_SetDouble(FLMutableDict d, FLString key, double val) {
-
429  FLSlot_SetDouble(FLMutableDict_Set(d, key), val);
-
430  }
-
431  static inline void FLMutableDict_SetString(FLMutableDict d, FLString key, FLString val) {
-
432  FLSlot_SetString(FLMutableDict_Set(d, key), val);
-
433  }
-
434  static inline void FLMutableDict_SetData(FLMutableDict d, FLString key, FLSlice val) {
-
435  FLSlot_SetData(FLMutableDict_Set(d, key), val);
-
436  }
-
437  static inline void FLMutableDict_SetValue(FLMutableDict d, FLString key, FLValue val) {
-
438  FLSlot_SetValue(FLMutableDict_Set(d, key), val);
-
439  }
-
440  static inline void FLMutableDict_SetArray(FLMutableDict d, FLString key, FLArray val) {
- -
442  }
-
443  static inline void FLMutableDict_SetDict(FLMutableDict d, FLString key, FLDict val) {
- -
445  }
-
446 
-
447 
-
450 #ifdef __cplusplus
-
451 }
-
452 #endif
-
453 
- -
455 
-
456 #endif // _FLMUTABLE_H
+Go to the documentation of this file.
1//
+
2// FLMutable.h
+
3//
+
4// Copyright 2016-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#ifndef _FLMUTABLE_H
+
15#define _FLMUTABLE_H
+
16
+
17#include "FLValue.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+
33 typedef enum {
+ + + + + +
39
+
40
+
41 //====== MUTABLE ARRAY
+
42
+
43
+ + +
60
+ +
64
+ + +
68 }
+ + +
72 }
+
73
+ +
76
+ +
79
+ +
82 bool changed) FLAPI;
+
83
+ +
89 uint32_t firstIndex,
+
90 uint32_t count) FLAPI;
+
91
+ +
97 uint32_t firstIndex,
+
98 uint32_t count) FLAPI;
+
99
+ +
104 uint32_t size) FLAPI;
+
105
+ +
112 uint32_t index) FLAPI;
+
113
+ +
120 uint32_t index) FLAPI;
+
121
+
122
+
124 static inline void FLMutableArray_SetNull(FLMutableArray, uint32_t index);
+
126 static inline void FLMutableArray_SetBool(FLMutableArray, uint32_t index, bool);
+
128 static inline void FLMutableArray_SetInt(FLMutableArray, uint32_t index, int64_t);
+
132 static inline void FLMutableArray_SetUInt(FLMutableArray, uint32_t index, uint64_t);
+
134 static inline void FLMutableArray_SetFloat(FLMutableArray, uint32_t index, float);
+
136 static inline void FLMutableArray_SetDouble(FLMutableArray, uint32_t index, double);
+
138 static inline void FLMutableArray_SetString(FLMutableArray, uint32_t index, FLString);
+
140 static inline void FLMutableArray_SetData(FLMutableArray, uint32_t index, FLSlice);
+
142 static inline void FLMutableArray_SetValue(FLMutableArray, uint32_t index, FLValue);
+
144 static inline void FLMutableArray_SetArray(FLMutableArray, uint32_t index, FLArray);
+
146 static inline void FLMutableArray_SetDict(FLMutableArray, uint32_t index, FLDict);
+
147
+
149 static inline void FLMutableArray_AppendNull(FLMutableArray);
+
151 static inline void FLMutableArray_AppendBool(FLMutableArray, bool);
+
153 static inline void FLMutableArray_AppendInt(FLMutableArray, int64_t);
+
157 static inline void FLMutableArray_AppendUInt(FLMutableArray, uint64_t);
+
159 static inline void FLMutableArray_AppendFloat(FLMutableArray, float);
+
161 static inline void FLMutableArray_AppendDouble(FLMutableArray, double);
+ + + + + +
172
+
176 //====== MUTABLE DICT
+
177
+
178
+ +
193
+ +
197
+ + +
201 }
+
202
+ + +
206 }
+
207
+ +
210
+ +
213
+ +
216
+ +
219
+ +
222
+ +
229
+ +
236
+
237
+
239 static inline void FLMutableDict_SetNull(FLMutableDict, FLString key);
+
241 static inline void FLMutableDict_SetBool(FLMutableDict, FLString key, bool);
+
243 static inline void FLMutableDict_SetInt(FLMutableDict, FLString key, int64_t);
+
247 static inline void FLMutableDict_SetUInt(FLMutableDict, FLString key, uint64_t);
+
249 static inline void FLMutableDict_SetFloat(FLMutableDict, FLString key, float);
+
251 static inline void FLMutableDict_SetDouble(FLMutableDict, FLString key, double);
+
253 static inline void FLMutableDict_SetString(FLMutableDict, FLString key, FLString);
+
255 static inline void FLMutableDict_SetData(FLMutableDict, FLString key, FLSlice);
+
257 static inline void FLMutableDict_SetValue(FLMutableDict, FLString key, FLValue);
+
259 static inline void FLMutableDict_SetArray(FLMutableDict, FLString key, FLArray);
+
261 static inline void FLMutableDict_SetDict(FLMutableDict, FLString key, FLDict);
+
262
+
266 //====== NEWSTRING, NEWDATA
+
267
+
268
+ +
276
+ +
281
+
285 //====== VALUE SLOTS
+
286
+
287
+ + +
308
+ + +
315
+ + +
322
+
323
+ + +
326 void FLSlot_SetInt(FLSlot, int64_t) FLAPI;
+
327 void FLSlot_SetUInt(FLSlot, uint64_t) FLAPI;
+ + + + + +
333
+
334 static inline void FLSlot_SetArray(FLSlot slot, FLArray array) {
+
335 FLSlot_SetValue(slot, (FLValue)array);
+
336 }
+
337
+
338 static inline void FLSlot_SetDict(FLSlot slot, FLDict dict) {
+
339 FLSlot_SetValue(slot, (FLValue)dict);
+
340 }
+
341
+
342
+
343 // implementations of the inline methods declared earlier:
+
344
+
345 static inline void FLMutableArray_SetNull(FLMutableArray a, uint32_t index) {
+ +
347 }
+
348 static inline void FLMutableArray_SetBool(FLMutableArray a, uint32_t index, bool val) {
+
349 FLSlot_SetBool(FLMutableArray_Set(a, index), val);
+
350 }
+
351 static inline void FLMutableArray_SetInt(FLMutableArray a, uint32_t index, int64_t val) {
+
352 FLSlot_SetInt(FLMutableArray_Set(a, index), val);
+
353 }
+
354 static inline void FLMutableArray_SetUInt(FLMutableArray a, uint32_t index, uint64_t val) {
+
355 FLSlot_SetUInt(FLMutableArray_Set(a, index), val);
+
356 }
+
357 static inline void FLMutableArray_SetFloat(FLMutableArray a, uint32_t index, float val) {
+
358 FLSlot_SetFloat(FLMutableArray_Set(a, index), val);
+
359 }
+
360 static inline void FLMutableArray_SetDouble(FLMutableArray a, uint32_t index, double val) {
+
361 FLSlot_SetDouble(FLMutableArray_Set(a, index), val);
+
362 }
+
363 static inline void FLMutableArray_SetString(FLMutableArray a, uint32_t index, FLString val) {
+
364 FLSlot_SetString(FLMutableArray_Set(a, index), val);
+
365 }
+
366 static inline void FLMutableArray_SetData(FLMutableArray a, uint32_t index, FLSlice val) {
+
367 FLSlot_SetData(FLMutableArray_Set(a, index), val);
+
368 }
+
369 static inline void FLMutableArray_SetValue(FLMutableArray a, uint32_t index, FLValue val) {
+
370 FLSlot_SetValue(FLMutableArray_Set(a, index), val);
+
371 }
+
372 static inline void FLMutableArray_SetArray(FLMutableArray a, uint32_t index, FLArray val) {
+ +
374 }
+
375 static inline void FLMutableArray_SetDict(FLMutableArray a, uint32_t index, FLDict val) {
+ +
377 }
+
378
+ + +
381 }
+
382 static inline void FLMutableArray_AppendBool(FLMutableArray a, bool val) {
+ +
384 }
+
385 static inline void FLMutableArray_AppendInt(FLMutableArray a, int64_t val) {
+ +
387 }
+
388 static inline void FLMutableArray_AppendUInt(FLMutableArray a, uint64_t val) {
+ +
390 }
+
391 static inline void FLMutableArray_AppendFloat(FLMutableArray a, float val) {
+ +
393 }
+
394 static inline void FLMutableArray_AppendDouble(FLMutableArray a, double val) {
+ +
396 }
+ + +
399 }
+ + +
402 }
+ + +
405 }
+ + +
408 }
+ + +
411 }
+
412
+
413 static inline void FLMutableDict_SetNull(FLMutableDict d, FLString key) {
+ +
415 }
+
416 static inline void FLMutableDict_SetBool(FLMutableDict d, FLString key, bool val) {
+
417 FLSlot_SetBool(FLMutableDict_Set(d, key), val);
+
418 }
+
419 static inline void FLMutableDict_SetInt(FLMutableDict d, FLString key, int64_t val) {
+
420 FLSlot_SetInt(FLMutableDict_Set(d, key), val);
+
421 }
+
422 static inline void FLMutableDict_SetUInt(FLMutableDict d, FLString key, uint64_t val) {
+
423 FLSlot_SetUInt(FLMutableDict_Set(d, key), val);
+
424 }
+
425 static inline void FLMutableDict_SetFloat(FLMutableDict d, FLString key, float val) {
+ +
427 }
+
428 static inline void FLMutableDict_SetDouble(FLMutableDict d, FLString key, double val) {
+ +
430 }
+
431 static inline void FLMutableDict_SetString(FLMutableDict d, FLString key, FLString val) {
+ +
433 }
+
434 static inline void FLMutableDict_SetData(FLMutableDict d, FLString key, FLSlice val) {
+
435 FLSlot_SetData(FLMutableDict_Set(d, key), val);
+
436 }
+
437 static inline void FLMutableDict_SetValue(FLMutableDict d, FLString key, FLValue val) {
+ +
439 }
+
440 static inline void FLMutableDict_SetArray(FLMutableDict d, FLString key, FLArray val) {
+ +
442 }
+
443 static inline void FLMutableDict_SetDict(FLMutableDict d, FLString key, FLDict val) {
+ +
445 }
+
446
+
447
+
450#ifdef __cplusplus
+
451}
+
452#endif
+
453
+ +
455
+
456#endif // _FLMUTABLE_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
@@ -457,7 +457,7 @@
diff --git a/docs/C/html/_f_l_slice_8h.html b/docs/C/html/_f_l_slice_8h.html index 7e4eeba2de..2c51541070 100644 --- a/docs/C/html/_f_l_slice_8h.html +++ b/docs/C/html/_f_l_slice_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLSlice.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Typedefs | Functions
-
-
FLSlice.h File Reference
+
FLSlice.h File Reference
-
#include "Base.h"
+
#include "CompilerSupport.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -83,7 +83,7 @@

Go to the source code of this file.

- @@ -92,7 +92,7 @@

+

Data Structures

struct  FLSlice
 A simple reference to a block of memory. More...
 A heap-allocated block of memory returned from an API call. More...
 
- @@ -105,7 +105,7 @@

+

Macros

#define _FLSLICE_H
 
 Macro version of FLStr, for use in initializing compile-time constants. More...
 
- @@ -115,24 +115,24 @@

+

Typedefs

typedef FLSlice FLHeapSlice
 A heap-allocated, reference-counted slice. More...
typedef FLSliceResult FLStringResult
 
- - + - + - + - + - + - + @@ -144,12 +144,12 @@ - + - + - + @@ -165,7 +165,7 @@

+

Functions

static FLPURE int FLMemCmp (const void *FL_NULLABLE a, const void *FL_NULLABLE b, size_t size)
static FLPURE int FLMemCmp (const void *FL_NULLABLE a, const void *FL_NULLABLE b, size_t size)
 Exactly like memcmp, but safely handles the case where a or b is NULL and size is 0 (by returning 0), instead of producing "undefined behavior" as per the C spec. More...
 
static void FLMemCpy (void *FL_NULLABLE dst, const void *FL_NULLABLE src, size_t size)
static void FLMemCpy (void *FL_NULLABLE dst, const void *FL_NULLABLE src, size_t size)
 Exactly like memcmp, but safely handles the case where dst or src is NULL and size is 0 (as a no-op), instead of producing "undefined behavior" as per the C spec. More...
 
static FLSlice FLStr (const char *FL_NULLABLE str)
static FLSlice FLStr (const char *FL_NULLABLE str)
 Returns a slice pointing to the contents of a C string. More...
 
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
 Equality test of two slices. More...
 
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
 Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences in length. More...
 
uint32_t FLSlice_Hash (FLSlice s) FLPURE
uint32_t FLSlice_Hash (FLSlice s) FLPURE
 Computes a 32-bit hash of a slice's data, suitable for use in hash tables. More...
 
bool FLSlice_ToCString (FLSlice s, char *buffer, size_t capacity)
FLSliceResult FLSlice_Copy (FLSlice)
 Allocates an FLSliceResult, copying the given slice. More...
 
static FLSliceResult FLSliceResult_CreateWith (const void *FL_NULLABLE bytes, size_t size)
static FLSliceResult FLSliceResult_CreateWith (const void *FL_NULLABLE bytes, size_t size)
 Allocates an FLSliceResult, copying size bytes starting at buf. More...
 
void _FLBuf_Retain (const void *FL_NULLABLE)
void _FLBuf_Retain (const void *FL_NULLABLE)
 
void _FLBuf_Release (const void *FL_NULLABLE)
void _FLBuf_Release (const void *FL_NULLABLE)
 
static FLSliceResult FLSliceResult_Retain (FLSliceResult s)
 Increments the ref-count of a FLSliceResult. More...
 

Macro Definition Documentation

- +

◆ _FLSLICE_H

@@ -179,7 +179,7 @@

+

◆ FLAPI

@@ -196,7 +196,7 @@

diff --git a/docs/C/html/_f_l_slice_8h_source.html b/docs/C/html/_f_l_slice_8h_source.html index 2093dfd544..196c64f43d 100644 --- a/docs/C/html/_f_l_slice_8h_source.html +++ b/docs/C/html/_f_l_slice_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLSlice.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLSlice.h
+
FLSlice.h
-Go to the documentation of this file.
1 //
-
2 // FLSlice.h
-
3 // Fleece
-
4 //
-
5 // Created by Jens Alfke on 8/13/18.
-
6 // Copyright 2018-Present Couchbase, Inc.
-
7 //
-
8 // Use of this software is governed by the Business Source License included
-
9 // in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
-
10 // in that file, in accordance with the Business Source License, use of this
-
11 // software will be governed by the Apache License, Version 2.0, included in
-
12 // the file licenses/APL2.txt.
-
13 //
-
14 
-
15 #pragma once
-
16 #ifndef _FLSLICE_H
-
17 #define _FLSLICE_H
-
18 
-
19 #include "Base.h"
-
20 #include <stdbool.h>
-
21 #include <stdint.h>
-
22 #include <stdlib.h>
-
23 #include <string.h>
-
24 
-
25 
-
26 #ifdef __cplusplus
-
27  #include <string>
-
28  #define FLAPI noexcept
-
29  namespace fleece { struct alloc_slice; }
-
30 #else
-
31  #define FLAPI
-
32 #endif
-
33 
-
34 
- -
36 
-
37 #ifdef __cplusplus
-
38 extern "C" {
-
39 #endif
-
40 
-
41 
-
48 typedef struct FLSlice {
-
49  const void* FL_NULLABLE buf;
-
50  size_t size;
-
51 
-
52 #ifdef __cplusplus
-
53  explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
-
54  explicit operator std::string() const {return std::string((char*)buf, size);}
-
55 #endif
-
56 } FLSlice;
-
57 
-
58 
-
66 typedef struct FLSliceResult {
-
67  const void* FL_NULLABLE buf;
-
68  size_t size;
-
69 
-
70 #ifdef __cplusplus
-
71  explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
-
72  explicit operator FLSlice () const {return {buf, size};}
-
73  inline explicit operator std::string() const;
-
74 #endif
- -
76 
-
77 
-
81 #ifdef __cplusplus
-
82  struct FLHeapSlice : public FLSlice {
-
83  constexpr FLHeapSlice() noexcept :FLSlice{nullptr, 0} { }
-
84  private:
-
85  constexpr FLHeapSlice(const void *FL_NULLABLE b, size_t s) noexcept :FLSlice{b, s} { }
-
86  friend struct fleece::alloc_slice;
-
87  };
-
88 #else
- -
90 #endif
-
91 
-
92 
-
93 // Aliases used to indicate that a slice is expected to contain UTF-8 data.
-
94 typedef FLSlice FLString;
- -
96 
-
97 
-
99 #ifdef _MSC_VER
-
100  static const FLSlice kFLSliceNull = { NULL, 0 };
-
101 #else
-
102  #define kFLSliceNull ((FLSlice){NULL, 0})
-
103 #endif
-
104 
-
105 
-
108 static inline FLPURE int FLMemCmp(const void * FL_NULLABLE a,
-
109  const void * FL_NULLABLE b, size_t size) FLAPI
-
110 {
-
111  if (_usuallyFalse(size == 0))
-
112  return 0;
-
113  return memcmp(a, b, size);
-
114 }
-
115 
-
118 static inline void FLMemCpy(void* FL_NULLABLE dst, const void* FL_NULLABLE src, size_t size) FLAPI {
-
119  if (_usuallyTrue(size > 0))
-
120  memcpy(dst, src, size);
-
121 }
-
122 
-
123 
-
128 static inline FLSlice FLStr(const char* FL_NULLABLE str) FLAPI {
-
129  FLSlice foo = { str, str ? strlen(str) : 0 };
-
130  return foo;
-
131 }
-
132 
-
135 #ifdef __cplusplus
-
136  #define FLSTR(STR) (FLSlice {("" STR), sizeof(("" STR))-1})
-
137 #else
-
138  #define FLSTR(STR) ((FLSlice){("" STR), sizeof(("" STR))-1})
-
139 #endif
-
140 
-
141 
- -
144 
- -
148 
- -
151 
-
159 bool FLSlice_ToCString(FLSlice s, char* buffer, size_t capacity) FLAPI;
-
160 
- -
163 
- -
166 
-
167 
-
169 static inline FLSliceResult FLSliceResult_CreateWith(const void* FL_NULLABLE bytes, size_t size) FLAPI {
-
170  FLSlice s = {bytes, size};
-
171  return FLSlice_Copy(s);
-
172 }
-
173 
-
174 
-
175 void _FLBuf_Retain(const void* FL_NULLABLE) FLAPI; // internal; do not call
-
176 void _FLBuf_Release(const void* FL_NULLABLE) FLAPI; // internal; do not call
-
177 
- -
180  _FLBuf_Retain(s.buf);
-
181  return s;
-
182 }
-
183 
- -
186  _FLBuf_Release(s.buf);
-
187 }
-
188 
- -
191  return *(FLSlice*)&sr;
-
192 }
-
193 
-
194 
-
198 void FL_WipeMemory(void *dst, size_t size) FLAPI;
-
199 
-
200 
-
203 #ifdef __cplusplus
-
204 }
-
205 
-
206  FLPURE static inline bool operator== (FLSlice s1, FLSlice s2) {return FLSlice_Equal(s1, s2);}
-
207  FLPURE static inline bool operator!= (FLSlice s1, FLSlice s2) {return !(s1 == s2);}
-
208 
-
209  FLPURE static inline bool operator== (FLSliceResult sr, FLSlice s) {return (FLSlice)sr == s;}
-
210  FLPURE static inline bool operator!= (FLSliceResult sr, FLSlice s) {return !(sr ==s);}
-
211 
-
212 
-
213  FLSliceResult::operator std::string () const {
-
214  auto str = std::string((char*)buf, size);
-
215  FLSliceResult_Release(*this);
-
216  return str;
-
217  }
-
218 #endif
-
219 
- -
221 #endif // _FLSLICE_H
- -
#define FL_NULLABLE
Definition: Base.h:74
-
#define FL_ASSUME_NONNULL_BEGIN
Definition: Base.h:72
-
#define _usuallyTrue(VAL)
Definition: Base.h:55
-
#define _usuallyFalse(VAL)
Definition: Base.h:56
-
#define FLPURE
Definition: Base.h:110
-
#define FL_ASSUME_NONNULL_END
Definition: Base.h:73
+Go to the documentation of this file.
1//
+
2// FLSlice.h
+
3// Fleece
+
4//
+
5// Created by Jens Alfke on 8/13/18.
+
6// Copyright 2018-Present Couchbase, Inc.
+
7//
+
8// Use of this software is governed by the Business Source License included
+
9// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
+
10// in that file, in accordance with the Business Source License, use of this
+
11// software will be governed by the Apache License, Version 2.0, included in
+
12// the file licenses/APL2.txt.
+
13//
+
14
+
15#pragma once
+
16#ifndef _FLSLICE_H
+
17#define _FLSLICE_H
+
18
+
19#include "CompilerSupport.h"
+
20#include <stdbool.h>
+
21#include <stdint.h>
+
22#include <stdlib.h>
+
23#include <string.h>
+
24
+
25
+
26#ifdef __cplusplus
+
27 #include <string>
+
28 #define FLAPI noexcept
+
29 namespace fleece { struct alloc_slice; }
+
30#else
+
31 #define FLAPI
+
32#endif
+
33
+
34
+ +
36
+
37#ifdef __cplusplus
+
38extern "C" {
+
39#endif
+
40
+
41
+
48typedef struct FLSlice {
+
49 const void* FL_NULLABLE buf;
+
50 size_t size;
+
51
+
52#ifdef __cplusplus
+
53 explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
+
54 explicit operator std::string() const {return std::string((char*)buf, size);}
+
55#endif
+
56} FLSlice;
+
57
+
58
+
66typedef struct FLSliceResult {
+
67 const void* FL_NULLABLE buf;
+
68 size_t size;
+
69
+
70#ifdef __cplusplus
+
71 explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
+
72 explicit operator FLSlice () const {return {buf, size};}
+
73 inline explicit operator std::string() const;
+
74#endif
+ +
76
+
77
+
81#ifdef __cplusplus
+
82 struct FLHeapSlice : public FLSlice {
+
83 constexpr FLHeapSlice() noexcept :FLSlice{nullptr, 0} { }
+
84 private:
+
85 constexpr FLHeapSlice(const void *FL_NULLABLE b, size_t s) noexcept :FLSlice{b, s} { }
+
86 friend struct fleece::alloc_slice;
+
87 };
+
88#else
+ +
90#endif
+
91
+
92
+
93// Aliases used to indicate that a slice is expected to contain UTF-8 data.
+ + +
96
+
97
+
99#ifdef _MSC_VER
+
100 static const FLSlice kFLSliceNull = { NULL, 0 };
+
101#else
+
102 #define kFLSliceNull ((FLSlice){NULL, 0})
+
103#endif
+
104
+
105
+
108static inline FLPURE int FLMemCmp(const void * FL_NULLABLE a,
+
109 const void * FL_NULLABLE b, size_t size) FLAPI
+
110{
+
111 if (_usuallyFalse(size == 0))
+
112 return 0;
+
113 return memcmp(a, b, size);
+
114}
+
115
+
118static inline void FLMemCpy(void* FL_NULLABLE dst, const void* FL_NULLABLE src, size_t size) FLAPI {
+
119 if (_usuallyTrue(size > 0))
+
120 memcpy(dst, src, size);
+
121}
+
122
+
123
+
128static inline FLSlice FLStr(const char* FL_NULLABLE str) FLAPI {
+
129 FLSlice foo = { str, str ? strlen(str) : 0 };
+
130 return foo;
+
131}
+
132
+
135#ifdef __cplusplus
+
136 #define FLSTR(STR) (FLSlice {("" STR), sizeof(("" STR))-1})
+
137#else
+
138 #define FLSTR(STR) ((FLSlice){("" STR), sizeof(("" STR))-1})
+
139#endif
+
140
+
141
+ +
144
+ +
148
+ +
151
+
159bool FLSlice_ToCString(FLSlice s, char* buffer, size_t capacity) FLAPI;
+
160
+ +
163
+ +
166
+
167
+
169static inline FLSliceResult FLSliceResult_CreateWith(const void* FL_NULLABLE bytes, size_t size) FLAPI {
+
170 FLSlice s = {bytes, size};
+
171 return FLSlice_Copy(s);
+
172}
+
173
+
174
+
175void _FLBuf_Retain(const void* FL_NULLABLE) FLAPI; // internal; do not call
+
176void _FLBuf_Release(const void* FL_NULLABLE) FLAPI; // internal; do not call
+
177
+ +
180 _FLBuf_Retain(s.buf);
+
181 return s;
+
182}
+
183
+ +
186 _FLBuf_Release(s.buf);
+
187}
+
188
+ +
191 FLSlice ret;
+
192 memcpy(&ret, &sr, sizeof(ret));
+
193 return ret;
+
194}
+
195
+
196
+
200void FL_WipeMemory(void *dst, size_t size) FLAPI;
+
201
+
202
+
205#ifdef __cplusplus
+
206}
+
207
+
208 FLPURE static inline bool operator== (FLSlice s1, FLSlice s2) {return FLSlice_Equal(s1, s2);}
+
209 FLPURE static inline bool operator!= (FLSlice s1, FLSlice s2) {return !(s1 == s2);}
+
210
+
211 FLPURE static inline bool operator== (FLSliceResult sr, FLSlice s) {return (FLSlice)sr == s;}
+
212 FLPURE static inline bool operator!= (FLSliceResult sr, FLSlice s) {return !(sr ==s);}
+
213
+
214
+
215 FLSliceResult::operator std::string () const {
+
216 auto str = std::string((char*)buf, size);
+ +
218 return str;
+
219 }
+
220#endif
+
221
+ +
223#endif // _FLSLICE_H
+ +
#define FL_NULLABLE
Definition: CompilerSupport.h:74
+
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
+
#define _usuallyTrue(VAL)
Definition: CompilerSupport.h:55
+
#define _usuallyFalse(VAL)
Definition: CompilerSupport.h:56
+
#define FLPURE
Definition: CompilerSupport.h:110
+
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
#define FLAPI
Definition: FLSlice.h:31
void _FLBuf_Retain(const void *FL_NULLABLE)
bool FLSlice_Equal(FLSlice a, FLSlice b) FLPURE
Equality test of two slices.
@@ -279,7 +281,7 @@
diff --git a/docs/C/html/_f_l_value_8h.html b/docs/C/html/_f_l_value_8h.html index 40bc788c0d..e0af756f62 100644 --- a/docs/C/html/_f_l_value_8h.html +++ b/docs/C/html/_f_l_value_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLValue.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
FLValue.h File Reference
+
FLValue.h File Reference

#include "FLBase.h"

Go to the source code of this file.

-

+

Macros

#define _FLVALUE_H
 
-

+

Enumerations

enum  FLValueType {
  kFLUndefined = -1 @@ -100,7 +100,7 @@
 Types of Fleece values. More...
 
- @@ -155,7 +155,7 @@ -

+

Functions

Accessors
FLValueType FLValue_GetType (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is mutable. More...
 
Reference-Counting

Retaining a value extends its lifespan (and that of any values contained in it) until at least such time that it's released.

+

Retaining a value extends its lifespan (and that of any values contained in it) until at least such time that it's released.

  • If the value comes from an FLDoc, the doc's ref-count will be incremented.
  • If the value is mutable (heap-based), it has its own ref-count that will be incremented.
    Warning
    Values obtained from FLValue_FromData don't match either of those critera. Their lifespan is entirely determined by the caller-provided data pointer, so the retain call can't do anything about it. In this situation Fleece will throw an exception like "Can't retain immutable Value that's not part of a Doc."
    @@ -177,7 +177,7 @@
static void FLDict_Release (FLDict FL_NULLABLE v)
 
- @@ -187,7 +187,7 @@

+

Variables

FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (like a JSON null, not a NULL pointer!) More...
 

Macro Definition Documentation

- +

◆ _FLVALUE_H

@@ -204,7 +204,7 @@

diff --git a/docs/C/html/_f_l_value_8h_source.html b/docs/C/html/_f_l_value_8h_source.html index e8e40fd337..c2a17352fa 100644 --- a/docs/C/html/_f_l_value_8h_source.html +++ b/docs/C/html/_f_l_value_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLValue.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLValue.h
+
FLValue.h
-Go to the documentation of this file.
1 //
-
2 // FLValue.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLVALUE_H
-
15 #define _FLVALUE_H
-
16 
-
17 #include "FLBase.h"
-
18 
- -
20 
-
21 #ifdef __cplusplus
-
22 extern "C" {
-
23 #endif
-
24 
-
25  // This is the C API! For the C++ API, see Fleece.hh.
-
26 
-
27 
-
49  typedef enum {
-
50  kFLUndefined = -1,
-
53  kFLNull = 0,
- - - - - -
59  kFLDict
- -
61 
-
62 
-
64  FLEECE_PUBLIC extern const FLValue kFLNullValue;
-
65 
- -
70 
-
71 
- -
78 
- -
81 
- -
87 
- -
90 
- -
94 
- -
100 
- -
105 
- -
112 
- -
119 
- -
122 
- -
127 
- -
130 
- -
133 
- -
136 
- -
140 
- -
143 
- -
146 
- -
164 
- -
169 
- - - - -
174 
-
179 #ifdef __cplusplus
-
180 }
-
181 #endif
-
182 
- -
184 
-
185 #endif // _FLVALUE_H
+Go to the documentation of this file.
1//
+
2// FLValue.h
+
3//
+
4// Copyright 2016-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#ifndef _FLVALUE_H
+
15#define _FLVALUE_H
+
16
+
17#include "FLBase.h"
+
18
+ +
20
+
21#ifdef __cplusplus
+
22extern "C" {
+
23#endif
+
24
+
25 // This is the C API! For the C++ API, see Fleece.hh.
+
26
+
27
+
49 typedef enum {
+
50 kFLUndefined = -1,
+
53 kFLNull = 0,
+ + + + + +
59 kFLDict
+ +
61
+
62
+ +
65
+ +
70
+
71
+ +
78
+ +
81
+ +
87
+ +
90
+ +
94
+ +
100
+ +
105
+ +
112
+ +
119
+ +
122
+ +
127
+ +
130
+ +
133
+ +
136
+ +
140
+ +
143
+ +
146
+ +
164
+ +
169
+ + + + +
174
+
179#ifdef __cplusplus
+
180}
+
181#endif
+
182
+ +
184
+
185#endif // _FLVALUE_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FLPURE
Definition: CompilerSupport.h:110
@@ -214,7 +214,7 @@
diff --git a/docs/C/html/_fleece_09_core_foundation_8h.html b/docs/C/html/_fleece_09_core_foundation_8h.html index ecc3cc4106..d323c699ee 100644 --- a/docs/C/html/_fleece_09_core_foundation_8h.html +++ b/docs/C/html/_fleece_09_core_foundation_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece+CoreFoundation.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
Fleece+CoreFoundation.h File Reference
+
Fleece+CoreFoundation.h File Reference
#include <CoreFoundation/CFBase.h>
-#include "Fleece.h"
+#include "fleece/FLCollections.h"

Go to the source code of this file.

- - + - +

+

Functions

bool FLEncoder_WriteCFObject (FLEncoder, CFTypeRef)
 Writes a Core Foundation (or Objective-C) object to an Encoder. More...
 
CFTypeRef FLValue_CopyCFObject (FLValue FL_NULLABLE)
CFTypeRef FLValue_CopyCFObject (FLValue FL_NULLABLE)
 Returns a Value as a corresponding CoreFoundation object. More...
 
FLValue FLDict_GetWithCFString (FLDict FL_NULLABLE, CFStringRef)
FLValue FLDict_GetWithCFString (FLDict FL_NULLABLE, CFStringRef)
 Same as FLDictGet, but takes the key as a CFStringRef. More...
 
diff --git a/docs/C/html/_fleece_09_core_foundation_8h_source.html b/docs/C/html/_fleece_09_core_foundation_8h_source.html index d6f106df92..15cc602fb3 100644 --- a/docs/C/html/_fleece_09_core_foundation_8h_source.html +++ b/docs/C/html/_fleece_09_core_foundation_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece+CoreFoundation.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
Fleece+CoreFoundation.h
+
Fleece+CoreFoundation.h
-Go to the documentation of this file.
1 //
-
2 // Fleece+CoreFoundation.h
-
3 //
-
4 // Copyright 2016-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 <CoreFoundation/CFBase.h>
-
15 #include "Fleece.h"
-
16 
-
17 #ifdef __OBJC__
-
18 #import <Foundation/NSMapTable.h>
-
19 #endif
-
20 
- -
22 
-
23 #ifdef __cplusplus
-
24 extern "C" {
-
25 #endif
-
26 
- -
33 
-
34 
- -
38 
-
39 
- -
42 
-
43 
-
44 #ifdef __OBJC__
-
45  // Equivalents of the above functions that take & return Objective-C object types:
-
46 
-
49  bool FLEncoder_WriteNSObject(FLEncoder, id) FLAPI;
-
50 
-
51 
-
53  NSMapTable* FLCreateSharedStringsTable(void) FLAPI;
-
54 
-
55 
-
57  id FLValue_GetNSObject(FLValue FL_NULLABLE, NSMapTable* FL_NULLABLE sharedStrings) FLAPI;
-
58 
-
59 
-
61  FLValue FLDict_GetWithNSString(FLDict FL_NULLABLE, NSString*) FLAPI;
-
62 
-
63 
-
65  NSString* FLDictIterator_GetKeyAsNSString(const FLDictIterator *i,
-
66  NSMapTable* FL_NULLABLE sharedStrings) FLAPI;
-
67 
-
69  NSData* FLEncoder_FinishWithNSData(FLEncoder, NSError** FL_NULLABLE) FLAPI;
-
70 
-
71 
-
73  extern NSString* const FLErrorDomain;
-
74 
-
75 
-
76  @interface NSObject (Fleece)
-
81  - (void) fl_encodeToFLEncoder: (FLEncoder)enc;
-
82  @end
-
83 #endif
-
84 
-
87 #ifdef __cplusplus
-
88 }
-
89 #endif
-
90 
- -
#define FL_NULLABLE
Definition: Base.h:74
-
#define FL_ASSUME_NONNULL_BEGIN
Definition: Base.h:72
-
#define FL_ASSUME_NONNULL_END
Definition: Base.h:73
+Go to the documentation of this file.
1//
+
2// Fleece+CoreFoundation.h
+
3//
+
4// Copyright 2016-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 <CoreFoundation/CFBase.h>
+ +
16
+
17#ifdef __OBJC__
+
18#import <Foundation/NSMapTable.h>
+
19#endif
+
20
+ +
22
+
23#ifdef __cplusplus
+
24extern "C" {
+
25#endif
+
26
+ +
33
+
34
+ +
38
+
39
+ +
42
+
43
+
44#ifdef __OBJC__
+
45 // Equivalents of the above functions that take & return Objective-C object types:
+
46
+
49 bool FLEncoder_WriteNSObject(FLEncoder, id) FLAPI;
+
50
+
51
+
53 NSMapTable* FLCreateSharedStringsTable(void) FLAPI;
+
54
+
55
+
57 id FLValue_GetNSObject(FLValue FL_NULLABLE, NSMapTable* FL_NULLABLE sharedStrings) FLAPI;
+
58
+
59
+
61 FLValue FLDict_GetWithNSString(FLDict FL_NULLABLE, NSString*) FLAPI;
+
62
+
63
+
65 NSString* FLDictIterator_GetKeyAsNSString(const FLDictIterator *i,
+
66 NSMapTable* FL_NULLABLE sharedStrings) FLAPI;
+
67
+
69 NSData* FLEncoder_FinishWithNSData(FLEncoder, NSError** FL_NULLABLE) FLAPI;
+
70
+
71
+
73 extern NSString* const FLErrorDomain;
+
74
+
75
+
76 @interface NSObject (Fleece)
+
81 - (void) fl_encodeToFLEncoder: (FLEncoder)enc;
+
82 @end
+
83#endif
+
84
+
87#ifdef __cplusplus
+
88}
+
89#endif
+
90
+ +
#define FL_NULLABLE
Definition: CompilerSupport.h:74
+
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
+
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
+
#define FLAPI
Definition: FLSlice.h:31
-
CFTypeRef FLValue_CopyCFObject(FLValue FL_NULLABLE)
Returns a Value as a corresponding CoreFoundation object.
bool FLEncoder_WriteCFObject(FLEncoder, CFTypeRef)
Writes a Core Foundation (or Objective-C) object to an Encoder.
FLValue FLDict_GetWithCFString(FLDict FL_NULLABLE, CFStringRef)
Same as FLDictGet, but takes the key as a CFStringRef.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:53
-
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:57
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
-
Opaque dictionary iterator.
Definition: Fleece.h:644
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:53
+
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: FLBase.h:57
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:51
+
Opaque dictionary iterator.
Definition: FLCollections.h:144
diff --git a/docs/C/html/_fleece_8h.html b/docs/C/html/_fleece_8h.html index d0f4536de0..b9024b886d 100644 --- a/docs/C/html/_fleece_8h.html +++ b/docs/C/html/_fleece_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
Fleece.h File Reference
+Macros
+
Fleece.h File Reference
-
#include "FLSlice.h"
-#include <stdio.h>
+
#include "FLBase.h"
+#include "FLCollections.h"
+#include "FLDeepIterator.h"
+#include "FLDoc.h"
+#include "FLEncoder.h"
+#include "FLJSON.h"
+#include "FLKeyPath.h"
+#include "FLMutable.h"
+#include "FLValue.h"

Go to the source code of this file.

- - - - - - - - - - - - -

-Data Structures

struct  FLArrayIterator
 Opaque array iterator. More...
 
struct  FLDictIterator
 Opaque dictionary iterator. More...
 
struct  FLDictKey
 Opaque key for a dictionary. More...
 
struct  FLPathComponent
 
- - - - - - -

+

Macros

#define _FLEECE_H
 
#define FLEECE_PUBLIC
 
#define FLTimestampNone   INT64_MIN
 A value representing a missing timestamp; returned when a date cannot be parsed. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
 
typedef const struct _FLArray * FLArray
 A reference to an array value. More...
 
typedef const struct _FLDict * FLDict
 A reference to a dictionary (map) value. More...
 
typedef struct _FLSlot * FLSlot
 A reference to a mutable array/dict item. More...
 
typedef struct _FLArray * FLMutableArray
 A reference to a mutable array. More...
 
typedef struct _FLDict * FLMutableDict
 A reference to a mutable dictionary. More...
 
typedef struct _FLEncoder * FLEncoder
 A reference to an encoder. More...
 
typedef int64_t FLTimestamp
 A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) More...
 
typedef struct _FLDeepIterator * FLDeepIterator
 A reference to a deep iterator. More...
 
typedef struct _FLKeyPath * FLKeyPath
 A reference to a key path. More...
 
typedef bool(* FLSharedKeysReadCallback) (void *FL_NULLABLE context, FLSharedKeys)
 
typedef struct _FLSharedKeyScope * FLSharedKeyScope
 
- - - - - - - -

-Enumerations

enum  FLError {
-  kFLNoError = 0 -, kFLMemoryError -, kFLOutOfRange -, kFLInvalidData -,
-  kFLEncodeError -, kFLJSONError -, kFLUnknownValue -, kFLInternalError -,
-  kFLNotFound -, kFLSharedKeysStateError -, kFLPOSIXError -, kFLUnsupported -
- }
 Error codes returned from some API calls. More...
 
enum  FLValueType {
-  kFLUndefined = -1 -, kFLNull = 0 -, kFLBoolean -, kFLNumber -,
-  kFLString -, kFLData -, kFLArray -, kFLDict -
- }
 Types of Fleece values. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-Functions

FLStringResult FLValue_ToJSON (FLValue FL_NULLABLE)
 Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings. More...
 
FLStringResult FLValue_ToJSON5 (FLValue FL_NULLABLE)
 Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric. More...
 
FLStringResult FLValue_ToJSONX (FLValue FL_NULLABLE v, bool json5, bool canonicalForm)
 Most general Fleece to JSON converter. More...
 
FLStringResult FLJSON5_ToJSON (FLString json5, FLStringResult *FL_NULLABLE outErrorMessage, size_t *FL_NULLABLE outErrorPos, FLError *FL_NULLABLE outError)
 Converts valid JSON5 https://json5.org to JSON. More...
 
FLValueType FLValue_GetType (FLValue FL_NULLABLE) FLPURE
 Returns the data type of an arbitrary Value. More...
 
bool FLValue_IsInteger (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is non-NULL and represents an integer. More...
 
bool FLValue_IsUnsigned (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is non-NULL and represents an integer >= 2^63. More...
 
bool FLValue_IsDouble (FLValue FL_NULLABLE)
 Returns true if the value is non-NULL and represents a 64-bit floating-point number. More...
 
bool FLValue_AsBool (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to boolean. More...
 
int64_t FLValue_AsInt (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to an integer. More...
 
uint64_t FLValue_AsUnsigned (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to an unsigned integer. More...
 
float FLValue_AsFloat (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 
double FLValue_AsDouble (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 
FLString FLValue_AsString (FLValue FL_NULLABLE) FLPURE
 Returns the exact contents of a string value, or null for all other types. More...
 
FLTimestamp FLValue_AsTimestamp (FLValue FL_NULLABLE) FLPURE
 Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure. More...
 
FLSlice FLValue_AsData (FLValue FL_NULLABLE) FLPURE
 Returns the exact contents of a data value, or null for all other types. More...
 
FLArray FL_NULLABLE FLValue_AsArray (FLValue FL_NULLABLE) FLPURE
 If a FLValue represents an array, returns it cast to FLArray, else NULL. More...
 
FLDict FL_NULLABLE FLValue_AsDict (FLValue FL_NULLABLE) FLPURE
 If a FLValue represents a dictionary, returns it as an FLDict, else NULL. More...
 
FLStringResult FLValue_ToString (FLValue FL_NULLABLE)
 Returns a string representation of any scalar value. More...
 
bool FLValue_IsEqual (FLValue FL_NULLABLE v1, FLValue FL_NULLABLE v2) FLPURE
 Compares two values for equality. More...
 
bool FLValue_IsMutable (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is mutable. More...
 
FLValue FL_NULLABLE FLValue_NewString (FLString)
 Allocates a string value on the heap. More...
 
FLValue FL_NULLABLE FLValue_NewData (FLSlice)
 Allocates a data/blob value on the heap. More...
 
uint32_t FLArray_Count (FLArray FL_NULLABLE) FLPURE
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 
bool FLArray_IsEmpty (FLArray FL_NULLABLE) FLPURE
 Returns true if an array is empty (or NULL). More...
 
FLMutableArray FL_NULLABLE FLArray_AsMutable (FLArray FL_NULLABLE) FLPURE
 If the array is mutable, returns it cast to FLMutableArray, else NULL. More...
 
FLValue FL_NULLABLE FLArray_Get (FLArray FL_NULLABLE, uint32_t index) FLPURE
 Returns an value at an array index, or NULL if the index is out of range. More...
 
uint32_t FLDict_Count (FLDict FL_NULLABLE) FLPURE
 Returns the number of items in a dictionary, or 0 if the pointer is NULL. More...
 
bool FLDict_IsEmpty (FLDict FL_NULLABLE) FLPURE
 Returns true if a dictionary is empty (or NULL). More...
 
FLMutableDict FL_NULLABLE FLDict_AsMutable (FLDict FL_NULLABLE) FLPURE
 If the dictionary is mutable, returns it cast to FLMutableDict, else NULL. More...
 
FLValue FL_NULLABLE FLDict_Get (FLDict FL_NULLABLE, FLSlice keyString) FLPURE
 Looks up a key in a dictionary, returning its value. More...
 
FLDeepIterator FLDeepIterator_New (FLValue FL_NULLABLE)
 Creates a FLDeepIterator to iterate over a dictionary. More...
 
void FLDeepIterator_Free (FLDeepIterator FL_NULLABLE)
 
FLValue FL_NULLABLE FLDeepIterator_GetValue (FLDeepIterator)
 Returns the current value being iterated over. More...
 
FLValue FL_NULLABLE FLDeepIterator_GetParent (FLDeepIterator)
 Returns the parent/container of the current value, or NULL at the end of iteration. More...
 
FLSlice FLDeepIterator_GetKey (FLDeepIterator)
 Returns the key of the current value in its parent, or an empty slice if not in a dictionary. More...
 
uint32_t FLDeepIterator_GetIndex (FLDeepIterator)
 Returns the array index of the current value in its parent, or 0 if not in an array. More...
 
size_t FLDeepIterator_GetDepth (FLDeepIterator)
 Returns the current depth in the hierarchy, starting at 1 for the top-level children. More...
 
void FLDeepIterator_SkipChildren (FLDeepIterator)
 Tells the iterator to skip the children of the current value. More...
 
bool FLDeepIterator_Next (FLDeepIterator)
 Advances the iterator to the next value, or returns false if at the end. More...
 
void FLDeepIterator_GetPath (FLDeepIterator, FLPathComponent *FL_NONNULL *FL_NONNULL outPath, size_t *outDepth)
 Returns the path as an array of FLPathComponents. More...
 
FLSliceResult FLDeepIterator_GetPathString (FLDeepIterator)
 Returns the current path in JavaScript format. More...
 
FLSliceResult FLDeepIterator_GetJSONPointer (FLDeepIterator)
 Returns the current path in JSONPointer format (RFC 6901). More...
 
FLKeyPath FL_NULLABLE FLKeyPath_New (FLSlice specifier, FLError *FL_NULLABLE outError)
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 
void FLKeyPath_Free (FLKeyPath FL_NULLABLE)
 Frees a compiled FLKeyPath object. More...
 
FLValue FL_NULLABLE FLKeyPath_Eval (FLKeyPath, FLValue root)
 Evaluates a compiled key-path for a given Fleece root object. More...
 
FLValue FL_NULLABLE FLKeyPath_EvalOnce (FLSlice specifier, FLValue root, FLError *FL_NULLABLE outError)
 Evaluates a key-path from a specifier string, for a given Fleece root object. More...
 
FLStringResult FLKeyPath_ToString (FLKeyPath path)
 Returns a path in string form. More...
 
bool FLKeyPath_Equals (FLKeyPath path1, FLKeyPath path2)
 Equality test. More...
 
bool FLKeyPath_GetElement (FLKeyPath, size_t i, FLSlice *outDictKey, int32_t *outArrayIndex)
 Returns an element of a path, either a key or an array index. More...
 
FLSharedKeys FLSharedKeys_New (void)
 Creates a new empty FLSharedKeys object, which must eventually be released. More...
 
FLSharedKeys FLSharedKeys_NewWithRead (FLSharedKeysReadCallback, void *FL_NULLABLE context)
 
FLSliceResult FLSharedKeys_GetStateData (FLSharedKeys)
 Returns a data blob containing the current state (all the keys and their integers.) More...
 
bool FLSharedKeys_LoadStateData (FLSharedKeys, FLSlice)
 Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData. More...
 
void FLSharedKeys_WriteState (FLSharedKeys, FLEncoder)
 Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed to FLSharedKeys_LoadState. More...
 
bool FLSharedKeys_LoadState (FLSharedKeys, FLValue)
 Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_WriteState. More...
 
int FLSharedKeys_Encode (FLSharedKeys, FLString, bool add)
 Maps a key string to a number in the range [0...2047], or returns -1 if it isn't mapped. More...
 
FLString FLSharedKeys_Decode (FLSharedKeys, int key)
 Returns the key string that maps to the given integer key, else NULL. More...
 
unsigned FLSharedKeys_Count (FLSharedKeys)
 Returns the number of keys in the mapping. More...
 
void FLSharedKeys_RevertToCount (FLSharedKeys, unsigned oldCount)
 Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount. More...
 
FLSharedKeys FL_NULLABLE FLSharedKeys_Retain (FLSharedKeys FL_NULLABLE)
 Increments the reference count of an FLSharedKeys. More...
 
void FLSharedKeys_Release (FLSharedKeys FL_NULLABLE)
 Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero. More...
 
FLSharedKeyScope FLSharedKeyScope_WithRange (FLSlice range, FLSharedKeys)
 
void FLSharedKeyScope_Free (FLSharedKeyScope FL_NULLABLE)
 
FLSliceResult FLCreateJSONDelta (FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
 Returns JSON that encodes the changes to turn the value old into nuu. More...
 
bool FLEncodeJSONDelta (FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu, FLEncoder jsonEncoder)
 Writes JSON that describes the changes to turn the value old into nuu. More...
 
FLSliceResult FLApplyJSONDelta (FLValue FL_NULLABLE old, FLSlice jsonDelta, FLError *FL_NULLABLE outError)
 Applies the JSON data created by CreateJSONDelta to the value old, which must be equal to the old value originally passed to FLCreateJSONDelta, and returns a Fleece document equal to the original nuu value. More...
 
bool FLEncodeApplyingJSONDelta (FLValue FL_NULLABLE old, FLSlice jsonDelta, FLEncoder encoder)
 Applies the (parsed) JSON data created by CreateJSONDelta to the value old, which must be equal to the old value originally passed to FLCreateJSONDelta, and writes the corresponding nuu value to the encoder. More...
 
MUST_USE_RESULT FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
 Returns an FLSlot that refers to the given index of the given array. More...
 
MUST_USE_RESULT FLSlot FLMutableArray_Append (FLMutableArray)
 Appends a null value to the array and returns an FLSlot that refers to that position. More...
 
MUST_USE_RESULT FLSlot FLMutableDict_Set (FLMutableDict, FLString key)
 Returns an FLSlot that refers to the given key/value pair of the given dictionary. More...
 
void FLSlot_SetNull (FLSlot)
 Stores a JSON null into a slot. More...
 
void FLSlot_SetBool (FLSlot, bool)
 Stores a boolean into a slot. More...
 
void FLSlot_SetInt (FLSlot, int64_t)
 Stores an integer into a slot. More...
 
void FLSlot_SetUInt (FLSlot, uint64_t)
 Stores an unsigned int into a slot. More...
 
void FLSlot_SetFloat (FLSlot, float)
 Stores a float into a slot. More...
 
void FLSlot_SetDouble (FLSlot, double)
 Stores a double into a slot. More...
 
void FLSlot_SetString (FLSlot, FLString)
 Stores a UTF-8 string into a slot. More...
 
void FLSlot_SetData (FLSlot, FLSlice)
 Stores a data blob into a slot. More...
 
void FLSlot_SetValue (FLSlot, FLValue)
 Stores an FLValue into a slot. More...
 
static void FLSlot_SetArray (FLSlot slot, FLArray array)
 
static void FLSlot_SetDict (FLSlot slot, FLDict dict)
 
Parsing And Converting Values Directly
FLValue FL_NULLABLE FLValue_FromData (FLSlice data, FLTrust) FLPURE
 Returns a pointer to the root value in the encoded data, or NULL if validation failed. More...
 
FLSliceResult FLData_ConvertJSON (FLSlice json, FLError *FL_NULLABLE outError)
 Directly converts JSON data to Fleece-encoded data. More...
 
FLStringResult FLData_Dump (FLSlice data)
 Produces a human-readable dump of the Value encoded in the data. More...
 
Debugging Functions
const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that returns a C string of JSON. More...
 
Ref-counting (mutable values only)
FLValue FL_NULLABLE FLValue_Retain (FLValue FL_NULLABLE)
 If this value is mutable (and thus heap-based) its ref-count is incremented. More...
 
void FLValue_Release (FLValue FL_NULLABLE)
 If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero the value is freed. More...
 
static FLArray FL_NULLABLE FLArray_Retain (FLArray FL_NULLABLE v)
 
static void FLArray_Release (FLArray FL_NULLABLE v)
 
static FLDict FL_NULLABLE FLDict_Retain (FLDict FL_NULLABLE v)
 
static void FLDict_Release (FLDict FL_NULLABLE v)
 
Array iteration

Iterating an array typically looks like this:

-
-
FLArrayIterator_Begin(theArray, &iter);
-
FLValue value;
-
while (NULL != (value = FLArrayIterator_GetValue(&iter))) {
-
// ...
- -
}
-
void FLArrayIterator_Begin(FLArray FL_NULLABLE, FLArrayIterator *)
Initializes a FLArrayIterator struct to iterate over an array.
-
bool FLArrayIterator_Next(FLArrayIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
FLValue FL_NULLABLE FLArrayIterator_GetValue(const FLArrayIterator *) FLPURE
Returns the current value being iterated over.
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
-
Opaque array iterator.
Definition: Fleece.h:436
-
void FLArrayIterator_Begin (FLArray FL_NULLABLE, FLArrayIterator *)
 Initializes a FLArrayIterator struct to iterate over an array. More...
 
FLValue FL_NULLABLE FLArrayIterator_GetValue (const FLArrayIterator *) FLPURE
 Returns the current value being iterated over. More...
 
FLValue FL_NULLABLE FLArrayIterator_GetValueAt (const FLArrayIterator *, uint32_t offset) FLPURE
 Returns a value in the array at the given offset from the current value. More...
 
uint32_t FLArrayIterator_GetCount (const FLArrayIterator *) FLPURE
 Returns the number of items remaining to be iterated, including the current one. More...
 
bool FLArrayIterator_Next (FLArrayIterator *)
 Advances the iterator to the next value, or returns false if at the end. More...
 
Dict iteration

Iterating a dictionary typically looks like this:

-
-
FLDictIterator_Begin(theDict, &iter);
-
FLValue value;
-
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
- -
// ...
- -
}
-
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
-
FLValue FL_NULLABLE FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
-
void FLDictIterator_Begin(FLDict FL_NULLABLE, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
-
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
Opaque dictionary iterator.
Definition: Fleece.h:644
-
A simple reference to a block of memory.
Definition: FLSlice.h:48
-
void FLDictIterator_Begin (FLDict FL_NULLABLE, FLDictIterator *)
 Initializes a FLDictIterator struct to iterate over a dictionary. More...
 
FLValue FL_NULLABLE FLDictIterator_GetKey (const FLDictIterator *) FLPURE
 Returns the current key being iterated over. More...
 
FLString FLDictIterator_GetKeyString (const FLDictIterator *)
 Returns the current key's string value. More...
 
FLValue FL_NULLABLE FLDictIterator_GetValue (const FLDictIterator *) FLPURE
 Returns the current value being iterated over. More...
 
uint32_t FLDictIterator_GetCount (const FLDictIterator *) FLPURE
 Returns the number of items remaining to be iterated, including the current one. More...
 
bool FLDictIterator_Next (FLDictIterator *)
 Advances the iterator to the next value, or returns false if at the end. More...
 
void FLDictIterator_End (FLDictIterator *)
 Cleans up after an iterator. More...
 
Optimized Keys
FLDictKey FLDictKey_Init (FLSlice string)
 Initializes an FLDictKey struct with a key string. More...
 
FLString FLDictKey_GetString (const FLDictKey *)
 Returns the string value of the key (which it was initialized with.) More...
 
FLValue FL_NULLABLE FLDict_GetWithKey (FLDict FL_NULLABLE, FLDictKey *)
 Looks up a key in a dictionary using an FLDictKey. More...
 
Mutable dictionaries
FLMutableDict FL_NULLABLE FLDict_MutableCopy (FLDict FL_NULLABLE source, FLCopyFlags)
 Creates a new mutable Dict that's a copy of the source Dict. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_New (void)
 Creates a new empty mutable Dict. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_NewFromJSON (FLString json, FLError *FL_NULLABLE outError)
 Creates a new mutable Dict from json. More...
 
static FLMutableDict FL_NULLABLE FLMutableDict_Retain (FLMutableDict FL_NULLABLE d)
 Increments the ref-count of a mutable Dict. More...
 
static void FLMutableDict_Release (FLMutableDict FL_NULLABLE d)
 Decrements the refcount of (and possibly frees) a mutable Dict. More...
 
FLDict FL_NULLABLE FLMutableDict_GetSource (FLMutableDict FL_NULLABLE)
 If the Dict was created by FLDict_MutableCopy, returns the original source Dict. More...
 
bool FLMutableDict_IsChanged (FLMutableDict FL_NULLABLE)
 Returns true if the Dict has been changed from the source it was copied from. More...
 
void FLMutableDict_SetChanged (FLMutableDict FL_NULLABLE, bool)
 Sets or clears the mutable Dict's "changed" flag. More...
 
void FLMutableDict_Remove (FLMutableDict FL_NULLABLE, FLString key)
 Removes the value for a key. More...
 
void FLMutableDict_RemoveAll (FLMutableDict FL_NULLABLE)
 Removes all keys and values. More...
 
FLMutableArray FL_NULLABLE FLMutableDict_GetMutableArray (FLMutableDict FL_NULLABLE, FLString key)
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_GetMutableDict (FLMutableDict FL_NULLABLE, FLString key)
 Convenience function for getting a dict-valued property in mutable form. More...
 
static void FLMutableDict_SetNull (FLMutableDict, FLString key)
 Stores a JSON null value into a mutable dictionary. More...
 
static void FLMutableDict_SetBool (FLMutableDict, FLString key, bool)
 Stores a boolean value into a mutable dictionary. More...
 
static void FLMutableDict_SetInt (FLMutableDict, FLString key, int64_t)
 Stores an integer into a mutable dictionary. More...
 
static void FLMutableDict_SetUInt (FLMutableDict, FLString key, uint64_t)
 Stores an unsigned integer into a mutable dictionary. More...
 
static void FLMutableDict_SetFloat (FLMutableDict, FLString key, float)
 Stores a 32-bit floating-point number into a mutable dictionary. More...
 
static void FLMutableDict_SetDouble (FLMutableDict, FLString key, double)
 Stores a 64-bit floating point number into a mutable dictionary. More...
 
static void FLMutableDict_SetString (FLMutableDict, FLString key, FLString)
 Stores a UTF-8-encoded string into a mutable dictionary. More...
 
static void FLMutableDict_SetData (FLMutableDict, FLString key, FLSlice)
 Stores a binary data blob into a mutable dictionary. More...
 
static void FLMutableDict_SetValue (FLMutableDict, FLString key, FLValue)
 Stores a Fleece value into a mutable dictionary. More...
 
static void FLMutableDict_SetArray (FLMutableDict, FLString key, FLArray)
 Stores a Fleece array into a mutable dictionary. More...
 
static void FLMutableDict_SetDict (FLMutableDict, FLString key, FLDict)
 Stores a Fleece dictionary into a mutable dictionary. More...
 
Writing to the encoder
Note
The functions that write to the encoder do not return error codes, just a 'false' result on error. The actual error is attached to the encoder and can be accessed by calling FLEncoder_GetError or FLEncoder_End.
-

After an error occurs, the encoder will ignore all subsequent writes.

-
bool FLEncoder_WriteNull (FLEncoder)
 Writes a null value to an encoder. More...
 
bool FLEncoder_WriteUndefined (FLEncoder)
 Writes an undefined value to an encoder. More...
 
bool FLEncoder_WriteBool (FLEncoder, bool)
 Writes a boolean value (true or false) to an encoder. More...
 
bool FLEncoder_WriteInt (FLEncoder, int64_t)
 Writes an integer to an encoder. More...
 
bool FLEncoder_WriteUInt (FLEncoder, uint64_t)
 Writes an unsigned integer to an encoder. More...
 
bool FLEncoder_WriteFloat (FLEncoder, float)
 Writes a 32-bit floating point number to an encoder. More...
 
bool FLEncoder_WriteDouble (FLEncoder, double)
 Writes a 64-bit floating point number to an encoder. More...
 
bool FLEncoder_WriteString (FLEncoder, FLString)
 Writes a string to an encoder. More...
 
bool FLEncoder_WriteDateString (FLEncoder encoder, FLTimestamp ts, bool asUTC)
 Writes a timestamp to an encoder, as an ISO-8601 date string. More...
 
bool FLEncoder_WriteData (FLEncoder, FLSlice)
 Writes a binary data value (a blob) to an encoder. More...
 
bool FLEncoder_WriteRaw (FLEncoder, FLSlice)
 Writes raw data directly to the encoded output. More...
 
bool FLEncoder_BeginArray (FLEncoder, size_t reserveCount)
 Begins writing an array value to an encoder. More...
 
bool FLEncoder_EndArray (FLEncoder)
 Ends writing an array value; pops back the previous encoding state. More...
 
bool FLEncoder_BeginDict (FLEncoder, size_t reserveCount)
 Begins writing a dictionary value to an encoder. More...
 
bool FLEncoder_WriteKey (FLEncoder, FLString)
 Specifies the key for the next value to be written to the current dictionary. More...
 
bool FLEncoder_WriteKeyValue (FLEncoder, FLValue)
 Specifies the key for the next value to be written to the current dictionary. More...
 
bool FLEncoder_EndDict (FLEncoder)
 Ends writing a dictionary value; pops back the previous encoding state. More...
 
bool FLEncoder_WriteValue (FLEncoder, FLValue)
 Writes a Fleece Value to an Encoder. More...
 
intptr_t FLEncoder_LastValueWritten (FLEncoder)
 Returns an opaque reference to the last complete value written to the encoder, if possible. More...
 
void FLEncoder_WriteValueAgain (FLEncoder, intptr_t preWrittenValue)
 Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten. More...
 
FLSliceResult FLEncoder_Snip (FLEncoder)
 Returns the data written so far as a standalone Fleece document, whose root is the last value written. More...
 
bool FLEncoder_ConvertJSON (FLEncoder, FLSlice json)
 Parses JSON data and writes the object(s) to the encoder. More...
 
Finishing up
size_t FLEncoder_FinishItem (FLEncoder)
 Finishes encoding the current item, and returns its offset in the output data. More...
 
MUST_USE_RESULT FLDoc FL_NULLABLE FLEncoder_FinishDoc (FLEncoder, FLError *FL_NULLABLE outError)
 Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc. More...
 
MUST_USE_RESULT FLSliceResult FLEncoder_Finish (FLEncoder, FLError *FL_NULLABLE outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null. More...
 
Error handling
FLError FLEncoder_GetError (FLEncoder)
 Returns the error code of an encoder, or NoError (0) if there's no error. More...
 
const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
- - - - - - - - - - - -

-Variables

FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
FLEECE_PUBLIC const FLValue kFLUndefinedValue
 A constant undefined value. More...
 
FLEECE_PUBLIC const FLArray kFLEmptyArray
 
FLEECE_PUBLIC const FLDict kFLEmptyDict
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

FLDoc

An FLDoc points to (and often owns) Fleece-encoded data and provides access to its Fleece values.

-
enum  FLTrust { kFLUntrusted -, kFLTrusted - }
 Specifies whether not input data is trusted to be 100% valid Fleece. More...
 
typedef struct _FLDoc * FLDoc
 A reference to a document. More...
 
typedef struct _FLSharedKeys * FLSharedKeys
 A reference to a shared-keys mapping. More...
 
FLDoc FLDoc_FromResultData (FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
 Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other API. More...
 
FLDoc FLDoc_FromJSON (FLSlice json, FLError *FL_NULLABLE outError)
 Creates an FLDoc from JSON-encoded data. More...
 
void FLDoc_Release (FLDoc FL_NULLABLE)
 Releases a reference to an FLDoc. More...
 
FLDoc FLDoc_Retain (FLDoc FL_NULLABLE)
 Adds a reference to an FLDoc. More...
 
FLSlice FLDoc_GetData (FLDoc FL_NULLABLE) FLPURE
 Returns the encoded Fleece data backing the document. More...
 
FLSliceResult FLDoc_GetAllocedData (FLDoc FL_NULLABLE) FLPURE
 Returns the FLSliceResult data owned by the document, if any, else a null slice. More...
 
FLValue FLDoc_GetRoot (FLDoc FL_NULLABLE) FLPURE
 Returns the root value in the FLDoc, usually an FLDict. More...
 
FLSharedKeys FLDoc_GetSharedKeys (FLDoc FL_NULLABLE) FLPURE
 Returns the FLSharedKeys used by this FLDoc, as specified when it was created. More...
 
bool FLDoc_SetAssociated (FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
 Associates an arbitrary pointer value with a document, and thus its contained values. More...
 
void * FLDoc_GetAssociated (FLDoc FL_NULLABLE doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 
FLDoc FL_NULLABLE FLValue_FindDoc (FLValue FL_NULLABLE) FLPURE
 Looks up the Doc containing the Value, or NULL if the Value was created without a Doc. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0 -, kFLDeepCopy = 1 -, kFLCopyImmutables = 2 -, kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) - }
 
FLMutableArray FL_NULLABLE FLArray_MutableCopy (FLArray FL_NULLABLE, FLCopyFlags)
 Creates a new mutable Array that's a copy of the source Array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_New (void)
 Creates a new empty mutable Array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_NewFromJSON (FLString json, FLError *FL_NULLABLE outError)
 Creates a new mutable Array from JSON. More...
 
static FLMutableArray FL_NULLABLE FLMutableArray_Retain (FLMutableArray FL_NULLABLE d)
 Increments the ref-count of a mutable Array. More...
 
static void FLMutableArray_Release (FLMutableArray FL_NULLABLE d)
 Decrements the refcount of (and possibly frees) a mutable Array. More...
 
FLArray FL_NULLABLE FLMutableArray_GetSource (FLMutableArray FL_NULLABLE)
 If the Array was created by FLArray_MutableCopy, returns the original source Array. More...
 
bool FLMutableArray_IsChanged (FLMutableArray FL_NULLABLE)
 Returns true if the Array has been changed from the source it was copied from. More...
 
void FLMutableArray_SetChanged (FLMutableArray FL_NULLABLE, bool)
 Sets or clears the mutable Array's "changed" flag. More...
 
void FLMutableArray_Insert (FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
 Inserts a contiguous range of JSON null values into the array. More...
 
void FLMutableArray_Remove (FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
 Removes contiguous items from the array. More...
 
void FLMutableArray_Resize (FLMutableArray FL_NULLABLE array, uint32_t size)
 Changes the size of an array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_GetMutableArray (FLMutableArray FL_NULLABLE, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FL_NULLABLE FLMutableArray_GetMutableDict (FLMutableArray FL_NULLABLE, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 
static void FLMutableArray_SetNull (FLMutableArray, uint32_t index)
 Stores a JSON null value into an array. More...
 
static void FLMutableArray_SetBool (FLMutableArray, uint32_t index, bool)
 Stores a boolean value into an array. More...
 
static void FLMutableArray_SetInt (FLMutableArray, uint32_t index, int64_t)
 Stores an integer into an array. More...
 
static void FLMutableArray_SetUInt (FLMutableArray, uint32_t index, uint64_t)
 Stores an unsigned integer into an array. More...
 
static void FLMutableArray_SetFloat (FLMutableArray, uint32_t index, float)
 Stores a 32-bit floating-point number into an array. More...
 
static void FLMutableArray_SetDouble (FLMutableArray, uint32_t index, double)
 Stores a 64-bit floating point number into an array. More...
 
static void FLMutableArray_SetString (FLMutableArray, uint32_t index, FLString)
 Stores a UTF-8-encoded string into an array. More...
 
static void FLMutableArray_SetData (FLMutableArray, uint32_t index, FLSlice)
 Stores a binary data blob into an array. More...
 
static void FLMutableArray_SetValue (FLMutableArray, uint32_t index, FLValue)
 Stores a Fleece value into an array. More...
 
static void FLMutableArray_SetArray (FLMutableArray, uint32_t index, FLArray)
 Stores a Fleece array into an array. More...
 
static void FLMutableArray_SetDict (FLMutableArray, uint32_t index, FLDict)
 Stores a Fleece dictionary into an array. More...
 
static void FLMutableArray_AppendNull (FLMutableArray)
 Appends a JSON null value to an array. More...
 
static void FLMutableArray_AppendBool (FLMutableArray, bool)
 Appends a boolean value to an array. More...
 
static void FLMutableArray_AppendInt (FLMutableArray, int64_t)
 Appends an integer to an array. More...
 
static void FLMutableArray_AppendUInt (FLMutableArray, uint64_t)
 Appends an unsigned integer to an array. More...
 
static void FLMutableArray_AppendFloat (FLMutableArray, float)
 Appends a 32-bit floating-point number to an array. More...
 
static void FLMutableArray_AppendDouble (FLMutableArray, double)
 Appends a 64-bit floating point number to an array. More...
 
static void FLMutableArray_AppendString (FLMutableArray, FLString)
 Appends a UTF-8-encoded string to an array. More...
 
static void FLMutableArray_AppendData (FLMutableArray, FLSlice)
 Appends a binary data blob to an array. More...
 
static void FLMutableArray_AppendValue (FLMutableArray, FLValue)
 Appends a Fleece value to an array. More...
 
static void FLMutableArray_AppendArray (FLMutableArray, FLArray)
 Appends a Fleece array to an array. More...
 
static void FLMutableArray_AppendDict (FLMutableArray, FLDict)
 Appends a Fleece dictionary to an array. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece -, kFLEncodeJSON -, kFLEncodeJSON5 - }
 Output formats a FLEncoder can generate. More...
 
FLEncoder FLEncoder_New (void)
 Creates a new encoder, for generating Fleece data. More...
 
FLEncoder FLEncoder_NewWithOptions (FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
 Creates a new encoder, allowing some options to be customized. More...
 
FLEncoder FLEncoder_NewWritingToFile (FILE *, bool uniqueStrings)
 Creates a new Fleece encoder that writes to a file, not to memory. More...
 
void FLEncoder_Free (FLEncoder FL_NULLABLE)
 Frees the space used by an encoder. More...
 
void FLEncoder_SetSharedKeys (FLEncoder, FLSharedKeys FL_NULLABLE)
 Tells the encoder to use a shared-keys mapping when encoding dictionary keys. More...
 
void FLEncoder_SetExtraInfo (FLEncoder, void *FL_NULLABLE info)
 Associates an arbitrary user-defined value with the encoder. More...
 
void * FLEncoder_GetExtraInfo (FLEncoder)
 Returns the user-defined value associated with the encoder; NULL by default. More...
 
void FLEncoder_Amend (FLEncoder e, FLSlice base, bool reuseStrings, bool externPointers)
 Tells the encoder to logically append to the given Fleece document, rather than making a standalone document. More...
 
FLSlice FLEncoder_GetBase (FLEncoder)
 Returns the base value passed to FLEncoder_Amend. More...
 
void FLEncoder_SuppressTrailer (FLEncoder)
 Tells the encoder not to write the two-byte Fleece trailer at the end of the data. More...
 
void FLEncoder_Reset (FLEncoder)
 Resets the state of an encoder without freeing it. More...
 
size_t FLEncoder_BytesWritten (FLEncoder)
 Returns the number of bytes encoded so far. More...
 
size_t FLEncoder_GetNextWritePos (FLEncoder)
 Returns the byte offset in the encoded data where the next value will be written. More...
 

Macro Definition Documentation

- +

◆ _FLEECE_H

@@ -923,26 +102,12 @@

-

-
- -

◆ FLEECE_PUBLIC

- -
-
- - - - -
#define FLEECE_PUBLIC
-
-
diff --git a/docs/C/html/_fleece_8h_source.html b/docs/C/html/_fleece_8h_source.html index 2b752beac2..60981172da 100644 --- a/docs/C/html/_fleece_8h_source.html +++ b/docs/C/html/_fleece_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
Fleece.h
+
Fleece.h
-Go to the documentation of this file.
1 //
-
2 // Fleece.h
-
3 //
-
4 // Copyright 2016-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 #ifndef _FLEECE_H
-
15 #define _FLEECE_H
-
16 
-
17 #include "FLSlice.h"
-
18 #include <stdio.h>
-
19 
-
20 // On Windows, FLEECE_PUBLIC marks symbols as being exported from the shared library.
-
21 // However, this is not the whole list of things that are exported. The API methods
-
22 // are exported using a definition list, but it is not possible to correctly include
-
23 // initialized global variables, so those need to be marked (both in the header and
-
24 // implementation) with FLEECE_PUBLIC. See kFLNullValue below and in Fleece.cc
-
25 // for an example.
-
26 #if defined(_MSC_VER)
-
27 #ifdef FLEECE_EXPORTS
-
28 #define FLEECE_PUBLIC __declspec(dllexport)
-
29 #else
-
30 #define FLEECE_PUBLIC __declspec(dllimport)
-
31 #endif
-
32 #else
-
33 #define FLEECE_PUBLIC
-
34 #endif
-
35 
- -
37 
-
38 #ifdef __cplusplus
-
39 extern "C" {
-
40 #endif
-
41 
-
42  // This is the C API! For the C++ API, see Fleece.hh.
-
43 
-
44 
-
46 
-
50 #ifndef FL_IMPL
-
51  typedef const struct _FLValue* FLValue;
-
52  typedef const struct _FLArray* FLArray;
-
53  typedef const struct _FLDict* FLDict;
-
54  typedef struct _FLSlot* FLSlot;
-
55  typedef struct _FLArray* FLMutableArray;
-
56  typedef struct _FLDict* FLMutableDict;
-
57  typedef struct _FLEncoder* FLEncoder;
-
58 #endif
-
59 
-
60 
-
62  typedef enum {
- -
64  kFLMemoryError, // Out of memory, or allocation failed
-
65  kFLOutOfRange, // Array index or iterator out of range
-
66  kFLInvalidData, // Bad input data (NaN, non-string key, etc.)
-
67  kFLEncodeError, // Structural error encoding (missing value, too many ends, etc.)
-
68  kFLJSONError, // Error parsing JSON
-
69  kFLUnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?)
-
70  kFLInternalError, // Something that shouldn't happen
-
71  kFLNotFound, // Key not found
-
72  kFLSharedKeysStateError, // Misuse of shared keys (not in transaction, etc.)
- -
74  kFLUnsupported, // Operation is unsupported
-
75  } FLError;
-
76 
-
77 
-
79 
-
80 
-
90 #ifndef FL_IMPL
-
91  typedef struct _FLDoc* FLDoc;
-
92  typedef struct _FLSharedKeys* FLSharedKeys;
-
93 #endif
-
94 
-
96  typedef enum {
- -
106  kFLTrusted
- -
108 
-
109 
- -
114  FLSharedKeys FL_NULLABLE, FLSlice externData) FLAPI;
-
115 
- -
120 
- -
123 
- -
127 
- -
130 
- -
133 
- -
136 
- -
139 
- -
155  void * FL_NULLABLE pointer,
-
156  const char *type) FLAPI;
-
157 
-
166  void* FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLAPI FLPURE;
-
167 
- -
171 
-
172 
- -
181 
- -
185 
- -
189 
-
190 
- -
201 
- -
205 
- -
208  bool json5,
-
209  bool canonicalForm) FLAPI;
-
210 
- -
226  FLStringResult* FL_NULLABLE outErrorMessage,
-
227  size_t* FL_NULLABLE outErrorPos,
-
228  FLError* FL_NULLABLE outError) FLAPI;
-
229 
- -
235  const char* FL_NULLABLE FLDumpData(FLSlice data) FLAPI;
-
236 
-
241 
-
242 
-
263  typedef enum {
- -
265  kFLNull = 0,
- - - - - -
271  kFLDict
- -
273 
-
274 
-
276  typedef int64_t FLTimestamp;
-
277 
-
279  #define FLTimestampNone INT64_MIN
-
280 
-
281 
- -
285 
- -
288 
- -
294 
- -
297 
- -
301 
- -
307 
- -
312 
- -
319 
- -
326 
- -
329 
- -
334 
- -
337 
- -
340 
- -
343 
- -
347 
- -
350 
- -
353 
- -
360 
- -
365 
- - - - -
370 
- -
377 
- -
382 
-
384  FLEECE_PUBLIC extern const FLValue kFLNullValue;
-
385 
- -
388 
-
389 
-
391 
-
392 
- -
406 
- -
410 
- -
413 
- -
416 
-
417  FLEECE_PUBLIC extern const FLArray kFLEmptyArray;
-
418 
-
436  typedef struct {
-
437 #if !DOXYGEN_PARSING
-
438  void* _private1;
-
439  uint32_t _private2;
-
440  bool _private3;
-
441  void* _private4;
-
442 #endif
-
443  } FLArrayIterator;
-
444 
- -
448 
- -
451 
- -
454 
- -
457 
- -
460 
-
465 
-
466 
-
470  typedef enum {
- - - - -
475  } FLCopyFlags;
-
476 
-
477 
- -
490 
- -
494 
- -
498 
- - -
502  }
- - -
506  }
-
507 
- -
510 
- -
513 
- -
516 
-
521  void FLMutableArray_Insert(FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count) FLAPI;
-
522 
-
527  void FLMutableArray_Remove(FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count) FLAPI;
-
528 
- -
533 
- -
540 
- -
547 
-
548 
-
550  static inline void FLMutableArray_SetNull(FLMutableArray, uint32_t index);
-
552  static inline void FLMutableArray_SetBool(FLMutableArray, uint32_t index, bool);
-
554  static inline void FLMutableArray_SetInt(FLMutableArray, uint32_t index, int64_t);
-
558  static inline void FLMutableArray_SetUInt(FLMutableArray, uint32_t index, uint64_t);
-
560  static inline void FLMutableArray_SetFloat(FLMutableArray, uint32_t index, float);
-
562  static inline void FLMutableArray_SetDouble(FLMutableArray, uint32_t index, double);
-
564  static inline void FLMutableArray_SetString(FLMutableArray, uint32_t index, FLString);
-
566  static inline void FLMutableArray_SetData(FLMutableArray, uint32_t index, FLSlice);
-
568  static inline void FLMutableArray_SetValue(FLMutableArray, uint32_t index, FLValue);
-
570  static inline void FLMutableArray_SetArray(FLMutableArray, uint32_t index, FLArray);
-
572  static inline void FLMutableArray_SetDict(FLMutableArray, uint32_t index, FLDict);
-
573 
-
575  static inline void FLMutableArray_AppendNull(FLMutableArray);
-
577  static inline void FLMutableArray_AppendBool(FLMutableArray, bool);
-
579  static inline void FLMutableArray_AppendInt(FLMutableArray, int64_t);
-
583  static inline void FLMutableArray_AppendUInt(FLMutableArray, uint64_t);
-
585  static inline void FLMutableArray_AppendFloat(FLMutableArray, float);
-
587  static inline void FLMutableArray_AppendDouble(FLMutableArray, double);
- -
591  static inline void FLMutableArray_AppendData(FLMutableArray, FLSlice);
- - -
597  static inline void FLMutableArray_AppendDict(FLMutableArray, FLDict);
-
598 
-
599 
-
604 
-
605 
- -
612 
- -
616 
- -
619 
- -
623 
-
624  FLEECE_PUBLIC extern const FLDict kFLEmptyDict;
-
625 
-
644  typedef struct {
-
645 #if !DOXYGEN_PARSING
-
646  void* _private1;
-
647  uint32_t _private2;
-
648  bool _private3;
-
649  void *_private4, *_private5, *_private6, *_private7;
-
650  int _private8;
-
651 #endif
-
652  } FLDictIterator;
-
653 
- -
658 
- -
661 
- -
664 
- -
667 
- -
670 
- -
673 
- -
677 
-
686  typedef struct {
-
687 #if !DOXYGEN_PARSING
-
688  FLSlice _private1;
-
689  void* _private2;
-
690  uint32_t _private3, private4;
-
691  bool private5;
-
692 #endif
-
693  } FLDictKey;
-
694 
- -
701 
- -
704 
- -
708 
-
709 
-
711 
-
712 
- -
728 
- -
732 
- -
736 
- - -
740  }
-
741 
- - -
745  }
-
746 
- -
749 
- -
752 
- -
755 
- -
758 
- -
761 
- -
768 
- -
775 
-
776 
-
778  static inline void FLMutableDict_SetNull(FLMutableDict, FLString key);
-
780  static inline void FLMutableDict_SetBool(FLMutableDict, FLString key, bool);
-
782  static inline void FLMutableDict_SetInt(FLMutableDict, FLString key, int64_t);
-
786  static inline void FLMutableDict_SetUInt(FLMutableDict, FLString key, uint64_t);
-
788  static inline void FLMutableDict_SetFloat(FLMutableDict, FLString key, float);
-
790  static inline void FLMutableDict_SetDouble(FLMutableDict, FLString key, double);
-
792  static inline void FLMutableDict_SetString(FLMutableDict, FLString key, FLString);
-
794  static inline void FLMutableDict_SetData(FLMutableDict, FLString key, FLSlice);
-
796  static inline void FLMutableDict_SetValue(FLMutableDict, FLString key, FLValue);
-
798  static inline void FLMutableDict_SetArray(FLMutableDict, FLString key, FLArray);
-
800  static inline void FLMutableDict_SetDict(FLMutableDict, FLString key, FLDict);
-
801 
-
802 
-
807 
-
808 
-
815 #ifndef FL_IMPL
-
816  typedef struct _FLDeepIterator* FLDeepIterator;
-
817 #endif
-
818 
- -
823 
- -
825 
- -
828 
- -
831 
- -
834 
- -
837 
- -
840 
- -
843 
- -
846 
-
847  typedef struct {
- -
849  uint32_t index;
-
850  } FLPathComponent;
-
851 
- - -
855  size_t* outDepth) FLAPI;
-
856 
- -
859 
- -
862 
-
863 
-
865 
-
866 
-
884 #ifndef FL_IMPL
-
885  typedef struct _FLKeyPath* FLKeyPath;
-
886 #endif
-
887 
- -
890 
- -
893 
- -
896 
- -
901  FLError* FL_NULLABLE outError) FLAPI;
-
902 
- -
905 
- -
908 
- -
911  size_t i,
-
912  FLSlice *outDictKey,
-
913  int32_t *outArrayIndex) FLAPI;
-
914 
-
916 
-
917 
- -
940 
-
941  typedef bool (*FLSharedKeysReadCallback)(void* FL_NULLABLE context, FLSharedKeys);
-
942 
- -
944  void* FL_NULLABLE context) FLAPI;
-
945 
- -
948 
- -
951 
- -
955 
- -
959 
- -
966 
- -
969 
- -
973 
- -
976 
- -
979 
- -
982 
-
983 
-
984  typedef struct _FLSharedKeyScope* FLSharedKeyScope;
- - -
987 
-
988 
-
990 
-
991 
-
1007  typedef enum {
- - - - -
1012 
-
1013 
- -
1016 
- -
1025  size_t reserveSize,
-
1026  bool uniqueStrings) FLAPI;
-
1027 
-
1029  FLEncoder FLEncoder_NewWritingToFile(FILE*, bool uniqueStrings) FLAPI;
-
1030 
- -
1033 
- -
1036 
- -
1039 
- -
1042 
-
1043 
- -
1059  bool reuseStrings, bool externPointers) FLAPI;
-
1060 
- -
1063 
- -
1067 
- -
1071 
- -
1074 
- -
1078 
- -
1091 
- -
1097 
- -
1100 
- -
1105 
- -
1110 
- -
1117 
- -
1123 
- -
1128 
-
1136  bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC) FLAPI;
-
1137 
- -
1142 
- -
1148 
-
1149 
-
1155  bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount) FLAPI;
-
1156 
- -
1159 
-
1160 
-
1169  bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount) FLAPI;
-
1170 
- -
1173 
- -
1177 
- -
1180 
-
1181 
- -
1184 
-
1185 
- -
1190 
-
1194  void FLEncoder_WriteValueAgain(FLEncoder, intptr_t preWrittenValue);
-
1195 
-
1196 
- -
1202 
-
1203 
- -
1208 
- -
1215 
- - -
1221 
- - -
1226 
- -
1233 
- -
1236 
-
1242 
-
1243 
- -
1261  FLValue FL_NULLABLE nuu) FLAPI;
-
1262 
- -
1271  FLValue FL_NULLABLE nuu,
-
1272  FLEncoder jsonEncoder) FLAPI;
-
1273 
-
1274 
- -
1284  FLSlice jsonDelta,
-
1285  FLError* FL_NULLABLE outError) FLAPI;
-
1286 
- -
1297  FLSlice jsonDelta,
-
1298  FLEncoder encoder) FLAPI;
-
1299 
-
1300 
-
1302 
-
1303 
- - -
1325 
- - -
1332 
- - -
1339 
-
1340 
- - -
1343  void FLSlot_SetInt(FLSlot, int64_t) FLAPI;
-
1344  void FLSlot_SetUInt(FLSlot, uint64_t) FLAPI;
- - - - - -
1350 
-
1351  static inline void FLSlot_SetArray(FLSlot slot, FLArray array) {
-
1352  FLSlot_SetValue(slot, (FLValue)array);
-
1353  }
-
1354 
-
1355  static inline void FLSlot_SetDict(FLSlot slot, FLDict dict) {
-
1356  FLSlot_SetValue(slot, (FLValue)dict);
-
1357  }
-
1358 
-
1359 
-
1360  // implementations of the inline methods declared earlier:
-
1361 
-
1362  static inline void FLMutableArray_SetNull(FLMutableArray a, uint32_t index) {
- -
1364  }
-
1365  static inline void FLMutableArray_SetBool(FLMutableArray a, uint32_t index, bool val) {
-
1366  FLSlot_SetBool(FLMutableArray_Set(a, index), val);
-
1367  }
-
1368  static inline void FLMutableArray_SetInt(FLMutableArray a, uint32_t index, int64_t val) {
-
1369  FLSlot_SetInt(FLMutableArray_Set(a, index), val);
-
1370  }
-
1371  static inline void FLMutableArray_SetUInt(FLMutableArray a, uint32_t index, uint64_t val) {
-
1372  FLSlot_SetUInt(FLMutableArray_Set(a, index), val);
-
1373  }
-
1374  static inline void FLMutableArray_SetFloat(FLMutableArray a, uint32_t index, float val) {
-
1375  FLSlot_SetFloat(FLMutableArray_Set(a, index), val);
-
1376  }
-
1377  static inline void FLMutableArray_SetDouble(FLMutableArray a, uint32_t index, double val) {
-
1378  FLSlot_SetDouble(FLMutableArray_Set(a, index), val);
-
1379  }
-
1380  static inline void FLMutableArray_SetString(FLMutableArray a, uint32_t index, FLString val) {
-
1381  FLSlot_SetString(FLMutableArray_Set(a, index), val);
-
1382  }
-
1383  static inline void FLMutableArray_SetData(FLMutableArray a, uint32_t index, FLSlice val) {
-
1384  FLSlot_SetData(FLMutableArray_Set(a, index), val);
-
1385  }
-
1386  static inline void FLMutableArray_SetValue(FLMutableArray a, uint32_t index, FLValue val) {
-
1387  FLSlot_SetValue(FLMutableArray_Set(a, index), val);
-
1388  }
-
1389  static inline void FLMutableArray_SetArray(FLMutableArray a, uint32_t index, FLArray val) {
-
1390  FLSlot_SetValue(FLMutableArray_Set(a, index), (FLValue)val);
-
1391  }
-
1392  static inline void FLMutableArray_SetDict(FLMutableArray a, uint32_t index, FLDict val) {
-
1393  FLSlot_SetValue(FLMutableArray_Set(a, index), (FLValue)val);
-
1394  }
-
1395 
- - -
1398  }
-
1399  static inline void FLMutableArray_AppendBool(FLMutableArray a, bool val) {
- -
1401  }
-
1402  static inline void FLMutableArray_AppendInt(FLMutableArray a, int64_t val) {
- -
1404  }
-
1405  static inline void FLMutableArray_AppendUInt(FLMutableArray a, uint64_t val) {
- -
1407  }
-
1408  static inline void FLMutableArray_AppendFloat(FLMutableArray a, float val) {
- -
1410  }
-
1411  static inline void FLMutableArray_AppendDouble(FLMutableArray a, double val) {
- -
1413  }
- - -
1416  }
-
1417  static inline void FLMutableArray_AppendData(FLMutableArray a, FLSlice val) {
- -
1419  }
- - -
1422  }
- - -
1425  }
-
1426  static inline void FLMutableArray_AppendDict(FLMutableArray a, FLDict val) {
- -
1428  }
-
1429 
-
1430  static inline void FLMutableDict_SetNull(FLMutableDict d, FLString key) {
- -
1432  }
-
1433  static inline void FLMutableDict_SetBool(FLMutableDict d, FLString key, bool val) {
-
1434  FLSlot_SetBool(FLMutableDict_Set(d, key), val);
-
1435  }
-
1436  static inline void FLMutableDict_SetInt(FLMutableDict d, FLString key, int64_t val) {
-
1437  FLSlot_SetInt(FLMutableDict_Set(d, key), val);
-
1438  }
-
1439  static inline void FLMutableDict_SetUInt(FLMutableDict d, FLString key, uint64_t val) {
-
1440  FLSlot_SetUInt(FLMutableDict_Set(d, key), val);
-
1441  }
-
1442  static inline void FLMutableDict_SetFloat(FLMutableDict d, FLString key, float val) {
-
1443  FLSlot_SetFloat(FLMutableDict_Set(d, key), val);
-
1444  }
-
1445  static inline void FLMutableDict_SetDouble(FLMutableDict d, FLString key, double val) {
-
1446  FLSlot_SetDouble(FLMutableDict_Set(d, key), val);
-
1447  }
-
1448  static inline void FLMutableDict_SetString(FLMutableDict d, FLString key, FLString val) {
-
1449  FLSlot_SetString(FLMutableDict_Set(d, key), val);
-
1450  }
-
1451  static inline void FLMutableDict_SetData(FLMutableDict d, FLString key, FLSlice val) {
-
1452  FLSlot_SetData(FLMutableDict_Set(d, key), val);
-
1453  }
-
1454  static inline void FLMutableDict_SetValue(FLMutableDict d, FLString key, FLValue val) {
-
1455  FLSlot_SetValue(FLMutableDict_Set(d, key), val);
-
1456  }
-
1457  static inline void FLMutableDict_SetArray(FLMutableDict d, FLString key, FLArray val) {
-
1458  FLSlot_SetValue(FLMutableDict_Set(d, key), (FLValue)val);
-
1459  }
-
1460  static inline void FLMutableDict_SetDict(FLMutableDict d, FLString key, FLDict val) {
-
1461  FLSlot_SetValue(FLMutableDict_Set(d, key), (FLValue)val);
-
1462  }
-
1463 
-
1464 
-
1467 #ifdef __cplusplus
-
1468 }
-
1469 #endif
-
1470 
- -
1472 
-
1473 #ifdef __OBJC__
-
1474 // When compiling as Objective-C, include CoreFoundation / Objective-C utilities:
-
1475 #include "Fleece+CoreFoundation.h"
-
1476 #endif
-
1477 
-
1478 #endif // _FLEECE_H
-
#define FL_NONNULL
Definition: Base.h:75
-
#define FL_NULLABLE
Definition: Base.h:74
-
#define FL_ASSUME_NONNULL_BEGIN
Definition: Base.h:72
-
#define FLPURE
Definition: Base.h:110
-
#define FL_ASSUME_NONNULL_END
Definition: Base.h:73
-
#define MUST_USE_RESULT
Definition: Base.h:53
- -
#define FLAPI
Definition: FLSlice.h:31
+Go to the documentation of this file.
1//
+
2// Fleece.h
+
3//
+
4// Copyright 2016-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#ifndef _FLEECE_H
+
15#define _FLEECE_H
+
16
+
17// This "umbrella header" includes the commonly-used parts of the Fleece C API.
+
18
+
19#include "FLBase.h"
+
20#include "FLCollections.h"
+
21#include "FLDeepIterator.h"
+
22#include "FLDoc.h"
+
23#include "FLEncoder.h"
+
24#include "FLJSON.h"
+
25#include "FLKeyPath.h"
+
26#include "FLMutable.h"
+
27#include "FLValue.h"
+
28
+
29// #include "FLExpert.h" -- advanced & rarely-used functionality
+
30
+
31#ifdef __OBJC__
+
32 // When compiling as Objective-C, include CoreFoundation / Objective-C utilities:
+ +
34#endif
+
35
+
36#endif // _FLEECE_H
+ + + + + + + + + -
#define FLEECE_PUBLIC
Definition: Fleece.h:33
-
FLMutableArray FL_NULLABLE FLMutableArray_GetMutableArray(FLMutableArray FL_NULLABLE, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
-
static void FLMutableArray_SetInt(FLMutableArray, uint32_t index, int64_t)
Stores an integer into an array.
Definition: Fleece.h:1368
-
FLMutableArray FL_NULLABLE FLMutableArray_New(void)
Creates a new empty mutable Array.
-
FLCopyFlags
Definition: Fleece.h:470
-
uint32_t FLArray_Count(FLArray FL_NULLABLE) FLPURE
Returns the number of items in an array, or 0 if the pointer is NULL.
-
static void FLMutableArray_AppendDict(FLMutableArray, FLDict)
Appends a Fleece dictionary to an array.
Definition: Fleece.h:1426
-
static void FLMutableArray_SetArray(FLMutableArray, uint32_t index, FLArray)
Stores a Fleece array into an array.
Definition: Fleece.h:1389
-
FLMutableArray FL_NULLABLE FLMutableArray_NewFromJSON(FLString json, FLError *FL_NULLABLE outError)
Creates a new mutable Array from JSON.
-
static void FLMutableArray_AppendDouble(FLMutableArray, double)
Appends a 64-bit floating point number to an array.
Definition: Fleece.h:1411
-
static void FLMutableArray_SetUInt(FLMutableArray, uint32_t index, uint64_t)
Stores an unsigned integer into an array.
Definition: Fleece.h:1371
-
uint32_t FLArrayIterator_GetCount(const FLArrayIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
-
FLMutableArray FL_NULLABLE FLArray_AsMutable(FLArray FL_NULLABLE) FLPURE
If the array is mutable, returns it cast to FLMutableArray, else NULL.
-
static void FLMutableArray_AppendUInt(FLMutableArray, uint64_t)
Appends an unsigned integer to an array.
Definition: Fleece.h:1405
-
FLArray FL_NULLABLE FLMutableArray_GetSource(FLMutableArray FL_NULLABLE)
If the Array was created by FLArray_MutableCopy, returns the original source Array.
-
static void FLMutableArray_SetFloat(FLMutableArray, uint32_t index, float)
Stores a 32-bit floating-point number into an array.
Definition: Fleece.h:1374
-
static void FLMutableArray_SetDict(FLMutableArray, uint32_t index, FLDict)
Stores a Fleece dictionary into an array.
Definition: Fleece.h:1392
-
static void FLMutableArray_AppendInt(FLMutableArray, int64_t)
Appends an integer to an array.
Definition: Fleece.h:1402
-
static void FLMutableArray_SetString(FLMutableArray, uint32_t index, FLString)
Stores a UTF-8-encoded string into an array.
Definition: Fleece.h:1380
-
bool FLMutableArray_IsChanged(FLMutableArray FL_NULLABLE)
Returns true if the Array has been changed from the source it was copied from.
-
static void FLMutableArray_AppendBool(FLMutableArray, bool)
Appends a boolean value to an array.
Definition: Fleece.h:1399
-
static void FLMutableArray_AppendString(FLMutableArray, FLString)
Appends a UTF-8-encoded string to an array.
Definition: Fleece.h:1414
-
FLValue FL_NULLABLE FLArrayIterator_GetValueAt(const FLArrayIterator *, uint32_t offset) FLPURE
Returns a value in the array at the given offset from the current value.
-
void FLMutableArray_Resize(FLMutableArray FL_NULLABLE array, uint32_t size)
Changes the size of an array.
-
FLValue FL_NULLABLE FLArray_Get(FLArray FL_NULLABLE, uint32_t index) FLPURE
Returns an value at an array index, or NULL if the index is out of range.
-
static void FLMutableArray_SetDouble(FLMutableArray, uint32_t index, double)
Stores a 64-bit floating point number into an array.
Definition: Fleece.h:1377
-
bool FLArray_IsEmpty(FLArray FL_NULLABLE) FLPURE
Returns true if an array is empty (or NULL).
-
static void FLMutableArray_AppendValue(FLMutableArray, FLValue)
Appends a Fleece value to an array.
Definition: Fleece.h:1420
-
static void FLMutableArray_SetData(FLMutableArray, uint32_t index, FLSlice)
Stores a binary data blob into an array.
Definition: Fleece.h:1383
-
static void FLMutableArray_Release(FLMutableArray FL_NULLABLE d)
Decrements the refcount of (and possibly frees) a mutable Array.
Definition: Fleece.h:504
-
FLEECE_PUBLIC const FLArray kFLEmptyArray
-
static void FLMutableArray_SetBool(FLMutableArray, uint32_t index, bool)
Stores a boolean value into an array.
Definition: Fleece.h:1365
-
FLMutableDict FL_NULLABLE FLMutableArray_GetMutableDict(FLMutableArray FL_NULLABLE, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
-
void FLMutableArray_Remove(FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
Removes contiguous items from the array.
-
void FLMutableArray_SetChanged(FLMutableArray FL_NULLABLE, bool)
Sets or clears the mutable Array's "changed" flag.
-
static void FLMutableArray_AppendNull(FLMutableArray)
Appends a JSON null value to an array.
Definition: Fleece.h:1396
-
void FLArrayIterator_Begin(FLArray FL_NULLABLE, FLArrayIterator *)
Initializes a FLArrayIterator struct to iterate over an array.
-
static FLMutableArray FL_NULLABLE FLMutableArray_Retain(FLMutableArray FL_NULLABLE d)
Increments the ref-count of a mutable Array.
Definition: Fleece.h:500
-
bool FLArrayIterator_Next(FLArrayIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
static void FLMutableArray_SetNull(FLMutableArray, uint32_t index)
Stores a JSON null value into an array.
Definition: Fleece.h:1362
-
FLMutableArray FL_NULLABLE FLArray_MutableCopy(FLArray FL_NULLABLE, FLCopyFlags)
Creates a new mutable Array that's a copy of the source Array.
-
static void FLMutableArray_AppendData(FLMutableArray, FLSlice)
Appends a binary data blob to an array.
Definition: Fleece.h:1417
-
void FLMutableArray_Insert(FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
Inserts a contiguous range of JSON null values into the array.
-
static void FLMutableArray_AppendFloat(FLMutableArray, float)
Appends a 32-bit floating-point number to an array.
Definition: Fleece.h:1408
-
static void FLMutableArray_SetValue(FLMutableArray, uint32_t index, FLValue)
Stores a Fleece value into an array.
Definition: Fleece.h:1386
-
static void FLMutableArray_AppendArray(FLMutableArray, FLArray)
Appends a Fleece array to an array.
Definition: Fleece.h:1423
-
FLValue FL_NULLABLE FLArrayIterator_GetValue(const FLArrayIterator *) FLPURE
Returns the current value being iterated over.
-
@ kFLDeepCopy
Definition: Fleece.h:472
-
@ kFLCopyImmutables
Definition: Fleece.h:473
-
@ kFLDefaultCopy
Definition: Fleece.h:471
-
@ kFLDeepCopyImmutables
Definition: Fleece.h:474
-
void FLDeepIterator_SkipChildren(FLDeepIterator)
Tells the iterator to skip the children of the current value.
-
size_t FLDeepIterator_GetDepth(FLDeepIterator)
Returns the current depth in the hierarchy, starting at 1 for the top-level children.
-
FLSlice FLDeepIterator_GetKey(FLDeepIterator)
Returns the key of the current value in its parent, or an empty slice if not in a dictionary.
-
struct _FLDeepIterator * FLDeepIterator
A reference to a deep iterator.
Definition: Fleece.h:816
-
FLValue FL_NULLABLE FLDeepIterator_GetParent(FLDeepIterator)
Returns the parent/container of the current value, or NULL at the end of iteration.
-
FLValue FL_NULLABLE FLDeepIterator_GetValue(FLDeepIterator)
Returns the current value being iterated over.
-
bool FLDeepIterator_Next(FLDeepIterator)
Advances the iterator to the next value, or returns false if at the end.
-
uint32_t FLDeepIterator_GetIndex(FLDeepIterator)
Returns the array index of the current value in its parent, or 0 if not in an array.
-
void FLDeepIterator_Free(FLDeepIterator FL_NULLABLE)
-
FLSliceResult FLDeepIterator_GetJSONPointer(FLDeepIterator)
Returns the current path in JSONPointer format (RFC 6901).
-
FLDeepIterator FLDeepIterator_New(FLValue FL_NULLABLE)
Creates a FLDeepIterator to iterate over a dictionary.
-
FLSliceResult FLDeepIterator_GetPathString(FLDeepIterator)
Returns the current path in JavaScript format.
-
void FLDeepIterator_GetPath(FLDeepIterator, FLPathComponent *FL_NONNULL *FL_NONNULL outPath, size_t *outDepth)
Returns the path as an array of FLPathComponents.
-
FLDict FL_NULLABLE FLMutableDict_GetSource(FLMutableDict FL_NULLABLE)
If the Dict was created by FLDict_MutableCopy, returns the original source Dict.
-
uint32_t FLDict_Count(FLDict FL_NULLABLE) FLPURE
Returns the number of items in a dictionary, or 0 if the pointer is NULL.
-
FLString FLDictKey_GetString(const FLDictKey *)
Returns the string value of the key (which it was initialized with.)
-
static void FLMutableDict_SetDict(FLMutableDict, FLString key, FLDict)
Stores a Fleece dictionary into a mutable dictionary.
Definition: Fleece.h:1460
-
static void FLMutableDict_SetNull(FLMutableDict, FLString key)
Stores a JSON null value into a mutable dictionary.
Definition: Fleece.h:1430
-
bool FLMutableDict_IsChanged(FLMutableDict FL_NULLABLE)
Returns true if the Dict has been changed from the source it was copied from.
-
FLMutableDict FL_NULLABLE FLDict_AsMutable(FLDict FL_NULLABLE) FLPURE
If the dictionary is mutable, returns it cast to FLMutableDict, else NULL.
-
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
-
FLMutableDict FL_NULLABLE FLMutableDict_NewFromJSON(FLString json, FLError *FL_NULLABLE outError)
Creates a new mutable Dict from json.
-
static void FLMutableDict_SetData(FLMutableDict, FLString key, FLSlice)
Stores a binary data blob into a mutable dictionary.
Definition: Fleece.h:1451
-
static void FLMutableDict_Release(FLMutableDict FL_NULLABLE d)
Decrements the refcount of (and possibly frees) a mutable Dict.
Definition: Fleece.h:743
-
void FLMutableDict_Remove(FLMutableDict FL_NULLABLE, FLString key)
Removes the value for a key.
-
uint32_t FLDictIterator_GetCount(const FLDictIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
-
FLEECE_PUBLIC const FLDict kFLEmptyDict
-
FLMutableDict FL_NULLABLE FLMutableDict_New(void)
Creates a new empty mutable Dict.
-
FLMutableDict FL_NULLABLE FLDict_MutableCopy(FLDict FL_NULLABLE source, FLCopyFlags)
Creates a new mutable Dict that's a copy of the source Dict.
-
FLValue FL_NULLABLE FLDictIterator_GetKey(const FLDictIterator *) FLPURE
Returns the current key being iterated over.
-
static FLMutableDict FL_NULLABLE FLMutableDict_Retain(FLMutableDict FL_NULLABLE d)
Increments the ref-count of a mutable Dict.
Definition: Fleece.h:738
-
void FLDictIterator_End(FLDictIterator *)
Cleans up after an iterator.
-
static void FLMutableDict_SetFloat(FLMutableDict, FLString key, float)
Stores a 32-bit floating-point number into a mutable dictionary.
Definition: Fleece.h:1442
-
static void FLMutableDict_SetInt(FLMutableDict, FLString key, int64_t)
Stores an integer into a mutable dictionary.
Definition: Fleece.h:1436
-
static void FLMutableDict_SetValue(FLMutableDict, FLString key, FLValue)
Stores a Fleece value into a mutable dictionary.
Definition: Fleece.h:1454
-
static void FLMutableDict_SetDouble(FLMutableDict, FLString key, double)
Stores a 64-bit floating point number into a mutable dictionary.
Definition: Fleece.h:1445
-
FLValue FL_NULLABLE FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
-
bool FLDict_IsEmpty(FLDict FL_NULLABLE) FLPURE
Returns true if a dictionary is empty (or NULL).
-
void FLDictIterator_Begin(FLDict FL_NULLABLE, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
-
void FLMutableDict_RemoveAll(FLMutableDict FL_NULLABLE)
Removes all keys and values.
-
FLMutableDict FL_NULLABLE FLMutableDict_GetMutableDict(FLMutableDict FL_NULLABLE, FLString key)
Convenience function for getting a dict-valued property in mutable form.
-
static void FLMutableDict_SetBool(FLMutableDict, FLString key, bool)
Stores a boolean value into a mutable dictionary.
Definition: Fleece.h:1433
-
static void FLMutableDict_SetArray(FLMutableDict, FLString key, FLArray)
Stores a Fleece array into a mutable dictionary.
Definition: Fleece.h:1457
-
void FLMutableDict_SetChanged(FLMutableDict FL_NULLABLE, bool)
Sets or clears the mutable Dict's "changed" flag.
-
static void FLMutableDict_SetString(FLMutableDict, FLString key, FLString)
Stores a UTF-8-encoded string into a mutable dictionary.
Definition: Fleece.h:1448
-
FLValue FL_NULLABLE FLDict_Get(FLDict FL_NULLABLE, FLSlice keyString) FLPURE
Looks up a key in a dictionary, returning its value.
-
FLMutableArray FL_NULLABLE FLMutableDict_GetMutableArray(FLMutableDict FL_NULLABLE, FLString key)
Convenience function for getting an array-valued property in mutable form.
-
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
FLValue FL_NULLABLE FLDict_GetWithKey(FLDict FL_NULLABLE, FLDictKey *)
Looks up a key in a dictionary using an FLDictKey.
-
FLDictKey FLDictKey_Init(FLSlice string)
Initializes an FLDictKey struct with a key string.
-
static void FLMutableDict_SetUInt(FLMutableDict, FLString key, uint64_t)
Stores an unsigned integer into a mutable dictionary.
Definition: Fleece.h:1439
-
bool FLEncoder_ConvertJSON(FLEncoder, FLSlice json)
Parses JSON data and writes the object(s) to the encoder.
-
bool FLEncoder_WriteUInt(FLEncoder, uint64_t)
Writes an unsigned integer to an encoder.
-
const char *FL_NULLABLE FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
-
FLEncoder FLEncoder_NewWritingToFile(FILE *, bool uniqueStrings)
Creates a new Fleece encoder that writes to a file, not to memory.
-
MUST_USE_RESULT FLSliceResult FLEncoder_Finish(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded data, else null.
-
void FLEncoder_SuppressTrailer(FLEncoder)
Tells the encoder not to write the two-byte Fleece trailer at the end of the data.
-
bool FLEncoder_WriteKey(FLEncoder, FLString)
Specifies the key for the next value to be written to the current dictionary.
-
FLEncoder FLEncoder_New(void)
Creates a new encoder, for generating Fleece data.
-
FLSlice FLEncoder_GetBase(FLEncoder)
Returns the base value passed to FLEncoder_Amend.
-
void * FLEncoder_GetExtraInfo(FLEncoder)
Returns the user-defined value associated with the encoder; NULL by default.
-
bool FLEncoder_WriteInt(FLEncoder, int64_t)
Writes an integer to an encoder.
-
bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount)
Begins writing an array value to an encoder.
-
bool FLEncoder_WriteUndefined(FLEncoder)
Writes an undefined value to an encoder.
-
bool FLEncoder_WriteFloat(FLEncoder, float)
Writes a 32-bit floating point number to an encoder.
-
bool FLEncoder_WriteBool(FLEncoder, bool)
Writes a boolean value (true or false) to an encoder.
-
bool FLEncoder_WriteDouble(FLEncoder, double)
Writes a 64-bit floating point number to an encoder.
-
void FLEncoder_WriteValueAgain(FLEncoder, intptr_t preWrittenValue)
Writes another reference (a "pointer") to an already-written value, given a reference previously retu...
-
bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC)
Writes a timestamp to an encoder, as an ISO-8601 date string.
-
size_t FLEncoder_GetNextWritePos(FLEncoder)
Returns the byte offset in the encoded data where the next value will be written.
-
FLSliceResult FLEncoder_Snip(FLEncoder)
Returns the data written so far as a standalone Fleece document, whose root is the last value written...
-
void FLEncoder_Amend(FLEncoder e, FLSlice base, bool reuseStrings, bool externPointers)
Tells the encoder to logically append to the given Fleece document, rather than making a standalone d...
-
intptr_t FLEncoder_LastValueWritten(FLEncoder)
Returns an opaque reference to the last complete value written to the encoder, if possible.
-
bool FLEncoder_WriteNull(FLEncoder)
Writes a null value to an encoder.
-
bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount)
Begins writing a dictionary value to an encoder.
-
void FLEncoder_SetSharedKeys(FLEncoder, FLSharedKeys FL_NULLABLE)
Tells the encoder to use a shared-keys mapping when encoding dictionary keys.
-
void FLEncoder_Free(FLEncoder FL_NULLABLE)
Frees the space used by an encoder.
-
size_t FLEncoder_BytesWritten(FLEncoder)
Returns the number of bytes encoded so far.
-
bool FLEncoder_WriteData(FLEncoder, FLSlice)
Writes a binary data value (a blob) to an encoder.
-
size_t FLEncoder_FinishItem(FLEncoder)
Finishes encoding the current item, and returns its offset in the output data.
-
bool FLEncoder_WriteValue(FLEncoder, FLValue)
Writes a Fleece Value to an Encoder.
-
bool FLEncoder_WriteString(FLEncoder, FLString)
Writes a string to an encoder.
-
bool FLEncoder_WriteKeyValue(FLEncoder, FLValue)
Specifies the key for the next value to be written to the current dictionary.
-
FLEncoderFormat
Output formats a FLEncoder can generate.
Definition: Fleece.h:1007
-
bool FLEncoder_EndDict(FLEncoder)
Ends writing a dictionary value; pops back the previous encoding state.
-
void FLEncoder_Reset(FLEncoder)
Resets the state of an encoder without freeing it.
-
FLEncoder FLEncoder_NewWithOptions(FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
Creates a new encoder, allowing some options to be customized.
-
FLError FLEncoder_GetError(FLEncoder)
Returns the error code of an encoder, or NoError (0) if there's no error.
-
void FLEncoder_SetExtraInfo(FLEncoder, void *FL_NULLABLE info)
Associates an arbitrary user-defined value with the encoder.
-
bool FLEncoder_EndArray(FLEncoder)
Ends writing an array value; pops back the previous encoding state.
-
bool FLEncoder_WriteRaw(FLEncoder, FLSlice)
Writes raw data directly to the encoded output.
-
MUST_USE_RESULT FLDoc FL_NULLABLE FLEncoder_FinishDoc(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc.
-
@ kFLEncodeFleece
Fleece encoding.
Definition: Fleece.h:1008
-
@ kFLEncodeJSON5
JSON5, an extension of JSON with a more readable syntax
Definition: Fleece.h:1010
-
@ kFLEncodeJSON
JSON encoding.
Definition: Fleece.h:1009
-
bool FLKeyPath_GetElement(FLKeyPath, size_t i, FLSlice *outDictKey, int32_t *outArrayIndex)
Returns an element of a path, either a key or an array index.
-
struct _FLKeyPath * FLKeyPath
A reference to a key path.
Definition: Fleece.h:885
-
bool FLKeyPath_Equals(FLKeyPath path1, FLKeyPath path2)
Equality test.
-
FLValue FL_NULLABLE FLKeyPath_Eval(FLKeyPath, FLValue root)
Evaluates a compiled key-path for a given Fleece root object.
-
FLStringResult FLKeyPath_ToString(FLKeyPath path)
Returns a path in string form.
-
FLKeyPath FL_NULLABLE FLKeyPath_New(FLSlice specifier, FLError *FL_NULLABLE outError)
Creates a new FLKeyPath object by compiling a path specifier string.
-
FLValue FL_NULLABLE FLKeyPath_EvalOnce(FLSlice specifier, FLValue root, FLError *FL_NULLABLE outError)
Evaluates a key-path from a specifier string, for a given Fleece root object.
-
void FLKeyPath_Free(FLKeyPath FL_NULLABLE)
Frees a compiled FLKeyPath object.
-
FLString FLSharedKeys_Decode(FLSharedKeys, int key)
Returns the key string that maps to the given integer key, else NULL.
-
FLSharedKeyScope FLSharedKeyScope_WithRange(FLSlice range, FLSharedKeys)
-
FLSharedKeys FL_NULLABLE FLSharedKeys_Retain(FLSharedKeys FL_NULLABLE)
Increments the reference count of an FLSharedKeys.
-
struct _FLSharedKeyScope * FLSharedKeyScope
Definition: Fleece.h:984
-
int FLSharedKeys_Encode(FLSharedKeys, FLString, bool add)
Maps a key string to a number in the range [0...2047], or returns -1 if it isn't mapped.
-
FLSliceResult FLSharedKeys_GetStateData(FLSharedKeys)
Returns a data blob containing the current state (all the keys and their integers....
-
void FLSharedKeys_WriteState(FLSharedKeys, FLEncoder)
Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed...
-
bool FLSharedKeys_LoadState(FLSharedKeys, FLValue)
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_Wr...
-
FLSharedKeys FLSharedKeys_NewWithRead(FLSharedKeysReadCallback, void *FL_NULLABLE context)
-
void FLSharedKeys_RevertToCount(FLSharedKeys, unsigned oldCount)
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount.
-
FLSharedKeys FLSharedKeys_New(void)
Creates a new empty FLSharedKeys object, which must eventually be released.
-
unsigned FLSharedKeys_Count(FLSharedKeys)
Returns the number of keys in the mapping.
-
bool FLSharedKeys_LoadStateData(FLSharedKeys, FLSlice)
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData.
-
bool(* FLSharedKeysReadCallback)(void *FL_NULLABLE context, FLSharedKeys)
Definition: Fleece.h:941
-
void FLSharedKeys_Release(FLSharedKeys FL_NULLABLE)
Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero.
-
void FLSharedKeyScope_Free(FLSharedKeyScope FL_NULLABLE)
-
FLValueType
Types of Fleece values.
Definition: Fleece.h:263
-
FLValue FL_NULLABLE FLValue_NewData(FLSlice)
Allocates a data/blob value on the heap.
-
int64_t FLValue_AsInt(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to an integer.
-
static void FLDict_Release(FLDict FL_NULLABLE v)
Definition: Fleece.h:369
-
FLTimestamp FLValue_AsTimestamp(FLValue FL_NULLABLE) FLPURE
Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure.
-
int64_t FLTimestamp
A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC....
Definition: Fleece.h:276
-
bool FLValue_IsEqual(FLValue FL_NULLABLE v1, FLValue FL_NULLABLE v2) FLPURE
Compares two values for equality.
-
static void FLArray_Release(FLArray FL_NULLABLE v)
Definition: Fleece.h:367
-
FLString FLValue_AsString(FLValue FL_NULLABLE) FLPURE
Returns the exact contents of a string value, or null for all other types.
-
FLArray FL_NULLABLE FLValue_AsArray(FLValue FL_NULLABLE) FLPURE
If a FLValue represents an array, returns it cast to FLArray, else NULL.
-
bool FLValue_IsUnsigned(FLValue FL_NULLABLE) FLPURE
Returns true if the value is non-NULL and represents an integer >= 2^63.
-
float FLValue_AsFloat(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to a 32-bit floating point number.
-
FLStringResult FLValue_ToString(FLValue FL_NULLABLE)
Returns a string representation of any scalar value.
-
static FLArray FL_NULLABLE FLArray_Retain(FLArray FL_NULLABLE v)
Definition: Fleece.h:366
-
FLSlice FLValue_AsData(FLValue FL_NULLABLE) FLPURE
Returns the exact contents of a data value, or null for all other types.
-
FLEECE_PUBLIC const FLValue kFLNullValue
A constant null value (not a NULL pointer!)
-
bool FLValue_AsBool(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to boolean.
-
static FLDict FL_NULLABLE FLDict_Retain(FLDict FL_NULLABLE v)
Definition: Fleece.h:368
-
bool FLValue_IsDouble(FLValue FL_NULLABLE)
Returns true if the value is non-NULL and represents a 64-bit floating-point number.
-
bool FLValue_IsInteger(FLValue FL_NULLABLE) FLPURE
Returns true if the value is non-NULL and represents an integer.
-
FLDict FL_NULLABLE FLValue_AsDict(FLValue FL_NULLABLE) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
-
bool FLValue_IsMutable(FLValue FL_NULLABLE) FLPURE
Returns true if the value is mutable.
-
FLEECE_PUBLIC const FLValue kFLUndefinedValue
A constant undefined value.
-
FLValueType FLValue_GetType(FLValue FL_NULLABLE) FLPURE
Returns the data type of an arbitrary Value.
-
void FLValue_Release(FLValue FL_NULLABLE)
If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero t...
-
FLValue FL_NULLABLE FLValue_Retain(FLValue FL_NULLABLE)
If this value is mutable (and thus heap-based) its ref-count is incremented.
-
double FLValue_AsDouble(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to a 32-bit floating point number.
-
uint64_t FLValue_AsUnsigned(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to an unsigned integer.
-
FLValue FL_NULLABLE FLValue_NewString(FLString)
Allocates a string value on the heap.
-
@ kFLArray
An array of values.
Definition: Fleece.h:270
-
@ kFLNumber
A numeric value, either integer or floating-point.
Definition: Fleece.h:267
-
@ kFLBoolean
A true or false value.
Definition: Fleece.h:266
-
@ kFLString
A string.
Definition: Fleece.h:268
-
@ kFLNull
Equivalent to a JSON 'null'.
Definition: Fleece.h:265
-
@ kFLUndefined
Type of a NULL pointer, i.e. no such value, like JSON undefined. Also the type of a value created by ...
Definition: Fleece.h:264
-
@ kFLDict
A mapping of strings to values.
Definition: Fleece.h:271
-
@ kFLData
Binary data (no JSON equivalent)
Definition: Fleece.h:269
-
void FLSlot_SetValue(FLSlot, FLValue)
Stores an FLValue into a slot.
-
void FLSlot_SetNull(FLSlot)
Stores a JSON null into a slot.
-
MUST_USE_RESULT FLSlot FLMutableDict_Set(FLMutableDict, FLString key)
Returns an FLSlot that refers to the given key/value pair of the given dictionary.
-
static void FLSlot_SetArray(FLSlot slot, FLArray array)
Definition: Fleece.h:1351
-
static void FLSlot_SetDict(FLSlot slot, FLDict dict)
Definition: Fleece.h:1355
-
void FLSlot_SetBool(FLSlot, bool)
Stores a boolean into a slot.
-
void FLSlot_SetInt(FLSlot, int64_t)
Stores an integer into a slot.
-
void FLSlot_SetUInt(FLSlot, uint64_t)
Stores an unsigned int into a slot.
-
void FLSlot_SetString(FLSlot, FLString)
Stores a UTF-8 string into a slot.
-
MUST_USE_RESULT FLSlot FLMutableArray_Set(FLMutableArray, uint32_t index)
Returns an FLSlot that refers to the given index of the given array.
-
void FLSlot_SetData(FLSlot, FLSlice)
Stores a data blob into a slot.
-
MUST_USE_RESULT FLSlot FLMutableArray_Append(FLMutableArray)
Appends a null value to the array and returns an FLSlot that refers to that position.
-
void FLSlot_SetFloat(FLSlot, float)
Stores a float into a slot.
-
void FLSlot_SetDouble(FLSlot, double)
Stores a double into a slot.
-
bool FLEncodeApplyingJSONDelta(FLValue FL_NULLABLE old, FLSlice jsonDelta, FLEncoder encoder)
Applies the (parsed) JSON data created by CreateJSONDelta to the value old, which must be equal to th...
-
FLSliceResult FLCreateJSONDelta(FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
Returns JSON that encodes the changes to turn the value old into nuu.
-
FLSliceResult FLApplyJSONDelta(FLValue FL_NULLABLE old, FLSlice jsonDelta, FLError *FL_NULLABLE outError)
Applies the JSON data created by CreateJSONDelta to the value old, which must be equal to the old val...
-
bool FLEncodeJSONDelta(FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu, FLEncoder jsonEncoder)
Writes JSON that describes the changes to turn the value old into nuu.
-
FLStringResult FLValue_ToJSONX(FLValue FL_NULLABLE v, bool json5, bool canonicalForm)
Most general Fleece to JSON converter.
-
const char *FL_NULLABLE FLDump(FLValue FL_NULLABLE)
Debugging function that returns a C string of JSON.
-
FLStringResult FLValue_ToJSON5(FLValue FL_NULLABLE)
Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unq...
-
const char *FL_NULLABLE FLDumpData(FLSlice data)
Debugging function that returns a C string of JSON.
-
FLStringResult FLJSON5_ToJSON(FLString json5, FLStringResult *FL_NULLABLE outErrorMessage, size_t *FL_NULLABLE outErrorPos, FLError *FL_NULLABLE outError)
Converts valid JSON5 https://json5.org to JSON.
-
FLStringResult FLValue_ToJSON(FLValue FL_NULLABLE)
Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON ...
-
FLDoc FL_NULLABLE FLValue_FindDoc(FLValue FL_NULLABLE) FLPURE
Looks up the Doc containing the Value, or NULL if the Value was created without a Doc.
-
FLSliceResult FLData_ConvertJSON(FLSlice json, FLError *FL_NULLABLE outError)
Directly converts JSON data to Fleece-encoded data.
-
FLDoc FLDoc_FromJSON(FLSlice json, FLError *FL_NULLABLE outError)
Creates an FLDoc from JSON-encoded data.
-
FLSlice FLDoc_GetData(FLDoc FL_NULLABLE) FLPURE
Returns the encoded Fleece data backing the document.
-
struct _FLDoc * FLDoc
A reference to a document.
Definition: Fleece.h:91
-
FLDoc FLDoc_FromResultData(FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other...
-
FLStringResult FLData_Dump(FLSlice data)
Produces a human-readable dump of the Value encoded in the data.
-
FLSharedKeys FLDoc_GetSharedKeys(FLDoc FL_NULLABLE) FLPURE
Returns the FLSharedKeys used by this FLDoc, as specified when it was created.
-
FLTrust
Specifies whether not input data is trusted to be 100% valid Fleece.
Definition: Fleece.h:96
-
FLValue FLDoc_GetRoot(FLDoc FL_NULLABLE) FLPURE
Returns the root value in the FLDoc, usually an FLDict.
-
void FLDoc_Release(FLDoc FL_NULLABLE)
Releases a reference to an FLDoc.
-
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: Fleece.h:92
-
FLValue FL_NULLABLE FLValue_FromData(FLSlice data, FLTrust) FLPURE
Returns a pointer to the root value in the encoded data, or NULL if validation failed.
-
void * FLDoc_GetAssociated(FLDoc FL_NULLABLE doc, const char *type) FLPURE
Returns the pointer associated with the document.
-
FLDoc FLDoc_Retain(FLDoc FL_NULLABLE)
Adds a reference to an FLDoc.
-
bool FLDoc_SetAssociated(FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
Associates an arbitrary pointer value with a document, and thus its contained values.
-
FLSliceResult FLDoc_GetAllocedData(FLDoc FL_NULLABLE) FLPURE
Returns the FLSliceResult data owned by the document, if any, else a null slice.
-
@ kFLTrusted
Input data is trusted to be valid.
Definition: Fleece.h:106
-
@ kFLUntrusted
Input data is not trusted to be valid, and will be fully validated by the API call.
Definition: Fleece.h:98
-
struct _FLDict * FLMutableDict
A reference to a mutable dictionary.
Definition: Fleece.h:56
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:53
-
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:54
-
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:55
-
FLError
Error codes returned from some API calls.
Definition: Fleece.h:62
-
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:52
-
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:57
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
-
@ kFLNotFound
Definition: Fleece.h:71
-
@ kFLInvalidData
Definition: Fleece.h:66
-
@ kFLInternalError
Definition: Fleece.h:70
-
@ kFLSharedKeysStateError
Definition: Fleece.h:72
-
@ kFLOutOfRange
Definition: Fleece.h:65
-
@ kFLEncodeError
Definition: Fleece.h:67
-
@ kFLMemoryError
Definition: Fleece.h:64
-
@ kFLUnsupported
Definition: Fleece.h:74
-
@ kFLUnknownValue
Definition: Fleece.h:69
-
@ kFLJSONError
Definition: Fleece.h:68
-
@ kFLPOSIXError
Definition: Fleece.h:73
-
@ kFLNoError
Definition: Fleece.h:63
-
Opaque array iterator.
Definition: Fleece.h:436
-
Opaque dictionary iterator.
Definition: Fleece.h:644
-
Opaque key for a dictionary.
Definition: Fleece.h:686
-
Definition: Fleece.h:847
-
uint32_t index
Array index, only if there's no key.
Definition: Fleece.h:849
-
FLSlice key
Dict key, or kFLSliceNull if none.
Definition: Fleece.h:848
-
A simple reference to a block of memory.
Definition: FLSlice.h:48
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:66
diff --git a/docs/C/html/annotated.html b/docs/C/html/annotated.html index fe32d85f2f..88bf4e3960 100644 --- a/docs/C/html/annotated.html +++ b/docs/C/html/annotated.html @@ -2,8 +2,8 @@ - - + + LiteCore: Data Structures @@ -30,21 +30,22 @@
- + +/* @license-end */ +
@@ -62,8 +63,7 @@
-
-
Data Structures
+
Data Structures
Here are the data structures with brief descriptions:
@@ -72,43 +72,45 @@  CC4BlobKeyA unique identifier of a blob based on a SHA-1 digest of its contents  CC4CollectionChangeRepresents a change to a document in a collection, as returned from c4dbobs_getChanges  CC4CollectionSpecFull identifier of a collection in a database, including its scope - CC4DatabaseConfig - CC4DatabaseConfig2Main database configuration struct (version 2) for use with c4db_openNamed etc - CC4DocPutRequestParameters for adding a revision using c4doc_put - CC4DocumentDescribes a version-controlled document - CC4DocumentEndedInformation about a document that's been pushed or pulled - CC4DocumentInfoMetadata about a document (actually about its current revision.) - CC4EncryptionKeyEncryption key specified in a C4DatabaseConfig - CC4EnumeratorOptionsOptions for enumerating over all documents - CC4ErrorAn error value - CC4ExtraInfoClient-defined metadata that can be associated with some objects like C4Database - CC4FullTextMatchInfo about a match of a full-text query term - CC4IndexOptionsOptions for indexes; these each apply to specific types of indexes - CC4ListenerConfigConfiguration for a C4Listener - CC4LogFileOptionsConfiguration for file-based logging - CC4PredictiveModelConfiguration struct for registering a predictive model - CC4ProgressRepresents the current progress of a replicator - CC4QueryEnumeratorA query result enumerator - CC4QueryOptionsOptions for running queries - CC4RawDocumentContents of a raw document - CC4ReplicatorParametersParameters describing a replication, used when creating a C4Replicator - CC4ReplicatorStatusCurrent status of replication - CC4RevisionDescribes a revision of a document - CC4SocketFactoryA group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API - CC4TLSConfigTLS configuration for C4Listener - CC4UUID - CFLArrayIteratorOpaque array iterator - CFLDictIteratorOpaque dictionary iterator - CFLDictKeyOpaque key for a dictionary - CFLPathComponent - CFLSliceA simple reference to a block of memory - CFLSliceResultA heap-allocated block of memory returned from an API call + CC4ConnectedClientParametersParameters describing a connected client, used when creating a C4ConnectedClient + CC4DatabaseConfig + CC4DatabaseConfig2Main database configuration struct (version 2) for use with c4db_openNamed etc + CC4DocPutRequestParameters for adding a revision using c4doc_put + CC4DocResponseResult of a successful c4client_getDoc call + CC4DocumentDescribes a version-controlled document + CC4DocumentEndedInformation about a document that's been pushed or pulled + CC4DocumentInfoMetadata about a document (actually about its current revision.) + CC4EncryptionKeyEncryption key specified in a C4DatabaseConfig + CC4EnumeratorOptionsOptions for enumerating over all documents + CC4ErrorAn error value + CC4ExtraInfoClient-defined metadata that can be associated with some objects like C4Database + CC4FullTextMatchInfo about a match of a full-text query term + CC4IndexOptionsOptions for indexes; these each apply to specific types of indexes + CC4ListenerConfigConfiguration for a C4Listener + CC4LogFileOptionsConfiguration for file-based logging + CC4PredictiveModelConfiguration struct for registering a predictive model + CC4ProgressRepresents the current progress of a replicator + CC4QueryEnumeratorA query result enumerator + CC4QueryOptionsOptions for running queries + CC4RawDocumentContents of a raw document + CC4ReplicatorParametersParameters describing a replication, used when creating a C4Replicator + CC4ReplicatorStatusCurrent status of replication + CC4RevisionDescribes a revision of a document + CC4SocketFactoryA group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API + CC4TLSConfigTLS configuration for C4Listener + CC4UUID + CFLArrayIteratorOpaque array iterator + CFLDictIteratorOpaque dictionary iterator + CFLDictKeyOpaque key for a dictionary + CFLPathComponent + CFLSliceA simple reference to a block of memory + CFLSliceResultA heap-allocated block of memory returned from an API call
diff --git a/docs/C/html/c4_8h.html b/docs/C/html/c4_8h.html index 930822bb54..b273178598 100644 --- a/docs/C/html/c4_8h.html +++ b/docs/C/html/c4_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4.h File Reference
+
c4.h File Reference
#include "c4BlobStore.h"
@@ -83,12 +83,13 @@ #include "c4Query.h"
#include "c4Replicator.h"
#include "c4Socket.h"
+#include "c4ConnectedClient.h"

Go to the source code of this file.

diff --git a/docs/C/html/c4_8h_source.html b/docs/C/html/c4_8h_source.html index fca82b0d6b..0348fbfc14 100644 --- a/docs/C/html/c4_8h_source.html +++ b/docs/C/html/c4_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4.h
+
c4.h
-Go to the documentation of this file.
1 //
-
2 // c4.h
-
3 //
-
4 // Copyright 2016-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 
-
15 #include "c4BlobStore.h"
-
16 #include "c4Certificate.h"
-
17 #include "c4Collection.h"
-
18 #include "c4Database.h"
-
19 #include "c4Document.h"
-
20 #include "c4Document+Fleece.h"
-
21 #include "c4DocEnumerator.h"
-
22 #include "c4Index.h"
-
23 #include "c4Listener.h"
-
24 #include "c4Observer.h"
-
25 #include "c4Query.h"
-
26 #include "c4Replicator.h"
-
27 #include "c4Socket.h"
+Go to the documentation of this file.
1//
+
2// c4.h
+
3//
+
4// Copyright 2016-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
+
15#include "c4BlobStore.h"
+
16#include "c4Certificate.h"
+
17#include "c4Collection.h"
+
18#include "c4Database.h"
+
19#include "c4Document.h"
+
20#include "c4Document+Fleece.h"
+
21#include "c4DocEnumerator.h"
+
22#include "c4Index.h"
+
23#include "c4Listener.h"
+
24#include "c4Observer.h"
+
25#include "c4Query.h"
+
26#include "c4Replicator.h"
+
27#include "c4Socket.h"
+
28#include "c4ConnectedClient.h"
+ @@ -113,7 +115,7 @@
diff --git a/docs/C/html/c4_base_8h.html b/docs/C/html/c4_base_8h.html index dea5f88bc1..893ff177f9 100644 --- a/docs/C/html/c4_base_8h.html +++ b/docs/C/html/c4_base_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Base.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Typedefs | Functions
-
-
c4Base.h File Reference
+
c4Base.h File Reference

#include "c4Compat.h"
@@ -83,13 +83,13 @@

Go to the source code of this file.

-

+

Data Structures

struct  C4ExtraInfo
 Client-defined metadata that can be associated with some objects like C4Database. More...
 
- @@ -104,7 +104,7 @@

+

Macros

#define LITECORE_VERSION   30000
 
#define kC4EnvironmentSupportedLocales   "supported_locales"
 
- @@ -133,6 +133,9 @@ + + + @@ -172,7 +175,7 @@

+

Typedefs

typedef FLSlice C4Slice
 
typedef struct C4Collection C4Collection
 Opaque handle to a namespace of documents in an opened database. More...
 
typedef struct C4ConnectedClient C4ConnectedClient
 Opaque reference to a Connected Client. More...
 
typedef struct C4Database C4Database
 Opaque handle to an opened database. More...
 
 An open stream for writing data to a blob. More...
 
- @@ -180,26 +183,30 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -256,7 +263,7 @@

+

Functions

static C4INLINE C4Slice c4str (const char *str)
 
 
static void c4slice_free (C4SliceResult s)
 
void * c4base_retain (void *obj)
 
void * c4base_retain (void *obj)
 
void c4base_release (void *obj)
 
static C4Certc4cert_retain (C4Cert *r)
 
static C4KeyPairc4keypair_retain (C4KeyPair *r)
 
static C4Databasec4db_retain (C4Database *r)
 
static C4Queryc4query_retain (C4Query *r)
 
C4Documentc4doc_retain (C4Document *)
 
C4QueryEnumeratorc4queryenum_retain (C4QueryEnumerator *)
 
C4Socketc4socket_retain (C4Socket *)
 
static C4Certc4cert_retain (C4Cert *r)
 
static C4ConnectedClientc4client_retain (C4ConnectedClient *r)
 
static C4KeyPairc4keypair_retain (C4KeyPair *r)
 
static C4Databasec4db_retain (C4Database *r)
 
static C4Queryc4query_retain (C4Query *r)
 
C4Documentc4doc_retain (C4Document *)
 
C4QueryEnumeratorc4queryenum_retain (C4QueryEnumerator *)
 
C4Socketc4socket_retain (C4Socket *)
 
static void c4cert_release (C4Cert *r)
 
static void c4client_release (C4ConnectedClient *r)
 
static void c4keypair_release (C4KeyPair *r)
 
static void c4db_release (C4Database *r)
 

Macro Definition Documentation

- +

◆ LITECORE_API_VERSION

@@ -270,7 +277,7 @@

+

◆ LITECORE_VERSION

@@ -287,7 +294,7 @@

diff --git a/docs/C/html/c4_base_8h_source.html b/docs/C/html/c4_base_8h_source.html index 6762f38a04..2a59b6c45f 100644 --- a/docs/C/html/c4_base_8h_source.html +++ b/docs/C/html/c4_base_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Base.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4Base.h
+
c4Base.h
-Go to the documentation of this file.
1 //
-
2 // c4Base.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 "c4Compat.h"
-
15 #include "c4Error.h"
-
16 #include "c4Log.h"
-
17 #include "fleece/FLSlice.h"
-
18 #include <stdarg.h>
-
19 
-
20 #if LITECORE_CPP_API
-
21 #include "c4EnumUtil.hh"
-
22 #endif
-
23 
- - -
26 
-
27 
-
28 // Corresponds to Couchbase Lite product version number, with 2 digits for minor and patch versions.
-
29 // i.e. `10000 * MajorVersion + 100 * MinorVersion + PatchVersion`
-
30 #define LITECORE_VERSION 30000
-
31 
-
32 // This number has no absolute meaning but is bumped whenever the LiteCore public API changes.
-
33 #define LITECORE_API_VERSION 351
-
34 
-
35 
-
40 #pragma mark - SLICES:
-
41 
-
42 
-
43 // (This is just renaming stuff from FLSlice.h ... feel free to use the FL names instead.)
-
44 
-
45 typedef FLSlice C4Slice;
- - -
48 typedef C4Slice C4String;
- - -
51 
-
52 static C4INLINE C4Slice c4str(const char* C4NULLABLE str) {return FLStr(str);}
-
53 #define C4STR(STR) FLSTR(STR)
-
54 #define kC4SliceNull kFLSliceNull
-
55 
-
56 static inline bool c4SliceEqual(C4Slice a, C4Slice b) {return FLSlice_Equal(a,b);}
- -
58 
-
59 
-
60 #pragma mark - COMMON TYPES:
-
61 
-
62 
-
63 #if LITECORE_CPP_API
-
64  C4API_END_DECLS // GCC doesn't like this stuff inside `extern "C" {}`
-
65 
-
67  enum class C4SequenceNumber : uint64_t { None = 0, Max = UINT64_MAX };
-
68  static inline C4SequenceNumber operator"" _seq (unsigned long long n) {return C4SequenceNumber(n);}
-
69  DEFINE_ENUM_INC_DEC(C4SequenceNumber)
-
70  DEFINE_ENUM_ADD_SUB_INT(C4SequenceNumber)
-
71 
-
72 
-
73 
-
76  enum class C4Timestamp : int64_t { None = 0, Error = -1 };
-
77  DEFINE_ENUM_ADD_SUB_INT(C4Timestamp)
-
78 
- -
80 #else
-
82  typedef uint64_t C4SequenceNumber;
-
83 
-
87  typedef int64_t C4Timestamp;
-
88 #endif
-
89 
-
90 
-
91 
-
99 typedef struct C4ExtraInfo {
- -
101  void (*C4NULLABLE destructor)(void *ptr);
-
102 } C4ExtraInfo;
-
103 
-
104 
-
106 typedef struct C4BlobKey C4BlobKey;
-
107 
-
109 typedef struct C4Address C4Address;
-
110 
-
112 typedef struct C4BlobStore C4BlobStore;
-
113 
-
115 typedef struct C4Cert C4Cert;
-
116 
-
118 typedef struct C4Collection C4Collection;
-
119 
-
121 typedef struct C4Database C4Database;
-
122 
- -
125 
-
126 #ifndef C4_STRICT_COLLECTION_API
- -
128 #endif
-
129 
-
131 typedef struct C4Document C4Document;
-
132 
- -
135 
-
137 typedef struct C4DocEnumerator C4DocEnumerator;
-
138 
-
140 typedef struct C4KeyPair C4KeyPair;
-
141 
-
143 typedef struct C4Listener C4Listener;
-
144 
-
146 typedef struct C4Query C4Query;
-
147 
-
149 typedef struct C4QueryEnumerator C4QueryEnumerator;
-
150 
-
152 typedef struct C4QueryObserver C4QueryObserver;
-
153 
-
155 typedef struct C4RawDocument C4RawDocument;
-
156 
-
158 typedef struct C4ReadStream C4ReadStream;
-
159 
-
161 typedef struct C4Replicator C4Replicator;
-
162 
-
164 typedef struct C4Socket C4Socket;
-
165 
-
167 typedef struct C4SocketFactory C4SocketFactory;
-
168 
-
170 typedef struct C4WriteStream C4WriteStream;
-
171 
-
172 
-
173 #pragma mark - REFERENCE COUNTING:
-
174 
-
175 
-
176 // The actual functions behind c4xxx_retain / c4xxx_release; don't call directly
-
177 void* c4base_retain(void * C4NULLABLE obj) C4API;
-
178 void c4base_release(void * C4NULLABLE obj) C4API;
-
179 
-
180 // These types are reference counted and have c4xxx_retain / c4xxx_release functions:
-
181 static inline C4Cert* C4NULLABLE
- -
183 static inline C4KeyPair* C4NULLABLE
- -
185 static inline C4Database* C4NULLABLE
- -
187 static inline C4Query* C4NULLABLE
- -
189 
- - - - - - -
196 
-
197 static inline void c4cert_release (C4Cert* C4NULLABLE r) C4API {c4base_release(r);}
- - - -
201 
- - - -
205 
-
206 // These types are _not_ ref-counted, but must be freed after use:
- - - - - - - - - -
216 
-
217 
- -
222 
- -
227 
-
228 
-
232 #pragma mark - INFO:
-
233 
-
234 
- -
242 
- -
245 
-
246 #define kC4EnvironmentTimezoneKey "tz"
-
247 #define kC4EnvironmentSupportedLocales "supported_locales"
-
248 
- -
258 
- -
261 
-
262 
- -
272 
-
273 
-
281 void c4_runAsyncTask(void (*task)(void*), void* C4NULLABLE context) C4API;
-
282 
-
283 
- - +Go to the documentation of this file.
1//
+
2// c4Base.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 "c4Compat.h"
+
15#include "c4Error.h"
+
16#include "c4Log.h"
+
17#include "fleece/FLSlice.h"
+
18#include <stdarg.h>
+
19
+
20#if LITECORE_CPP_API
+
21#include "c4EnumUtil.hh"
+
22#endif
+
23
+ + +
26
+
27
+
28// Corresponds to Couchbase Lite product version number, with 2 digits for minor and patch versions.
+
29// i.e. `10000 * MajorVersion + 100 * MinorVersion + PatchVersion`
+
30#define LITECORE_VERSION 30000
+
31
+
32// This number has no absolute meaning but is bumped whenever the LiteCore public API changes.
+
33#define LITECORE_API_VERSION 351
+
34
+
35
+
40#pragma mark - SLICES:
+
41
+
42
+
43// (This is just renaming stuff from FLSlice.h ... feel free to use the FL names instead.)
+
44
+ + + + + + +
51
+
52static C4INLINE C4Slice c4str(const char* C4NULLABLE str) {return FLStr(str);}
+
53#define C4STR(STR) FLSTR(STR)
+
54#define kC4SliceNull kFLSliceNull
+
55
+
56static inline bool c4SliceEqual(C4Slice a, C4Slice b) {return FLSlice_Equal(a,b);}
+ +
58
+
59
+
60#pragma mark - COMMON TYPES:
+
61
+
62
+
63#if LITECORE_CPP_API
+
64 C4API_END_DECLS // GCC doesn't like this stuff inside `extern "C" {}`
+
65
+
67 enum class C4SequenceNumber : uint64_t { None = 0, Max = UINT64_MAX };
+
68 static inline C4SequenceNumber operator"" _seq (unsigned long long n) {return C4SequenceNumber(n);}
+
69 DEFINE_ENUM_INC_DEC(C4SequenceNumber)
+
70 DEFINE_ENUM_ADD_SUB_INT(C4SequenceNumber)
+
71
+
72
+
73
+
76 enum class C4Timestamp : int64_t { None = 0, Error = -1 };
+
77 DEFINE_ENUM_ADD_SUB_INT(C4Timestamp)
+
78
+ +
80#else
+
82 typedef uint64_t C4SequenceNumber;
+
83
+
87 typedef int64_t C4Timestamp;
+
88#endif
+
89
+
90
+
91
+
99typedef struct C4ExtraInfo {
+ +
101 void (*C4NULLABLE destructor)(void *ptr);
+ +
103
+
104
+
106typedef struct C4BlobKey C4BlobKey;
+
107
+
109typedef struct C4Address C4Address;
+
110
+ +
113
+
115typedef struct C4Cert C4Cert;
+
116
+ +
119
+ +
122
+
124typedef struct C4Database C4Database;
+
125
+ +
128
+
129#ifndef C4_STRICT_COLLECTION_API
+ +
131#endif
+
132
+
134typedef struct C4Document C4Document;
+
135
+ +
138
+ +
141
+
143typedef struct C4KeyPair C4KeyPair;
+
144
+
146typedef struct C4Listener C4Listener;
+
147
+
149typedef struct C4Query C4Query;
+
150
+ +
153
+ +
156
+
158typedef struct C4RawDocument C4RawDocument;
+
159
+ +
162
+ +
165
+
167typedef struct C4Socket C4Socket;
+
168
+
170typedef struct C4SocketFactory C4SocketFactory;
+
171
+ +
174
+
175
+
176#pragma mark - REFERENCE COUNTING:
+
177
+
178
+
179// The actual functions behind c4xxx_retain / c4xxx_release; don't call directly
+ + +
182
+
183// These types are reference counted and have c4xxx_retain / c4xxx_release functions:
+
184static inline C4Cert* C4NULLABLE
+ +
186static inline C4ConnectedClient* C4NULLABLE
+ +
188static inline C4KeyPair* C4NULLABLE
+ +
190static inline C4Database* C4NULLABLE
+ +
192static inline C4Query* C4NULLABLE
+ +
194
+ + + + + + +
201
+ + + + + +
207
+ + + +
211
+
212// These types are _not_ ref-counted, but must be freed after use:
+ + + + + + + + + +
222
+
223
+ +
228
+ +
233
+
234
+
238#pragma mark - INFO:
+
239
+
240
+ +
248
+ +
251
+
252#define kC4EnvironmentTimezoneKey "tz"
+
253#define kC4EnvironmentSupportedLocales "supported_locales"
+
254
+ +
264
+ +
267
+
268
+ +
278
+
279
+
287void c4_runAsyncTask(void (*task)(void*), void* C4NULLABLE context) C4API;
+
288
+
289
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
@@ -287,60 +292,63 @@
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4ReadStream C4ReadStream
An open stream for reading data from a blob.
Definition: c4Base.h:158
+
struct C4ReadStream C4ReadStream
An open stream for reading data from a blob.
Definition: c4Base.h:161
+
C4Document * c4doc_retain(C4Document *)
C4Slice C4String
Definition: c4Base.h:48
void c4queryobs_free(C4QueryObserver *)
-
static C4Database * c4db_retain(C4Database *r)
Definition: c4Base.h:186
void c4base_release(void *obj)
-
static C4Cert * c4cert_retain(C4Cert *r)
Definition: c4Base.h:182
-
static void c4db_release(C4Database *r)
Definition: c4Base.h:199
+
static void c4db_release(C4Database *r)
Definition: c4Base.h:205
void c4repl_free(C4Replicator *)
void c4dbobs_free(C4CollectionObserver *)
void c4raw_free(C4RawDocument *)
void c4listener_free(C4Listener *)
-
C4QueryEnumerator * c4queryenum_retain(C4QueryEnumerator *)
int c4_getObjectCount(void)
Returns the number of objects that have been created but not yet freed.
static bool c4SliceEqual(C4Slice a, C4Slice b)
Definition: c4Base.h:56
struct C4BlobStore C4BlobStore
Opaque handle for an object that manages storage of blobs.
Definition: c4Base.h:112
-
static C4Query * c4query_retain(C4Query *r)
Definition: c4Base.h:188
-
struct C4WriteStream C4WriteStream
An open stream for writing data to a blob.
Definition: c4Base.h:170
+
static C4Cert * c4cert_retain(C4Cert *r)
Definition: c4Base.h:185
+
struct C4WriteStream C4WriteStream
An open stream for writing data to a blob.
Definition: c4Base.h:173
C4HeapSlice C4HeapString
Definition: c4Base.h:49
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: c4Base.h:87
static void c4slice_free(C4SliceResult s)
Definition: c4Base.h:57
-
struct C4DocEnumerator C4DocEnumerator
Opaque handle to a document enumerator.
Definition: c4Base.h:137
-
static void c4query_release(C4Query *r)
Definition: c4Base.h:200
-
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:143
-
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:146
+
struct C4DocEnumerator C4DocEnumerator
Opaque handle to a document enumerator.
Definition: c4Base.h:140
+
static void c4query_release(C4Query *r)
Definition: c4Base.h:206
+
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:146
+
C4Socket * c4socket_retain(C4Socket *)
+
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:149
+
void * c4base_retain(void *obj)
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
-
struct C4CollectionObserver C4CollectionObserver
A collection-observer reference.
Definition: c4Base.h:124
-
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:161
+
struct C4CollectionObserver C4CollectionObserver
A collection-observer reference.
Definition: c4Base.h:127
+
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:164
FLSliceResult C4SliceResult
Definition: c4Base.h:47
void c4docobs_free(C4DocumentObserver *)
+
static C4ConnectedClient * c4client_retain(C4ConnectedClient *r)
Definition: c4Base.h:187
void c4socket_release(C4Socket *)
-
struct C4QueryObserver C4QueryObserver
A query-observer reference.
Definition: c4Base.h:152
-
struct C4DocumentObserver C4DocumentObserver
A document-observer reference.
Definition: c4Base.h:134
+
struct C4QueryObserver C4QueryObserver
A query-observer reference.
Definition: c4Base.h:155
+
struct C4DocumentObserver C4DocumentObserver
A document-observer reference.
Definition: c4Base.h:137
void c4_dumpInstances(void)
Logs information about object in memory.
-
C4Socket * c4socket_retain(C4Socket *)
C4SliceResult C4StringResult
Definition: c4Base.h:50
-
static void c4keypair_release(C4KeyPair *r)
Definition: c4Base.h:198
-
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:140
+
static C4KeyPair * c4keypair_retain(C4KeyPair *r)
Definition: c4Base.h:189
+
static void c4keypair_release(C4KeyPair *r)
Definition: c4Base.h:204
+
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:143
void c4queryenum_release(C4QueryEnumerator *)
-
static C4KeyPair * c4keypair_retain(C4KeyPair *r)
Definition: c4Base.h:184
+
static C4Database * c4db_retain(C4Database *r)
Definition: c4Base.h:191
+
static void c4client_release(C4ConnectedClient *r)
Definition: c4Base.h:203
void c4stream_close(C4ReadStream *)
void c4enum_free(C4DocEnumerator *)
FLSlice C4Slice
Definition: c4Base.h:45
void c4doc_release(C4Document *)
void c4stream_closeWriter(C4WriteStream *)
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition: c4Base.h:118
-
C4CollectionObserver C4DatabaseObserver
Definition: c4Base.h:127
+
C4CollectionObserver C4DatabaseObserver
Definition: c4Base.h:130
static C4INLINE C4Slice c4str(const char *str)
Definition: c4Base.h:52
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
-
static void c4cert_release(C4Cert *r)
Definition: c4Base.h:197
-
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:164
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
+
static void c4cert_release(C4Cert *r)
Definition: c4Base.h:202
+
C4QueryEnumerator * c4queryenum_retain(C4QueryEnumerator *)
+
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:167
FLHeapSlice C4HeapSlice
Definition: c4Base.h:46
-
C4Document * c4doc_retain(C4Document *)
+
static C4Query * c4query_retain(C4Query *r)
Definition: c4Base.h:193
+
struct C4ConnectedClient C4ConnectedClient
Opaque reference to a Connected Client.
Definition: c4Base.h:121
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition: c4Base.h:115
-
void * c4base_retain(void *obj)
bool FLSlice_Equal(FLSlice a, FLSlice b) FLPURE
Equality test of two slices.
static void FLSliceResult_Release(FLSliceResult s)
Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero.
Definition: FLSlice.h:185
static FLSlice FLStr(const char *FL_NULLABLE str)
Returns a slice pointing to the contents of a C string.
Definition: FLSlice.h:128
@@ -365,7 +373,7 @@
diff --git a/docs/C/html/c4_blob_store_8h.html b/docs/C/html/c4_blob_store_8h.html index 3f2f175a8e..2370299284 100644 --- a/docs/C/html/c4_blob_store_8h.html +++ b/docs/C/html/c4_blob_store_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4BlobStore.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4BlobStore.h File Reference
+
c4BlobStore.h File Reference
#include "c4BlobStoreTypes.h"
@@ -76,7 +76,7 @@

Go to the source code of this file.

- @@ -86,12 +86,12 @@ - - - - - - + + + + + + @@ -118,9 +118,9 @@ - - - + + + @@ -134,9 +134,9 @@ - - - + + + @@ -156,7 +156,7 @@ diff --git a/docs/C/html/c4_blob_store_8h_source.html b/docs/C/html/c4_blob_store_8h_source.html index cf0838000c..43024a4e9b 100644 --- a/docs/C/html/c4_blob_store_8h_source.html +++ b/docs/C/html/c4_blob_store_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4BlobStore.h Source File @@ -30,21 +30,22 @@

+

Functions

Blob Keys
bool c4blob_keyFromString (C4String str, C4BlobKey *)
 Encodes a blob key to a string of the form "sha1-"+base64. More...
 
Blob Store API
C4BlobStorec4db_getBlobStore (C4Database *db, C4Error *outError)
 Returns the BlobStore associated with a bundled database. More...
 
C4BlobStorec4blob_openStore (C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
 Opens a BlobStore in a directory. More...
 
C4BlobStorec4db_getBlobStore (C4Database *db, C4Error *outError)
 Returns the BlobStore associated with a bundled database. More...
 
C4BlobStorec4blob_openStore (C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
 Opens a BlobStore in a directory. More...
 
void c4blob_freeStore (C4BlobStore *)
 Closes/frees a BlobStore. More...
 
 Deletes a blob from the store given its key. More...
 
Streamed Reads
C4ReadStreamc4blob_openReadStream (C4BlobStore *, C4BlobKey, C4Error *)
 Opens a blob for reading, as a random-access byte stream. More...
 
C4ReadStreamc4blob_openReadStream (C4BlobStore *, C4BlobKey, C4Error *)
 Opens a blob for reading, as a random-access byte stream. More...
 
size_t c4stream_read (C4ReadStream *stream, void *buffer, size_t maxBytesToRead, C4Error *error)
 Reads from an open stream. More...
 
 Closes a read-stream. More...
 
Streamed Writes
C4WriteStreamc4blob_openWriteStream (C4BlobStore *, C4Error *)
 Opens a write stream for creating a new blob. More...
 
C4WriteStreamc4blob_openWriteStream (C4BlobStore *, C4Error *)
 Opens a write stream for creating a new blob. More...
 
bool c4stream_write (C4WriteStream *, const void *bytes, size_t length, C4Error *)
 Writes data to a stream. More...
 
- + +/* @license-end */ +
-
-
c4BlobStore.h
+
c4BlobStore.h
-Go to the documentation of this file.
1 //
-
2 // c4BlobStore.h
-
3 //
-
4 // Copyright 2016-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 "c4BlobStoreTypes.h"
-
15 #include "c4DatabaseTypes.h"
-
16 #include <stdio.h>
-
17 
- - -
20 
- -
30 
- -
33 
-
38 
- -
46 
- -
57  C4DatabaseFlags flags,
-
58  const C4EncryptionKey* C4NULLABLE encryptionKey,
-
59  C4Error* C4NULLABLE outError) C4API;
-
60 
- -
65 
- -
70 
-
77  /* NOTE: Every function in this section is thread-safe, as long as the C4BlobStore
-
78  reference remains valid while the function executes, i.e. there are no concurrent calls
-
79  to c4blob_freeStore, c4blob_deleteStore or c4db_close. */
-
80 
- -
85 
- -
88 
- -
97 
- -
100 
- -
105  C4Slice contents,
-
106  const C4BlobKey *C4NULLABLE expectedKey,
-
107  C4BlobKey* C4NULLABLE outKey,
-
108  C4Error* C4NULLABLE error) C4API;
-
109 
- -
112 
-
117 
-
121  /* NOTE: These functions are thread-safe in the same manner as described in the previous
-
122  section, with the additional restriction that a stream cannot be called concurrently on
-
123  multiple threads. */
-
124 
- -
127  C4BlobKey,
- -
129 
-
136  size_t c4stream_read(C4ReadStream* stream,
-
137  void *buffer,
-
138  size_t maxBytesToRead,
-
139  C4Error* C4NULLABLE error) C4API;
-
140 
- -
143 
- -
147  uint64_t position,
- -
149 
- -
152 
- - -
164 
- -
167  const void *bytes,
-
168  size_t length,
- -
170 
- -
173 
- -
177 
- -
184  const C4BlobKey* C4NULLABLE expectedKey,
- -
186 
- -
191 
-
192 
- - +Go to the documentation of this file.
1//
+
2// c4BlobStore.h
+
3//
+
4// Copyright 2016-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 "c4BlobStoreTypes.h"
+
15#include "c4DatabaseTypes.h"
+
16#include <stdio.h>
+
17
+ + +
20
+ +
30
+ +
33
+
38
+ +
46
+ +
57 C4DatabaseFlags flags,
+
58 const C4EncryptionKey* C4NULLABLE encryptionKey,
+
59 C4Error* C4NULLABLE outError) C4API;
+
60
+ +
65
+ +
70
+
77 /* NOTE: Every function in this section is thread-safe, as long as the C4BlobStore
+
78 reference remains valid while the function executes, i.e. there are no concurrent calls
+
79 to c4blob_freeStore, c4blob_deleteStore or c4db_close. */
+
80
+ +
85
+ +
88
+ +
97
+ +
100
+ +
105 C4Slice contents,
+
106 const C4BlobKey *C4NULLABLE expectedKey,
+
107 C4BlobKey* C4NULLABLE outKey,
+
108 C4Error* C4NULLABLE error) C4API;
+
109
+ +
112
+
117
+
121 /* NOTE: These functions are thread-safe in the same manner as described in the previous
+
122 section, with the additional restriction that a stream cannot be called concurrently on
+
123 multiple threads. */
+
124
+ +
127 C4BlobKey,
+ +
129
+ +
137 void *buffer,
+
138 size_t maxBytesToRead,
+
139 C4Error* C4NULLABLE error) C4API;
+
140
+ +
143
+ +
147 uint64_t position,
+ +
149
+ +
152
+ + +
164
+ +
167 const void *bytes,
+
168 size_t length,
+ +
170
+ +
173
+ +
177
+ +
184 const C4BlobKey* C4NULLABLE expectedKey,
+ +
186
+ +
191
+
192
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
@@ -177,33 +177,33 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4ReadStream C4ReadStream
An open stream for reading data from a blob.
Definition: c4Base.h:158
+
struct C4ReadStream C4ReadStream
An open stream for reading data from a blob.
Definition: c4Base.h:161
struct C4BlobStore C4BlobStore
Opaque handle for an object that manages storage of blobs.
Definition: c4Base.h:112
-
struct C4WriteStream C4WriteStream
An open stream for writing data to a blob.
Definition: c4Base.h:170
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
-
C4BlobStore * c4blob_openStore(C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
Opens a BlobStore in a directory.
+
struct C4WriteStream C4WriteStream
An open stream for writing data to a blob.
Definition: c4Base.h:173
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
int64_t c4blob_getSize(C4BlobStore *, C4BlobKey)
Gets the content size of a blob given its key.
bool c4stream_install(C4WriteStream *, const C4BlobKey *expectedKey, C4Error *)
Adds the data written to the stream as a finished blob to the store.
bool c4blob_keyFromString(C4String str, C4BlobKey *)
Decodes a string of the form "sha1-"+base64 into a raw key.
int64_t c4stream_getLength(C4ReadStream *, C4Error *)
Returns the exact length in bytes of the stream.
+
C4BlobStore * c4db_getBlobStore(C4Database *db, C4Error *outError)
Returns the BlobStore associated with a bundled database.
bool c4blob_delete(C4BlobStore *, C4BlobKey, C4Error *)
Deletes a blob from the store given its key.
bool c4stream_seek(C4ReadStream *, uint64_t position, C4Error *)
Moves to a random location in the stream; the next c4stream_read call will read from that location.
bool c4stream_write(C4WriteStream *, const void *bytes, size_t length, C4Error *)
Writes data to a stream.
C4BlobKey c4stream_computeBlobKey(C4WriteStream *)
Computes the blob-key (digest) of the data written to the stream.
C4SliceResult c4blob_getContents(C4BlobStore *, C4BlobKey, C4Error *)
Reads the entire contents of a blob into memory.
C4StringResult c4blob_getFilePath(C4BlobStore *, C4BlobKey, C4Error *)
Returns the path of the file that stores the blob, if possible.
+
C4BlobStore * c4blob_openStore(C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
Opens a BlobStore in a directory.
C4StringResult c4blob_keyToString(C4BlobKey)
Encodes a blob key to a string of the form "sha1-"+base64.
bool c4blob_deleteStore(C4BlobStore *, C4Error *)
Deletes the BlobStore's blobs and directory, and (if successful) frees the object.
size_t c4stream_read(C4ReadStream *stream, void *buffer, size_t maxBytesToRead, C4Error *error)
Reads from an open stream.
-
C4WriteStream * c4blob_openWriteStream(C4BlobStore *, C4Error *)
Opens a write stream for creating a new blob.
+
C4ReadStream * c4blob_openReadStream(C4BlobStore *, C4BlobKey, C4Error *)
Opens a blob for reading, as a random-access byte stream.
+
C4WriteStream * c4blob_openWriteStream(C4BlobStore *, C4Error *)
Opens a write stream for creating a new blob.
C4BlobKey c4blob_computeKey(C4Slice contents)
Derives the key of the given data, without storing it.
void c4blob_freeStore(C4BlobStore *)
Closes/frees a BlobStore.
bool c4blob_create(C4BlobStore *store, C4Slice contents, const C4BlobKey *expectedKey, C4BlobKey *outKey, C4Error *error)
Stores a blob.
void c4stream_close(C4ReadStream *)
Closes a read-stream.
-
C4ReadStream * c4blob_openReadStream(C4BlobStore *, C4BlobKey, C4Error *)
Opens a blob for reading, as a random-access byte stream.
uint64_t c4stream_bytesWritten(C4WriteStream *)
Returns the number of bytes written to the stream.
void c4stream_closeWriter(C4WriteStream *)
Closes a blob write-stream.
-
C4BlobStore * c4db_getBlobStore(C4Database *db, C4Error *outError)
Returns the BlobStore associated with a bundled database.
C4DatabaseFlags
Boolean options for C4DatabaseConfig.
Definition: c4DatabaseTypes.h:33
A unique identifier of a blob based on a SHA-1 digest of its contents.
Definition: c4BlobStoreTypes.h:34
Encryption key specified in a C4DatabaseConfig.
Definition: c4DatabaseTypes.h:57
@@ -213,7 +213,7 @@
diff --git a/docs/C/html/c4_blob_store_types_8h.html b/docs/C/html/c4_blob_store_types_8h.html index d99e7b87bc..ce17e20472 100644 --- a/docs/C/html/c4_blob_store_types_8h.html +++ b/docs/C/html/c4_blob_store_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4BlobStoreTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4BlobStoreTypes.h File Reference
+
c4BlobStoreTypes.h File Reference
#include "c4Base.h"

Go to the source code of this file.

- @@ -85,7 +85,7 @@ diff --git a/docs/C/html/c4_blob_store_types_8h_source.html b/docs/C/html/c4_blob_store_types_8h_source.html index 0cb0cc7e69..248cf2602e 100644 --- a/docs/C/html/c4_blob_store_types_8h_source.html +++ b/docs/C/html/c4_blob_store_types_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4BlobStoreTypes.h Source File @@ -30,21 +30,22 @@

+

Data Structures

struct  C4BlobKey
 A unique identifier of a blob based on a SHA-1 digest of its contents. More...
- + +/* @license-end */ +
-
-
c4BlobStoreTypes.h
+
c4BlobStoreTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4BlobStoreTypes.h
-
3 //
-
4 // Copyright 2021-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 "c4Base.h"
-
15 #ifdef __cplusplus
-
16  #include "fleece/slice.hh"
-
17  #include <optional>
-
18  #include <string>
-
19 #endif
-
20 
- - -
23 
-
24 
-
29 
-
34 struct C4BlobKey {
-
35  uint8_t bytes[20];
-
36 
-
37 #ifdef __cplusplus
-
38  using slice = fleece::slice;
-
39 
-
41  static C4BlobKey computeDigestOfContent(slice content);
-
42 
-
45  static std::optional<C4BlobKey> withDigestString(slice base64);
-
46 
-
48  std::string digestString() const;
-
49 
-
51  explicit operator slice() const {return slice(bytes, sizeof(bytes));}
-
52 
-
53  bool operator== (const C4BlobKey &k) const {
-
54  return memcmp(bytes, k.bytes, sizeof(bytes)) == 0;
-
55  }
-
56 
-
57  bool operator!= (const C4BlobKey &k) const {
-
58  return !(*this == k);
-
59  }
-
60 #endif
-
61 };
-
62 
-
63 
- - +Go to the documentation of this file.
1//
+
2// c4BlobStoreTypes.h
+
3//
+
4// Copyright 2021-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 "c4Base.h"
+
15#ifdef __cplusplus
+
16 #include "fleece/slice.hh"
+
17 #include <optional>
+
18 #include <string>
+
19#endif
+
20
+ + +
23
+
24
+
29
+
34struct C4BlobKey {
+
35 uint8_t bytes[20];
+
36
+
37#ifdef __cplusplus
+
38 using slice = fleece::slice;
+
39
+
41 static C4BlobKey computeDigestOfContent(slice content);
+
42
+
45 static std::optional<C4BlobKey> withDigestString(slice base64);
+
46
+
48 std::string digestString() const;
+
49
+
51 explicit operator slice() const {return slice(bytes, sizeof(bytes));}
+
52
+
53 bool operator== (const C4BlobKey &k) const {
+
54 return memcmp(bytes, k.bytes, sizeof(bytes)) == 0;
+
55 }
+
56
+
57 bool operator!= (const C4BlobKey &k) const {
+
58 return !(*this == k);
+
59 }
+
60#endif
+
61};
+
62
+
63
+ +
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
#define C4API_END_DECLS
Definition: c4Compat.h:95
@@ -132,7 +132,7 @@
diff --git a/docs/C/html/c4_certificate_8h.html b/docs/C/html/c4_certificate_8h.html index a1b58f49e4..cea92b8dcd 100644 --- a/docs/C/html/c4_certificate_8h.html +++ b/docs/C/html/c4_certificate_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Certificate.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Certificate.h File Reference
+
c4Certificate.h File Reference
#include "c4CertificateTypes.h"
@@ -76,7 +76,7 @@
diff --git a/docs/C/html/c4_certificate_8h_source.html b/docs/C/html/c4_certificate_8h_source.html index 3d2d35c9e6..49e39357b6 100644 --- a/docs/C/html/c4_certificate_8h_source.html +++ b/docs/C/html/c4_certificate_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Certificate.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Certificate.h
+
c4Certificate.h
-Go to the documentation of this file.
1 //
-
2 // c4Certificate.h
-
3 //
-
4 // Copyright 2019-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 
-
15 #include "c4CertificateTypes.h"
-
16 
-
17 #ifdef COUCHBASE_ENTERPRISE
-
18 
- - -
21 
-
33 C4Cert* c4cert_fromData(C4Slice certData,
-
34  C4Error* C4NULLABLE outError) C4API;
-
35 
-
40 C4SliceResult c4cert_copyData(C4Cert*,
-
41  bool pemEncoded) C4API;
-
42 
-
45 C4StringResult c4cert_summary(C4Cert*) C4API;
-
46 
-
52 C4StringResult c4cert_subjectName(C4Cert*) C4API;
-
53 
-
57 C4StringResult c4cert_subjectNameComponent(C4Cert*, C4CertNameAttributeID) C4API;
-
58 
-
66 bool c4cert_subjectNameAtIndex(C4Cert* cert,
-
67  unsigned index,
-
68  C4CertNameInfo *outInfo) C4API;
-
69 
-
74 void c4cert_getValidTimespan(C4Cert* cert,
-
75  C4Timestamp* C4NULLABLE outCreated,
-
76  C4Timestamp* C4NULLABLE outExpires);
-
77 
-
79 C4CertUsage c4cert_usages(C4Cert*) C4API;
-
80 
-
83 bool c4cert_isSelfSigned(C4Cert*) C4API;
-
84 
-
87 C4KeyPair* c4cert_getPublicKey(C4Cert*) C4API;
-
88 
-
92 C4KeyPair* c4cert_loadPersistentPrivateKey(C4Cert*,
-
93  C4Error* C4NULLABLE outError) C4API;
-
94 
-
111 C4Cert* c4cert_createRequest(const C4CertNameComponent *nameComponents,
-
112  size_t nameCount,
-
113  C4CertUsage certUsages,
-
114  C4KeyPair *subjectKey,
-
115  C4Error* C4NULLABLE outError) C4API;
-
116 
-
119 C4Cert* c4cert_requestFromData(C4Slice certRequestData,
-
120  C4Error* C4NULLABLE outError) C4API;
-
121 
-
123 bool c4cert_isSigned(C4Cert*) C4API;
-
124 
-
129 typedef void (*C4CertSigningCallback)(void *context,
-
130  C4Cert *signedCert,
-
131  C4Error error);
-
132 
-
147 bool c4cert_sendSigningRequest(C4Cert *certRequest,
-
148  C4Address address,
-
149  C4Slice optionsDictFleece,
-
150  C4CertSigningCallback callback,
-
151  void* C4NULLABLE context,
-
152  C4Error* C4NULLABLE outError) C4API;
-
153 
-
166 C4Cert* c4cert_signRequest(C4Cert *certRequest,
-
167  const C4CertIssuerParameters* C4NULLABLE params,
-
168  C4KeyPair *issuerPrivateKey,
-
169  C4Cert* C4NULLABLE issuerCert,
-
170  C4Error* C4NULLABLE outError) C4API;
-
171 
-
181 C4Cert* C4NULLABLE c4cert_nextInChain(C4Cert*) C4API;
-
182 
-
185 C4SliceResult c4cert_copyChainData(C4Cert*) C4API;
-
186 
-
201 bool c4cert_save(C4Cert* C4NULLABLE cert,
-
202  bool entireChain,
-
203  C4String name,
-
204  C4Error* C4NULLABLE outError);
-
205 
-
211 C4Cert* c4cert_load(C4String name,
-
212  C4Error* C4NULLABLE outError);
-
213 
-
233 C4KeyPair* c4keypair_generate(C4KeyPairAlgorithm algorithm,
-
234  unsigned sizeInBits,
-
235  bool persistent,
-
236  C4Error* C4NULLABLE outError) C4API;
-
237 
-
241 C4KeyPair* c4keypair_fromPublicKeyData(C4Slice publicKeyData,
-
242  C4Error* C4NULLABLE outError) C4API;
-
243 
-
247 C4KeyPair* c4keypair_fromPrivateKeyData(C4Slice privateKeyData,
-
248  C4Slice passwordOrNull,
-
249  C4Error* C4NULLABLE outError) C4API;
-
250 
-
252 bool c4keypair_hasPrivateKey(C4KeyPair*) C4API;
-
253 
-
256 C4SliceResult c4keypair_publicKeyDigest(C4KeyPair*) C4API;
-
257 
-
260 C4SliceResult c4keypair_publicKeyData(C4KeyPair*) C4API;
-
261 
-
265 C4SliceResult c4keypair_privateKeyData(C4KeyPair*) C4API;
-
266 
-
268 bool c4keypair_isPersistent(C4KeyPair*) C4API;
-
269 
-
273 C4KeyPair* c4keypair_persistentWithPublicKey(C4KeyPair*,
-
274  C4Error* C4NULLABLE outError) C4API;
-
275 
-
277 bool c4keypair_removePersistent(C4KeyPair*,
-
278  C4Error* C4NULLABLE outError) C4API;
-
279 
-
296 C4KeyPair* c4keypair_fromExternal(C4KeyPairAlgorithm algorithm,
-
297  size_t keySizeInBits,
-
298  void *externalKey,
-
299  struct C4ExternalKeyCallbacks callbacks,
-
300  C4Error* C4NULLABLE outError);
-
301 
- - -
308 
-
309 #endif // COUCHBASE_ENTERPRISE
+Go to the documentation of this file.
1//
+
2// c4Certificate.h
+
3//
+
4// Copyright 2019-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
+
15#include "c4CertificateTypes.h"
+
16
+
17#ifdef COUCHBASE_ENTERPRISE
+
18
+ + +
21
+
33C4Cert* c4cert_fromData(C4Slice certData,
+
34 C4Error* C4NULLABLE outError) C4API;
+
35
+
40C4SliceResult c4cert_copyData(C4Cert*,
+
41 bool pemEncoded) C4API;
+
42
+
45C4StringResult c4cert_summary(C4Cert*) C4API;
+
46
+
52C4StringResult c4cert_subjectName(C4Cert*) C4API;
+
53
+
57C4StringResult c4cert_subjectNameComponent(C4Cert*, C4CertNameAttributeID) C4API;
+
58
+
66bool c4cert_subjectNameAtIndex(C4Cert* cert,
+
67 unsigned index,
+
68 C4CertNameInfo *outInfo) C4API;
+
69
+
74void c4cert_getValidTimespan(C4Cert* cert,
+
75 C4Timestamp* C4NULLABLE outCreated,
+
76 C4Timestamp* C4NULLABLE outExpires);
+
77
+
79C4CertUsage c4cert_usages(C4Cert*) C4API;
+
80
+
83bool c4cert_isSelfSigned(C4Cert*) C4API;
+
84
+
87C4KeyPair* c4cert_getPublicKey(C4Cert*) C4API;
+
88
+
92C4KeyPair* c4cert_loadPersistentPrivateKey(C4Cert*,
+
93 C4Error* C4NULLABLE outError) C4API;
+
94
+
111C4Cert* c4cert_createRequest(const C4CertNameComponent *nameComponents,
+
112 size_t nameCount,
+
113 C4CertUsage certUsages,
+
114 C4KeyPair *subjectKey,
+
115 C4Error* C4NULLABLE outError) C4API;
+
116
+
119C4Cert* c4cert_requestFromData(C4Slice certRequestData,
+
120 C4Error* C4NULLABLE outError) C4API;
+
121
+
123bool c4cert_isSigned(C4Cert*) C4API;
+
124
+
129typedef void (*C4CertSigningCallback)(void *context,
+
130 C4Cert *signedCert,
+
131 C4Error error);
+
132
+
147bool c4cert_sendSigningRequest(C4Cert *certRequest,
+
148 C4Address address,
+
149 C4Slice optionsDictFleece,
+
150 C4CertSigningCallback callback,
+
151 void* C4NULLABLE context,
+
152 C4Error* C4NULLABLE outError) C4API;
+
153
+
166C4Cert* c4cert_signRequest(C4Cert *certRequest,
+
167 const C4CertIssuerParameters* C4NULLABLE params,
+
168 C4KeyPair *issuerPrivateKey,
+
169 C4Cert* C4NULLABLE issuerCert,
+
170 C4Error* C4NULLABLE outError) C4API;
+
171
+
181C4Cert* C4NULLABLE c4cert_nextInChain(C4Cert*) C4API;
+
182
+
185C4SliceResult c4cert_copyChainData(C4Cert*) C4API;
+
186
+
201bool c4cert_save(C4Cert* C4NULLABLE cert,
+
202 bool entireChain,
+
203 C4String name,
+
204 C4Error* C4NULLABLE outError);
+
205
+
211C4Cert* c4cert_load(C4String name,
+
212 C4Error* C4NULLABLE outError);
+
213
+
233C4KeyPair* c4keypair_generate(C4KeyPairAlgorithm algorithm,
+
234 unsigned sizeInBits,
+
235 bool persistent,
+
236 C4Error* C4NULLABLE outError) C4API;
+
237
+
241C4KeyPair* c4keypair_fromPublicKeyData(C4Slice publicKeyData,
+
242 C4Error* C4NULLABLE outError) C4API;
+
243
+
247C4KeyPair* c4keypair_fromPrivateKeyData(C4Slice privateKeyData,
+
248 C4Slice passwordOrNull,
+
249 C4Error* C4NULLABLE outError) C4API;
+
250
+
252bool c4keypair_hasPrivateKey(C4KeyPair*) C4API;
+
253
+
256C4SliceResult c4keypair_publicKeyDigest(C4KeyPair*) C4API;
+
257
+
260C4SliceResult c4keypair_publicKeyData(C4KeyPair*) C4API;
+
261
+
265C4SliceResult c4keypair_privateKeyData(C4KeyPair*) C4API;
+
266
+
268bool c4keypair_isPersistent(C4KeyPair*) C4API;
+
269
+
273C4KeyPair* c4keypair_persistentWithPublicKey(C4KeyPair*,
+
274 C4Error* C4NULLABLE outError) C4API;
+
275
+
277bool c4keypair_removePersistent(C4KeyPair*,
+
278 C4Error* C4NULLABLE outError) C4API;
+
279
+
296C4KeyPair* c4keypair_fromExternal(C4KeyPairAlgorithm algorithm,
+
297 size_t keySizeInBits,
+
298 void *externalKey,
+
299 struct C4ExternalKeyCallbacks callbacks,
+
300 C4Error* C4NULLABLE outError);
+
301
+ + +
308
+
309#endif // COUCHBASE_ENTERPRISE
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
@@ -206,7 +206,7 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#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:87
-
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:140
+
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:143
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition: c4Base.h:115
A simple parsed-URL type.
Definition: c4ReplicatorTypes.h:56
An error value.
Definition: c4Error.h:130
@@ -215,7 +215,7 @@
diff --git a/docs/C/html/c4_certificate_types_8h.html b/docs/C/html/c4_certificate_types_8h.html index 79fbd0ee2d..0d24a8aff5 100644 --- a/docs/C/html/c4_certificate_types_8h.html +++ b/docs/C/html/c4_certificate_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4CertificateTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4CertificateTypes.h File Reference
+
c4CertificateTypes.h File Reference
@@ -75,7 +75,7 @@
diff --git a/docs/C/html/c4_certificate_types_8h_source.html b/docs/C/html/c4_certificate_types_8h_source.html index 51c8cfdc12..1b12478166 100644 --- a/docs/C/html/c4_certificate_types_8h_source.html +++ b/docs/C/html/c4_certificate_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4CertificateTypes.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4CertificateTypes.h
+
c4CertificateTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4CertificateTypes.h
-
3 //
-
4 // Copyright 2019-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 #ifdef COUCHBASE_ENTERPRISE
-
15 
-
16 #include "c4Base.h"
-
17 
- - -
20 
-
25 typedef C4_OPTIONS(uint8_t, C4CertUsage) { // Note: Same values as `MBEDTLS_X509_NS_CERT_TYPE_*`
-
26  kC4CertUsage_NotSpecified = 0x00,
-
27  kC4CertUsage_TLSClient = 0x80,
-
28  kC4CertUsage_TLSServer = 0x40,
-
29  kC4CertUsage_Email = 0x20,
-
30  kC4CertUsage_ObjectSigning = 0x10,
-
31  kC4CertUsage_TLS_CA = 0x04,
-
32  kC4CertUsage_Email_CA = 0x02,
-
33  kC4CertUsage_ObjectSigning_CA = 0x01
-
34 };
-
35 
-
36 
-
40 typedef C4Slice C4CertNameAttributeID;
-
41 
-
42 // Some common Distinguished Name attributes:
-
43 #define kC4Cert_CommonName C4STR("CN") // e.g. "Jane Doe", (or "jane.example.com")
-
44 #define kC4Cert_Pseudonym C4STR("pseudonym") // e.g. "plainjane837"
-
45 #define kC4Cert_GivenName C4STR("GN") // e.g. "Jane"
-
46 #define kC4Cert_Surname C4STR("SN") // e.g. "Doe"
-
47 #define kC4Cert_Organization C4STR("O") // e.g. "Example Corp."
-
48 #define kC4Cert_OrganizationUnit C4STR("OU") // e.g. "Marketing"
-
49 #define kC4Cert_PostalAddress C4STR("postalAddress")// e.g. "123 Example Blvd #2A"
-
50 #define kC4Cert_Locality C4STR("locality") // e.g. "Boston"
-
51 #define kC4Cert_PostalCode C4STR("postalCode") // e.g. "02134"
-
52 #define kC4Cert_StateOrProvince C4STR("ST") // e.g. "Massachusetts" (or "Quebec", ...)
-
53 #define kC4Cert_Country C4STR("C") // e.g. "us" (2-letter ISO country code)
-
54 
-
55 // These are the Subject Alternative Name attributes:
-
56 #define kC4Cert_EmailAddress C4STR("rfc822Name") // 'rfc822Name', e.g. "jane@example.com"
-
57 #define kC4Cert_Hostname C4STR("dNSName") // 'dnsName', e.g. "www.example.com"
-
58 #define kC4Cert_URL C4STR("uniformResourceIdentifier") // "https://example.com/jane"
-
59 #define kC4Cert_IPAddress C4STR("iPAddress") // *Binary* IP address, e.g. "\x0A\x00\x01\x01"
-
60 #define kC4Cert_RegisteredID C4STR("registeredID") // Some sort of domain-specific ID?
-
61 
-
63 typedef struct C4CertNameInfo {
-
64  C4StringResult id;
-
65  C4StringResult value;
-
66 } C4CertNameInfo;
-
67 
-
68 
-
73 typedef struct {
-
74  C4CertNameAttributeID attributeID;
-
75  C4String value;
-
76 } C4CertNameComponent;
-
77 
-
80 typedef struct {
-
81  unsigned validityInSeconds;
-
82  C4String serialNumber;
-
83  int maxPathLen;
-
84  bool isCA;
-
85  bool addAuthorityIdentifier;
-
86  bool addSubjectIdentifier;
-
87  bool addBasicConstraints;
-
88 } C4CertIssuerParameters;
-
89 
-
91 CBL_CORE_API extern const C4CertIssuerParameters kDefaultCertIssuerParameters;
-
92 
-
100 typedef C4_ENUM(uint8_t, C4KeyPairAlgorithm) {
-
101  kC4RSA,
-
102 };
-
111 typedef C4_ENUM(int, C4SignatureDigestAlgorithm) {
-
112  kC4SignatureDigestNone = 0,
-
113  kC4SignatureDigestSHA1 = 4,
-
114  kC4SignatureDigestSHA224,
-
115  kC4SignatureDigestSHA256,
-
116  kC4SignatureDigestSHA384,
-
117  kC4SignatureDigestSHA512,
-
118  kC4SignatureDigestRIPEMD160,
-
119 };
-
120 
-
121 
-
123 typedef struct C4ExternalKeyCallbacks {
-
130  bool (*publicKeyData)(void *externalKey,
-
131  void *output,
-
132  size_t outputMaxLen,
-
133  size_t *outputLen);
-
141  bool (*decrypt)(void *externalKey,
-
142  C4Slice input,
-
143  void *output,
-
144  size_t outputMaxLen,
-
145  size_t *outputLen);
-
154  bool (*sign)(void *externalKey,
-
155  C4SignatureDigestAlgorithm digestAlgorithm,
-
156  C4Slice inputData,
-
157  void *outSignature);
-
161  void (* C4NULLABLE free)(void *externalKey);
-
162 } C4ExternalKeyCallbacks;
-
163 
- - -
171 
-
172 #endif // COUCHBASE_ENTERPRISE
+Go to the documentation of this file.
1//
+
2// c4CertificateTypes.h
+
3//
+
4// Copyright 2019-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#ifdef COUCHBASE_ENTERPRISE
+
15
+
16#include "c4Base.h"
+
17
+ + +
20
+
25typedef C4_OPTIONS(uint8_t, C4CertUsage) { // Note: Same values as `MBEDTLS_X509_NS_CERT_TYPE_*`
+
26 kC4CertUsage_NotSpecified = 0x00,
+
27 kC4CertUsage_TLSClient = 0x80,
+
28 kC4CertUsage_TLSServer = 0x40,
+
29 kC4CertUsage_Email = 0x20,
+
30 kC4CertUsage_ObjectSigning = 0x10,
+
31 kC4CertUsage_TLS_CA = 0x04,
+
32 kC4CertUsage_Email_CA = 0x02,
+
33 kC4CertUsage_ObjectSigning_CA = 0x01
+
34};
+
35
+
36
+
40typedef C4Slice C4CertNameAttributeID;
+
41
+
42// Some common Distinguished Name attributes:
+
43#define kC4Cert_CommonName C4STR("CN") // e.g. "Jane Doe", (or "jane.example.com")
+
44#define kC4Cert_Pseudonym C4STR("pseudonym") // e.g. "plainjane837"
+
45#define kC4Cert_GivenName C4STR("GN") // e.g. "Jane"
+
46#define kC4Cert_Surname C4STR("SN") // e.g. "Doe"
+
47#define kC4Cert_Organization C4STR("O") // e.g. "Example Corp."
+
48#define kC4Cert_OrganizationUnit C4STR("OU") // e.g. "Marketing"
+
49#define kC4Cert_PostalAddress C4STR("postalAddress")// e.g. "123 Example Blvd #2A"
+
50#define kC4Cert_Locality C4STR("locality") // e.g. "Boston"
+
51#define kC4Cert_PostalCode C4STR("postalCode") // e.g. "02134"
+
52#define kC4Cert_StateOrProvince C4STR("ST") // e.g. "Massachusetts" (or "Quebec", ...)
+
53#define kC4Cert_Country C4STR("C") // e.g. "us" (2-letter ISO country code)
+
54
+
55// These are the Subject Alternative Name attributes:
+
56#define kC4Cert_EmailAddress C4STR("rfc822Name") // 'rfc822Name', e.g. "jane@example.com"
+
57#define kC4Cert_Hostname C4STR("dNSName") // 'dnsName', e.g. "www.example.com"
+
58#define kC4Cert_URL C4STR("uniformResourceIdentifier") // "https://example.com/jane"
+
59#define kC4Cert_IPAddress C4STR("iPAddress") // *Binary* IP address, e.g. "\x0A\x00\x01\x01"
+
60#define kC4Cert_RegisteredID C4STR("registeredID") // Some sort of domain-specific ID?
+
61
+
63typedef struct C4CertNameInfo {
+ +
65 C4StringResult value;
+
66} C4CertNameInfo;
+
67
+
68
+
73typedef struct {
+
74 C4CertNameAttributeID attributeID;
+
75 C4String value;
+
76} C4CertNameComponent;
+
77
+
80typedef struct {
+
81 unsigned validityInSeconds;
+
82 C4String serialNumber;
+
83 int maxPathLen;
+
84 bool isCA;
+
85 bool addAuthorityIdentifier;
+
86 bool addSubjectIdentifier;
+
87 bool addBasicConstraints;
+
88} C4CertIssuerParameters;
+
89
+
91CBL_CORE_API extern const C4CertIssuerParameters kDefaultCertIssuerParameters;
+
92
+
100typedef C4_ENUM(uint8_t, C4KeyPairAlgorithm) {
+
101 kC4RSA,
+
102};
+
111typedef C4_ENUM(int, C4SignatureDigestAlgorithm) {
+
112 kC4SignatureDigestNone = 0,
+
113 kC4SignatureDigestSHA1 = 4,
+
114 kC4SignatureDigestSHA224,
+
115 kC4SignatureDigestSHA256,
+
116 kC4SignatureDigestSHA384,
+
117 kC4SignatureDigestSHA512,
+
118 kC4SignatureDigestRIPEMD160,
+
119};
+
120
+
121
+
123typedef struct C4ExternalKeyCallbacks {
+
130 bool (*publicKeyData)(void *externalKey,
+
131 void *output,
+
132 size_t outputMaxLen,
+
133 size_t *outputLen);
+
141 bool (*decrypt)(void *externalKey,
+
142 C4Slice input,
+
143 void *output,
+
144 size_t outputMaxLen,
+
145 size_t *outputLen);
+
154 bool (*sign)(void *externalKey,
+
155 C4SignatureDigestAlgorithm digestAlgorithm,
+
156 C4Slice inputData,
+
157 void *outSignature);
+
161 void (* C4NULLABLE free)(void *externalKey);
+
162} C4ExternalKeyCallbacks;
+
163
+ + +
171
+
172#endif // COUCHBASE_ENTERPRISE
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define CBL_CORE_API
Definition: c4Compat.h:113
@@ -196,7 +196,7 @@
diff --git a/docs/C/html/c4_collection_8h.html b/docs/C/html/c4_collection_8h.html index 2bedb97b82..f32052f061 100644 --- a/docs/C/html/c4_collection_8h.html +++ b/docs/C/html/c4_collection_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Collection.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Collection.h File Reference
+
c4Collection.h File Reference
#include "c4DocumentTypes.h"
@@ -75,21 +75,21 @@

Go to the source code of this file.

- - - - + + + - - - - - - + + + + + + @@ -103,9 +103,9 @@ - - - + + + @@ -113,18 +113,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -158,7 +158,7 @@ diff --git a/docs/C/html/c4_collection_8h_source.html b/docs/C/html/c4_collection_8h_source.html index 88d49a1678..ed805e5246 100644 --- a/docs/C/html/c4_collection_8h_source.html +++ b/docs/C/html/c4_collection_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Collection.h Source File @@ -30,21 +30,22 @@

+

Functions

Lifecycle
C4Collectionc4db_getDefaultCollection (C4Database *db)
 Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName). More...
 
C4Collectionc4db_getDefaultCollection (C4Database *db)
 Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName). More...
 
bool c4db_hasCollection (C4Database *db, C4CollectionSpec spec)
 Returns true if the collection exists. More...
 
C4Collectionc4db_getCollection (C4Database *db, C4CollectionSpec spec)
 Returns the existing collection with the given name & scope, or NULL if it doesn't exist. More...
 
C4Collectionc4db_createCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Creates and returns an empty collection with the given name & scope. More...
 
C4Collectionc4db_getCollection (C4Database *db, C4CollectionSpec spec)
 Returns the existing collection with the given name & scope, or NULL if it doesn't exist. More...
 
C4Collectionc4db_createCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Creates and returns an empty collection with the given name & scope. More...
 
bool c4db_deleteCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Deletes the collection with the given name & scope. More...
 
C4CollectionSpec c4coll_getSpec (C4Collection *)
 Returns the name and scope of the collection. More...
 
C4Databasec4coll_getDatabase (C4Collection *)
 Returns the database containing the collection. More...
 
C4Databasec4coll_getDatabase (C4Collection *)
 Returns the database containing the collection. More...
 
uint64_t c4coll_getDocumentCount (C4Collection *)
 Returns the number of (undeleted) documents in the collection. More...
 
 Returns the latest sequence number allocated to a revision. More...
 
Documents
C4Documentc4coll_getDoc (C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the collection given its ID. More...
 
C4Documentc4coll_getDocBySequence (C4Collection *collection, C4SequenceNumber, C4Error *outError)
 Gets a document from the collection given its sequence number. More...
 
C4Documentc4coll_putDoc (C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4coll_createDoc (C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4coll_getDoc (C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the collection given its ID. More...
 
C4Documentc4coll_getDocBySequence (C4Collection *collection, C4SequenceNumber, C4Error *outError)
 Gets a document from the collection given its sequence number. More...
 
C4Documentc4coll_putDoc (C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4coll_createDoc (C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
bool c4coll_moveDoc (C4Collection *collection, C4String docID, C4Collection *toCollection, C4String newDocID, C4Error *error)
 Moves a document to another collection, possibly with a different docID. More...
 
- + +/* @license-end */ +
-
-
c4Collection.h
+
c4Collection.h
-Go to the documentation of this file.
1 //
-
2 // c4Collection.h
-
3 //
-
4 // Copyright 2021-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 "c4DocumentTypes.h"
-
15 #include "c4IndexTypes.h"
-
16 
- - -
19 
-
20 
-
21 /* NOTE:
-
22  Enumeration-related functions are in c4DocEnumerator.h:
-
23  - c4coll_enumerateChanges
-
24  - c4coll_enumerateAllDocs
-
25  Observer-related functions are in c4Observer.h:
-
26  - c4dbobs_createOnCollection
-
27  - c4docobs_createWithCollection
-
28 */
-
29 
-
30 
- -
91 
- -
94  C4CollectionSpec spec) C4API;
-
95 
- -
98  C4CollectionSpec spec) C4API;
-
99 
- -
104  C4CollectionSpec spec,
-
105  C4Error* C4NULLABLE outError) C4API;
-
106 
- -
111  C4CollectionSpec spec,
-
112  C4Error* C4NULLABLE outError) C4API;
-
113 
- -
118  C4String inScope) C4API;
-
119 
- -
123 
-
124 
- -
132 
- -
135 
- -
138 
- -
141 
-
142 
- -
159  C4String docID,
-
160  bool mustExist,
-
161  C4DocContentLevel content,
-
162  C4Error* C4NULLABLE outError) C4API;
-
163 
- - -
168  C4Error* C4NULLABLE outError) C4API;
-
169 
- -
182  const C4DocPutRequest *request,
-
183  size_t * C4NULLABLE outCommonAncestorIndex,
-
184  C4Error* C4NULLABLE outError) C4API;
-
185 
- -
196  C4String docID,
-
197  C4Slice body,
-
198  C4RevisionFlags revisionFlags,
-
199  C4Error* C4NULLABLE error) C4API;
-
200 
-
208 bool c4coll_moveDoc(C4Collection *collection,
-
209  C4String docID,
-
210  C4Collection *toCollection,
-
211  C4String newDocID,
-
212  C4Error* C4NULLABLE error) C4API;
-
213 
-
214 
-
216 
-
217 
-
224 bool c4coll_purgeDoc(C4Collection *collection,
-
225  C4String docID,
-
226  C4Error* C4NULLABLE outError) C4API;
-
227 
-
228 
- -
238  C4String docID,
-
239  C4Timestamp timestamp,
-
240  C4Error* C4NULLABLE outError) C4API;
-
241 
- -
250  C4String docID,
-
251  C4Error* C4NULLABLE outError) C4API;
-
252 
- -
256 
- - -
261 
-
262 
- -
282  C4String name,
-
283  C4String indexSpec,
-
284  C4QueryLanguage queryLanguage,
-
285  C4IndexType indexType,
-
286  const C4IndexOptions* C4NULLABLE indexOptions,
-
287  C4Error* C4NULLABLE outError) C4API;
-
288 
- -
295  C4String name,
-
296  C4Error* C4NULLABLE outError) C4API;
-
297 
- -
305  C4Error* C4NULLABLE outError) C4API;
-
306  // end Collections group
-
309 
-
310 
- - +Go to the documentation of this file.
1//
+
2// c4Collection.h
+
3//
+
4// Copyright 2021-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 "c4DocumentTypes.h"
+
15#include "c4IndexTypes.h"
+
16
+ + +
19
+
20
+
21/* NOTE:
+
22 Enumeration-related functions are in c4DocEnumerator.h:
+
23 - c4coll_enumerateChanges
+
24 - c4coll_enumerateAllDocs
+
25 Observer-related functions are in c4Observer.h:
+
26 - c4dbobs_createOnCollection
+
27 - c4docobs_createWithCollection
+
28*/
+
29
+
30
+ +
91
+ + +
95
+ + +
99
+ +
104 C4CollectionSpec spec,
+
105 C4Error* C4NULLABLE outError) C4API;
+
106
+ +
111 C4CollectionSpec spec,
+
112 C4Error* C4NULLABLE outError) C4API;
+
113
+ +
118 C4String inScope) C4API;
+
119
+ +
123
+
124
+ +
132
+ +
135
+ +
138
+ +
141
+
142
+ +
159 C4String docID,
+
160 bool mustExist,
+
161 C4DocContentLevel content,
+
162 C4Error* C4NULLABLE outError) C4API;
+
163
+ + +
168 C4Error* C4NULLABLE outError) C4API;
+
169
+ +
182 const C4DocPutRequest *request,
+
183 size_t * C4NULLABLE outCommonAncestorIndex,
+
184 C4Error* C4NULLABLE outError) C4API;
+
185
+ +
196 C4String docID,
+
197 C4Slice body,
+
198 C4RevisionFlags revisionFlags,
+
199 C4Error* C4NULLABLE error) C4API;
+
200
+ +
209 C4String docID,
+
210 C4Collection *toCollection,
+
211 C4String newDocID,
+
212 C4Error* C4NULLABLE error) C4API;
+
213
+
214
+
216
+
217
+ +
225 C4String docID,
+
226 C4Error* C4NULLABLE outError) C4API;
+
227
+
228
+ +
238 C4String docID,
+
239 C4Timestamp timestamp,
+
240 C4Error* C4NULLABLE outError) C4API;
+
241
+ +
250 C4String docID,
+
251 C4Error* C4NULLABLE outError) C4API;
+
252
+ +
256
+ + +
261
+
262
+ +
282 C4String name,
+
283 C4String indexSpec,
+
284 C4QueryLanguage queryLanguage,
+
285 C4IndexType indexType,
+
286 const C4IndexOptions* C4NULLABLE indexOptions,
+
287 C4Error* C4NULLABLE outError) C4API;
+
288
+ +
295 C4String name,
+
296 C4Error* C4NULLABLE outError) C4API;
+
297
+ +
305 C4Error* C4NULLABLE outError) C4API;
+
306 // end Collections group
+
309
+
310
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -211,36 +211,36 @@
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: c4Base.h:87
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition: c4Base.h:118
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
C4Timestamp c4coll_getDocExpiration(C4Collection *collection, C4String docID, C4Error *outError)
Returns the expiration time of a document, if one has been set, else 0.
bool c4coll_setDocExpiration(C4Collection *collection, C4String docID, C4Timestamp timestamp, C4Error *outError)
Sets an expiration date on a document.
+
C4Collection * c4db_getDefaultCollection(C4Database *db)
Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName).
C4CollectionSpec c4coll_getSpec(C4Collection *)
Returns the name and scope of the collection.
-
C4Collection * c4db_createCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Creates and returns an empty collection with the given name & scope.
bool c4coll_createIndex(C4Collection *collection, C4String name, C4String indexSpec, C4QueryLanguage queryLanguage, C4IndexType indexType, const C4IndexOptions *indexOptions, C4Error *outError)
Creates a collection index, of the values of specific expressions across all documents.
bool c4coll_purgeDoc(C4Collection *collection, C4String docID, C4Error *outError)
Removes all trace of a document and its revisions from the collection.
+
C4Collection * c4db_createCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Creates and returns an empty collection with the given name & scope.
uint64_t c4coll_getDocumentCount(C4Collection *)
Returns the number of (undeleted) documents in the collection.
-
C4Database * c4coll_getDatabase(C4Collection *)
Returns the database containing the collection.
bool c4db_deleteCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Deletes the collection with the given name & scope.
C4Timestamp c4coll_nextDocExpiration(C4Collection *)
Returns the time at which the next document expiration in this collection should take place,...
-
C4Document * c4coll_getDoc(C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the collection given its ID.
-
C4Collection * c4db_getCollection(C4Database *db, C4CollectionSpec spec)
Returns the existing collection with the given name & scope, or NULL if it doesn't exist.
+
C4Collection * c4db_getCollection(C4Database *db, C4CollectionSpec spec)
Returns the existing collection with the given name & scope, or NULL if it doesn't exist.
bool c4coll_moveDoc(C4Collection *collection, C4String docID, C4Collection *toCollection, C4String newDocID, C4Error *error)
Moves a document to another collection, possibly with a different docID.
+
C4Document * c4coll_getDoc(C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the collection given its ID.
+
C4Database * c4coll_getDatabase(C4Collection *)
Returns the database containing the collection.
+
C4Document * c4coll_createDoc(C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
bool c4db_hasCollection(C4Database *db, C4CollectionSpec spec)
Returns true if the collection exists.
FLMutableArray c4db_scopeNames(C4Database *db)
Returns the names of all existing scopes, in the order in which they were created.
-
C4Document * c4coll_putDoc(C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
A high-level Put operation, to insert a new or downloaded revision.
-
C4Document * c4coll_getDocBySequence(C4Collection *collection, C4SequenceNumber, C4Error *outError)
Gets a document from the collection given its sequence number.
-
C4Collection * c4db_getDefaultCollection(C4Database *db)
Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName).
C4SequenceNumber c4coll_getLastSequence(C4Collection *)
Returns the latest sequence number allocated to a revision.
C4SliceResult c4coll_getIndexesInfo(C4Collection *collection, C4Error *outError)
Returns information about all indexes in the collection.
int64_t c4coll_purgeExpiredDocs(C4Collection *, C4Error *)
Purges all documents that have expired.
+
C4Document * c4coll_putDoc(C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
A high-level Put operation, to insert a new or downloaded revision.
FLMutableArray c4db_collectionNames(C4Database *db, C4String inScope)
Returns the names of all existing collections in the given scope, in the order in which they were cre...
-
C4Document * c4coll_createDoc(C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
bool c4coll_deleteIndex(C4Collection *collection, C4String name, C4Error *outError)
Deletes an index that was created by c4coll_createIndex.
+
C4Document * c4coll_getDocBySequence(C4Collection *collection, C4SequenceNumber, C4Error *outError)
Gets a document from the collection given its sequence number.
C4DocContentLevel
Specifies how much content to retrieve when getting a document.
Definition: c4DocumentTypes.h:50
C4RevisionFlags
Flags that apply to a revision.
Definition: c4DocumentTypes.h:33
C4IndexType
Types of indexes.
Definition: c4IndexTypes.h:26
C4QueryLanguage
Supported query languages.
Definition: c4QueryTypes.h:26
-
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:55
+
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: FLBase.h:55
Full identifier of a collection in a database, including its scope.
Definition: c4DatabaseTypes.h:95
Parameters for adding a revision using c4doc_put.
Definition: c4DocumentTypes.h:86
Describes a version-controlled document.
Definition: c4DocumentStruct.h:31
@@ -251,7 +251,7 @@
diff --git a/docs/C/html/c4_compat_8h.html b/docs/C/html/c4_compat_8h.html index 82dec09269..c0e424b587 100644 --- a/docs/C/html/c4_compat_8h.html +++ b/docs/C/html/c4_compat_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Compat.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Compat.h File Reference
+
c4Compat.h File Reference
-
#include "fleece/CompilerSupport.h"
+

Go to the source code of this file.

- @@ -114,7 +114,7 @@

+

Macros

#define C4INLINE   inline
 
 

Macro Definition Documentation

- +

◆ __C4_ENUM_ATTRIBUTES

@@ -128,7 +128,7 @@

+

◆ __C4_OPTIONS_ATTRIBUTES

@@ -142,7 +142,7 @@

+

◆ __printflike

@@ -170,7 +170,7 @@

+

◆ C4_ASSUME_NONNULL_BEGIN

@@ -184,7 +184,7 @@

+

◆ C4_ASSUME_NONNULL_END

@@ -198,7 +198,7 @@

+

◆ C4_DEPRECATED

@@ -216,7 +216,7 @@

+

◆ C4_ENUM

@@ -244,7 +244,7 @@

+

◆ C4_OPTIONS

@@ -272,7 +272,7 @@

+

◆ C4_RETURNS_NONNULL

@@ -286,7 +286,7 @@

+

◆ C4API

@@ -300,7 +300,7 @@

+

◆ C4API_BEGIN_DECLS

@@ -314,7 +314,7 @@

+

◆ C4API_END_DECLS

@@ -328,7 +328,7 @@

+

◆ C4INLINE

@@ -342,7 +342,7 @@

+

◆ C4NONNULL

@@ -356,7 +356,7 @@

+

◆ C4NULLABLE

@@ -370,7 +370,7 @@

+

◆ C4UNUSED

@@ -384,7 +384,7 @@

+

◆ CBL_CORE_API

@@ -401,7 +401,7 @@

diff --git a/docs/C/html/c4_compat_8h_source.html b/docs/C/html/c4_compat_8h_source.html index 2de538b262..6ccb3310a7 100644 --- a/docs/C/html/c4_compat_8h_source.html +++ b/docs/C/html/c4_compat_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Compat.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4Compat.h
+
c4Compat.h
-Go to the documentation of this file.
1 //
-
2 // c4Compat.h
-
3 //
-
4 // Copyright 2018-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 "fleece/CompilerSupport.h"
-
15 
-
16 #ifdef _MSC_VER
-
17 # define C4INLINE __forceinline
-
18 #else
-
19 # define C4INLINE inline
-
20 #endif
-
21 
-
22 // Non-null annotations, for function parameters and struct fields.
-
23 // In between C4_ASSUME_NONNULL_BEGIN and C4_ASSUME_NONNULL_END, all pointer declarations implicitly
-
24 // disallow NULL values, unless annotated with C4NULLABLE (which must come after the `*`.)
-
25 // (C4NONNULL is occasionally necessary when there are multiple levels of pointers.)
-
26 // NOTE: Does not apply to function return values, for some reason. Those may still be null,
-
27 // unless annotated with C4_RETURNS_NONNULL.
-
28 // NOTE: Only supported in Clang, so far.
-
29 #if __has_feature(nullability)
-
30 # define C4_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
-
31 # define C4_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
-
32 # define C4NULLABLE _Nullable
-
33 # define C4NONNULL _Nonnull
-
34 # define C4_RETURNS_NONNULL __attribute__((returns_nonnull))
-
35 #else
-
36 # define C4_ASSUME_NONNULL_BEGIN
-
37 # define C4_ASSUME_NONNULL_END
-
38 # define C4NULLABLE
-
39 # define C4NONNULL
-
40 # define C4_RETURNS_NONNULL
-
41 #endif
-
42 
-
43 // Macros for defining typed enumerations and option flags.
-
44 // To define an enumeration whose values won't be combined:
-
45 // typedef C4_ENUM(baseIntType, name) { ... };
-
46 // To define an enumeration of option flags that will be ORed together:
-
47 // typedef C4_OPTIONS(baseIntType, name) { ... };
-
48 // These aren't just a convenience; they are required for Swift bindings.
-
49 #if __has_attribute(enum_extensibility)
-
50 #define __C4_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
-
51 #define __C4_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open)))
-
52 #else
-
53 #define __C4_ENUM_ATTRIBUTES
-
54 #define __C4_OPTIONS_ATTRIBUTES
-
55 #endif
-
56 
-
57 #if __APPLE__
-
58  #include <CoreFoundation/CFBase.h> /* for CF_ENUM and CF_OPTIONS macros */
-
59  #define C4_ENUM CF_ENUM
-
60  #define C4_OPTIONS CF_OPTIONS
-
61 #elif DOXYGEN_PARSING
-
62  #define C4_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-
63  #define C4_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
-
64 #else
-
65  #if (__cplusplus && _MSC_VER) || (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
-
66  #define C4_ENUM(_type, _name) int __C4_ENUM_ ## _name; enum __C4_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
-
67  #if (__cplusplus)
-
68  #define C4_OPTIONS(_type, _name) _type _name; enum __C4_OPTIONS_ATTRIBUTES : _type
-
69  #else
-
70  #define C4_OPTIONS(_type, _name) int __C4_OPTIONS_ ## _name; enum __C4_OPTIONS_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
-
71  #endif
-
72  #else
-
73  #define C4_ENUM(_type, _name) _type _name; enum
-
74  #define C4_OPTIONS(_type, _name) _type _name; enum
-
75  #endif
-
76 #endif
-
77 
-
78 
-
79 // Suppresses warnings if an entity is unused.
-
80 #if __has_attribute(unused)
-
81 # define C4UNUSED __attribute__((unused))
-
82 #else
-
83 # define C4UNUSED
-
84 #endif
-
85 
-
86 
-
87 // Declaration for API functions; should be just before the ending ";".
-
88 #ifdef __cplusplus
-
89  #define C4API noexcept
-
90  #define C4API_BEGIN_DECLS extern "C" {
-
91  #define C4API_END_DECLS }
-
92 #else
-
93  #define C4API
-
94  #define C4API_BEGIN_DECLS
-
95  #define C4API_END_DECLS
-
96 #endif
-
97 
-
98 // Deprecating functions & types (Note: In C++only code, can use standard `[[deprecated]]`)
-
99 #ifdef _MSC_VER
-
100 # define C4_DEPRECATED(MSG) __declspec(deprecated(MSG))
-
101 #else
-
102 # define C4_DEPRECATED(MSG) __attribute((deprecated(MSG)))
-
103 #endif
-
104 
-
105 // Export/import stuff:
-
106 #ifdef _MSC_VER
-
107  #ifdef LITECORE_EXPORTS
-
108  #define CBL_CORE_API __declspec(dllexport)
-
109  #else
-
110  #define CBL_CORE_API __declspec(dllimport)
-
111  #endif
-
112 #else
-
113  #define CBL_CORE_API
-
114 #endif
-
115 
-
116 
-
117 // Type-checking for printf-style vararg functions:
-
118 #ifdef _MSC_VER
-
119  #define __printflike(A, B)
-
120 #else
-
121  #ifndef __printflike
-
122  #define __printflike(fmtarg, firstvararg) __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
-
123  #endif
-
124 #endif
+Go to the documentation of this file.
1//
+
2// c4Compat.h
+
3//
+
4// Copyright 2018-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
+ +
15
+
16#ifdef _MSC_VER
+
17# define C4INLINE __forceinline
+
18#else
+
19# define C4INLINE inline
+
20#endif
+
21
+
22// Non-null annotations, for function parameters and struct fields.
+
23// In between C4_ASSUME_NONNULL_BEGIN and C4_ASSUME_NONNULL_END, all pointer declarations implicitly
+
24// disallow NULL values, unless annotated with C4NULLABLE (which must come after the `*`.)
+
25// (C4NONNULL is occasionally necessary when there are multiple levels of pointers.)
+
26// NOTE: Does not apply to function return values, for some reason. Those may still be null,
+
27// unless annotated with C4_RETURNS_NONNULL.
+
28// NOTE: Only supported in Clang, so far.
+
29#if __has_feature(nullability)
+
30# define C4_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
+
31# define C4_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
+
32# define C4NULLABLE _Nullable
+
33# define C4NONNULL _Nonnull
+
34# define C4_RETURNS_NONNULL __attribute__((returns_nonnull))
+
35#else
+
36# define C4_ASSUME_NONNULL_BEGIN
+
37# define C4_ASSUME_NONNULL_END
+
38# define C4NULLABLE
+
39# define C4NONNULL
+
40# define C4_RETURNS_NONNULL
+
41#endif
+
42
+
43// Macros for defining typed enumerations and option flags.
+
44// To define an enumeration whose values won't be combined:
+
45// typedef C4_ENUM(baseIntType, name) { ... };
+
46// To define an enumeration of option flags that will be ORed together:
+
47// typedef C4_OPTIONS(baseIntType, name) { ... };
+
48// These aren't just a convenience; they are required for Swift bindings.
+
49#if __has_attribute(enum_extensibility)
+
50#define __C4_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
+
51#define __C4_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open)))
+
52#else
+
53#define __C4_ENUM_ATTRIBUTES
+
54#define __C4_OPTIONS_ATTRIBUTES
+
55#endif
+
56
+
57#if __APPLE__
+
58 #include <CoreFoundation/CFBase.h> /* for CF_ENUM and CF_OPTIONS macros */
+
59 #define C4_ENUM CF_ENUM
+
60 #define C4_OPTIONS CF_OPTIONS
+
61#elif DOXYGEN_PARSING
+
62 #define C4_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+
63 #define C4_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+
64#else
+
65 #if (__cplusplus && _MSC_VER) || (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
+
66 #define C4_ENUM(_type, _name) int __C4_ENUM_ ## _name; enum __C4_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
+
67 #if (__cplusplus)
+
68 #define C4_OPTIONS(_type, _name) _type _name; enum __C4_OPTIONS_ATTRIBUTES : _type
+
69 #else
+
70 #define C4_OPTIONS(_type, _name) int __C4_OPTIONS_ ## _name; enum __C4_OPTIONS_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
+
71 #endif
+
72 #else
+
73 #define C4_ENUM(_type, _name) _type _name; enum
+
74 #define C4_OPTIONS(_type, _name) _type _name; enum
+
75 #endif
+
76#endif
+
77
+
78
+
79// Suppresses warnings if an entity is unused.
+
80#if __has_attribute(unused)
+
81# define C4UNUSED __attribute__((unused))
+
82#else
+
83# define C4UNUSED
+
84#endif
+
85
+
86
+
87// Declaration for API functions; should be just before the ending ";".
+
88#ifdef __cplusplus
+
89 #define C4API noexcept
+
90 #define C4API_BEGIN_DECLS extern "C" {
+
91 #define C4API_END_DECLS }
+
92#else
+
93 #define C4API
+
94 #define C4API_BEGIN_DECLS
+
95 #define C4API_END_DECLS
+
96#endif
+
97
+
98// Deprecating functions & types (Note: In C++only code, can use standard `[[deprecated]]`)
+
99#ifdef _MSC_VER
+
100# define C4_DEPRECATED(MSG) __declspec(deprecated(MSG))
+
101#else
+
102# define C4_DEPRECATED(MSG) __attribute((deprecated(MSG)))
+
103#endif
+
104
+
105// Export/import stuff:
+
106#ifdef _MSC_VER
+
107 #ifdef LITECORE_EXPORTS
+
108 #define CBL_CORE_API __declspec(dllexport)
+
109 #else
+
110 #define CBL_CORE_API __declspec(dllimport)
+
111 #endif
+
112#else
+
113 #define CBL_CORE_API
+
114#endif
+
115
+
116
+
117// Type-checking for printf-style vararg functions:
+
118#ifdef _MSC_VER
+
119 #define __printflike(A, B)
+
120#else
+
121 #ifndef __printflike
+
122 #define __printflike(fmtarg, firstvararg) __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+
123 #endif
+
124#endif
+
diff --git a/docs/C/html/c4_connected_client_8h.html b/docs/C/html/c4_connected_client_8h.html new file mode 100644 index 0000000000..1922bcde50 --- /dev/null +++ b/docs/C/html/c4_connected_client_8h.html @@ -0,0 +1,103 @@ + + + + + + + +LiteCore: c4ConnectedClient.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LiteCore +
+
Couchbase Lite cross-platform core implementation
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
c4ConnectedClient.h File Reference
+
+
+ +

Go to the source code of this file.

+ + + + + + + + + + + + + + + + + +

+Functions

C4ConnectedClientc4client_new (const C4ConnectedClientParameters *params, C4Error *error)
 Creates a new connected client and starts it automatically. More...
 
bool c4client_getDoc (C4ConnectedClient *, C4Slice docID, C4Slice collectionID, C4Slice unlessRevID, bool asFleece, C4ConnectedClientGetDocumentCallback callback, void *context, C4Error *outError)
 Gets the current revision of a document from the server. More...
 
bool c4client_putDoc (C4ConnectedClient *client, C4Slice docID, C4Slice collectionID, C4Slice revID, C4RevisionFlags revisionFlags, C4Slice fleeceData, C4ConnectedClientUpdateDocumentCallback callback, void *context, C4Error *outError)
 Pushes a new document revision to the server. More...
 
void c4client_start (C4ConnectedClient *)
 Tells a connected client to start. More...
 
void c4client_stop (C4ConnectedClient *)
 Tells a replicator to stop. More...
 
+
+ + + + diff --git a/docs/C/html/c4_connected_client_8h_source.html b/docs/C/html/c4_connected_client_8h_source.html new file mode 100644 index 0000000000..93f5bc0dd6 --- /dev/null +++ b/docs/C/html/c4_connected_client_8h_source.html @@ -0,0 +1,144 @@ + + + + + + + +LiteCore: c4ConnectedClient.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LiteCore +
+
Couchbase Lite cross-platform core implementation
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
c4ConnectedClient.h
+
+
+Go to the documentation of this file.
1//
+
2// c4ConnectedClient.h
+
3//
+
4// Copyright 2022-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
+ +
15
+ + +
18
+ +
32 C4Error* C4NULLABLE error) C4API;
+
33
+ +
46 C4Slice docID,
+
47 C4Slice collectionID,
+
48 C4Slice unlessRevID,
+
49 bool asFleece,
+ +
51 void * C4NULLABLE context,
+
52 C4Error* C4NULLABLE outError) C4API;
+
53
+ +
65 C4Slice docID,
+
66 C4Slice collectionID,
+
67 C4Slice revID,
+
68 C4RevisionFlags revisionFlags,
+
69 C4Slice fleeceData,
+ +
71 void * C4NULLABLE context,
+
72 C4Error* C4NULLABLE outError) C4API;
+
73
+ +
77
+ +
81
+ + +
#define C4NULLABLE
Definition: c4Compat.h:38
+
#define C4API
Definition: c4Compat.h:93
+
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
+
#define C4API_END_DECLS
Definition: c4Compat.h:95
+
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
+
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
+ +
struct C4ConnectedClient C4ConnectedClient
Opaque reference to a Connected Client.
Definition: c4Base.h:121
+
C4ConnectedClient * c4client_new(const C4ConnectedClientParameters *params, C4Error *error)
Creates a new connected client and starts it automatically.
+
bool c4client_putDoc(C4ConnectedClient *client, C4Slice docID, C4Slice collectionID, C4Slice revID, C4RevisionFlags revisionFlags, C4Slice fleeceData, C4ConnectedClientUpdateDocumentCallback callback, void *context, C4Error *outError)
Pushes a new document revision to the server.
+
void c4client_stop(C4ConnectedClient *)
Tells a replicator to stop.
+
void(* C4ConnectedClientUpdateDocumentCallback)(C4ConnectedClient *client, C4HeapSlice revID, C4Error *err, void *context)
Callback for updating the document result.
Definition: c4ConnectedClientTypes.h:58
+
bool c4client_getDoc(C4ConnectedClient *, C4Slice docID, C4Slice collectionID, C4Slice unlessRevID, bool asFleece, C4ConnectedClientGetDocumentCallback callback, void *context, C4Error *outError)
Gets the current revision of a document from the server.
+
void c4client_start(C4ConnectedClient *)
Tells a connected client to start.
+
void(* C4ConnectedClientGetDocumentCallback)(C4ConnectedClient *client, const C4DocResponse *doc, C4Error *err, void *context)
Callback for getting the document result.
Definition: c4ConnectedClientTypes.h:49
+
C4RevisionFlags
Flags that apply to a revision.
Definition: c4DocumentTypes.h:33
+
Parameters describing a connected client, used when creating a C4ConnectedClient.
Definition: c4ConnectedClientTypes.h:32
+
An error value.
Definition: c4Error.h:130
+
A simple reference to a block of memory.
Definition: FLSlice.h:48
+
+ + + + diff --git a/docs/C/html/c4_connected_client_types_8h.html b/docs/C/html/c4_connected_client_types_8h.html new file mode 100644 index 0000000000..73f24939e8 --- /dev/null +++ b/docs/C/html/c4_connected_client_types_8h.html @@ -0,0 +1,106 @@ + + + + + + + +LiteCore: c4ConnectedClientTypes.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LiteCore +
+
Couchbase Lite cross-platform core implementation
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
c4ConnectedClientTypes.h File Reference
+
+
+
#include "c4ReplicatorTypes.h"
+
+

Go to the source code of this file.

+ + + + + + + + +

+Data Structures

struct  C4DocResponse
 Result of a successful c4client_getDoc call. More...
 
struct  C4ConnectedClientParameters
 Parameters describing a connected client, used when creating a C4ConnectedClient. More...
 
+ + + + + + + + + +

+Typedefs

typedef C4ReplicatorStatus C4ConnectedClientStatus
 
typedef void(* C4ConnectedClientGetDocumentCallback) (C4ConnectedClient *client, const C4DocResponse *doc, C4Error *err, void *context)
 Callback for getting the document result. More...
 
typedef void(* C4ConnectedClientUpdateDocumentCallback) (C4ConnectedClient *client, C4HeapSlice revID, C4Error *err, void *context)
 Callback for updating the document result. More...
 
+
+ + + + diff --git a/docs/C/html/c4_connected_client_types_8h_source.html b/docs/C/html/c4_connected_client_types_8h_source.html new file mode 100644 index 0000000000..e41a8ec19c --- /dev/null +++ b/docs/C/html/c4_connected_client_types_8h_source.html @@ -0,0 +1,156 @@ + + + + + + + +LiteCore: c4ConnectedClientTypes.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LiteCore +
+
Couchbase Lite cross-platform core implementation
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
c4ConnectedClientTypes.h
+
+
+Go to the documentation of this file.
1//
+
2// c4ConnectedClientTypes.h
+
3//
+
4// Copyright 2022-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 "c4ReplicatorTypes.h"
+
15
+ + +
18
+
23typedef struct C4DocResponse {
+ + + +
27 bool deleted;
+ +
29
+
30
+ + + + + + + + +
40
+
41
+ +
43
+ +
50 const C4DocResponse* C4NULLABLE doc,
+ +
52 void * C4NULLABLE context);
+
53
+ +
59 C4HeapSlice revID,
+ +
61 void * C4NULLABLE context);
+ + +
#define C4NULLABLE
Definition: c4Compat.h:38
+
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
+
#define C4API_END_DECLS
Definition: c4Compat.h:95
+
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
+
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
+ +
struct C4ConnectedClient C4ConnectedClient
Opaque reference to a Connected Client.
Definition: c4Base.h:121
+
C4ReplicatorStatus C4ConnectedClientStatus
Definition: c4ConnectedClientTypes.h:42
+
void(* C4ConnectedClientUpdateDocumentCallback)(C4ConnectedClient *client, C4HeapSlice revID, C4Error *err, void *context)
Callback for updating the document result.
Definition: c4ConnectedClientTypes.h:58
+
void(* C4ConnectedClientGetDocumentCallback)(C4ConnectedClient *client, const C4DocResponse *doc, C4Error *err, void *context)
Callback for getting the document result.
Definition: c4ConnectedClientTypes.h:49
+
void * C4ReplicatorPropertyDecryptionCallback
Definition: c4ReplicatorTypes.h:183
+
void * C4ReplicatorPropertyEncryptionCallback
Definition: c4ReplicatorTypes.h:182
+
Parameters describing a connected client, used when creating a C4ConnectedClient.
Definition: c4ConnectedClientTypes.h:32
+
const C4SocketFactory * socketFactory
Custom C4SocketFactory.
Definition: c4ConnectedClientTypes.h:38
+
C4Slice url
URL with database to connect.
Definition: c4ConnectedClientTypes.h:33
+
C4ReplicatorPropertyDecryptionCallback propertyDecryptor
Decryption callback.
Definition: c4ConnectedClientTypes.h:36
+
C4ReplicatorPropertyEncryptionCallback propertyEncryptor
Encryption callback.
Definition: c4ConnectedClientTypes.h:35
+
C4Slice optionsDictFleece
Fleece-encoded dictionary of optional parameters.
Definition: c4ConnectedClientTypes.h:34
+
void * callbackContext
Value passed to callbacks.
Definition: c4ConnectedClientTypes.h:37
+
Result of a successful c4client_getDoc call.
Definition: c4ConnectedClientTypes.h:23
+
bool deleted
True if the document is deleted.
Definition: c4ConnectedClientTypes.h:27
+
C4HeapSlice docID
The document ID.
Definition: c4ConnectedClientTypes.h:24
+
C4HeapSlice body
The document body (Fleece or JSON, as requested)
Definition: c4ConnectedClientTypes.h:26
+
C4HeapSlice revID
The revision ID.
Definition: c4ConnectedClientTypes.h:25
+
An error value.
Definition: c4Error.h:130
+
Current status of replication.
Definition: c4ReplicatorTypes.h:101
+
A group of callbacks that define the implementation of sockets; the client must fill this out and pas...
Definition: c4SocketTypes.h:58
+
A simple reference to a block of memory.
Definition: FLSlice.h:48
+
+ + + + diff --git a/docs/C/html/c4_database_8h.html b/docs/C/html/c4_database_8h.html index 114ef2a4ca..e6a43b8571 100644 --- a/docs/C/html/c4_database_8h.html +++ b/docs/C/html/c4_database_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Database.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
c4Database.h File Reference
+
c4Database.h File Reference

#include "c4DatabaseTypes.h"

Go to the source code of this file.

-

+

Macros

#define kC4InfoStore   C4STR("info")
 
#define kC4LocalDocStore   C4STR("_local")
 
- - - - + + + @@ -106,12 +106,12 @@ - - - - - - + + + + + + @@ -137,9 +137,9 @@ - - - + + + @@ -179,7 +179,7 @@ diff --git a/docs/C/html/c4_database_8h_source.html b/docs/C/html/c4_database_8h_source.html index 12d9e235c4..7be260d478 100644 --- a/docs/C/html/c4_database_8h_source.html +++ b/docs/C/html/c4_database_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Database.h Source File @@ -30,21 +30,22 @@

+

Functions

void c4raw_free (C4RawDocument *rawDoc)
 Frees the storage occupied by a raw document. More...
 
C4RawDocumentc4raw_get (C4Database *database, C4String storeName, C4String docID, C4Error *outError)
 Reads a raw document from the database. More...
 
C4RawDocumentc4raw_get (C4Database *database, C4String storeName, C4String docID, C4Error *outError)
 Reads a raw document from the database. More...
 
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. More...
 
bool c4db_exists (C4String name, C4String inDirectory)
 Returns true if a database with the given name exists in the directory. More...
 
C4Databasec4db_openNamed (C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
 Opens a database given its name (without the ".cblite2" extension) and directory. More...
 
C4Databasec4db_openAgain (C4Database *db, C4Error *outError)
 Opens a new handle to the same database file as db. More...
 
C4Databasec4db_openNamed (C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
 Opens a database given its name (without the ".cblite2" extension) and directory. More...
 
C4Databasec4db_openAgain (C4Database *db, C4Error *outError)
 Opens a new handle to the same database file as db. More...
 
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, with the given name. More...
 
C4StringResult c4db_getPath (C4Database *)
 Returns the path of the database. More...
 
const C4DatabaseConfig2c4db_getConfig2 (C4Database *database)
 Returns the configuration the database was opened with. More...
 
const C4DatabaseConfig2c4db_getConfig2 (C4Database *database)
 Returns the configuration the database was opened with. More...
 
uint64_t c4db_getDocumentCount (C4Database *database)
 Returns the number of (undeleted) documents in the database. More...
 
- + +/* @license-end */ +
-
-
c4Database.h
+
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 
-
24 
-
35  bool c4key_setPassword(C4EncryptionKey *encryptionKey,
-
36  C4String password,
- -
38 
- -
47  C4String password,
- -
49 
-
53 
-
54 
-
59  bool c4db_exists(C4String name, C4String inDirectory) C4API;
-
60 
-
61 
- -
64  const C4DatabaseConfig2 *config,
-
65  C4Error* C4NULLABLE outError) C4API;
-
66 
- -
70  C4Error* C4NULLABLE outError) C4API;
-
71 
-
81  bool c4db_copyNamed(C4String sourcePath,
-
82  C4String destinationName,
-
83  const C4DatabaseConfig2* config,
-
84  C4Error* C4NULLABLE error) C4API;
-
85 
- -
89 
-
92  bool c4db_delete(C4Database* database, C4Error* C4NULLABLE outError) C4API;
-
93 
- -
98  C4String inDirectory,
-
99  C4Error* C4NULLABLE outError) C4API;
-
100 
-
101 
-
103  bool c4db_rekey(C4Database* database,
-
104  const C4EncryptionKey * C4NULLABLE newKey,
-
105  C4Error* C4NULLABLE outError) C4API;
-
106 
- -
110 
-
111 
- -
120 
- -
123 
- -
126 
-
127 #ifndef C4_STRICT_COLLECTION_API
-
128 
- -
131 
- -
134 
- -
138 
- -
145 
-
146 #endif // C4_STRICT_COLLECTION_API
-
147 
-
149  bool c4db_getUUIDs(C4Database* database,
-
150  C4UUID* C4NULLABLE publicUUID, C4UUID* C4NULLABLE privateUUID,
-
151  C4Error* C4NULLABLE outError) C4API;
-
152 
- -
159 
- -
162 
-
163 
-
171  bool c4db_maintenance(C4Database* database,
-
172  C4MaintenanceType type,
-
173  C4Error* C4NULLABLE outError) C4API;
-
174 
-
175 
- -
184  C4Error* C4NULLABLE outError) C4API;
-
185 
- -
190  bool commit,
-
191  C4Error* C4NULLABLE outError) C4API;
-
192 
- -
195 
-
196 
-
202 
-
203 
- -
210 
- -
214  C4String storeName,
-
215  C4String docID,
-
216  C4Error* C4NULLABLE outError) C4API;
-
217 
-
219  bool c4raw_put(C4Database* database,
-
220  C4String storeName,
-
221  C4String key,
-
222  C4String meta,
-
223  C4String body,
-
224  C4Error* C4NULLABLE outError) C4API;
-
225 
-
226  // Store used for database metadata.
-
227  #define kC4InfoStore C4STR("info")
-
228 
-
229  // Store used for local (non-replicated) documents.
-
230  #define kC4LocalDocStore C4STR("_local")
-
231 
- - +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
+
24
+ +
36 C4String password,
+ +
38
+ +
47 C4String password,
+ +
49
+
53
+
54
+
59 bool c4db_exists(C4String name, C4String inDirectory) C4API;
+
60
+
61
+ +
64 const C4DatabaseConfig2 *config,
+
65 C4Error* C4NULLABLE outError) C4API;
+
66
+ +
70 C4Error* C4NULLABLE outError) C4API;
+
71
+
81 bool c4db_copyNamed(C4String sourcePath,
+
82 C4String destinationName,
+
83 const C4DatabaseConfig2* config,
+
84 C4Error* C4NULLABLE error) C4API;
+
85
+ +
89
+
92 bool c4db_delete(C4Database* database, C4Error* C4NULLABLE outError) C4API;
+
93
+ +
98 C4String inDirectory,
+
99 C4Error* C4NULLABLE outError) C4API;
+
100
+
101
+
103 bool c4db_rekey(C4Database* database,
+
104 const C4EncryptionKey * C4NULLABLE newKey,
+
105 C4Error* C4NULLABLE outError) C4API;
+
106
+ +
110
+
111
+ +
120
+ +
123
+ +
126
+
127#ifndef C4_STRICT_COLLECTION_API
+
128
+ +
131
+ +
134
+ +
138
+ +
145
+
146#endif // C4_STRICT_COLLECTION_API
+
147
+
149 bool c4db_getUUIDs(C4Database* database,
+
150 C4UUID* C4NULLABLE publicUUID, C4UUID* C4NULLABLE privateUUID,
+
151 C4Error* C4NULLABLE outError) C4API;
+
152
+ +
159
+ +
162
+
163
+ + +
173 C4Error* C4NULLABLE outError) C4API;
+
174
+
175
+ +
184 C4Error* C4NULLABLE outError) C4API;
+
185
+ +
190 bool commit,
+
191 C4Error* C4NULLABLE outError) C4API;
+
192
+ +
195
+
196
+
202
+
203
+ +
210
+ +
214 C4String storeName,
+
215 C4String docID,
+
216 C4Error* C4NULLABLE outError) C4API;
+
217
+
219 bool c4raw_put(C4Database* database,
+
220 C4String storeName,
+
221 C4String key,
+
222 C4String meta,
+
223 C4String body,
+
224 C4Error* C4NULLABLE outError) C4API;
+
225
+
226 // Store used for database metadata.
+
227 #define kC4InfoStore C4STR("info")
+
228
+
229 // Store used for local (non-replicated) documents.
+
230 #define kC4LocalDocStore C4STR("_local")
+
231
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_RETURNS_NONNULL
Definition: c4Compat.h:40
@@ -206,20 +206,18 @@
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: c4Base.h:87
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
void c4db_setExtraInfo(C4Database *database, C4ExtraInfo)
Associates an arbitrary pointer with this database instance, for client use.
C4ExtraInfo c4db_getExtraInfo(C4Database *database)
Returns the C4ExtraInfo associated with this db reference.
+
C4Database * c4db_openAgain(C4Database *db, C4Error *outError)
Opens a new handle to the same database file as db.
bool c4db_exists(C4String name, C4String inDirectory)
Returns true if a database with the given name exists in the directory.
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...
bool c4db_maintenance(C4Database *database, C4MaintenanceType type, C4Error *outError)
Performs database maintenance.
bool c4db_delete(C4Database *database, C4Error *outError)
Closes the database and deletes the file/bundle.
-
const C4DatabaseConfig2 * c4db_getConfig2(C4Database *database)
Returns the configuration the database was opened with.
bool c4db_deleteNamed(C4String dbName, C4String inDirectory, C4Error *outError)
Deletes the file(s) for the database with the given name in the given directory.
bool c4db_endTransaction(C4Database *database, bool commit, C4Error *outError)
Commits or aborts a transaction.
-
C4Database * c4db_openAgain(C4Database *db, C4Error *outError)
Opens a new handle to the same database file as db.
int64_t c4db_purgeExpiredDocs(C4Database *db, C4Error *)
Purges all documents that have expired.
bool c4db_close(C4Database *database, C4Error *outError)
Closes the database.
-
C4Database * c4db_openNamed(C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
Opens a database given its name (without the ".cblite2" extension) and directory.
C4StringResult c4db_getPath(C4Database *)
Returns the path of the database.
bool c4db_rekey(C4Database *database, const C4EncryptionKey *newKey, C4Error *outError)
Changes a database's encryption key (removing encryption if it's NULL.)
C4MaintenanceType
Types of maintenance that c4db_maintenance can perform.
Definition: c4DatabaseTypes.h:107
@@ -234,8 +232,10 @@
C4SequenceNumber c4db_getLastSequence(C4Database *database)
Returns the latest sequence number allocated to a revision.
bool c4db_beginTransaction(C4Database *database, C4Error *outError)
Begins a transaction.
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...
+
C4Database * c4db_openNamed(C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
Opens a database given its name (without the ".cblite2" extension) and directory.
+
const C4DatabaseConfig2 * c4db_getConfig2(C4Database *database)
Returns the configuration the database was opened with.
+
C4RawDocument * c4raw_get(C4Database *database, C4String storeName, C4String docID, C4Error *outError)
Reads a raw document from the database.
void c4raw_free(C4RawDocument *rawDoc)
Frees the storage occupied by a raw document.
-
C4RawDocument * c4raw_get(C4Database *database, C4String storeName, C4String docID, C4Error *outError)
Reads a raw document from the database.
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:64
Encryption key specified in a C4DatabaseConfig.
Definition: c4DatabaseTypes.h:57
@@ -248,7 +248,7 @@
diff --git a/docs/C/html/c4_database_types_8h.html b/docs/C/html/c4_database_types_8h.html index fb0644437a..aab97c5a57 100644 --- a/docs/C/html/c4_database_types_8h.html +++ b/docs/C/html/c4_database_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DatabaseTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Typedefs | Enumerations | Variables
-
-
c4DatabaseTypes.h File Reference
+
c4DatabaseTypes.h File Reference

#include "c4Base.h"

Go to the source code of this file.

- @@ -98,7 +98,7 @@

+

Data Structures

struct  C4EncryptionKey
 Encryption key specified in a C4DatabaseConfig. More...
struct  C4DatabaseConfig
 
- @@ -106,12 +106,12 @@

+

Macros

Scopes and Collections
#define kC4DefaultScopeID   FLSTR("_default")
#define kC4DefaultCollectionName   FLSTR("_default")
 
-

+

Typedefs

typedef const char * C4StorageEngine
 
-

+

Enumerations

enum  C4DocumentVersioning : uint32_t { kC4TreeVersioning_v2 , kC4TreeVersioning @@ -131,7 +131,7 @@
 Types of maintenance that c4db_maintenance can perform. More...
 
- @@ -163,7 +163,7 @@

+

Variables

CBL_CORE_API C4StorageEngine const kC4SQLiteStorageEngine
 
 

Typedef Documentation

- +

◆ C4StorageEngine

Variable Documentation

-
+

◆ kC4SQLiteStorageEngine

@@ -226,7 +226,7 @@

diff --git a/docs/C/html/c4_database_types_8h_source.html b/docs/C/html/c4_database_types_8h_source.html index 56c26fcd2f..03cf1a3242 100644 --- a/docs/C/html/c4_database_types_8h_source.html +++ b/docs/C/html/c4_database_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DatabaseTypes.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4DatabaseTypes.h
+
c4DatabaseTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4DatabaseTypes.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 
-
15 #include "c4Base.h"
-
16 
-
17 
- - -
20 
-
21 
-
27 
-
33 typedef C4_OPTIONS(uint32_t, C4DatabaseFlags) {
-
34  kC4DB_Create = 0x01,
-
35  kC4DB_ReadOnly = 0x02,
- - -
38  kC4DB_NoUpgrade = 0x20,
- -
40 };
-
41 
-
42 
-
44 typedef C4_ENUM(uint32_t, C4EncryptionAlgorithm) {
- - -
47 };
-
48 
-
49 
-
51 typedef C4_ENUM(uint64_t, C4EncryptionKeySize) {
- -
53 };
-
54 
-
55 
-
57 typedef struct C4EncryptionKey {
- -
59  uint8_t bytes[32];
- -
61 
-
62 
-
64 typedef struct C4DatabaseConfig2 {
- - - - -
69 
-
70 
-
72 CBL_CORE_API extern const char* const kC4DatabaseFilenameExtension;
-
73 
-
74 
-
80 typedef struct C4UUID {
-
81  uint8_t bytes[16];
-
82 } C4UUID;
-
83 
-
84 
-
90 #define kC4DefaultScopeID FLSTR("_default")
-
91 
-
92 #define kC4DefaultCollectionName FLSTR("_default")
-
93 
-
95 typedef struct C4CollectionSpec {
- - - -
99 
-
100 
-
107 typedef C4_ENUM(uint32_t, C4MaintenanceType) {
- -
112 
- -
117 
- -
122 
- -
130 
- -
136 }; // *NOTE:* These enum values must match the ones in DataFile::MaintenanceType
-
137 
-
138 
- - - - -
152 };
-
153 
-
154 
-
158 //-------- DEPRECATED --------
-
159 
-
160 typedef C4_ENUM(uint32_t, C4DocumentVersioning) {
- - - -
164 };
-
165 
-
166 typedef const char* C4StorageEngine;
- -
168 
-
169 typedef struct C4DatabaseConfig {
- - - - - -
175 
-
176 
- - +Go to the documentation of this file.
1//
+
2// c4DatabaseTypes.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
+
15#include "c4Base.h"
+
16
+
17
+ + +
20
+
21
+
27
+
33typedef C4_OPTIONS(uint32_t, C4DatabaseFlags) {
+
34 kC4DB_Create = 0x01,
+ + + + + +
40};
+
41
+
42
+
44typedef C4_ENUM(uint32_t, C4EncryptionAlgorithm) {
+ + +
47};
+
48
+
49
+
51typedef C4_ENUM(uint64_t, C4EncryptionKeySize) {
+ +
53};
+
54
+
55
+
57typedef struct C4EncryptionKey {
+ +
59 uint8_t bytes[32];
+ +
61
+
62
+
64typedef struct C4DatabaseConfig2 {
+ + + + +
69
+
70
+
72CBL_CORE_API extern const char* const kC4DatabaseFilenameExtension;
+
73
+
74
+
80typedef struct C4UUID {
+
81 uint8_t bytes[16];
+
82} C4UUID;
+
83
+
84
+
90#define kC4DefaultScopeID FLSTR("_default")
+
91
+
92#define kC4DefaultCollectionName FLSTR("_default")
+
93
+
95typedef struct C4CollectionSpec {
+ + + +
99
+
100
+
107typedef C4_ENUM(uint32_t, C4MaintenanceType) {
+ +
112
+ +
117
+ +
122
+ +
130
+ +
136}; // *NOTE:* These enum values must match the ones in DataFile::MaintenanceType
+
137
+
138
+ + + + +
152};
+
153
+
154
+
158//-------- DEPRECATED --------
+
159
+
160typedef C4_ENUM(uint32_t, C4DocumentVersioning) {
+ + + + +
165
+
166typedef const char* C4StorageEngine;
+ +
168
+
169typedef struct C4DatabaseConfig {
+ + + + + +
175
+
176
+ +
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define CBL_CORE_API
Definition: c4Compat.h:113
@@ -244,7 +244,7 @@
diff --git a/docs/C/html/c4_doc_enumerator_8h.html b/docs/C/html/c4_doc_enumerator_8h.html index 10a9b0fe51..1aec0d92e0 100644 --- a/docs/C/html/c4_doc_enumerator_8h.html +++ b/docs/C/html/c4_doc_enumerator_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocEnumerator.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4DocEnumerator.h File Reference
+
c4DocEnumerator.h File Reference

Go to the source code of this file.

- @@ -84,24 +84,24 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + @@ -109,7 +109,7 @@ diff --git a/docs/C/html/c4_doc_enumerator_8h_source.html b/docs/C/html/c4_doc_enumerator_8h_source.html index bbe5f1d033..e79e31beea 100644 --- a/docs/C/html/c4_doc_enumerator_8h_source.html +++ b/docs/C/html/c4_doc_enumerator_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4DocEnumerator.h Source File @@ -30,21 +30,22 @@

+

Functions

void c4enum_close (C4DocEnumerator *e)
 Closes an enumeration. More...
void c4enum_free (C4DocEnumerator *e)
 Frees a C4DocEnumerator handle. More...
 
C4DocEnumeratorc4db_enumerateChanges (C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4db_enumerateAllDocs (C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4coll_enumerateChanges (C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4coll_enumerateAllDocs (C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4db_enumerateChanges (C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4db_enumerateAllDocs (C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4coll_enumerateChanges (C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4coll_enumerateAllDocs (C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
bool c4enum_next (C4DocEnumerator *e, C4Error *outError)
 Advances the enumerator to the next document. More...
 
C4Documentc4enum_getDocument (C4DocEnumerator *e, C4Error *outError)
 Returns the current document, if any, from an enumerator. More...
 
C4Documentc4enum_getDocument (C4DocEnumerator *e, C4Error *outError)
 Returns the current document, if any, from an enumerator. More...
 
bool c4enum_getDocumentInfo (C4DocEnumerator *e, C4DocumentInfo *outInfo)
 Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct. More...
 
- + +/* @license-end */ +
-
-
c4DocEnumerator.h
+
c4DocEnumerator.h
-Go to the documentation of this file.
1 //
-
2 // c4DocEnumerator.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 
-
15 #include "c4DocEnumeratorTypes.h"
-
16 
- - -
19 
- -
27 
- -
30 
-
31 #ifndef C4_STRICT_COLLECTION_API
- -
40  C4SequenceNumber since,
-
41  const C4EnumeratorOptions* C4NULLABLE options,
-
42  C4Error* C4NULLABLE outError) C4API;
-
43 
- -
53  const C4EnumeratorOptions* C4NULLABLE options,
-
54  C4Error* C4NULLABLE outError) C4API;
-
55 #endif
-
56 
- -
65  C4SequenceNumber since,
-
66  const C4EnumeratorOptions* C4NULLABLE options,
-
67  C4Error* C4NULLABLE outError) C4API;
-
68 
- -
78  const C4EnumeratorOptions* C4NULLABLE options,
-
79  C4Error* C4NULLABLE outError) C4API;
-
80 
- -
85 
- -
92  C4Error* C4NULLABLE outError) C4API;
-
93 
- -
101  C4DocumentInfo *outInfo) C4API;
-
102 
- - +Go to the documentation of this file.
1//
+
2// c4DocEnumerator.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
+ +
16
+ + +
19
+ +
27
+ +
30
+
31#ifndef C4_STRICT_COLLECTION_API
+ +
40 C4SequenceNumber since,
+
41 const C4EnumeratorOptions* C4NULLABLE options,
+
42 C4Error* C4NULLABLE outError) C4API;
+
43
+ +
53 const C4EnumeratorOptions* C4NULLABLE options,
+
54 C4Error* C4NULLABLE outError) C4API;
+
55#endif
+
56
+ +
65 C4SequenceNumber since,
+
66 const C4EnumeratorOptions* C4NULLABLE options,
+
67 C4Error* C4NULLABLE outError) C4API;
+
68
+ +
78 const C4EnumeratorOptions* C4NULLABLE options,
+
79 C4Error* C4NULLABLE outError) C4API;
+
80
+ +
85
+ +
92 C4Error* C4NULLABLE outError) C4API;
+
93
+ +
101 C4DocumentInfo *outInfo) C4API;
+
102
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -130,19 +130,19 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4DocEnumerator C4DocEnumerator
Opaque handle to a document enumerator.
Definition: c4Base.h:137
+
struct C4DocEnumerator C4DocEnumerator
Opaque handle to a document enumerator.
Definition: c4Base.h:140
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition: c4Base.h:118
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
-
C4DocEnumerator * c4db_enumerateAllDocs(C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by docID.
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
+
C4DocEnumerator * c4coll_enumerateAllDocs(C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by docID.
void c4enum_free(C4DocEnumerator *e)
Frees a C4DocEnumerator handle.
-
C4DocEnumerator * c4coll_enumerateChanges(C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by sequence.
-
C4DocEnumerator * c4db_enumerateChanges(C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by sequence.
bool c4enum_getDocumentInfo(C4DocEnumerator *e, C4DocumentInfo *outInfo)
Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct.
void c4enum_close(C4DocEnumerator *e)
Closes an enumeration.
+
C4DocEnumerator * c4db_enumerateChanges(C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by sequence.
+
C4Document * c4enum_getDocument(C4DocEnumerator *e, C4Error *outError)
Returns the current document, if any, from an enumerator.
+
C4DocEnumerator * c4coll_enumerateChanges(C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by sequence.
bool c4enum_next(C4DocEnumerator *e, C4Error *outError)
Advances the enumerator to the next document.
-
C4DocEnumerator * c4coll_enumerateAllDocs(C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by docID.
-
C4Document * c4enum_getDocument(C4DocEnumerator *e, C4Error *outError)
Returns the current document, if any, from an enumerator.
+
C4DocEnumerator * c4db_enumerateAllDocs(C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
Creates an enumerator ordered by docID.
Describes a version-controlled document.
Definition: c4DocumentStruct.h:31
Metadata about a document (actually about its current revision.)
Definition: c4DocEnumeratorTypes.h:52
Options for enumerating over all documents.
Definition: c4DocEnumeratorTypes.h:43
@@ -150,7 +150,7 @@
diff --git a/docs/C/html/c4_doc_enumerator_types_8h.html b/docs/C/html/c4_doc_enumerator_types_8h.html index dcabd17bd2..159cf78bfd 100644 --- a/docs/C/html/c4_doc_enumerator_types_8h.html +++ b/docs/C/html/c4_doc_enumerator_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocEnumeratorTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Data Structures | Enumerations | Variables
-
-
c4DocEnumeratorTypes.h File Reference
+
c4DocEnumeratorTypes.h File Reference
#include "c4DocumentTypes.h"

Go to the source code of this file.

- @@ -87,7 +87,7 @@

+

Data Structures

struct  C4EnumeratorOptions
 Options for enumerating over all documents. More...
 Metadata about a document (actually about its current revision.) More...
 
-

+

Enumerations

enum  C4EnumeratorFlags : uint16_t {
  kC4Descending = 0x01 @@ -101,7 +101,7 @@ }
 
- @@ -110,7 +110,7 @@ diff --git a/docs/C/html/c4_doc_enumerator_types_8h_source.html b/docs/C/html/c4_doc_enumerator_types_8h_source.html index c5a4a7c815..d6074e9fd6 100644 --- a/docs/C/html/c4_doc_enumerator_types_8h_source.html +++ b/docs/C/html/c4_doc_enumerator_types_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4DocEnumeratorTypes.h Source File @@ -30,21 +30,22 @@

+

Variables

CBL_CORE_API const C4EnumeratorOptions kC4DefaultEnumeratorOptions
 Default all-docs enumeration options. More...
- + +/* @license-end */ +
-
-
c4DocEnumeratorTypes.h
+
c4DocEnumeratorTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4DocEnumeratorTypes.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 
-
15 #include "c4DocumentTypes.h"
-
16 
- - -
19 
-
20 
-
26 
-
27 
-
28 typedef C4_OPTIONS(uint16_t, C4EnumeratorFlags) {
-
29  kC4Descending = 0x01,
-
30  kC4Unsorted = 0x02,
- - - -
38  kC4IncludeRevHistory = 0x40
-
39 };
-
40 
-
41 
-
43 typedef struct {
- - -
46 
- -
49 
-
50 
-
52 typedef struct C4DocumentInfo {
- - - - -
57  uint64_t bodySize;
-
58  uint64_t metaSize;
- - -
61 
-
62 
- - +Go to the documentation of this file.
1//
+
2// c4DocEnumeratorTypes.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
+
15#include "c4DocumentTypes.h"
+
16
+ + +
19
+
20
+
26
+
27
+
28typedef C4_OPTIONS(uint16_t, C4EnumeratorFlags) {
+ +
30 kC4Unsorted = 0x02,
+ + + + +
39};
+
40
+
41
+
43typedef struct {
+ + +
46
+ +
49
+
50
+
52typedef struct C4DocumentInfo {
+ + + + +
57 uint64_t bodySize;
+
58 uint64_t metaSize;
+ + +
61
+
62
+ +
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define CBL_CORE_API
Definition: c4Compat.h:113
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -154,7 +154,7 @@
diff --git a/docs/C/html/c4_document_09_fleece_8h.html b/docs/C/html/c4_document_09_fleece_8h.html index 6900729938..625516ddf6 100644 --- a/docs/C/html/c4_document_09_fleece_8h.html +++ b/docs/C/html/c4_document_09_fleece_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Document+Fleece.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Document+Fleece.h File Reference
+
c4Document+Fleece.h File Reference
#include "c4Document.h"
@@ -100,22 +100,22 @@ FLDict c4doc_getProperties (C4Document *)  Returns the properties of the selected revision, i.e. More...
  -FLDoc c4doc_createFleeceDoc (C4Document *) +FLDoc c4doc_createFleeceDoc (C4Document *)  Returns a Fleece document reference created from the selected revision. More...
  bool c4doc_resolveConflict2 (C4Document *doc, C4String winningRevID, C4String losingRevID, FLDict mergedProperties, C4RevisionFlags mergedFlags, C4Error *error)  Resolves a conflict between two leaf revisions. More...
  -C4Documentc4doc_containingValue (FLValue value) - Returns the C4Document, if any, that contains the given Fleece value. More...
-  +C4Documentc4doc_containingValue (FLValue value) + Returns the C4Document, if any, that contains the given Fleece value. More...
+  bool c4doc_isOldMetaProperty (C4String prop)  Returns true if this is the name of a 1.x metadata property ("_id", "_rev", "_deleted".) Does NOT return true for "_attachments" because that property isn't obsolete. More...
  bool c4doc_hasOldMetaProperties (FLDict doc)  Returns true if the document contains 1.x metadata properties at top level. More...
  -C4SliceResult c4doc_encodeStrippingOldMetaProperties (FLDict doc, FLSharedKeys sk, C4Error *outError) +C4SliceResult c4doc_encodeStrippingOldMetaProperties (FLDict doc, FLSharedKeys sk, C4Error *outError)  Re-encodes to Fleece, without any 1.x metadata properties. More...
  bool c4doc_getDictBlobKey (FLDict dict, C4BlobKey *outKey) @@ -144,14 +144,14 @@ C4SliceResult c4db_encodeJSON (C4Database *, C4String jsonData, C4Error *outError)  Encodes JSON data to Fleece, to store into a document. More...
  -FLSharedKeys c4db_getFLSharedKeys (C4Database *db) +FLSharedKeys c4db_getFLSharedKeys (C4Database *db)  Returns the FLSharedKeys object used by the given database. More...
 
diff --git a/docs/C/html/c4_document_09_fleece_8h_source.html b/docs/C/html/c4_document_09_fleece_8h_source.html index 30c5352544..2b1cb975d6 100644 --- a/docs/C/html/c4_document_09_fleece_8h_source.html +++ b/docs/C/html/c4_document_09_fleece_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Document+Fleece.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Document+Fleece.h
+
c4Document+Fleece.h
-Go to the documentation of this file.
1 //
-
2 // c4Document+Fleece.h
-
3 //
-
4 // Copyright 2016-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 
-
15 #include "c4Document.h"
-
16 #include "fleece/Fleece.h"
-
17 
- - -
20 
-
30  #define kC4ObjectTypeProperty "@type"
-
31 
-
32 
-
34  #define kC4ObjectType_Blob "blob"
-
35 
-
37  #define kC4BlobDigestProperty "digest"
-
38 
-
40  #define kC4BlobDataProperty "data"
-
41 
-
43  #define kC4LegacyAttachmentsProperty "_attachments"
-
44 
-
45 
-
47  #define kC4ObjectType_Encryptable "encryptable"
-
48 
-
50  #define kC4EncryptableValueProperty "value"
-
51 
-
52 
- -
55 
- -
59 
- -
64  C4String winningRevID,
-
65  C4String losingRevID,
-
66  FLDict C4NULLABLE mergedProperties,
-
67  C4RevisionFlags mergedFlags,
-
68  C4Error* C4NULLABLE error) C4API;
-
69 
- -
72 
- -
76 
- -
80 
- -
84  FLSharedKeys sk,
-
85  C4Error* C4NULLABLE outError) C4API;
-
86 
- -
90  C4BlobKey *outKey);
-
91 
- -
96  C4BlobKey *outKey) C4API;
-
97 
- -
99 
- -
109  C4BlobStore* C4NULLABLE blobStore,
-
110  C4Error* C4NULLABLE outError) C4API;
-
111 
- -
117 
- -
120  bool canonical,
-
121  C4Error* C4NULLABLE outError) C4API;
-
122 
- -
125 
- -
129 
- -
132 
- -
135 
- - +Go to the documentation of this file.
1//
+
2// c4Document+Fleece.h
+
3//
+
4// Copyright 2016-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
+
15#include "c4Document.h"
+
16#include "fleece/Fleece.h"
+
17
+ + +
20
+
30 #define kC4ObjectTypeProperty "@type"
+
31
+
32
+
34 #define kC4ObjectType_Blob "blob"
+
35
+
37 #define kC4BlobDigestProperty "digest"
+
38
+
40 #define kC4BlobDataProperty "data"
+
41
+
43 #define kC4LegacyAttachmentsProperty "_attachments"
+
44
+
45
+
47 #define kC4ObjectType_Encryptable "encryptable"
+
48
+
50 #define kC4EncryptableValueProperty "value"
+
51
+
52
+ +
55
+ +
59
+ +
64 C4String winningRevID,
+
65 C4String losingRevID,
+
66 FLDict C4NULLABLE mergedProperties,
+
67 C4RevisionFlags mergedFlags,
+
68 C4Error* C4NULLABLE error) C4API;
+
69
+ +
72
+ +
76
+ +
80
+ +
84 FLSharedKeys sk,
+
85 C4Error* C4NULLABLE outError) C4API;
+
86
+ +
90 C4BlobKey *outKey);
+
91
+ +
96 C4BlobKey *outKey) C4API;
+
97
+ +
99
+ +
109 C4BlobStore* C4NULLABLE blobStore,
+
110 C4Error* C4NULLABLE outError) C4API;
+
111
+ +
117
+ +
120 bool canonical,
+
121 C4Error* C4NULLABLE outError) C4API;
+
122
+ +
125
+ +
129
+ +
132
+ +
135
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
@@ -166,12 +166,11 @@
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
struct C4BlobStore C4BlobStore
Opaque handle for an object that manages storage of blobs.
Definition: c4Base.h:112
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
bool c4doc_dictIsBlob(FLDict dict, C4BlobKey *outKey)
Returns true if the given dictionary is a [reference to a] blob; if so, gets its key.
bool c4doc_isOldMetaProperty(C4String prop)
Returns true if this is the name of a 1.x metadata property ("_id", "_rev", "_deleted"....
bool c4doc_getDictBlobKey(FLDict dict, C4BlobKey *outKey)
Decodes the dict's "digest" property to a C4BlobKey.
FLDict c4doc_getProperties(C4Document *)
Returns the properties of the selected revision, i.e.
-
C4Document * c4doc_containingValue(FLValue value)
Returns the C4Document, if any, that contains the given Fleece value.
C4SliceResult c4db_encodeJSON(C4Database *, C4String jsonData, C4Error *outError)
Encodes JSON data to Fleece, to store into a document.
bool c4doc_blobIsCompressible(FLDict blobDict)
Given a dictionary that's a reference to a blob, determines whether it's worth trying to compress the...
bool c4doc_hasOldMetaProperties(FLDict doc)
Returns true if the document contains 1.x metadata properties at top level.
@@ -179,17 +178,18 @@
C4SliceResult c4doc_encodeStrippingOldMetaProperties(FLDict doc, FLSharedKeys sk, C4Error *outError)
Re-encodes to Fleece, without any 1.x metadata properties.
C4StringResult c4doc_bodyAsJSON(C4Document *doc, bool canonical, C4Error *outError)
Translates the body of the selected revision from Fleece to JSON.
FLDoc c4doc_createFleeceDoc(C4Document *)
Returns a Fleece document reference created from the selected revision.
+
C4Document * c4doc_containingValue(FLValue value)
Returns the C4Document, if any, that contains the given Fleece value.
FLEncoder c4db_createFleeceEncoder(C4Database *db)
Creates a Fleece encoder for creating documents for a given database.
bool c4doc_dictContainsBlobs(FLDict dict)
FLEncoder c4db_getSharedFleeceEncoder(C4Database *db)
Returns a shared Fleece encoder for creating documents for a given database.
C4SliceResult c4doc_getBlobData(FLDict dict, C4BlobStore *blobStore, C4Error *outError)
Returns the contents of a blob dictionary, whether they're inline in the "data" property,...
FLSharedKeys c4db_getFLSharedKeys(C4Database *db)
Returns the FLSharedKeys object used by the given database.
C4RevisionFlags
Flags that apply to a revision.
Definition: c4DocumentTypes.h:33
-
struct _FLDoc * FLDoc
A reference to a document.
Definition: Fleece.h:91
-
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: Fleece.h:92
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:53
-
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:57
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:53
+
struct _FLDoc * FLDoc
A reference to a document.
Definition: FLBase.h:58
+
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: FLBase.h:57
+
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: FLBase.h:59
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:51
A unique identifier of a blob based on a SHA-1 digest of its contents.
Definition: c4BlobStoreTypes.h:34
Describes a version-controlled document.
Definition: c4DocumentStruct.h:31
An error value.
Definition: c4Error.h:130
@@ -198,7 +198,7 @@
diff --git a/docs/C/html/c4_document_8h.html b/docs/C/html/c4_document_8h.html index 0c0bd42b75..64460b014c 100644 --- a/docs/C/html/c4_document_8h.html +++ b/docs/C/html/c4_document_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Document.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Document.h File Reference
+
c4Document.h File Reference
#include "c4DocumentTypes.h"
@@ -77,12 +77,12 @@

Go to the source code of this file.

-

+

Macros

#define __C4DOCUMENT_H__
 
- @@ -153,37 +153,37 @@ - - - - - - - - - + + + + + + + + +

+

Functions

Revisions
bool c4doc_selectRevision (C4Document *doc, C4String revID, bool withBody, C4Error *outError)
 Returns the expiration time of a document, if one has been set, else 0. More...
 
Creating and Updating Documents
C4Documentc4doc_put (C4Database *database, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4doc_create (C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4doc_update (C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
 Adds a revision to a document already in memory as a C4Document. More...
 
C4Documentc4doc_put (C4Database *database, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4doc_create (C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4doc_update (C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
 Adds a revision to a document already in memory as a C4Document. More...
 
- - - - - - - - - - - - + + + + + + + + + + + +

Lifecycle

#define kC4GeneratedIDLength   23
 
char * c4doc_generateID (char *buffer, size_t bufferSize)
 Generates a random 23-byte C string suitable for use as a unique new document ID. More...
 
C4Documentc4db_getDoc (C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the database given its ID. More...
 
C4Documentc4doc_get (C4Database *database, C4String docID, bool mustExist, C4Error *outError)
 Gets a document from the database given its ID (semi-deprecated). More...
 
C4Documentc4doc_getBySequence (C4Database *database, C4SequenceNumber, C4Error *outError)
 Gets a document from the database given its sequence number. More...
 
char * c4doc_generateID (char *buffer, size_t bufferSize)
 Generates a random 23-byte C string suitable for use as a unique new document ID. More...
 
C4Documentc4db_getDoc (C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the database given its ID. More...
 
C4Documentc4doc_get (C4Database *database, C4String docID, bool mustExist, C4Error *outError)
 Gets a document from the database given its ID (semi-deprecated). More...
 
C4Documentc4doc_getBySequence (C4Database *database, C4SequenceNumber, C4Error *outError)
 Gets a document from the database given its sequence number. More...
 
bool c4doc_save (C4Document *doc, uint32_t maxRevTreeDepth, C4Error *outError)
 Saves changes to a C4Document. More...
 

Macro Definition Documentation

- +

◆ __C4DOCUMENT_H__

@@ -200,7 +200,7 @@

diff --git a/docs/C/html/c4_document_8h_source.html b/docs/C/html/c4_document_8h_source.html index 8762534f3d..f158e1778a 100644 --- a/docs/C/html/c4_document_8h_source.html +++ b/docs/C/html/c4_document_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Document.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4Document.h
+
c4Document.h
-Go to the documentation of this file.
1 //
-
2 // c4Document.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 #define __C4DOCUMENT_H__
-
15 #include "c4DocumentTypes.h"
-
16 
-
17 #if LITECORE_CPP_API
-
18 #include "c4Document.hh" // C++ version of C4Document struct
-
19 #else
-
20 #include "c4DocumentStruct.h" // C version of C4Document struct
-
21 #endif
-
22 
- - -
25 
-
26 
-
36  #define kC4GeneratedIDLength 23
-
37 
-
42  char* c4doc_generateID(char *buffer, size_t bufferSize) C4API;
-
43 
-
44 
-
45 #ifndef C4_STRICT_COLLECTION_API
-
46 
- -
58  C4String docID,
-
59  bool mustExist,
-
60  C4DocContentLevel content,
-
61  C4Error* C4NULLABLE outError) C4API;
-
62 
- -
66  C4String docID,
-
67  bool mustExist,
-
68  C4Error* C4NULLABLE outError) C4API;
-
69 
- - -
74  C4Error* C4NULLABLE outError) C4API;
-
75 
-
76 #endif
-
77 
- -
82  uint32_t maxRevTreeDepth,
-
83  C4Error* C4NULLABLE outError) C4API;
-
84 
-
89 
-
90 
- -
97  C4String revID,
-
98  bool withBody,
-
99  C4Error* C4NULLABLE outError) C4API;
-
100 
- -
104 
- -
108  C4Error* C4NULLABLE outError) C4API;
-
109 
- -
113 
- -
118 
- -
131  unsigned maxRevs,
-
132  const C4String backToRevs[C4NULLABLE],
-
133  unsigned backToRevsCount) C4API;
-
134 
- -
139 
- -
142 
- -
146 
- -
151  bool includeDeleted,
-
152  bool withBody,
-
153  C4Error* C4NULLABLE outError) C4API;
-
154 
- -
157  C4String rev1ID,
-
158  C4String rev2ID) C4API;
-
159 
- -
168  C4String remoteAddress,
-
169  bool canCreate,
-
170  C4Error* C4NULLABLE outError) C4API;
-
171 
- -
177  C4RemoteID remoteID) C4API;
-
178 
- -
181  C4RemoteID remoteDatabase) C4API;
-
182 
- -
185  C4RemoteID remoteDatabase,
-
186  C4String revID,
-
187  C4Error* C4NULLABLE error) C4API;
-
188 
- -
192 
-
193 
-
197  bool c4rev_equal(C4Slice rev1, C4Slice rev2) C4API;
-
198 
-
199 
- -
212  C4String revID,
-
213  C4Error* C4NULLABLE outError) C4API;
-
214 
- -
226  C4String winningRevID,
-
227  C4String losingRevID,
-
228  C4Slice mergedBody,
-
229  C4RevisionFlags mergedFlags,
-
230  C4Error* C4NULLABLE error) C4API;
-
231 
-
236 
-
237 
-
238 #ifndef C4_STRICT_COLLECTION_API
-
239 
-
245  bool c4db_purgeDoc(C4Database *database, C4String docID, C4Error* C4NULLABLE outError) C4API;
-
246 
-
247 
- -
257  C4String docID,
-
258  C4Timestamp timestamp,
-
259  C4Error* C4NULLABLE outError) C4API;
-
260 
- -
269  C4String docID,
-
270  C4Error* C4NULLABLE outError) C4API;
-
271 
-
272 #endif // C4_STRICT_COLLECTION_API
-
273 
-
278 
-
279 
-
283 #ifndef C4_STRICT_COLLECTION_API
-
284 
- -
295  const C4DocPutRequest *request,
-
296  size_t * C4NULLABLE outCommonAncestorIndex,
-
297  C4Error* C4NULLABLE outError) C4API;
-
298 
- -
308  C4String docID,
-
309  C4Slice body,
-
310  C4RevisionFlags revisionFlags,
-
311  C4Error* C4NULLABLE error) C4API;
-
312 
-
313 #endif // C4_STRICT_COLLECTION_API
-
314 
- -
326  C4Slice revisionBody,
-
327  C4RevisionFlags revisionFlags,
-
328  C4Error* C4NULLABLE error) C4API;
-
329 
- - +Go to the documentation of this file.
1//
+
2// c4Document.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#define __C4DOCUMENT_H__
+
15#include "c4DocumentTypes.h"
+
16
+
17#if LITECORE_CPP_API
+
18#include "c4Document.hh" // C++ version of C4Document struct
+
19#else
+
20#include "c4DocumentStruct.h" // C version of C4Document struct
+
21#endif
+
22
+ + +
25
+
26
+
36 #define kC4GeneratedIDLength 23
+
37
+
42 char* c4doc_generateID(char *buffer, size_t bufferSize) C4API;
+
43
+
44
+
45#ifndef C4_STRICT_COLLECTION_API
+
46
+ +
58 C4String docID,
+
59 bool mustExist,
+
60 C4DocContentLevel content,
+
61 C4Error* C4NULLABLE outError) C4API;
+
62
+ +
66 C4String docID,
+
67 bool mustExist,
+
68 C4Error* C4NULLABLE outError) C4API;
+
69
+ + +
74 C4Error* C4NULLABLE outError) C4API;
+
75
+
76#endif
+
77
+ +
82 uint32_t maxRevTreeDepth,
+
83 C4Error* C4NULLABLE outError) C4API;
+
84
+
89
+
90
+ +
97 C4String revID,
+
98 bool withBody,
+
99 C4Error* C4NULLABLE outError) C4API;
+
100
+ +
104
+ +
108 C4Error* C4NULLABLE outError) C4API;
+
109
+ +
113
+ +
118
+ +
131 unsigned maxRevs,
+
132 const C4String backToRevs[C4NULLABLE],
+
133 unsigned backToRevsCount) C4API;
+
134
+ +
139
+ +
142
+ +
146
+ +
151 bool includeDeleted,
+
152 bool withBody,
+
153 C4Error* C4NULLABLE outError) C4API;
+
154
+ +
157 C4String rev1ID,
+
158 C4String rev2ID) C4API;
+
159
+ +
168 C4String remoteAddress,
+
169 bool canCreate,
+
170 C4Error* C4NULLABLE outError) C4API;
+
171
+ +
177 C4RemoteID remoteID) C4API;
+
178
+ +
181 C4RemoteID remoteDatabase) C4API;
+
182
+ +
185 C4RemoteID remoteDatabase,
+
186 C4String revID,
+
187 C4Error* C4NULLABLE error) C4API;
+
188
+ +
192
+
193
+ +
198
+
199
+ +
212 C4String revID,
+
213 C4Error* C4NULLABLE outError) C4API;
+
214
+ +
226 C4String winningRevID,
+
227 C4String losingRevID,
+
228 C4Slice mergedBody,
+
229 C4RevisionFlags mergedFlags,
+
230 C4Error* C4NULLABLE error) C4API;
+
231
+
236
+
237
+
238#ifndef C4_STRICT_COLLECTION_API
+
239
+
245 bool c4db_purgeDoc(C4Database *database, C4String docID, C4Error* C4NULLABLE outError) C4API;
+
246
+
247
+ +
257 C4String docID,
+
258 C4Timestamp timestamp,
+
259 C4Error* C4NULLABLE outError) C4API;
+
260
+ +
269 C4String docID,
+
270 C4Error* C4NULLABLE outError) C4API;
+
271
+
272#endif // C4_STRICT_COLLECTION_API
+
273
+
278
+
279
+
283#ifndef C4_STRICT_COLLECTION_API
+
284
+ +
295 const C4DocPutRequest *request,
+
296 size_t * C4NULLABLE outCommonAncestorIndex,
+
297 C4Error* C4NULLABLE outError) C4API;
+
298
+ +
308 C4String docID,
+
309 C4Slice body,
+
310 C4RevisionFlags revisionFlags,
+
311 C4Error* C4NULLABLE error) C4API;
+
312
+
313#endif // C4_STRICT_COLLECTION_API
+
314
+ +
326 C4Slice revisionBody,
+
327 C4RevisionFlags revisionFlags,
+
328 C4Error* C4NULLABLE error) C4API;
+
329
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -245,20 +245,21 @@
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: c4Base.h:87
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
bool c4doc_selectCommonAncestorRevision(C4Document *doc, C4String rev1ID, C4String rev2ID)
Selects the common ancestor of two revisions.
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.)
bool c4doc_selectNextRevision(C4Document *doc)
Selects the next revision in priority order.
-
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.
-
C4Document * c4db_getDoc(C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the database given its ID.
+
C4Document * c4doc_update(C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
Adds a revision to a document already in memory as a C4Document.
C4SliceResult c4doc_getRemoteAncestor(C4Document *doc, C4RemoteID remoteDatabase)
Returns the revision ID that has been marked as current for the given remote database.
C4SliceResult c4db_getRemoteDBAddress(C4Database *db, C4RemoteID remoteID)
Given a remote database ID, returns its replication URL / unique identifier.
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(...
+
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.
bool c4doc_save(C4Document *doc, uint32_t maxRevTreeDepth, C4Error *outError)
Saves changes to a C4Document.
-
C4Document * c4doc_getBySequence(C4Database *database, C4SequenceNumber, C4Error *outError)
Gets a document from the database given its sequence number.
+
char * c4doc_generateID(char *buffer, size_t bufferSize)
Generates a random 23-byte C string suitable for use as a unique new document ID.
C4Timestamp c4doc_getExpiration(C4Database *db, C4String docID, C4Error *outError)
Returns the expiration time of a document, if one has been set, else 0.
-
C4Document * c4doc_create(C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
bool c4doc_selectParentRevision(C4Document *doc)
Selects the parent of the selected revision, if it's known, else returns NULL.
+
C4Document * c4doc_create(C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
+
C4Document * c4doc_get(C4Database *database, C4String docID, bool mustExist, C4Error *outError)
Gets a document from the database given its ID (semi-deprecated).
unsigned c4rev_getGeneration(C4String revID)
Given a revision ID, returns its generation number (the decimal number before the hyphen),...
bool c4doc_setExpiration(C4Database *db, C4String docID, C4Timestamp timestamp, C4Error *outError)
Sets an expiration date on a document.
C4Slice c4doc_getRevisionBody(C4Document *doc)
Returns the body (encoded Fleece data) of the selected revision, if available.
@@ -267,16 +268,15 @@
bool c4doc_setRemoteAncestor(C4Document *doc, C4RemoteID remoteDatabase, C4String revID, C4Error *error)
Marks a revision as current for the given remote database.
bool c4doc_selectCurrentRevision(C4Document *doc)
Selects the current revision of a document.
C4SliceResult c4doc_getSelectedRevIDGlobalForm(C4Document *doc)
Returns the selected revision's ID in a form that will make sense to another peer/server.
-
char * c4doc_generateID(char *buffer, size_t bufferSize)
Generates a random 23-byte C string suitable for use as a unique new document ID.
+
C4Document * c4db_getDoc(C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the database given its ID.
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.
-
C4Document * c4doc_update(C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
Adds a revision to a document already in memory as a C4Document.
+
C4Document * c4doc_getBySequence(C4Database *database, C4SequenceNumber, C4Error *outError)
Gets a document from the database given its sequence number.
int32_t c4doc_purgeRevision(C4Document *doc, C4String revID, C4Error *outError)
Removes a branch from a document's history.
bool c4doc_selectNextLeafRevision(C4Document *doc, bool includeDeleted, bool withBody, C4Error *outError)
Selects the next leaf revision; like selectNextRevision but skips over non-leaves.
C4DocContentLevel
Specifies how much content to retrieve when getting a document.
Definition: c4DocumentTypes.h:50
uint32_t C4RemoteID
Identifies a remote database being replicated with.
Definition: c4DocumentTypes.h:46
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...
bool c4db_purgeDoc(C4Database *database, C4String docID, C4Error *outError)
Removes all trace of a document and its revisions from the database.
-
C4Document * c4doc_get(C4Database *database, C4String docID, bool mustExist, C4Error *outError)
Gets a document from the database given its ID (semi-deprecated).
bool c4rev_equal(C4Slice rev1, C4Slice rev2)
Returns true if two revision IDs are equivalent.
C4RevisionFlags
Flags that apply to a revision.
Definition: c4DocumentTypes.h:33
Parameters for adding a revision using c4doc_put.
Definition: c4DocumentTypes.h:86
@@ -287,7 +287,7 @@
diff --git a/docs/C/html/c4_document_struct_8h.html b/docs/C/html/c4_document_struct_8h.html index 479f8096ce..1b7418ef2d 100644 --- a/docs/C/html/c4_document_struct_8h.html +++ b/docs/C/html/c4_document_struct_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocumentStruct.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
c4DocumentStruct.h File Reference
+
c4DocumentStruct.h File Reference
#include "c4DocumentTypes.h"

Go to the source code of this file.

-

+

Data Structures

struct  C4Document
 Describes a version-controlled document. More...
 
-

+

Macros

#define LITECORE_CPP_API   0
 

Macro Definition Documentation

- +

◆ LITECORE_CPP_API

@@ -106,7 +106,7 @@

diff --git a/docs/C/html/c4_document_struct_8h_source.html b/docs/C/html/c4_document_struct_8h_source.html index 1353192096..4986edfc40 100644 --- a/docs/C/html/c4_document_struct_8h_source.html +++ b/docs/C/html/c4_document_struct_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocumentStruct.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4DocumentStruct.h
+
c4DocumentStruct.h
-Go to the documentation of this file.
1 //
-
2 // c4DocumentStruct.h
-
3 //
-
4 // Copyright 2021-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 "c4DocumentTypes.h"
-
15 
-
16 #ifndef LITECORE_CPP_API
-
17 #define LITECORE_CPP_API 0
-
18 #endif
-
19 
- - -
22 
-
23 
-
25 struct
-
26 #if ! LITECORE_CPP_API // C++ has a different declaration, in c4Document.hh
- -
28 #else
-
29 C4Document_C
-
30 #endif
-
31 {
-
32  void* _internal1; // placeholders for vtable-ptr and refcount (see c4Document.hh)
-
33  void* _internal2;
-
34 
- - - - -
39 
- -
41 
- -
43 };
-
44 
-
45 
- - +Go to the documentation of this file.
1//
+
2// c4DocumentStruct.h
+
3//
+
4// Copyright 2021-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 "c4DocumentTypes.h"
+
15
+
16#ifndef LITECORE_CPP_API
+
17#define LITECORE_CPP_API 0
+
18#endif
+
19
+ + +
22
+
23
+
25struct
+
26#if ! LITECORE_CPP_API // C++ has a different declaration, in c4Document.hh
+ +
28#else
+
29C4Document_C
+
30#endif
+
31{
+
32 void* _internal1; // placeholders for vtable-ptr and refcount (see c4Document.hh)
+ +
34
+ + + + +
39
+ +
41
+ +
43};
+
44
+
45
+ +
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
#define C4API_END_DECLS
Definition: c4Compat.h:95
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
@@ -138,7 +138,7 @@
diff --git a/docs/C/html/c4_document_types_8h.html b/docs/C/html/c4_document_types_8h.html index 7b1db5fb0d..0673a56249 100644 --- a/docs/C/html/c4_document_types_8h.html +++ b/docs/C/html/c4_document_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocumentTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Data Structures | Typedefs | Enumerations
-
-
c4DocumentTypes.h File Reference
+
c4DocumentTypes.h File Reference
#include "c4Base.h"

Go to the source code of this file.

- @@ -90,7 +90,7 @@

+

Data Structures

struct  C4Revision
 Describes a revision of a document. More...
 Represents a change to a document in a collection, as returned from c4dbobs_getChanges. More...
 
- @@ -103,7 +103,7 @@

+

Typedefs

typedef uint32_t C4RemoteID
 Identifies a remote database being replicated with. More...
typedef C4CollectionChange C4DatabaseChange
 
-

+

Enumerations

enum  C4DocumentFlags : uint32_t { kDocDeleted = 0x01 , kDocConflicted = 0x02 @@ -136,7 +136,7 @@ diff --git a/docs/C/html/c4_document_types_8h_source.html b/docs/C/html/c4_document_types_8h_source.html index 9da663929a..c048a49baf 100644 --- a/docs/C/html/c4_document_types_8h_source.html +++ b/docs/C/html/c4_document_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4DocumentTypes.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4DocumentTypes.h
+
c4DocumentTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4DocumentTypes.h
-
3 //
-
4 // Copyright 2021-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 "c4Base.h"
-
15 
- - -
18 
-
19 
-
25 typedef C4_OPTIONS(uint32_t, C4DocumentFlags) {
-
26  kDocDeleted = 0x01,
-
27  kDocConflicted = 0x02,
- -
29  kDocExists = 0x1000
-
30 }; // Note: Superset of DocumentFlags
-
31 
-
33 typedef C4_OPTIONS(uint8_t, C4RevisionFlags) {
-
34  kRevDeleted = 0x01,
-
35  kRevLeaf = 0x02,
-
36  kRevNew = 0x04,
- -
38  kRevKeepBody = 0x10,
-
39  kRevIsConflict = 0x20,
-
40  kRevClosed = 0x40,
-
41  kRevPurged = 0x80,
-
42 }; // Note: Same as litecore::Rev::Flags
-
43 
-
44 
-
46 typedef uint32_t C4RemoteID;
-
47 
-
48 
-
50 typedef C4_ENUM(uint8_t, C4DocContentLevel) {
- - - -
54 }; // Note: Same as litecore::ContentOption
-
55 
-
56 
-
58 typedef struct C4Revision {
- - - -
62 } C4Revision;
-
63 
-
64 
-
65 // NOTE: Looking for C4Document itself? It's moved to c4DocumentStruct.h
-
66 
-
67 
-
80 typedef C4SliceResult (*C4DocDeltaApplier)(void *context,
-
81  C4Document *doc,
-
82  C4Slice delta,
-
83  C4Error* C4NULLABLE outError);
-
84 
-
86 typedef struct C4DocPutRequest {
- - - - - -
92  const C4String *history;
-
93  size_t historyCount;
-
94  bool save;
-
95  uint32_t maxRevTreeDepth;
- -
97 
- -
99 
- - - - -
104 
-
105 
-
117 typedef struct {
- - - -
121  uint32_t bodySize;
- - -
124 
-
125 #ifndef C4_STRICT_COLLECTION_API
- -
127 #endif
-
128 
- - +Go to the documentation of this file.
1//
+
2// c4DocumentTypes.h
+
3//
+
4// Copyright 2021-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 "c4Base.h"
+
15
+ + +
18
+
19
+
25typedef C4_OPTIONS(uint32_t, C4DocumentFlags) {
+
26 kDocDeleted = 0x01,
+ + +
29 kDocExists = 0x1000
+
30}; // Note: Superset of DocumentFlags
+
31
+
33typedef C4_OPTIONS(uint8_t, C4RevisionFlags) {
+
34 kRevDeleted = 0x01,
+
35 kRevLeaf = 0x02,
+
36 kRevNew = 0x04,
+ +
38 kRevKeepBody = 0x10,
+ +
40 kRevClosed = 0x40,
+
41 kRevPurged = 0x80,
+
42}; // Note: Same as litecore::Rev::Flags
+
43
+
44
+
46typedef uint32_t C4RemoteID;
+
47
+
48
+
50typedef C4_ENUM(uint8_t, C4DocContentLevel) {
+ + + +
54}; // Note: Same as litecore::ContentOption
+
55
+
56
+
58typedef struct C4Revision {
+ + + + +
63
+
64
+
65// NOTE: Looking for C4Document itself? It's moved to c4DocumentStruct.h
+
66
+
67
+
80typedef C4SliceResult (*C4DocDeltaApplier)(void *context,
+
81 C4Document *doc,
+
82 C4Slice delta,
+
83 C4Error* C4NULLABLE outError);
+
84
+
86typedef struct C4DocPutRequest {
+ + + + + + +
93 size_t historyCount;
+
94 bool save;
+
95 uint32_t maxRevTreeDepth;
+ +
97
+ +
99
+ + + + +
104
+
105
+
117typedef struct {
+ + + +
121 uint32_t bodySize;
+ + +
124
+
125#ifndef C4_STRICT_COLLECTION_API
+ +
127#endif
+
128
+ +
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define C4NULLABLE
Definition: c4Compat.h:38
@@ -230,7 +230,7 @@
diff --git a/docs/C/html/c4_error_8h.html b/docs/C/html/c4_error_8h.html index 1c5b872b53..052c27528c 100644 --- a/docs/C/html/c4_error_8h.html +++ b/docs/C/html/c4_error_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Error.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Error.h File Reference
+
c4Error.h File Reference
#include "c4Compat.h"
@@ -82,13 +83,18 @@

Go to the source code of this file.

-

+

Data Structures

struct  C4Error
 An error value. More...
 
- + + +

+

+Macros

#define kC4NoError   ((C4Error){ })
 
+

Enumerations

enum  C4ErrorDomain : uint8_t {
  LiteCoreDomain = 1 @@ -187,7 +193,7 @@
 Network error codes (potentially higher level than POSIX, lower level than HTTP.) The entries marked with a POSIX code mirror that code so that platform bindings have a stable cross platform error code to use for transient or network dependent errors, and will behave the same as if the errno in question was passed. More...
 
- @@ -195,9 +201,9 @@ - - - + + + @@ -228,7 +234,7 @@ diff --git a/docs/C/html/c4_error_8h_source.html b/docs/C/html/c4_error_8h_source.html index 90de45e2f6..b4c1a89c80 100644 --- a/docs/C/html/c4_error_8h_source.html +++ b/docs/C/html/c4_error_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Error.h Source File @@ -30,21 +30,22 @@

+

Functions

FLStringResult c4error_getMessage (C4Error error)
 Returns an error message describing a C4Error. More...
FLSliceResult c4error_getDescription (C4Error error)
 Returns a description of an error, including the domain and code as well as the message. More...
 
char * c4error_getDescriptionC (C4Error error, char *outBuffer, size_t bufferSize)
 Returns a description of an error, including the domain and code as well as the message. More...
 
char * c4error_getDescriptionC (C4Error error, char *outBuffer, size_t bufferSize)
 Returns a description of an error, including the domain and code as well as the message. More...
 
void c4error_setCaptureBacktraces (bool)
 If set to true, then when a C4Error is created the current thread's stack backtrace will be captured along with it, and can later be examined by calling c4error_getBacktrace. More...
 
- + +/* @license-end */ +
-
-
c4Error.h
+
c4Error.h
-Go to the documentation of this file.
1 //
-
2 // c4Error.h
-
3 //
-
4 // Copyright 2021-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 "c4Compat.h"
-
15 #include "fleece/FLSlice.h"
-
16 #include <stdarg.h>
-
17 #include <stdbool.h>
-
18 #include <stdint.h>
-
19 
-
20 #ifdef __cplusplus
-
21 #include "fleece/slice.hh"
-
22 #include <exception>
-
23 #include <string>
-
24 #endif
-
25 
- - -
28 
-
29 
-
34 // (These are identical to the internal C++ error::Domain enum values.)
-
35 typedef C4_ENUM(uint8_t, C4ErrorDomain) {
-
36  LiteCoreDomain = 1, // code is a Couchbase Lite Core error code (see below)
-
37  POSIXDomain, // code is an errno
-
38  SQLiteDomain, // code is a SQLite error; see "sqlite3.h"
-
39  FleeceDomain, // code is a Fleece error; see "FleeceException.h"
-
40  NetworkDomain, // code is a network error; see enum C4NetworkErrorCode, below
-
41  WebSocketDomain, // code is a WebSocket close code (1000...1015) or HTTP error (300..599)
-
42  MbedTLSDomain, // code is an mbedTLS error; see "mbedtls/error.h"
-
43 
- -
45 };
-
46 
-
47 
-
48 // LiteCoreDomain error codes:
-
49 // (These are identical to the internal C++ error::LiteCoreError enum values.)
-
50 typedef C4_ENUM(int32_t, C4ErrorCode) {
-
51  kC4ErrorAssertionFailed = 1, // Internal assertion failure
-
52  kC4ErrorUnimplemented, // Oops, an unimplemented API call
-
53  kC4ErrorUnsupportedEncryption, // Unsupported encryption algorithm
-
54  kC4ErrorBadRevisionID, // Invalid revision ID syntax
-
55  kC4ErrorCorruptRevisionData, // Revision contains corrupted/unreadable data
-
56  kC4ErrorNotOpen, // Database/KeyStore/index is not open
-
57  kC4ErrorNotFound, // Document not found
-
58  kC4ErrorConflict, // Document update conflict
-
59  kC4ErrorInvalidParameter, // Invalid function parameter or struct value
-
60  kC4ErrorUnexpectedError, /*10*/ // Internal unexpected C++ exception
-
61  kC4ErrorCantOpenFile, // Database file can't be opened; may not exist
-
62  kC4ErrorIOError, // File I/O error
-
63  kC4ErrorMemoryError, // Memory allocation failed (out of memory?)
-
64  kC4ErrorNotWriteable, // File is not writeable
-
65  kC4ErrorCorruptData, // Data is corrupted
-
66  kC4ErrorBusy, // Database is busy/locked
-
67  kC4ErrorNotInTransaction, // Function must be called while in a transaction
-
68  kC4ErrorTransactionNotClosed, // Database can't be closed while a transaction is open
-
69  kC4ErrorUnsupported, // Operation not supported in this database
-
70  kC4ErrorNotADatabaseFile,/*20*/ // File is not a database, or encryption key is wrong
-
71  kC4ErrorWrongFormat, // Database exists but not in the format/storage requested
-
72  kC4ErrorCrypto, // Encryption/decryption error
-
73  kC4ErrorInvalidQuery, // Invalid query
-
74  kC4ErrorMissingIndex, // No such index, or query requires a nonexistent index
-
75  kC4ErrorInvalidQueryParam, // Unknown query param name, or param number out of range
-
76  kC4ErrorRemoteError, // Unknown error from remote server
-
77  kC4ErrorDatabaseTooOld, // Database file format is older than what I can open
-
78  kC4ErrorDatabaseTooNew, // Database file format is newer than what I can open
-
79  kC4ErrorBadDocID, // Invalid document ID
-
80  kC4ErrorCantUpgradeDatabase,/*30*/ // DB can't be upgraded (might be unsupported dev version)
-
81  kC4ErrorDeltaBaseUnknown, // Replicator can't apply delta: base revision body is missing
-
82  kC4ErrorCorruptDelta, // Replicator can't apply delta: delta data invalid
- -
84 };
-
85 
-
86 
-
92 // (These are identical to the internal C++ NetworkError enum values in WebSocketInterface.hh.)
-
93 typedef C4_ENUM(int32_t, C4NetworkErrorCode) {
-
94  kC4NetErrDNSFailure = 1, // DNS lookup failed [retryable]
-
95  kC4NetErrUnknownHost, // DNS server doesn't know the hostname [retryable]
-
96  kC4NetErrTimeout, // Connection timeout [ETIMEDOUT, retryable]
-
97  kC4NetErrInvalidURL, // Invalid URL
-
98  kC4NetErrTooManyRedirects, // HTTP redirect loop
-
99  kC4NetErrTLSHandshakeFailed, // TLS handshake failed, for reasons other than below
-
100  kC4NetErrTLSCertExpired, // Peer's cert has expired
-
101  kC4NetErrTLSCertUntrusted, // Peer's cert isn't trusted for other reason
-
102  kC4NetErrTLSCertRequiredByPeer, // Peer (server) requires me to provide a (client) cert
-
103  kC4NetErrTLSCertRejectedByPeer, // Peer says my cert is invalid or unauthorized
-
104  kC4NetErrTLSCertUnknownRoot, // Self-signed cert, or unknown anchor cert
-
105  kC4NetErrInvalidRedirect, // Attempted redirect to invalid replication endpoint
-
106  kC4NetErrUnknown, // Unknown error
-
107  kC4NetErrTLSCertRevoked, // Peer's cert has been revoked
-
108  kC4NetErrTLSCertNameMismatch, // Peer's cert's Common Name doesn't match hostname
-
109  kC4NetErrNetworkReset, // The network subsystem was reset [ENETRESET, retryable]
-
110  kC4NetErrConnectionAborted, // The connection was aborted by the OS [ECONNABORTED, retryable]
-
111  kC4NetErrConnectionReset, // The connection was reset by the other side [ECONNRESET, retryable]
-
112  kC4NetErrConnectionRefused, // The other side refused the connection [ECONNREFUSED, retryable]
-
113  kC4NetErrNetworkDown, // The network subsystem is not functioning [ENETDOWN, retryable]
-
114  kC4NetErrNetworkUnreachable, // There is no usable network at the moment [ENETUNREACH, retryable]
-
115  kC4NetErrNotConnected, // The socket in question is no longer connected [ENOTCONN, retryable]
-
116  kC4NetErrHostDown, // The other side reports it is down [EHOSTDOWN, retryable]
-
117  kC4NetErrHostUnreachable, // There is no network path to the host [EHOSTUNREACH, retryable]
-
118  kC4NetErrAddressNotAvailable, // The address in question is already being used [EADDRNOTAVAIL, retryable]
-
119  kC4NetErrBrokenPipe, // Broken pipe [EPIPE, retryable]
- -
121 };
-
122 
-
123 
-
130 typedef struct C4Error {
-
131 #if 0 // this cut the size of C4Error to 8 bytes, but caused problems for .NET bindings :(
-
132  C4ErrorDomain domain : 8;
-
133  int code :24;
-
134  unsigned internal_info :32;
-
135 #else
-
136  C4ErrorDomain domain; // Domain of error (LiteCore, POSIX, SQLite, ...)
-
137  int code; // Error code. Domain-specific, except 0 is ALWAYS "none".
-
138  unsigned internal_info; // No user-serviceable parts inside. Do not touch.
-
139 #endif
-
140 
-
141 #ifdef __cplusplus
-
142  // C4Error C++ API:
-
143  static C4Error make(C4ErrorDomain, int code, fleece::slice message ={});
-
144  static C4Error printf(C4ErrorDomain, int code, const char *format, ...)
-
145  __printflike(3,4);
-
146  static C4Error vprintf(C4ErrorDomain, int code, const char *format, va_list args)
-
147  __printflike(3,0);
-
148  static void set(C4Error* C4NULLABLE, C4ErrorDomain, int code, const char *format =nullptr, ...) __printflike(4,5);
-
149  static void set(C4ErrorDomain domain, int code, fleece::slice message, C4Error* C4NULLABLE outError) {
-
150  if (outError) *outError = make(domain, code, message);
-
151  }
-
152 
-
153  static C4Error fromException(const std::exception &e) noexcept;
-
154  static C4Error fromCurrentException() noexcept;
-
155  static void fromException(const std::exception &e, C4Error* C4NULLABLE outError) noexcept {
-
156  if (outError) *outError = fromException(e);
-
157  }
-
158  static void fromCurrentException(C4Error* C4NULLABLE outError) noexcept {
-
159  if (outError) *outError = fromCurrentException();
-
160  }
-
161 
-
162  static void warnCurrentException(const char *inFunction) noexcept;
-
163 
-
164  [[noreturn]] static void raise(C4ErrorDomain, int code,
-
165  const char* C4NULLABLE format =nullptr, ...) __printflike(3,4);
-
166  [[noreturn]] static void raise(C4Error e) {e.raise();}
-
167 
-
168  static void setCaptureBacktraces(bool) noexcept;
-
169  static bool getCaptureBacktraces() noexcept;
-
170 
-
171  [[noreturn]] void raise() const;
-
172 
-
173  bool operator== (const C4Error &b) const {return code == b.code
-
174  && (code == 0 || domain == b.domain);}
-
175  bool operator!= (const C4Error &b) const {return !(*this == b);}
-
176  explicit operator bool() const {return code != 0;}
-
177  bool operator!() const {return code == 0;}
-
178 
-
179  std::string message() const;
-
180  std::string description() const;
-
181  std::string backtrace() const;
-
182 
-
183  bool mayBeTransient() const noexcept;
-
184  bool mayBeNetworkDependent() const noexcept;
-
185 #endif
-
186 } C4Error;
-
187 
-
188 
-
189 // C4Error C API:
-
190 
-
191 
- -
194 
- -
198 
-
206 char* c4error_getDescriptionC(C4Error error, char *outBuffer, size_t bufferSize) C4API;
-
207 
- -
212 
- -
214 
- -
218 
-
219 
-
221 C4Error c4error_make(C4ErrorDomain domain, int code, FLString message) C4API;
-
222 
- -
226  int code,
-
227  const char *format, ...) C4API __printflike(3,4);
-
228 
- -
231  const char *format, va_list args) C4API __printflike(3,0);
-
232 
-
235 void c4error_return(C4ErrorDomain domain, int code,
-
236  FLString message,
-
237  C4Error* C4NULLABLE outError) C4API;
-
238 
-
239 
- -
243 
- -
247 
-
248 
- - +Go to the documentation of this file.
1//
+
2// c4Error.h
+
3//
+
4// Copyright 2021-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 "c4Compat.h"
+
15#include "fleece/FLSlice.h"
+
16#include <stdarg.h>
+
17#include <stdbool.h>
+
18#include <stdint.h>
+
19
+
20#ifdef __cplusplus
+
21#include "fleece/slice.hh"
+
22#include <exception>
+
23#include <string>
+
24#endif
+
25
+ + +
28
+
29
+
34// (These are identical to the internal C++ error::Domain enum values.)
+
35typedef C4_ENUM(uint8_t, C4ErrorDomain) {
+
36 LiteCoreDomain = 1, // code is a Couchbase Lite Core error code (see below)
+
37 POSIXDomain, // code is an errno
+
38 SQLiteDomain, // code is a SQLite error; see "sqlite3.h"
+
39 FleeceDomain, // code is a Fleece error; see "FleeceException.h"
+
40 NetworkDomain, // code is a network error; see enum C4NetworkErrorCode, below
+
41 WebSocketDomain, // code is a WebSocket close code (1000...1015) or HTTP error (300..599)
+
42 MbedTLSDomain, // code is an mbedTLS error; see "mbedtls/error.h"
+
43
+ +
45};
+
46
+
47
+
48// LiteCoreDomain error codes:
+
49// (These are identical to the internal C++ error::LiteCoreError enum values.)
+
50typedef C4_ENUM(int32_t, C4ErrorCode) {
+
51 kC4ErrorAssertionFailed = 1, // Internal assertion failure
+
52 kC4ErrorUnimplemented, // Oops, an unimplemented API call
+
53 kC4ErrorUnsupportedEncryption, // Unsupported encryption algorithm
+
54 kC4ErrorBadRevisionID, // Invalid revision ID syntax
+
55 kC4ErrorCorruptRevisionData, // Revision contains corrupted/unreadable data
+
56 kC4ErrorNotOpen, // Database/KeyStore/index is not open
+
57 kC4ErrorNotFound, // Document not found
+
58 kC4ErrorConflict, // Document update conflict
+
59 kC4ErrorInvalidParameter, // Invalid function parameter or struct value
+
60 kC4ErrorUnexpectedError, /*10*/ // Internal unexpected C++ exception
+
61 kC4ErrorCantOpenFile, // Database file can't be opened; may not exist
+
62 kC4ErrorIOError, // File I/O error
+
63 kC4ErrorMemoryError, // Memory allocation failed (out of memory?)
+
64 kC4ErrorNotWriteable, // File is not writeable
+
65 kC4ErrorCorruptData, // Data is corrupted
+
66 kC4ErrorBusy, // Database is busy/locked
+
67 kC4ErrorNotInTransaction, // Function must be called while in a transaction
+
68 kC4ErrorTransactionNotClosed, // Database can't be closed while a transaction is open
+
69 kC4ErrorUnsupported, // Operation not supported in this database
+
70 kC4ErrorNotADatabaseFile,/*20*/ // File is not a database, or encryption key is wrong
+
71 kC4ErrorWrongFormat, // Database exists but not in the format/storage requested
+
72 kC4ErrorCrypto, // Encryption/decryption error
+
73 kC4ErrorInvalidQuery, // Invalid query
+
74 kC4ErrorMissingIndex, // No such index, or query requires a nonexistent index
+
75 kC4ErrorInvalidQueryParam, // Unknown query param name, or param number out of range
+
76 kC4ErrorRemoteError, // Unknown error from remote server
+
77 kC4ErrorDatabaseTooOld, // Database file format is older than what I can open
+
78 kC4ErrorDatabaseTooNew, // Database file format is newer than what I can open
+
79 kC4ErrorBadDocID, // Invalid document ID
+
80 kC4ErrorCantUpgradeDatabase,/*30*/ // DB can't be upgraded (might be unsupported dev version)
+
81 kC4ErrorDeltaBaseUnknown, // Replicator can't apply delta: base revision body is missing
+
82 kC4ErrorCorruptDelta, // Replicator can't apply delta: delta data invalid
+ +
84};
+
85
+
86
+
92// (These are identical to the internal C++ NetworkError enum values in WebSocketInterface.hh.)
+
93typedef C4_ENUM(int32_t, C4NetworkErrorCode) {
+
94 kC4NetErrDNSFailure = 1, // DNS lookup failed [retryable]
+
95 kC4NetErrUnknownHost, // DNS server doesn't know the hostname [retryable]
+
96 kC4NetErrTimeout, // Connection timeout [ETIMEDOUT, retryable]
+
97 kC4NetErrInvalidURL, // Invalid URL
+
98 kC4NetErrTooManyRedirects, // HTTP redirect loop
+
99 kC4NetErrTLSHandshakeFailed, // TLS handshake failed, for reasons other than below
+
100 kC4NetErrTLSCertExpired, // Peer's cert has expired
+
101 kC4NetErrTLSCertUntrusted, // Peer's cert isn't trusted for other reason
+
102 kC4NetErrTLSCertRequiredByPeer, // Peer (server) requires me to provide a (client) cert
+
103 kC4NetErrTLSCertRejectedByPeer, // Peer says my cert is invalid or unauthorized
+
104 kC4NetErrTLSCertUnknownRoot, // Self-signed cert, or unknown anchor cert
+
105 kC4NetErrInvalidRedirect, // Attempted redirect to invalid replication endpoint
+
106 kC4NetErrUnknown, // Unknown error
+
107 kC4NetErrTLSCertRevoked, // Peer's cert has been revoked
+
108 kC4NetErrTLSCertNameMismatch, // Peer's cert's Common Name doesn't match hostname
+
109 kC4NetErrNetworkReset, // The network subsystem was reset [ENETRESET, retryable]
+
110 kC4NetErrConnectionAborted, // The connection was aborted by the OS [ECONNABORTED, retryable]
+
111 kC4NetErrConnectionReset, // The connection was reset by the other side [ECONNRESET, retryable]
+
112 kC4NetErrConnectionRefused, // The other side refused the connection [ECONNREFUSED, retryable]
+
113 kC4NetErrNetworkDown, // The network subsystem is not functioning [ENETDOWN, retryable]
+
114 kC4NetErrNetworkUnreachable, // There is no usable network at the moment [ENETUNREACH, retryable]
+
115 kC4NetErrNotConnected, // The socket in question is no longer connected [ENOTCONN, retryable]
+
116 kC4NetErrHostDown, // The other side reports it is down [EHOSTDOWN, retryable]
+
117 kC4NetErrHostUnreachable, // There is no network path to the host [EHOSTUNREACH, retryable]
+
118 kC4NetErrAddressNotAvailable, // The address in question is already being used [EADDRNOTAVAIL, retryable]
+
119 kC4NetErrBrokenPipe, // Broken pipe [EPIPE, retryable]
+ + +
122
+
123
+
130typedef struct C4Error {
+
131#if 0 // this cut the size of C4Error to 8 bytes, but caused problems for .NET bindings :(
+ +
133 int code :24;
+
134 unsigned internal_info :32;
+
135#else
+
136 C4ErrorDomain domain; // Domain of error (LiteCore, POSIX, SQLite, ...)
+
137 int code; // Error code. Domain-specific, except 0 is ALWAYS "none".
+
138 unsigned internal_info; // No user-serviceable parts inside. Do not touch.
+
139#endif
+
140
+
141#ifdef __cplusplus
+
142 // C4Error C++ API:
+
143 static C4Error make(C4ErrorDomain, int code, fleece::slice message ={});
+
144 static C4Error printf(C4ErrorDomain, int code, const char *format, ...)
+
145 __printflike(3,4);
+
146 static C4Error vprintf(C4ErrorDomain, int code, const char *format, va_list args)
+
147 __printflike(3,0);
+
148 static void set(C4Error* C4NULLABLE, C4ErrorDomain, int code, const char *format =nullptr, ...) __printflike(4,5);
+
149 static void set(C4ErrorDomain domain, int code, fleece::slice message, C4Error* C4NULLABLE outError) {
+
150 if (outError) *outError = make(domain, code, message);
+
151 }
+
152
+
153 static C4Error fromException(const std::exception &e) noexcept;
+
154 static C4Error fromCurrentException() noexcept;
+
155 static void fromException(const std::exception &e, C4Error* C4NULLABLE outError) noexcept {
+
156 if (outError) *outError = fromException(e);
+
157 }
+
158 static void fromCurrentException(C4Error* C4NULLABLE outError) noexcept {
+
159 if (outError) *outError = fromCurrentException();
+
160 }
+
161
+
162 static void warnCurrentException(const char *inFunction) noexcept;
+
163
+
164 [[noreturn]] static void raise(C4ErrorDomain, int code,
+
165 const char* C4NULLABLE format =nullptr, ...) __printflike(3,4);
+
166 [[noreturn]] static void raise(C4Error e) {e.raise();}
+
167
+
168 static void setCaptureBacktraces(bool) noexcept;
+
169 static bool getCaptureBacktraces() noexcept;
+
170
+
171 [[noreturn]] void raise() const;
+
172
+
173 bool operator== (const C4Error &b) const {return code == b.code
+
174 && (code == 0 || domain == b.domain);}
+
175 bool operator!= (const C4Error &b) const {return !(*this == b);}
+
176 explicit operator bool() const {return code != 0;}
+
177 bool operator!() const {return code == 0;}
+
178
+
179 std::string message() const;
+
180 std::string description() const;
+
181 std::string backtrace() const;
+
182
+
183 bool mayBeTransient() const noexcept;
+
184 bool mayBeNetworkDependent() const noexcept;
+
185#endif
+
186} C4Error;
+
187
+
188
+
189#ifdef _MSC_VER
+
190static const C4Error kC4NoError = { };
+
191#else
+
192#define kC4NoError ((C4Error){ })
+
193#endif
+
194
+
195
+
196// C4Error C API:
+
197
+
198
+ +
201
+ +
205
+
213char* c4error_getDescriptionC(C4Error error, char *outBuffer, size_t bufferSize) C4API;
+
214
+ +
219
+ +
221
+ +
225
+
226
+ +
229
+ +
233 int code,
+
234 const char *format, ...) C4API __printflike(3,4);
+
235
+ +
238 const char *format, va_list args) C4API __printflike(3,0);
+
239
+
242void c4error_return(C4ErrorDomain domain, int code,
+
243 FLString message,
+
244 C4Error* C4NULLABLE outError) C4API;
+
245
+
246
+ +
250
+ +
254
+
255
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
@@ -291,6 +298,7 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
FLSliceResult c4error_getDescription(C4Error error)
Returns a description of an error, including the domain and code as well as the message.
+
#define kC4NoError
Definition: c4Error.h:192
C4Error c4error_printf(C4ErrorDomain domain, int code, const char *format,...) __printflike(3
Creates a C4Error struct with the given domain and code, formats the message as with printf,...
C4NetworkErrorCode
Network error codes (potentially higher level than POSIX, lower level than HTTP.) The entries marked ...
Definition: c4Error.h:93
bool c4error_getCaptureBacktraces(void)
@@ -298,12 +306,12 @@
C4Error c4error_make(C4ErrorDomain domain, int code, FLString message)
Creates a C4Error struct with the given domain and code, and associates the message with it.
C4ErrorDomain
Definition: c4Error.h:35
C4ErrorCode
Definition: c4Error.h:50
-
char * c4error_getDescriptionC(C4Error error, char *outBuffer, size_t bufferSize)
Returns a description of an error, including the domain and code as well as the message.
void c4error_setCaptureBacktraces(bool)
If set to true, then when a C4Error is created the current thread's stack backtrace will be captured ...
FLStringResult c4error_getBacktrace(C4Error error)
Returns the stack backtrace, if any, associated with a C4Error.
bool c4error_mayBeNetworkDependent(C4Error err)
Returns true if this error might go away when the network environment changes, i.e.
C4Error C4Error void c4error_return(C4ErrorDomain domain, int code, FLString message, C4Error *outError)
Creates and stores a C4Error in *outError, if not NULL.
C4Error C4Error c4error_vprintf(C4ErrorDomain domain, int code, const char *format, va_list args) __printflike(3
Same as c4error_printf, but with a premade va_list.
+
char * c4error_getDescriptionC(C4Error error, char *outBuffer, size_t bufferSize)
Returns a description of an error, including the domain and code as well as the message.
FLStringResult c4error_getMessage(C4Error error)
Returns an error message describing a C4Error.
@ kC4NetErrTLSCertExpired
Definition: c4Error.h:100
@ kC4NetErrTLSCertUnknownRoot
Definition: c4Error.h:104
@@ -382,7 +390,7 @@
diff --git a/docs/C/html/c4_index_8h.html b/docs/C/html/c4_index_8h.html index b4297d17e8..a3f0acdf48 100644 --- a/docs/C/html/c4_index_8h.html +++ b/docs/C/html/c4_index_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Index.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Index.h File Reference
+
c4Index.h File Reference
#include "c4IndexTypes.h"

Go to the source code of this file.

- @@ -93,7 +93,7 @@ diff --git a/docs/C/html/c4_index_8h_source.html b/docs/C/html/c4_index_8h_source.html index a49b23e822..5ed9b87aa7 100644 --- a/docs/C/html/c4_index_8h_source.html +++ b/docs/C/html/c4_index_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Index.h Source File @@ -30,21 +30,22 @@

+

Functions

bool c4db_createIndex (C4Database *database, C4String name, C4String indexSpecJSON, C4IndexType indexType, const C4IndexOptions *indexOptions, C4Error *outError)
 Creates a database index, of the values of specific expressions across all documents. More...
- + +/* @license-end */ +
-
-
c4Index.h
+
c4Index.h
-Go to the documentation of this file.
1 //
-
2 // c4Index.h
-
3 //
-
4 // Copyright 2019-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 "c4IndexTypes.h"
-
15 
- - -
18 
-
75  bool c4db_createIndex(C4Database *database,
-
76  C4String name,
-
77  C4String indexSpecJSON,
-
78  C4IndexType indexType,
-
79  const C4IndexOptions* C4NULLABLE indexOptions,
-
80  C4Error* C4NULLABLE outError) C4API;
-
81 
-
91  bool c4db_createIndex2(C4Database *database,
-
92  C4String name,
-
93  C4String indexSpec,
-
94  C4QueryLanguage queryLanguage,
-
95  C4IndexType indexType,
-
96  const C4IndexOptions* C4NULLABLE indexOptions,
-
97  C4Error* C4NULLABLE outError) C4API;
-
98 
-
99 
-
105  bool c4db_deleteIndex(C4Database *database,
-
106  C4String name,
-
107  C4Error* C4NULLABLE outError) C4API;
-
108 
-
109 
- -
117  C4Error* C4NULLABLE outError) C4API;
-
118 
- - +Go to the documentation of this file.
1//
+
2// c4Index.h
+
3//
+
4// Copyright 2019-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 "c4IndexTypes.h"
+
15
+ + +
18
+ +
76 C4String name,
+
77 C4String indexSpecJSON,
+
78 C4IndexType indexType,
+
79 const C4IndexOptions* C4NULLABLE indexOptions,
+
80 C4Error* C4NULLABLE outError) C4API;
+
81
+ +
92 C4String name,
+
93 C4String indexSpec,
+
94 C4QueryLanguage queryLanguage,
+
95 C4IndexType indexType,
+
96 const C4IndexOptions* C4NULLABLE indexOptions,
+
97 C4Error* C4NULLABLE outError) C4API;
+
98
+
99
+ +
106 C4String name,
+
107 C4Error* C4NULLABLE outError) C4API;
+
108
+
109
+ +
117 C4Error* C4NULLABLE outError) C4API;
+
118
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -121,7 +121,7 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
bool c4db_deleteIndex(C4Database *database, C4String name, C4Error *outError)
Deletes an index that was created by c4db_createIndex.
C4SliceResult c4db_getIndexesInfo(C4Database *database, C4Error *outError)
Returns information about all indexes in the database.
bool c4db_createIndex(C4Database *database, C4String name, C4String indexSpecJSON, C4IndexType indexType, const C4IndexOptions *indexOptions, C4Error *outError)
Creates a database index, of the values of specific expressions across all documents.
@@ -135,7 +135,7 @@
diff --git a/docs/C/html/c4_index_types_8h.html b/docs/C/html/c4_index_types_8h.html index 0b42d2d7c0..72714fb360 100644 --- a/docs/C/html/c4_index_types_8h.html +++ b/docs/C/html/c4_index_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4IndexTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
c4IndexTypes.h File Reference
+
c4IndexTypes.h File Reference

#include "c4Base.h"
@@ -78,13 +78,13 @@

Go to the source code of this file.

-

+

Data Structures

struct  C4IndexOptions
 Options for indexes; these each apply to specific types of indexes. More...
 
-

+

Enumerations

enum  C4IndexType : uint32_t { kC4ValueIndex , kC4FullTextIndex @@ -97,7 +97,7 @@ diff --git a/docs/C/html/c4_index_types_8h_source.html b/docs/C/html/c4_index_types_8h_source.html index a430c1dc9a..5268aca70a 100644 --- a/docs/C/html/c4_index_types_8h_source.html +++ b/docs/C/html/c4_index_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4IndexTypes.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4IndexTypes.h
+
c4IndexTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4IndexTypes.h
-
3 //
-
4 // Copyright 2019-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 "c4Base.h"
-
15 #include "c4QueryTypes.h"
-
16 
- - -
19 
-
20 
-
26 typedef C4_ENUM(uint32_t, C4IndexType) {
- - - - -
31 };
-
32 
-
33 
-
35 typedef struct {
-
44  const char* C4NULLABLE language;
-
45 
- -
49 
- -
57 
-
65  const char* C4NULLABLE stopWords;
- -
67 
-
68 
- - +Go to the documentation of this file.
1//
+
2// c4IndexTypes.h
+
3//
+
4// Copyright 2019-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 "c4Base.h"
+
15#include "c4QueryTypes.h"
+
16
+ + +
19
+
20
+
26typedef C4_ENUM(uint32_t, C4IndexType) {
+ + + + +
31};
+
32
+
33
+
35typedef struct {
+
44 const char* C4NULLABLE language;
+
45
+ +
49
+ +
57
+
65 const char* C4NULLABLE stopWords;
+ +
67
+
68
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4_ENUM(_type, _name)
Definition: c4Compat.h:62
@@ -132,7 +132,7 @@
diff --git a/docs/C/html/c4_listener_8h.html b/docs/C/html/c4_listener_8h.html index 4be969f4db..b4337e10ea 100644 --- a/docs/C/html/c4_listener_8h.html +++ b/docs/C/html/c4_listener_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Listener.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Listener.h File Reference
+
c4Listener.h File Reference
#include "c4ListenerTypes.h"
@@ -77,14 +77,14 @@

Go to the source code of this file.

- - - - + + + @@ -110,7 +110,7 @@ diff --git a/docs/C/html/c4_listener_8h_source.html b/docs/C/html/c4_listener_8h_source.html index 373a57aa61..ced15fbba0 100644 --- a/docs/C/html/c4_listener_8h_source.html +++ b/docs/C/html/c4_listener_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Listener.h Source File @@ -30,21 +30,22 @@

+

Functions

C4ListenerAPIs c4listener_availableAPIs (void)
 Returns flags for the available APIs in this build (REST, sync, or both.) More...
 
C4Listenerc4listener_start (const C4ListenerConfig *config, C4Error *error)
 Starts a new listener. More...
 
C4Listenerc4listener_start (const C4ListenerConfig *config, C4Error *error)
 Starts a new listener. More...
 
void c4listener_free (C4Listener *listener)
 Closes and disposes a listener. More...
 
- + +/* @license-end */ +
-
-
c4Listener.h
+
c4Listener.h
-Go to the documentation of this file.
1 //
-
2 // c4Listener.h
-
3 //
-
4 // Copyright 2017-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 "c4ListenerTypes.h"
-
15 #include "fleece/Fleece.h"
-
16 
- - -
19 
- -
25 
- -
28  C4Error* C4NULLABLE error) C4API;
-
29 
- -
32 
- -
42  C4String name,
-
43  C4Database *db,
-
44  C4Error* C4NULLABLE outError) C4API;
-
45 
- -
48  C4Database *db,
-
49  C4Error* C4NULLABLE outError) C4API;
-
50 
- - -
69  C4ListenerAPIs api,
-
70  C4Error* C4NULLABLE err) C4API;
-
71 
-
75  uint16_t c4listener_getPort(const C4Listener *listener) C4API;
-
76 
- -
80  unsigned * C4NULLABLE connectionCount,
-
81  unsigned * C4NULLABLE activeConnectionCount) C4API;
-
82 
- -
92 
-
93 
- - +Go to the documentation of this file.
1//
+
2// c4Listener.h
+
3//
+
4// Copyright 2017-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 "c4ListenerTypes.h"
+
15#include "fleece/Fleece.h"
+
16
+ + +
19
+ +
25
+ +
28 C4Error* C4NULLABLE error) C4API;
+
29
+ +
32
+ +
42 C4String name,
+
43 C4Database *db,
+
44 C4Error* C4NULLABLE outError) C4API;
+
45
+ +
48 C4Database *db,
+
49 C4Error* C4NULLABLE outError) C4API;
+
50
+ + + + +
71
+
75 uint16_t c4listener_getPort(const C4Listener *listener) C4API;
+
76
+ +
80 unsigned * C4NULLABLE connectionCount,
+
81 unsigned * C4NULLABLE activeConnectionCount) C4API;
+
82
+ +
92
+
93
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
@@ -129,19 +129,19 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:143
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:146
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
C4StringResult c4db_URINameFromPath(C4String path)
A convenience that, given a filesystem path to a database, returns the database name for use in an HT...
bool c4listener_shareDB(C4Listener *listener, C4String name, C4Database *db, C4Error *outError)
Makes a database available from the network.
uint16_t c4listener_getPort(const C4Listener *listener)
Returns the port number the listener is accepting connections on.
bool c4listener_unshareDB(C4Listener *listener, C4Database *db, C4Error *outError)
Makes a previously-shared database unavailable.
void c4listener_free(C4Listener *listener)
Closes and disposes a listener.
C4ListenerAPIs
Flags indicating which network API(s) to serve.
Definition: c4ListenerTypes.h:24
-
C4Listener * c4listener_start(const C4ListenerConfig *config, C4Error *error)
Starts a new listener.
FLMutableArray c4listener_getURLs(const C4Listener *listener, C4Database *db, C4ListenerAPIs api, C4Error *err)
Returns the URL(s) of a database being shared, or of the root, separated by "\n" bytes.
+
C4Listener * c4listener_start(const C4ListenerConfig *config, C4Error *error)
Starts a new listener.
C4ListenerAPIs c4listener_availableAPIs(void)
Returns flags for the available APIs in this build (REST, sync, or both.)
void c4listener_getConnectionStatus(const C4Listener *listener, unsigned *connectionCount, unsigned *activeConnectionCount)
Returns the number of client connections, and how many of those are currently active.
-
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:55
+
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: FLBase.h:55
An error value.
Definition: c4Error.h:130
Configuration for a C4Listener.
Definition: c4ListenerTypes.h:69
A simple reference to a block of memory.
Definition: FLSlice.h:48
@@ -149,7 +149,7 @@
diff --git a/docs/C/html/c4_listener_types_8h.html b/docs/C/html/c4_listener_types_8h.html index 47cd827ea9..510da7d2ed 100644 --- a/docs/C/html/c4_listener_types_8h.html +++ b/docs/C/html/c4_listener_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4ListenerTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Data Structures | Typedefs | Enumerations
-
-
c4ListenerTypes.h File Reference
+
c4ListenerTypes.h File Reference

#include "c4Base.h"

Go to the source code of this file.

- @@ -87,7 +87,7 @@

+

Data Structures

struct  C4TLSConfig
 TLS configuration for C4Listener. More...
 Configuration for a C4Listener. More...
 
- @@ -96,7 +96,7 @@

+

Typedefs

typedef bool(* C4ListenerCertAuthCallback) (C4Listener *listener, C4Slice clientCertData, void *context)
 Called when a client connects, during the TLS handshake, if a client certificate is received. More...
 Called when a client connects, after the TLS handshake (if any), when the initial HTTP request is received. More...
 
-

+

Enumerations

enum  C4ListenerAPIs : unsigned { kC4RESTAPI = 0x01 , kC4SyncAPI = 0x02 @@ -112,7 +112,7 @@ diff --git a/docs/C/html/c4_listener_types_8h_source.html b/docs/C/html/c4_listener_types_8h_source.html index e4b8ad5db7..6bcef54434 100644 --- a/docs/C/html/c4_listener_types_8h_source.html +++ b/docs/C/html/c4_listener_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4ListenerTypes.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4ListenerTypes.h
+
c4ListenerTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4ListenerTypes.h
-
3 //
-
4 // Copyright 2021-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 "c4Base.h"
-
15 
- - -
18 
-
24 typedef C4_OPTIONS(unsigned, C4ListenerAPIs) {
-
25  kC4RESTAPI = 0x01,
-
26  kC4SyncAPI = 0x02
-
27 };
-
28 
-
29 
-
31 typedef C4_ENUM(unsigned, C4PrivateKeyRepresentation) {
- - -
34 };
-
35 
-
36 
-
42 typedef bool (*C4ListenerCertAuthCallback)(C4Listener *listener,
-
43  C4Slice clientCertData,
-
44  void * C4NULLABLE context);
-
45 
-
52 typedef bool (*C4ListenerHTTPAuthCallback)(C4Listener *listener,
-
53  C4Slice authHeader,
-
54  void * C4NULLABLE context);
-
55 
-
57 typedef struct C4TLSConfig {
- - - - - - - -
65 } C4TLSConfig;
-
66 
-
67 
-
69 typedef struct C4ListenerConfig {
-
70  uint16_t port;
- - - -
74 
- - -
77 
-
78  // For REST listeners only:
- - - -
82 
-
83  // For sync listeners only:
-
84  bool allowPush;
-
85  bool allowPull;
- - -
88 
-
89 
- - +Go to the documentation of this file.
1//
+
2// c4ListenerTypes.h
+
3//
+
4// Copyright 2021-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 "c4Base.h"
+
15
+ + +
18
+
24typedef C4_OPTIONS(unsigned, C4ListenerAPIs) {
+
25 kC4RESTAPI = 0x01,
+
26 kC4SyncAPI = 0x02
+
27};
+
28
+
29
+ + + +
34};
+
35
+
36
+
42typedef bool (*C4ListenerCertAuthCallback)(C4Listener *listener,
+
43 C4Slice clientCertData,
+
44 void * C4NULLABLE context);
+
45
+
52typedef bool (*C4ListenerHTTPAuthCallback)(C4Listener *listener,
+
53 C4Slice authHeader,
+
54 void * C4NULLABLE context);
+
55
+
57typedef struct C4TLSConfig {
+ + + + + + + + +
66
+
67
+
69typedef struct C4ListenerConfig {
+
70 uint16_t port;
+ + + +
74
+ + +
77
+
78 // For REST listeners only:
+ + + +
82
+
83 // For sync listeners only:
+
84 bool allowPush;
+
85 bool allowPull;
+ + +
88
+
89
+ +
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define C4NULLABLE
Definition: c4Compat.h:38
@@ -150,8 +150,8 @@
#define C4API_END_DECLS
Definition: c4Compat.h:95
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:143
-
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:140
+
struct C4Listener C4Listener
A LiteCore network listener – supports the REST API, replication, or both.
Definition: c4Base.h:146
+
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition: c4Base.h:143
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition: c4Base.h:115
C4ListenerAPIs
Flags indicating which network API(s) to serve.
Definition: c4ListenerTypes.h:24
C4PrivateKeyRepresentation
Different ways to provide TLS private keys.
Definition: c4ListenerTypes.h:31
@@ -186,7 +186,7 @@
diff --git a/docs/C/html/c4_log_8h.html b/docs/C/html/c4_log_8h.html index e537f4398f..22ca62f80f 100644 --- a/docs/C/html/c4_log_8h.html +++ b/docs/C/html/c4_log_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Log.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Enumerations | Functions | Variables
-
-
c4Log.h File Reference
+
c4Log.h File Reference

#include "c4Compat.h"
@@ -84,13 +84,13 @@

Go to the source code of this file.

-

+

Data Structures

struct  C4LogFileOptions
 Configuration for file-based logging. More...
 
- @@ -105,7 +105,7 @@

+

Macros

#define C4LogToAt(DOMAIN, LEVEL, FMT, ...)
 
#define C4WarnError(FMT, ...)   C4LogToAt(kC4DefaultLog, kC4LogError, FMT, ## __VA_ARGS__)
 
- @@ -114,7 +114,7 @@

+

Typedefs

typedef struct c4LogDomain * C4LogDomain
 Reference to a log domain: a specific source of logs that can be enabled or disabled. More...
 A logging callback that the application can register. More...
 
-

+

Enumerations

enum  C4LogLevel : int8_t {
  kC4LogDebug @@ -129,7 +129,7 @@
 Logging levels. More...
 
- @@ -161,9 +161,9 @@ - - - + + + @@ -192,7 +192,7 @@

+

Functions

bool c4log_writeToBinaryFile (C4LogFileOptions options, C4Error *error)
 Causes log messages to be written to a file, overwriting any previous contents. More...
C4LogDomain c4log_getDomain (const char *name, bool create)
 Looks up a named log domain. More...
 
const char * c4log_getDomainName (C4LogDomain)
 Returns the name of a log domain. More...
 
const char * c4log_getDomainName (C4LogDomain)
 Returns the name of a log domain. More...
 
C4LogLevel c4log_getLevel (C4LogDomain)
 Returns the current log level of a domain, the minimum level of message it will log. More...
 
 Same as c4log, except it accepts preformatted messages as FLSlices. More...
 
- @@ -213,7 +213,7 @@ diff --git a/docs/C/html/c4_log_8h_source.html b/docs/C/html/c4_log_8h_source.html index 69d9dfeeb3..75562afa37 100644 --- a/docs/C/html/c4_log_8h_source.html +++ b/docs/C/html/c4_log_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Log.h Source File @@ -30,21 +30,22 @@

+

Variables

CBL_CORE_API const C4LogDomain kC4DefaultLog
 Subsystems that produce logs. More...
- + +/* @license-end */ +
-
-
c4Log.h
+
c4Log.h
-Go to the documentation of this file.
1 //
-
2 // c4Log.h
-
3 //
-
4 // Copyright 2021-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 "c4Compat.h"
-
15 #include "c4Error.h"
-
16 #include "fleece/FLSlice.h"
-
17 #include <stdarg.h>
-
18 
- - -
21 
-
22 
-
28 typedef C4_ENUM(int8_t, C4LogLevel) {
- - - - - -
34  kC4LogNone
-
35 };
-
36 
-
38 typedef struct c4LogDomain *C4LogDomain;
-
39 
-
40 
-
43 CBL_CORE_API extern const C4LogDomain
- - - - - -
49 
-
50 
-
51 #pragma mark - FILE LOGGING:
-
52 
-
53 
-
55 typedef struct C4LogFileOptions {
- - -
58  int64_t max_size_bytes;
-
59  int32_t max_rotate_count;
- - - -
63 
- -
71 
- -
74 
- -
77 
- -
81 
- -
84 
-
85 
-
86 #pragma mark - CALLBACK LOGGING:
-
87 
-
88 
-
90 typedef void (* C4NULLABLE C4LogCallback)(C4LogDomain, C4LogLevel, const char *fmt, va_list args);
-
91 
-
100 void c4log_writeToCallback(C4LogLevel level, C4LogCallback callback, bool preformatted) C4API;
-
101 
- -
104 
- -
108 
- -
111 
-
112 
-
113 #pragma mark - LOG DOMAINS:
-
114 
-
115 
-
120 C4LogDomain c4log_getDomain(const char *name, bool create) C4API;
-
121 
- -
124 
- -
127 
- -
135 
- -
143 
-
144 
-
145 #pragma mark - LOGGING EXCEPTIONs:
-
146 
-
147 
- -
152 
- -
155 
- -
159 
-
160 
-
161 #pragma mark - WRITING LOG MESSAGES:
-
162 
-
163 
-
171 void c4log(C4LogDomain domain, C4LogLevel level, const char *fmt, ...) C4API __printflike(3,4);
-
172 
-
174 void c4vlog(C4LogDomain domain, C4LogLevel level, const char *fmt, va_list args) C4API
-
175  __printflike(3, 0);
-
176 
-
178 void c4slog(C4LogDomain domain, C4LogLevel level, FLString msg) C4API;
-
179 
-
180 // Convenient aliases for c4log:
-
181 #define C4LogToAt(DOMAIN, LEVEL, FMT, ...) \
-
182  do {if (c4log_willLog(DOMAIN, LEVEL)) \
-
183  c4log(DOMAIN, LEVEL, FMT, ## __VA_ARGS__);} while (false)
-
184 #define C4Debug(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogDebug, FMT, ## __VA_ARGS__)
-
185 #define C4Log(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogInfo, FMT, ## __VA_ARGS__)
-
186 #define C4LogVerbose(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogVerbose, FMT, ## __VA_ARGS__)
-
187 #define C4Warn(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogWarning, FMT, ## __VA_ARGS__)
-
188 #define C4WarnError(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogError, FMT, ## __VA_ARGS__)
-
189 
-
190 
- - +Go to the documentation of this file.
1//
+
2// c4Log.h
+
3//
+
4// Copyright 2021-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 "c4Compat.h"
+
15#include "c4Error.h"
+
16#include "fleece/FLSlice.h"
+
17#include <stdarg.h>
+
18
+ + +
21
+
22
+
28typedef C4_ENUM(int8_t, C4LogLevel) {
+ + + + + + +
35};
+
36
+
38typedef struct c4LogDomain *C4LogDomain;
+
39
+
40
+
43CBL_CORE_API extern const C4LogDomain
+ + + + + +
49
+
50
+
51#pragma mark - FILE LOGGING:
+
52
+
53
+
55typedef struct C4LogFileOptions {
+ + + + + + + +
63
+ +
71
+ +
74
+ +
77
+ +
81
+ +
84
+
85
+
86#pragma mark - CALLBACK LOGGING:
+
87
+
88
+
90typedef void (* C4NULLABLE C4LogCallback)(C4LogDomain, C4LogLevel, const char *fmt, va_list args);
+
91
+
100void c4log_writeToCallback(C4LogLevel level, C4LogCallback callback, bool preformatted) C4API;
+
101
+ +
104
+ +
108
+ +
111
+
112
+
113#pragma mark - LOG DOMAINS:
+
114
+
115
+
120C4LogDomain c4log_getDomain(const char *name, bool create) C4API;
+
121
+ +
124
+ +
127
+ +
135
+ +
143
+
144
+
145#pragma mark - LOGGING EXCEPTIONs:
+
146
+
147
+ +
152
+ +
155
+ +
159
+
160
+
161#pragma mark - WRITING LOG MESSAGES:
+
162
+
163
+
171void c4log(C4LogDomain domain, C4LogLevel level, const char *fmt, ...) C4API __printflike(3,4);
+
172
+
174void c4vlog(C4LogDomain domain, C4LogLevel level, const char *fmt, va_list args) C4API
+
175 __printflike(3, 0);
+
176
+
178void c4slog(C4LogDomain domain, C4LogLevel level, FLString msg) C4API;
+
179
+
180// Convenient aliases for c4log:
+
181#define C4LogToAt(DOMAIN, LEVEL, FMT, ...) \
+
182 do {if (c4log_willLog(DOMAIN, LEVEL)) \
+
183 c4log(DOMAIN, LEVEL, FMT, ## __VA_ARGS__);} while (false)
+
184#define C4Debug(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogDebug, FMT, ## __VA_ARGS__)
+
185#define C4Log(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogInfo, FMT, ## __VA_ARGS__)
+
186#define C4LogVerbose(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogVerbose, FMT, ## __VA_ARGS__)
+
187#define C4Warn(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogWarning, FMT, ## __VA_ARGS__)
+
188#define C4WarnError(FMT, ...) C4LogToAt(kC4DefaultLog, kC4LogError, FMT, ## __VA_ARGS__)
+
189
+
190
+ +
#define CBL_CORE_API
Definition: c4Compat.h:113
@@ -211,6 +211,7 @@
void c4log_enableFatalExceptionBacktrace(void)
Registers a handler with the C++ runtime that will log a backtrace when an uncaught C++ exception occ...
void c4log_setCallbackLevel(C4LogLevel level)
Sets the minimum level of log messages to be reported via callback.
CBL_CORE_API const C4LogDomain kC4DatabaseLog
Log domain for database operations.
Definition: c4Log.h:45
+
const char * c4log_getDomainName(C4LogDomain)
Returns the name of a log domain.
void c4log_writeToCallback(C4LogLevel level, C4LogCallback callback, bool preformatted)
Registers (or unregisters) a log callback, and sets the minimum log level to report.
C4LogDomain c4log_getDomain(const char *name, bool create)
Looks up a named log domain.
C4LogCallback c4log_getCallback(void)
Returns the current logging callback, or the default one if none has been set.
@@ -218,7 +219,6 @@
bool c4log_willLog(C4LogDomain, C4LogLevel)
Returns true if logging to this domain at this level will have an effect.
void c4log_setLevel(C4LogDomain c4Domain, C4LogLevel level)
Changes the level of the given log domain.
FLStringResult c4log_binaryFilePath(void)
Returns the filesystem path of the directory where log files are kept.
-
const char * c4log_getDomainName(C4LogDomain)
Returns the name of a log domain.
bool c4log_writeToBinaryFile(C4LogFileOptions options, C4Error *error)
Causes log messages to be written to a file, overwriting any previous contents.
CBL_CORE_API const C4LogDomain kC4SyncLog
Log domain for replication operations.
Definition: c4Log.h:47
void c4log_flushLogFiles(void)
Ensures all log messages have been written to the current log files.
@@ -255,7 +255,7 @@
diff --git a/docs/C/html/c4_observer_8h.html b/docs/C/html/c4_observer_8h.html index e6f28d0ea0..7295da30c6 100644 --- a/docs/C/html/c4_observer_8h.html +++ b/docs/C/html/c4_observer_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Observer.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Observer.h File Reference
+
c4Observer.h File Reference
#include "c4DocumentTypes.h"
@@ -80,12 +80,12 @@   typedef C4CollectionObserverCallback C4DatabaseObserverCallback   -C4DatabaseObserverc4dbobs_create (C4Database *database, C4DatabaseObserverCallback callback, void *context) - Creates a collection observer on the database's default collection. More...
-  -C4CollectionObserverc4dbobs_createOnCollection (C4Collection *collection, C4CollectionObserverCallback callback, void *context) - Creates a new collection observer, with a callback that will be invoked after one or more documents in the collection have changed. More...
-  +C4DatabaseObserverc4dbobs_create (C4Database *database, C4DatabaseObserverCallback callback, void *context) + Creates a collection observer on the database's default collection. More...
+  +C4CollectionObserverc4dbobs_createOnCollection (C4Collection *collection, C4CollectionObserverCallback callback, void *context) + Creates a new collection observer, with a callback that will be invoked after one or more documents in the collection have changed. More...
+  uint32_t c4dbobs_getChanges (C4CollectionObserver *observer, C4CollectionChange outChanges[], uint32_t maxChanges, bool *outExternal)  Identifies which documents have changed in the collection since the last time this function was called, or since the observer was created. More...
  @@ -100,20 +100,20 @@ typedef void(* C4DocumentObserverCallback) (C4DocumentObserver *observer, C4String docID, C4SequenceNumber sequence, void *context)  Callback invoked by a document observer. More...
  -C4DocumentObserverc4docobs_create (C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context) - Creates a new document observer, on a document in the database's default collection. More...
-  -C4DocumentObserverc4docobs_createWithCollection (C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context) - Creates a new document observer, with a callback that will be invoked when the document changes. More...
-  +C4DocumentObserverc4docobs_create (C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context) + Creates a new document observer, on a document in the database's default collection. More...
+  +C4DocumentObserverc4docobs_createWithCollection (C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context) + Creates a new document observer, with a callback that will be invoked when the document changes. More...
+  void c4docobs_free (C4DocumentObserver *)  Stops an observer and frees the resources it's using. More...
  - - - - + + + - - - + + + @@ -148,7 +148,7 @@ diff --git a/docs/C/html/c4_observer_8h_source.html b/docs/C/html/c4_observer_8h_source.html index b4dbb1db7b..6d0086efcc 100644 --- a/docs/C/html/c4_observer_8h_source.html +++ b/docs/C/html/c4_observer_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Observer.h Source File @@ -30,21 +30,22 @@

Query Observer

A query observer, also called a "live query", notifies the client when the query's result set changes.

-

(Not just any time the database changes.)

-

This is done as follows, starting from when the first time an observer on a particular query is enabled:

+

A query observer, also called a "live query", notifies the client when the query's result set changes.

+

(Not just any time the database changes.)

+

This is done as follows, starting from when the first time an observer on a particular query is enabled:

  1. A separate C4Query instance is created, on a separate database instance (there's one of these background database instances per C4Database.)
  2. The copied query is run on a background thread, and it saves its results.
  3. @@ -126,21 +126,21 @@
  4. This background task stops when the last observer is disabled.
-

Some notes on performance:

-

All C4Queries on a single C4Database share a single background C4Database, which can only do one thing at a time. That means multiple live queries can bog down since they have to run one after the other. The first time any query observer is added in a given C4Database, the background database instance has to be opened, which takes a few milliseconds. The first time an observer is added to a C4Query, a copy of that query has to be created and compiled by the background database, which can also take a few millseconds. Running a C4Query before adding an observer is a bit of a waste, because the query will be run twice. It's more efficient to skip running it, and instead wait for the first call to the observer. The timing logic in step 4 is a heuristic to provide low latency on occasional database changes, but prevent rapid database changes (as happen during pull replication) from running the query constantly and/or spamming observers with notifications. (The specific times are not currently alterable; they're constants in LiveQuerier.cc.)

+

Some notes on performance:

+

All C4Queries on a single C4Database share a single background C4Database, which can only do one thing at a time. That means multiple live queries can bog down since they have to run one after the other. The first time any query observer is added in a given C4Database, the background database instance has to be opened, which takes a few milliseconds. The first time an observer is added to a C4Query, a copy of that query has to be created and compiled by the background database, which can also take a few millseconds. Running a C4Query before adding an observer is a bit of a waste, because the query will be run twice. It's more efficient to skip running it, and instead wait for the first call to the observer. The timing logic in step 4 is a heuristic to provide low latency on occasional database changes, but prevent rapid database changes (as happen during pull replication) from running the query constantly and/or spamming observers with notifications. (The specific times are not currently alterable; they're constants in LiveQuerier.cc.)

typedef void(* C4QueryObserverCallback) (C4QueryObserver *observer, C4Query *query, void *context)
 Callback invoked by a query observer, notifying that the query results have changed. More...
 
C4QueryObserverc4queryobs_create (C4Query *query, C4QueryObserverCallback callback, void *context)
 Creates a new query observer, with a callback that will be invoked when the query results change, with an enumerator containing the new results. More...
 
C4QueryObserverc4queryobs_create (C4Query *query, C4QueryObserverCallback callback, void *context)
 Creates a new query observer, with a callback that will be invoked when the query results change, with an enumerator containing the new results. More...
 
void c4queryobs_setEnabled (C4QueryObserver *obs, bool enabled)
 Enables a query observer so its callback can be called, or disables it to stop callbacks. More...
 
C4QueryEnumeratorc4queryobs_getEnumerator (C4QueryObserver *obs, bool forget, C4Error *error)
 Returns the current query results, if any. More...
 
C4QueryEnumeratorc4queryobs_getEnumerator (C4QueryObserver *obs, bool forget, C4Error *error)
 Returns the current query results, if any. More...
 
void c4queryobs_free (C4QueryObserver *)
 Stops an observer and frees the resources it's using. More...
 
- + +/* @license-end */ +
-
-
c4Observer.h
+
c4Observer.h
-Go to the documentation of this file.
1 //
-
2 // c4Observer.h
-
3 //
-
4 // Copyright 2016-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 
-
15 #include "c4DocumentTypes.h"
-
16 
- - -
19 
-
20 
- -
42  void* C4NULLABLE context);
-
43 
-
44 #ifndef C4_STRICT_COLLECTION_API
-
45 
- -
47 
- - -
51  void* C4NULLABLE context) C4API;
-
52 
-
53 #endif
-
54 
- - -
64  void* C4NULLABLE context) C4API;
-
65 
- -
87  C4CollectionChange outChanges[C4NONNULL],
-
88  uint32_t maxChanges,
-
89  bool *outExternal) C4API;
-
90 
- -
97  uint32_t numChanges) C4API;
-
98 
- -
102 
- -
115  C4String docID,
-
116  C4SequenceNumber sequence,
-
117  void * C4NULLABLE context);
-
118 
-
119 #ifndef C4_STRICT_COLLECTION_API
-
120 
- -
123  C4String docID,
- -
125  void* C4NULLABLE context) C4API;
-
126 
-
127 #endif
-
128 
- -
138  C4String docID,
- -
140  void* C4NULLABLE context) C4API;
-
141 
- -
145 
-
197  typedef void (*C4QueryObserverCallback)(C4QueryObserver *observer,
-
198  C4Query *query,
-
199  void* C4NULLABLE context);
-
200 
- -
208  C4QueryObserverCallback callback,
-
209  void* C4NULLABLE context) C4API;
-
210 
-
218  void c4queryobs_setEnabled(C4QueryObserver *obs, bool enabled) C4API;
-
219 
- -
233  bool forget,
-
234  C4Error* C4NULLABLE error) C4API;
-
235 
- -
239 
- - +Go to the documentation of this file.
1//
+
2// c4Observer.h
+
3//
+
4// Copyright 2016-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
+
15#include "c4DocumentTypes.h"
+
16
+ + +
19
+
20
+ +
42 void* C4NULLABLE context);
+
43
+
44#ifndef C4_STRICT_COLLECTION_API
+
45
+ +
47
+ + +
51 void* C4NULLABLE context) C4API;
+
52
+
53#endif
+
54
+ + +
64 void* C4NULLABLE context) C4API;
+
65
+ +
87 C4CollectionChange outChanges[C4NONNULL],
+
88 uint32_t maxChanges,
+
89 bool *outExternal) C4API;
+
90
+ +
97 uint32_t numChanges) C4API;
+
98
+ +
102
+ +
115 C4String docID,
+
116 C4SequenceNumber sequence,
+
117 void * C4NULLABLE context);
+
118
+
119#ifndef C4_STRICT_COLLECTION_API
+
120
+ +
123 C4String docID,
+ +
125 void* C4NULLABLE context) C4API;
+
126
+
127#endif
+
128
+ +
138 C4String docID,
+ +
140 void* C4NULLABLE context) C4API;
+
141
+ +
145
+
197 typedef void (*C4QueryObserverCallback)(C4QueryObserver *observer,
+
198 C4Query *query,
+
199 void* C4NULLABLE context);
+
200
+ + +
209 void* C4NULLABLE context) C4API;
+
210
+ +
219
+ +
233 bool forget,
+
234 C4Error* C4NULLABLE error) C4API;
+
235
+ +
239
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -164,30 +164,30 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:146
+
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:149
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
-
struct C4CollectionObserver C4CollectionObserver
A collection-observer reference.
Definition: c4Base.h:124
-
struct C4QueryObserver C4QueryObserver
A query-observer reference.
Definition: c4Base.h:152
-
struct C4DocumentObserver C4DocumentObserver
A document-observer reference.
Definition: c4Base.h:134
+
struct C4CollectionObserver C4CollectionObserver
A collection-observer reference.
Definition: c4Base.h:127
+
struct C4QueryObserver C4QueryObserver
A query-observer reference.
Definition: c4Base.h:155
+
struct C4DocumentObserver C4DocumentObserver
A document-observer reference.
Definition: c4Base.h:137
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition: c4Base.h:118
-
C4CollectionObserver C4DatabaseObserver
Definition: c4Base.h:127
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
C4CollectionObserver C4DatabaseObserver
Definition: c4Base.h:130
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
void c4queryobs_free(C4QueryObserver *)
Stops an observer and frees the resources it's using.
-
C4CollectionObserver * c4dbobs_createOnCollection(C4Collection *collection, C4CollectionObserverCallback callback, void *context)
Creates a new collection observer, with a callback that will be invoked after one or more documents i...
void c4dbobs_free(C4CollectionObserver *)
Stops an observer and frees the resources it's using.
void c4dbobs_releaseChanges(C4CollectionChange changes[], uint32_t numChanges)
Releases the memory used by the C4CollectionChange structs (to hold the docID and revID strings....
-
C4DocumentObserver * c4docobs_create(C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context)
Creates a new document observer, on a document in the database's default collection.
-
C4QueryObserver * c4queryobs_create(C4Query *query, C4QueryObserverCallback callback, void *context)
Creates a new query observer, with a callback that will be invoked when the query results change,...
+
C4QueryObserver * c4queryobs_create(C4Query *query, C4QueryObserverCallback callback, void *context)
Creates a new query observer, with a callback that will be invoked when the query results change,...
void(* C4CollectionObserverCallback)(C4CollectionObserver *observer, void *context)
Callback invoked by a collection/database observer.
Definition: c4Observer.h:41
-
C4DatabaseObserver * c4dbobs_create(C4Database *database, C4DatabaseObserverCallback callback, void *context)
Creates a collection observer on the database's default collection.
-
C4QueryEnumerator * c4queryobs_getEnumerator(C4QueryObserver *obs, bool forget, C4Error *error)
Returns the current query results, if any.
+
C4CollectionObserver * c4dbobs_createOnCollection(C4Collection *collection, C4CollectionObserverCallback callback, void *context)
Creates a new collection observer, with a callback that will be invoked after one or more documents i...
void c4docobs_free(C4DocumentObserver *)
Stops an observer and frees the resources it's using.
void(* C4DocumentObserverCallback)(C4DocumentObserver *observer, C4String docID, C4SequenceNumber sequence, void *context)
Callback invoked by a document observer.
Definition: c4Observer.h:114
+
C4DatabaseObserver * c4dbobs_create(C4Database *database, C4DatabaseObserverCallback callback, void *context)
Creates a collection observer on the database's default collection.
uint32_t c4dbobs_getChanges(C4CollectionObserver *observer, C4CollectionChange outChanges[], uint32_t maxChanges, bool *outExternal)
Identifies which documents have changed in the collection since the last time this function was calle...
-
C4DocumentObserver * c4docobs_createWithCollection(C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context)
Creates a new document observer, with a callback that will be invoked when the document changes.
+
C4DocumentObserver * c4docobs_create(C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context)
Creates a new document observer, on a document in the database's default collection.
C4CollectionObserverCallback C4DatabaseObserverCallback
Definition: c4Observer.h:46
void(* C4QueryObserverCallback)(C4QueryObserver *observer, C4Query *query, void *context)
Callback invoked by a query observer, notifying that the query results have changed.
Definition: c4Observer.h:197
void c4queryobs_setEnabled(C4QueryObserver *obs, bool enabled)
Enables a query observer so its callback can be called, or disables it to stop callbacks.
+
C4DocumentObserver * c4docobs_createWithCollection(C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context)
Creates a new document observer, with a callback that will be invoked when the document changes.
+
C4QueryEnumerator * c4queryobs_getEnumerator(C4QueryObserver *obs, bool forget, C4Error *error)
Returns the current query results, if any.
Represents a change to a document in a collection, as returned from c4dbobs_getChanges.
Definition: c4DocumentTypes.h:117
An error value.
Definition: c4Error.h:130
A query result enumerator.
Definition: c4QueryTypes.h:56
@@ -195,7 +195,7 @@
diff --git a/docs/C/html/c4_predictive_query_8h.html b/docs/C/html/c4_predictive_query_8h.html index 9d943872f5..16af53981a 100644 --- a/docs/C/html/c4_predictive_query_8h.html +++ b/docs/C/html/c4_predictive_query_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4PredictiveQuery.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
c4PredictiveQuery.h File Reference
+
c4PredictiveQuery.h File Reference
#include "c4Base.h"
@@ -78,13 +78,13 @@

Go to the source code of this file.

-

+

Data Structures

struct  C4PredictiveModel
 Configuration struct for registering a predictive model. More...
 
- @@ -96,7 +96,7 @@ diff --git a/docs/C/html/c4_predictive_query_8h_source.html b/docs/C/html/c4_predictive_query_8h_source.html index 501e705873..7a44e88e17 100644 --- a/docs/C/html/c4_predictive_query_8h_source.html +++ b/docs/C/html/c4_predictive_query_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4PredictiveQuery.h Source File @@ -30,21 +30,22 @@

+

Functions

void c4pred_registerModel (const char *name, C4PredictiveModel)
 Registers a predictive model, under a name. More...
- + +/* @license-end */ +
-
-
c4PredictiveQuery.h
+
c4PredictiveQuery.h
-Go to the documentation of this file.
1 //
-
2 // c4PredictiveQuery.h
-
3 //
-
4 // Copyright 2018-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 "c4Base.h"
-
15 #include "fleece/Fleece.h"
-
16 
- - -
19 
-
56  typedef struct {
- -
60 
-
78  C4SliceResult (*prediction)(void* C4NULLABLE context,
-
79  FLDict input,
-
80  C4Database* database,
-
81  C4Error* C4NULLABLE error);
-
82 
-
84  void (* C4NULLABLE unregistered)(void* context);
- -
86 
-
87 
-
91  void c4pred_registerModel(const char* name, C4PredictiveModel) C4API;
-
92 
-
94  bool c4pred_unregisterModel(const char* name) C4API;
-
95 
-
96 
- - +Go to the documentation of this file.
1//
+
2// c4PredictiveQuery.h
+
3//
+
4// Copyright 2018-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 "c4Base.h"
+
15#include "fleece/Fleece.h"
+
16
+ + +
19
+
56 typedef struct {
+ +
60
+
78 C4SliceResult (*prediction)(void* C4NULLABLE context,
+
79 FLDict input,
+
80 C4Database* database,
+
81 C4Error* C4NULLABLE error);
+
82
+
84 void (* C4NULLABLE unregistered)(void* context);
+ +
86
+
87
+ +
92
+
94 bool c4pred_unregisterModel(const char* name) C4API;
+
95
+
96
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
@@ -117,17 +117,17 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
FLSliceResult C4SliceResult
Definition: c4Base.h:47
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
void c4pred_registerModel(const char *name, C4PredictiveModel)
Registers a predictive model, under a name.
bool c4pred_unregisterModel(const char *name)
Unregisters whatever model was last registered with this name.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:53
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:53
An error value.
Definition: c4Error.h:130
Configuration struct for registering a predictive model.
Definition: c4PredictiveQuery.h:56
void * context
A pointer to any external data needed by the prediction callback, which will receive this as its firs...
Definition: c4PredictiveQuery.h:59
diff --git a/docs/C/html/c4_query_8h.html b/docs/C/html/c4_query_8h.html index 1129173575..480ca7d386 100644 --- a/docs/C/html/c4_query_8h.html +++ b/docs/C/html/c4_query_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Query.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Query.h File Reference
+
c4Query.h File Reference
#include "c4QueryTypes.h"
@@ -77,11 +77,11 @@

Go to the source code of this file.

- - - - + + + @@ -92,11 +92,11 @@ - + - - - + + + @@ -112,9 +112,9 @@ - - - + + + @@ -122,7 +122,7 @@ diff --git a/docs/C/html/c4_query_8h_source.html b/docs/C/html/c4_query_8h_source.html index c50f62d23f..18041095d0 100644 --- a/docs/C/html/c4_query_8h_source.html +++ b/docs/C/html/c4_query_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Query.h Source File @@ -30,21 +30,22 @@

+

Functions

C4Queryc4query_new2 (C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
 Compiles a query from an expression given as JSON. More...
 
C4Queryc4query_new2 (C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
 Compiles a query from an expression given as JSON. More...
 
C4StringResult c4query_explain (C4Query *)
 Returns a string describing the implementation of the compiled query. More...
 
 Returns a suggested title for a column, which may be: An alias specified in an 'AS' modifier in the column definition A property name A function/operator that computes the column value, e.g. More...
 
void c4query_setParameters (C4Query *query, C4String encodedParameters)
 Sets the parameter values to use when running the query, if no parameters are given to c4query_run. More...
 Sets the parameter values to use when running the query, if no parameters are given to c4query_run. More...
 
C4QueryEnumeratorc4query_run (C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
 Runs a compiled query. More...
 
C4QueryEnumeratorc4query_run (C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
 Runs a compiled query. More...
 
C4StringResult c4query_fullTextMatched (C4Query *query, const C4FullTextMatch *term, C4Error *outError)
 Given a C4FullTextMatch from the enumerator, returns the entire text of the property that was matched. More...
 
static bool c4queryenum_restart (C4QueryEnumerator *e, C4Error *outError)
 Restarts the enumeration, as though it had just been created: the next call to c4queryenum_next will read the first row, and so on from there. More...
 
C4QueryEnumeratorc4queryenum_refresh (C4QueryEnumerator *e, C4Error *outError)
 Checks whether the query results have changed since this enumerator was created; if so, returns a new enumerator. More...
 
C4QueryEnumeratorc4queryenum_refresh (C4QueryEnumerator *e, C4Error *outError)
 Checks whether the query results have changed since this enumerator was created; if so, returns a new enumerator. More...
 
void c4queryenum_close (C4QueryEnumerator *)
 Closes an enumerator without freeing it. More...
 
- + +/* @license-end */ +
-
-
c4Query.h
+
c4Query.h
-Go to the documentation of this file.
1 //
-
2 // c4Query.h
-
3 //
-
4 // Copyright 2016-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 "c4QueryTypes.h"
-
15 #include "fleece/Fleece.h"
-
16 
- - -
19 
-
25 
-
26 
- -
38  C4QueryLanguage language,
-
39  C4String expression,
-
40  int* C4NULLABLE outErrorPos,
-
41  C4Error* C4NULLABLE error) C4API;
-
42 
- -
47 
-
48 
- -
51 
- -
59 
-
60 
-
62 
-
63 
- -
71  C4String encodedParameters) C4API;
-
72 
-
73 
- -
84  const C4QueryOptions* C4NULLABLE options,
-
85  C4String encodedParameters,
-
86  C4Error* C4NULLABLE outError) C4API;
-
87 
- -
95  const C4FullTextMatch *term,
-
96  C4Error* C4NULLABLE outError) C4API;
-
97 
- -
101  C4Error* C4NULLABLE outError) C4API;
-
102 
- -
109  C4Error* C4NULLABLE outError) C4API;
-
110 
- -
118  int64_t rowIndex,
-
119  C4Error* C4NULLABLE outError) C4API;
-
120 
-
123  static inline bool c4queryenum_restart(C4QueryEnumerator *e,
-
124  C4Error* C4NULLABLE outError) C4API
-
125  { return c4queryenum_seek(e, -1, outError); }
-
126 
- -
130  C4Error* C4NULLABLE outError) C4API;
-
131 
- -
135 
-
136 
- - +Go to the documentation of this file.
1//
+
2// c4Query.h
+
3//
+
4// Copyright 2016-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 "c4QueryTypes.h"
+
15#include "fleece/Fleece.h"
+
16
+ + +
19
+
25
+
26
+ +
38 C4QueryLanguage language,
+
39 C4String expression,
+
40 int* C4NULLABLE outErrorPos,
+
41 C4Error* C4NULLABLE error) C4API;
+
42
+ +
47
+
48
+ +
51
+ +
59
+
60
+
62
+
63
+ +
71 C4String encodedParameters) C4API;
+
72
+
73
+ +
84 const C4QueryOptions* C4NULLABLE options,
+
85 C4String encodedParameters,
+
86 C4Error* C4NULLABLE outError) C4API;
+
87
+ +
95 const C4FullTextMatch *term,
+
96 C4Error* C4NULLABLE outError) C4API;
+
97
+ +
101 C4Error* C4NULLABLE outError) C4API;
+
102
+ +
109 C4Error* C4NULLABLE outError) C4API;
+
110
+ +
118 int64_t rowIndex,
+
119 C4Error* C4NULLABLE outError) C4API;
+
120
+ +
124 C4Error* C4NULLABLE outError) C4API
+
125 { return c4queryenum_seek(e, -1, outError); }
+
126
+ +
130 C4Error* C4NULLABLE outError) C4API;
+
131
+ +
135
+
136
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
@@ -150,16 +150,16 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:146
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
+
struct C4Query C4Query
Opaque handle to a compiled query.
Definition: c4Base.h:149
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
C4StringResult c4query_fullTextMatched(C4Query *query, const C4FullTextMatch *term, C4Error *outError)
Given a C4FullTextMatch from the enumerator, returns the entire text of the property that was matched...
+
C4QueryEnumerator * c4query_run(C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
Runs a compiled query.
C4QueryLanguage
Supported query languages.
Definition: c4QueryTypes.h:26
int64_t c4queryenum_getRowCount(C4QueryEnumerator *e, C4Error *outError)
Returns the total number of rows in the query, if known.
bool c4queryenum_next(C4QueryEnumerator *e, C4Error *outError)
Advances a query enumerator to the next row, populating its fields.
-
C4QueryEnumerator * c4queryenum_refresh(C4QueryEnumerator *e, C4Error *outError)
Checks whether the query results have changed since this enumerator was created; if so,...
unsigned c4query_columnCount(C4Query *)
Returns the number of columns (the values specified in the WHAT clause) in each row.
-
C4Query * c4query_new2(C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
Compiles a query from an expression given as JSON.
-
C4QueryEnumerator * c4query_run(C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
Runs a compiled query.
+
C4QueryEnumerator * c4queryenum_refresh(C4QueryEnumerator *e, C4Error *outError)
Checks whether the query results have changed since this enumerator was created; if so,...
+
C4Query * c4query_new2(C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
Compiles a query from an expression given as JSON.
void c4query_setParameters(C4Query *query, C4String encodedParameters)
Sets the parameter values to use when running the query, if no parameters are given to c4query_run.
bool c4queryenum_seek(C4QueryEnumerator *e, int64_t rowIndex, C4Error *outError)
Jumps to a specific row.
FLString c4query_columnTitle(C4Query *, unsigned column)
Returns a suggested title for a column, which may be: An alias specified in an 'AS' modifier in the c...
@@ -175,7 +175,7 @@
diff --git a/docs/C/html/c4_query_types_8h.html b/docs/C/html/c4_query_types_8h.html index 2bfac2905b..4ae15864f9 100644 --- a/docs/C/html/c4_query_types_8h.html +++ b/docs/C/html/c4_query_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4QueryTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Data Structures | Enumerations | Variables
-
-
c4QueryTypes.h File Reference
+
c4QueryTypes.h File Reference

#include "c4Base.h"
@@ -79,7 +79,7 @@

Go to the source code of this file.

- @@ -91,7 +91,7 @@

+

Data Structures

struct  C4QueryOptions
 Options for running queries. More...
 A query result enumerator. More...
 
-

+

Enumerations

enum  C4QueryLanguage : uint32_t { kC4JSONQuery , kC4N1QLQuery @@ -99,7 +99,7 @@
 Supported query languages. More...
 
- @@ -108,7 +108,7 @@ diff --git a/docs/C/html/c4_query_types_8h_source.html b/docs/C/html/c4_query_types_8h_source.html index bb92e08267..3281ed4451 100644 --- a/docs/C/html/c4_query_types_8h_source.html +++ b/docs/C/html/c4_query_types_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4QueryTypes.h Source File @@ -30,21 +30,22 @@

+

Variables

CBL_CORE_API const C4QueryOptions kC4DefaultQueryOptions
 Default query options. More...
- + +/* @license-end */ +
-
-
c4QueryTypes.h
+
c4QueryTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4QueryTypes.h
-
3 //
-
4 // Copyright 2016-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 "c4Base.h"
-
15 #include "fleece/Fleece.h"
-
16 
- - -
19 
-
20 
-
26 typedef C4_ENUM(uint32_t, C4QueryLanguage) {
- - -
29 };
-
30 
-
31 
-
33 typedef struct {
- - -
36 
-
37 
- -
40 
-
41 
-
43 typedef struct {
-
44  uint64_t dataSource;
-
45  uint32_t property;
-
46  uint32_t term;
-
47  uint32_t start;
-
48  uint32_t length;
- -
50 
-
51 
- - -
59 
-
63  uint64_t missingColumns;
-
64 
- -
67 
- -
70 };
-
71 
-
72 
- - +Go to the documentation of this file.
1//
+
2// c4QueryTypes.h
+
3//
+
4// Copyright 2016-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 "c4Base.h"
+
15#include "fleece/Fleece.h"
+
16
+ + +
19
+
20
+
26typedef C4_ENUM(uint32_t, C4QueryLanguage) {
+ + +
29};
+
30
+
31
+
33typedef struct {
+ + +
36
+
37
+ +
40
+
41
+
43typedef struct {
+
44 uint64_t dataSource;
+
45 uint32_t property;
+
46 uint32_t term;
+
47 uint32_t start;
+
48 uint32_t length;
+ +
50
+
51
+ + +
59
+ +
64
+ +
67
+ +
70};
+
71
+
72
+ +
#define CBL_CORE_API
Definition: c4Compat.h:113
@@ -152,11 +152,11 @@
uint32_t fullTextMatchCount
The number of full-text matches (i.e.
Definition: c4QueryTypes.h:66
Options for running queries.
Definition: c4QueryTypes.h:33
bool rankFullText_DEPRECATED
Ignored; use the rank() query function instead.
Definition: c4QueryTypes.h:34
-
Opaque array iterator.
Definition: Fleece.h:436
+
Opaque array iterator.
Definition: FLCollections.h:73
diff --git a/docs/C/html/c4_replicator_8h.html b/docs/C/html/c4_replicator_8h.html index 272de7cec1..b233fa545b 100644 --- a/docs/C/html/c4_replicator_8h.html +++ b/docs/C/html/c4_replicator_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Replicator.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Replicator.h File Reference
+
c4Replicator.h File Reference

Go to the source code of this file.

- @@ -90,12 +90,12 @@ - - - - - - + + + + + + @@ -129,9 +129,9 @@ - - - + + + @@ -148,7 +148,7 @@ diff --git a/docs/C/html/c4_replicator_8h_source.html b/docs/C/html/c4_replicator_8h_source.html index 5669140fe0..ab60debb15 100644 --- a/docs/C/html/c4_replicator_8h_source.html +++ b/docs/C/html/c4_replicator_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4Replicator.h Source File @@ -30,21 +30,22 @@

+

Functions

bool c4repl_isValidDatabaseName (C4String dbName)
 Checks whether a database name is valid, for purposes of appearing in a replication URL. More...
C4StringResult c4address_toURL (C4Address address)
 Converts a C4Address to a URL. More...
 
C4Replicatorc4repl_new (C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
 Creates a new networked replicator. More...
 
C4Replicatorc4repl_newWithSocket (C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
 Creates a new replicator from an already-open C4Socket. More...
 
C4Replicatorc4repl_new (C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
 Creates a new networked replicator. More...
 
C4Replicatorc4repl_newWithSocket (C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
 Creates a new replicator from an already-open C4Socket. More...
 
void c4repl_free (C4Replicator *repl)
 Frees a replicator reference. More...
 
bool c4repl_isDocumentPending (C4Replicator *repl, C4String docID, C4Error *outErr)
 Checks if the document with the given ID has revisions pending push. More...
 
C4Certc4repl_getPeerTLSCertificate (C4Replicator *repl, C4Error *outErr)
 Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when using BuiltInWebSocket) More...
 
C4Certc4repl_getPeerTLSCertificate (C4Replicator *repl, C4Error *outErr)
 Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when using BuiltInWebSocket) More...
 
bool c4repl_setProgressLevel (C4Replicator *repl, C4ReplicatorProgressLevel level, C4Error *outErr)
 Sets the progress level of the replicator, indicating what information should be provided via callback. More...
 
- + +/* @license-end */ +
-
-
c4Replicator.h
+
c4Replicator.h
-Go to the documentation of this file.
1 //
-
2 // c4Replicator.h
-
3 //
-
4 // Copyright 2017-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 "c4ReplicatorTypes.h"
-
15 
- - -
18 
- -
25 
-
28  bool c4repl_isValidRemote(C4Address remoteAddress,
-
29  C4String remoteDatabaseName,
-
30  C4Error* C4NULLABLE outError) C4API;
-
31 
- -
42  C4Address *address,
-
43  C4String * C4NULLABLE dbName) C4API;
-
44 
- -
47 
-
48 
- -
57  C4Address remoteAddress,
-
58  C4String remoteDatabaseName,
- -
60  C4Error* C4NULLABLE outError) C4API;
-
61 
-
62 #ifdef COUCHBASE_ENTERPRISE
-
69  C4Replicator* c4repl_newLocal(C4Database* db,
-
70  C4Database* otherLocalDB,
- -
72  C4Error* C4NULLABLE outError) C4API;
-
73 #endif
-
74 
- -
84  C4Socket *openSocket,
- -
86  C4Error* C4NULLABLE outError) C4API;
-
87 
- -
93 
-
99  void c4repl_start(C4Replicator* repl, bool reset) C4API;
-
100 
- -
104 
- -
111 
-
118  void c4repl_setHostReachable(C4Replicator* repl, bool reachable) C4API;
-
119 
-
126  void c4repl_setSuspended(C4Replicator* repl, bool suspended) C4API;
-
127 
-
131  void c4repl_setOptions(C4Replicator* repl, C4Slice optionsDictFleece) C4API;
-
132 
- -
136 
- -
140 
- -
152 
- -
164 
-
165 
- -
168  C4Error* C4NULLABLE outErr) C4API;
-
169 
- - -
180  C4Error* C4NULLABLE outErr) C4API;
-
181 
-
182 
-
183 #pragma mark - COOKIES:
-
184 
-
185 
- -
192  C4String setCookieHeader,
-
193  C4String fromHost,
-
194  C4String fromPath,
-
195  C4Error* C4NULLABLE outError) C4API;
-
196 
- -
200  C4Address request,
-
201  C4Error* C4NULLABLE error) C4API;
-
202 
- -
205 
- - +Go to the documentation of this file.
1//
+
2// c4Replicator.h
+
3//
+
4// Copyright 2017-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 "c4ReplicatorTypes.h"
+
15
+ + +
18
+ +
25
+
28 bool c4repl_isValidRemote(C4Address remoteAddress,
+
29 C4String remoteDatabaseName,
+
30 C4Error* C4NULLABLE outError) C4API;
+
31
+ +
42 C4Address *address,
+
43 C4String * C4NULLABLE dbName) C4API;
+
44
+ +
47
+
48
+ +
57 C4Address remoteAddress,
+
58 C4String remoteDatabaseName,
+ +
60 C4Error* C4NULLABLE outError) C4API;
+
61
+
62#ifdef COUCHBASE_ENTERPRISE
+
69 C4Replicator* c4repl_newLocal(C4Database* db,
+
70 C4Database* otherLocalDB,
+ +
72 C4Error* C4NULLABLE outError) C4API;
+
73#endif
+
74
+ +
84 C4Socket *openSocket,
+ +
86 C4Error* C4NULLABLE outError) C4API;
+
87
+ +
93
+
99 void c4repl_start(C4Replicator* repl, bool reset) C4API;
+
100
+ +
104
+ +
111
+
118 void c4repl_setHostReachable(C4Replicator* repl, bool reachable) C4API;
+
119
+
126 void c4repl_setSuspended(C4Replicator* repl, bool suspended) C4API;
+
127
+
131 void c4repl_setOptions(C4Replicator* repl, C4Slice optionsDictFleece) C4API;
+
132
+ +
136
+ +
140
+ +
152
+ +
164
+
165
+ +
168 C4Error* C4NULLABLE outErr) C4API;
+
169
+ + +
180 C4Error* C4NULLABLE outErr) C4API;
+
181
+
182
+
183#pragma mark - COOKIES:
+
184
+
185
+ +
192 C4String setCookieHeader,
+
193 C4String fromHost,
+
194 C4String fromPath,
+
195 C4Error* C4NULLABLE outError) C4API;
+
196
+ +
200 C4Address request,
+
201 C4Error* C4NULLABLE error) C4API;
+
202
+ +
205
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -174,18 +174,20 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:161
-
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:121
-
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:164
+
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:164
+
struct C4Database C4Database
Opaque handle to an opened database.
Definition: c4Base.h:124
+
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:167
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition: c4Base.h:115
bool c4repl_setProgressLevel(C4Replicator *repl, C4ReplicatorProgressLevel level, C4Error *outErr)
Sets the progress level of the replicator, indicating what information should be provided via callbac...
bool c4repl_isValidDatabaseName(C4String dbName)
Checks whether a database name is valid, for purposes of appearing in a replication URL.
void c4repl_setOptions(C4Replicator *repl, C4Slice optionsDictFleece)
Sets the replicator's options dictionary.
void c4repl_setSuspended(C4Replicator *repl, bool suspended)
Puts the replicator in or out of "suspended" state.
-
C4Cert * c4repl_getPeerTLSCertificate(C4Replicator *repl, C4Error *outErr)
Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when usi...
C4ReplicatorProgressLevel
An enumeration of the levels of progress callbacks the replicator can provide.
Definition: c4ReplicatorTypes.h:94
C4Slice c4repl_getResponseHeaders(C4Replicator *repl)
Returns the HTTP response headers as a Fleece-encoded dictionary.
+
C4Replicator * c4repl_new(C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
Creates a new networked replicator.
bool c4repl_isDocumentPending(C4Replicator *repl, C4String docID, C4Error *outErr)
Checks if the document with the given ID has revisions pending push.
+
C4Cert * c4repl_getPeerTLSCertificate(C4Replicator *repl, C4Error *outErr)
Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when usi...
+
C4Replicator * c4repl_newWithSocket(C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
Creates a new replicator from an already-open C4Socket.
C4SliceResult c4repl_getPendingDocIDs(C4Replicator *repl, C4Error *outErr)
Gets a fleece encoded list of IDs of documents who have revisions pending push.
C4ReplicatorStatus c4repl_getStatus(C4Replicator *repl)
Returns the current state of a replicator.
bool c4repl_retry(C4Replicator *repl, C4Error *outError)
Tells a replicator that's in the offline state to reconnect immediately.
@@ -195,11 +197,9 @@
bool c4db_setCookie(C4Database *db, C4String setCookieHeader, C4String fromHost, C4String fromPath, C4Error *outError)
Takes the value of a "Set-Cookie:" header, received from the given host, from an HTTP request with th...
void c4repl_stop(C4Replicator *repl)
Tells a replicator to stop.
bool c4address_fromURL(C4String url, C4Address *address, C4String *dbName)
A simple URL parser that populates a C4Address from a URL string.
-
C4Replicator * c4repl_newWithSocket(C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
Creates a new replicator from an already-open C4Socket.
void c4repl_free(C4Replicator *repl)
Frees a replicator reference.
void c4repl_setHostReachable(C4Replicator *repl, bool reachable)
Informs the replicator whether it's considered possible to reach the remote host with the current net...
void c4db_clearCookies(C4Database *db)
Removes all cookies from the database's cookie store.
-
C4Replicator * c4repl_new(C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
Creates a new networked replicator.
bool c4repl_isValidRemote(C4Address remoteAddress, C4String remoteDatabaseName, C4Error *outError)
Checks whether the destination of a replication is valid.
A simple parsed-URL type.
Definition: c4ReplicatorTypes.h:56
An error value.
Definition: c4Error.h:130
@@ -210,7 +210,7 @@
diff --git a/docs/C/html/c4_replicator_types_8h.html b/docs/C/html/c4_replicator_types_8h.html index adc09d4200..455279f61d 100644 --- a/docs/C/html/c4_replicator_types_8h.html +++ b/docs/C/html/c4_replicator_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4ReplicatorTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Typedefs | Enumerations | Variables
-
-
c4ReplicatorTypes.h File Reference
+
c4ReplicatorTypes.h File Reference

#include "c4DocumentTypes.h"
@@ -81,7 +81,7 @@

Go to the source code of this file.

- @@ -99,7 +99,7 @@

+

Data Structures

struct  C4Address
 A simple parsed-URL type. More...
 Parameters describing a replication, used when creating a C4Replicator. More...
 
- @@ -144,6 +144,9 @@ + + + @@ -232,7 +235,7 @@

+

Macros

#define kC4Replicator2Scheme   C4STR("ws")
 
#define kC4ReplicatorOptionAutoPurge   "autoPurge"
 Enables auto purge; default is true (bool) More...
 
#define kC4ReplicatorOptionAllowConnectedClient   "allowConnectedClient"
 Allow peer to use connected-client (CRUD) API. More...
 
#define kC4ReplicatorOptionRootCerts   "rootCerts"
 Trusted root certs (data) More...
 
 SOCKS proxy. More...
 
- @@ -251,7 +254,7 @@

+

Typedefs

typedef void(* C4ReplicatorStatusChangedCallback) (C4Replicator *, C4ReplicatorStatus, void *context)
 Callback a client can register, to get progress information. More...
typedef void * C4ReplicatorPropertyDecryptionCallback
 
-

+

Enumerations

enum  C4ReplicatorMode : int32_t { kC4Disabled , kC4Passive @@ -285,7 +288,7 @@
 An enumeration of the levels of progress callbacks the replicator can provide. More...
 
- @@ -294,7 +297,7 @@ diff --git a/docs/C/html/c4_replicator_types_8h_source.html b/docs/C/html/c4_replicator_types_8h_source.html index 52c1b4b6a5..7eaa993c7c 100644 --- a/docs/C/html/c4_replicator_types_8h_source.html +++ b/docs/C/html/c4_replicator_types_8h_source.html @@ -2,8 +2,8 @@ - - + +LiteCore: c4ReplicatorTypes.h Source File @@ -30,21 +30,22 @@

+

Variables

CBL_CORE_API const char *const kC4ReplicatorActivityLevelNames [6]
 For convenience, an array of C strings naming the C4ReplicatorActivityLevel values. More...
- + +/* @license-end */ +
-
-
c4ReplicatorTypes.h
+
c4ReplicatorTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4ReplicatorTypes.h
-
3 //
-
4 // Copyright 2017-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 "c4DocumentTypes.h"
-
15 #include "fleece/Fleece.h"
-
16 
-
17 #ifdef __cplusplus
-
18 #include "fleece/slice.hh"
-
19 #endif
-
20 
- - -
23 
-
27 #define kC4Replicator2Scheme C4STR("ws")
-
28 #define kC4Replicator2TLSScheme C4STR("wss")
-
29 
-
31  typedef C4_ENUM(int32_t, C4ReplicatorMode) {
-
32  kC4Disabled, // Do not allow this direction
-
33  kC4Passive, // Allow peer to initiate this direction
-
34  kC4OneShot, // Replicate, then stop
-
35  kC4Continuous // Keep replication active until stopped by application
-
36  };
-
37 
-
39  typedef C4_ENUM(int32_t, C4ReplicatorActivityLevel) {
-
40  /* EXTERNAL STATES */
- - - - - -
46 
-
47  /* INTERNAL STATES */
- -
49  };
-
50 
-
52  CBL_CORE_API extern const char* C4NONNULL const kC4ReplicatorActivityLevelNames[6];
-
53 
-
54 
-
56  struct C4Address {
- - -
59  uint16_t port;
- -
61 
-
62 #if __cplusplus
-
63  bool isValidRemote(fleece::slice withDbName,
-
64  C4Error* C4NULLABLE =nullptr) const noexcept;
-
65  fleece::alloc_slice toURL() const;
-
66  static bool fromURL(fleece::slice url,
-
67  C4Address *outAddress,
-
68  fleece::slice* C4NULLABLE outDBName);
-
69 #endif
-
70  };
-
71 
-
72 
-
76  typedef struct {
-
77  uint64_t unitsCompleted;
-
78  uint64_t unitsTotal;
-
79  uint64_t documentCount;
-
80  } C4Progress;
-
81 
-
83  typedef C4_OPTIONS(int32_t, C4ReplicatorStatusFlags) {
-
84  kC4WillRetry = 0x1,
- -
86  kC4Suspended = 0x4
-
87  };
-
88 
-
94  typedef C4_ENUM(int32_t, C4ReplicatorProgressLevel) {
- - - -
98  };
-
99 
-
101  typedef struct {
- - - - - -
107 
-
109  typedef struct {
- - - - - - - -
117  } C4DocumentEnded;
-
118 
-
119 
- - -
124  void * C4NULLABLE context);
-
125 
- -
131  bool pushing,
-
132  size_t numDocs,
-
133  const C4DocumentEnded* C4NONNULL docs[C4NONNULL],
-
134  void * C4NULLABLE context);
-
135 
- -
138  bool pushing,
-
139  C4String collectionName,
-
140  C4String docID,
-
141  C4String docProperty,
-
142  C4BlobKey blobKey,
-
143  uint64_t bytesComplete,
-
144  uint64_t bytesTotal,
-
145  C4Error error,
-
146  void * C4NULLABLE context);
-
147 
-
152  typedef bool (*C4ReplicatorValidationFunction)(C4String collectionName,
-
153  C4String docID,
-
154  C4String revID,
- -
156  FLDict body,
-
157  void* C4NULLABLE context);
-
158 
-
159 #ifdef COUCHBASE_ENTERPRISE
- -
162  void* C4NULLABLE context,
-
163  C4String documentID,
-
164  FLDict properties,
-
165  C4String keyPath,
-
166  C4Slice input,
-
167  C4StringResult* outAlgorithm,
-
168  C4StringResult* outKeyID,
-
169  C4Error* outError);
-
170 
- -
173  void* C4NULLABLE context,
-
174  C4String documentID,
-
175  FLDict properties,
-
176  C4String keyPath,
-
177  C4Slice input,
-
178  C4String algorithm,
-
179  C4String keyID,
-
180  C4Error* outError);
-
181 #else
- - -
184 #endif // COUCHBASE_ENTERPRISE
-
185 
-
186 
-
188  typedef struct C4ReplicatorParameters {
- - - - - - - - - - - - - -
202 
-
203 
-
204 #pragma mark - CONSTANTS:
-
205 
-
206 
-
207  // Replicator option dictionary keys:
-
208  #define kC4ReplicatorOptionDocIDs "docIDs"
-
209  #define kC4ReplicatorOptionChannels "channels"
-
210  #define kC4ReplicatorOptionFilter "filter"
-
211  #define kC4ReplicatorOptionFilterParams "filterParams"
-
212  #define kC4ReplicatorOptionSkipDeleted "skipDeleted"
-
213  #define kC4ReplicatorOptionNoIncomingConflicts "noIncomingConflicts"
-
214  #define kC4ReplicatorCheckpointInterval "checkpointInterval"
-
215  #define kC4ReplicatorOptionRemoteDBUniqueID "remoteDBUniqueID"
-
216  #define kC4ReplicatorOptionDisableDeltas "noDeltas"
-
217  #define kC4ReplicatorOptionDisablePropertyDecryption "noDecryption"
-
218  #define kC4ReplicatorOptionMaxRetries "maxRetries"
-
219  #define kC4ReplicatorOptionMaxRetryInterval "maxRetryInterval"
-
220  #define kC4ReplicatorOptionAutoPurge "autoPurge"
-
221 
-
222  // TLS options:
-
223  #define kC4ReplicatorOptionRootCerts "rootCerts"
-
224  #define kC4ReplicatorOptionPinnedServerCert "pinnedCert"
-
225  #define kC4ReplicatorOptionOnlySelfSignedServerCert "onlySelfSignedServer"
-
226 
-
227  // HTTP options:
-
228  #define kC4ReplicatorOptionExtraHeaders "headers"
-
229  #define kC4ReplicatorOptionCookies "cookies"
-
230  #define kC4ReplicatorOptionAuthentication "auth"
-
231  #define kC4ReplicatorOptionProxyServer "proxy"
-
232 
-
233  // WebSocket options:
-
234  #define kC4ReplicatorHeartbeatInterval "heartbeat"
-
235  #define kC4SocketOptionWSProtocols "WS-Protocols"
-
236 
-
237  // BLIP options:
-
238  #define kC4ReplicatorCompressionLevel "BLIPCompressionLevel"
-
239 
-
240  // [1]: Auth dictionary keys:
-
241  #define kC4ReplicatorAuthType "type"
-
242  #define kC4ReplicatorAuthUserName "username"
-
243  #define kC4ReplicatorAuthPassword "password"
-
244  #define kC4ReplicatorAuthClientCert "clientCert"
-
245  #define kC4ReplicatorAuthClientCertKey "clientCertKey"
-
246  #define kC4ReplicatorAuthToken "token"
-
247 
-
248  // [2]: auth.type values:
-
249  #define kC4AuthTypeBasic "Basic"
-
250  #define kC4AuthTypeSession "Session"
-
251  #define kC4AuthTypeOpenIDConnect "OpenID Connect"
-
252  #define kC4AuthTypeFacebook "Facebook"
-
253  #define kC4AuthTypeClientCert "Client Cert"
-
254 
-
255  // [3]: Proxy dictionary keys:
-
256  #define kC4ReplicatorProxyType "type"
-
257  #define kC4ReplicatorProxyHost "host"
-
258  #define kC4ReplicatorProxyPort "port"
-
259  #define kC4ReplicatorProxyAuth "auth"
-
260 
-
261  // [4]: proxy.type values:
-
262  #define kC4ProxyTypeNone "none"
-
263  #define kC4ProxyTypeHTTP "HTTP"
-
264  #define kC4ProxyTypeHTTPS "HTTPS"
-
265  #define kC4ProxyTypeSOCKS "SOCKS"
-
266 
-
267 
- - +Go to the documentation of this file.
1//
+
2// c4ReplicatorTypes.h
+
3//
+
4// Copyright 2017-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 "c4DocumentTypes.h"
+
15#include "fleece/Fleece.h"
+
16
+
17#ifdef __cplusplus
+
18#include "fleece/slice.hh"
+
19#endif
+
20
+ + +
23
+
27#define kC4Replicator2Scheme C4STR("ws")
+
28#define kC4Replicator2TLSScheme C4STR("wss")
+
29
+
31 typedef C4_ENUM(int32_t, C4ReplicatorMode) {
+
32 kC4Disabled, // Do not allow this direction
+
33 kC4Passive, // Allow peer to initiate this direction
+
34 kC4OneShot, // Replicate, then stop
+
35 kC4Continuous // Keep replication active until stopped by application
+
36 };
+
37
+ +
40 /* EXTERNAL STATES */
+ + + + + +
46
+
47 /* INTERNAL STATES */
+ +
49 };
+
50
+
52 CBL_CORE_API extern const char* C4NONNULL const kC4ReplicatorActivityLevelNames[6];
+
53
+
54
+
56 struct C4Address {
+ + +
59 uint16_t port;
+ +
61
+
62#if __cplusplus
+
63 bool isValidRemote(fleece::slice withDbName,
+
64 C4Error* C4NULLABLE =nullptr) const noexcept;
+
65 fleece::alloc_slice toURL() const;
+
66 static bool fromURL(fleece::slice url,
+
67 C4Address *outAddress,
+
68 fleece::slice* C4NULLABLE outDBName);
+
69#endif
+
70 };
+
71
+
72
+
76 typedef struct {
+
77 uint64_t unitsCompleted;
+
78 uint64_t unitsTotal;
+
79 uint64_t documentCount;
+
80 } C4Progress;
+
81
+ + + +
86 kC4Suspended = 0x4
+
87 };
+
88
+ + + + +
98 };
+
99
+
101 typedef struct {
+ + + + + +
107
+
109 typedef struct {
+ + + + + + + + +
118
+
119
+ + +
124 void * C4NULLABLE context);
+
125
+ +
131 bool pushing,
+
132 size_t numDocs,
+ +
134 void * C4NULLABLE context);
+
135
+ +
138 bool pushing,
+
139 C4String collectionName,
+
140 C4String docID,
+
141 C4String docProperty,
+
142 C4BlobKey blobKey,
+
143 uint64_t bytesComplete,
+
144 uint64_t bytesTotal,
+
145 C4Error error,
+
146 void * C4NULLABLE context);
+
147
+
152 typedef bool (*C4ReplicatorValidationFunction)(C4String collectionName,
+
153 C4String docID,
+
154 C4String revID,
+ +
156 FLDict body,
+
157 void* C4NULLABLE context);
+
158
+
159#ifdef COUCHBASE_ENTERPRISE
+ +
162 void* C4NULLABLE context,
+
163 C4String documentID,
+
164 FLDict properties,
+
165 C4String keyPath,
+
166 C4Slice input,
+
167 C4StringResult* outAlgorithm,
+
168 C4StringResult* outKeyID,
+
169 C4Error* outError);
+
170
+ +
173 void* C4NULLABLE context,
+
174 C4String documentID,
+
175 FLDict properties,
+
176 C4String keyPath,
+
177 C4Slice input,
+
178 C4String algorithm,
+
179 C4String keyID,
+
180 C4Error* outError);
+
181#else
+ + +
184#endif // COUCHBASE_ENTERPRISE
+
185
+
186
+
188 typedef struct C4ReplicatorParameters {
+ + + + + + + + + + + + + +
202
+
203
+
204#pragma mark - CONSTANTS:
+
205
+
206
+
207 // Replicator option dictionary keys:
+
208 #define kC4ReplicatorOptionDocIDs "docIDs"
+
209 #define kC4ReplicatorOptionChannels "channels"
+
210 #define kC4ReplicatorOptionFilter "filter"
+
211 #define kC4ReplicatorOptionFilterParams "filterParams"
+
212 #define kC4ReplicatorOptionSkipDeleted "skipDeleted"
+
213 #define kC4ReplicatorOptionNoIncomingConflicts "noIncomingConflicts"
+
214 #define kC4ReplicatorCheckpointInterval "checkpointInterval"
+
215 #define kC4ReplicatorOptionRemoteDBUniqueID "remoteDBUniqueID"
+
216 #define kC4ReplicatorOptionDisableDeltas "noDeltas"
+
217 #define kC4ReplicatorOptionDisablePropertyDecryption "noDecryption"
+
218 #define kC4ReplicatorOptionMaxRetries "maxRetries"
+
219 #define kC4ReplicatorOptionMaxRetryInterval "maxRetryInterval"
+
220 #define kC4ReplicatorOptionAutoPurge "autoPurge"
+
221 #define kC4ReplicatorOptionAllowConnectedClient "allowConnectedClient"
+
222
+
223 // TLS options:
+
224 #define kC4ReplicatorOptionRootCerts "rootCerts"
+
225 #define kC4ReplicatorOptionPinnedServerCert "pinnedCert"
+
226 #define kC4ReplicatorOptionOnlySelfSignedServerCert "onlySelfSignedServer"
+
227
+
228 // HTTP options:
+
229 #define kC4ReplicatorOptionExtraHeaders "headers"
+
230 #define kC4ReplicatorOptionCookies "cookies"
+
231 #define kC4ReplicatorOptionAuthentication "auth"
+
232 #define kC4ReplicatorOptionProxyServer "proxy"
+
233
+
234 // WebSocket options:
+
235 #define kC4ReplicatorHeartbeatInterval "heartbeat"
+
236 #define kC4SocketOptionWSProtocols "WS-Protocols"
+
237
+
238 // BLIP options:
+
239 #define kC4ReplicatorCompressionLevel "BLIPCompressionLevel"
+
240
+
241 // [1]: Auth dictionary keys:
+
242 #define kC4ReplicatorAuthType "type"
+
243 #define kC4ReplicatorAuthUserName "username"
+
244 #define kC4ReplicatorAuthPassword "password"
+
245 #define kC4ReplicatorAuthClientCert "clientCert"
+
246 #define kC4ReplicatorAuthClientCertKey "clientCertKey"
+
247 #define kC4ReplicatorAuthToken "token"
+
248
+
249 // [2]: auth.type values:
+
250 #define kC4AuthTypeBasic "Basic"
+
251 #define kC4AuthTypeSession "Session"
+
252 #define kC4AuthTypeOpenIDConnect "OpenID Connect"
+
253 #define kC4AuthTypeFacebook "Facebook"
+
254 #define kC4AuthTypeClientCert "Client Cert"
+
255
+
256 // [3]: Proxy dictionary keys:
+
257 #define kC4ReplicatorProxyType "type"
+
258 #define kC4ReplicatorProxyHost "host"
+
259 #define kC4ReplicatorProxyPort "port"
+
260 #define kC4ReplicatorProxyAuth "auth"
+
261
+
262 // [4]: proxy.type values:
+
263 #define kC4ProxyTypeNone "none"
+
264 #define kC4ProxyTypeHTTP "HTTP"
+
265 #define kC4ProxyTypeHTTPS "HTTPS"
+
266 #define kC4ProxyTypeSOCKS "SOCKS"
+
267
+
268
+ +
#define C4_OPTIONS(_type, _name)
Definition: c4Compat.h:63
#define CBL_CORE_API
Definition: c4Compat.h:113
@@ -319,7 +320,7 @@
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition: c4Base.h:82
-
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:161
+
struct C4Replicator C4Replicator
Opaque reference to a replicator.
Definition: c4Base.h:164
FLSliceResult C4SliceResult
Definition: c4Base.h:47
C4RevisionFlags
Flags that apply to a revision.
Definition: c4DocumentTypes.h:33
void(* C4ReplicatorDocumentsEndedCallback)(C4Replicator *, bool pushing, size_t numDocs, const C4DocumentEnded *docs[], void *context)
Callback a client can register, to hear about the replication status of documents.
Definition: c4ReplicatorTypes.h:130
@@ -349,7 +350,7 @@
@ kC4OneShot
Definition: c4ReplicatorTypes.h:34
@ kC4Passive
Definition: c4ReplicatorTypes.h:33
@ kC4Disabled
Definition: c4ReplicatorTypes.h:32
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:53
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:53
A simple parsed-URL type.
Definition: c4ReplicatorTypes.h:56
C4String hostname
Definition: c4ReplicatorTypes.h:58
C4String path
Definition: c4ReplicatorTypes.h:60
@@ -393,7 +394,7 @@
diff --git a/docs/C/html/c4_socket_8h.html b/docs/C/html/c4_socket_8h.html index e6f92635ab..e20ed69287 100644 --- a/docs/C/html/c4_socket_8h.html +++ b/docs/C/html/c4_socket_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Socket.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4Socket.h File Reference
+
c4Socket.h File Reference
#include "c4SocketTypes.h"

Go to the source code of this file.

- @@ -84,9 +84,9 @@ - - - + + + @@ -105,14 +105,14 @@ - - - + + +

+

Functions

void c4socket_registerFactory (C4SocketFactory factory)
 One-time registration of socket callbacks. More...
void c4Socket_setNativeHandle (C4Socket *, void *)
 Associates an opaque "native handle" with this object. More...
 
void * c4Socket_getNativeHandle (C4Socket *)
 Returns the opaque "native handle" associated with this object. More...
 
void * c4Socket_getNativeHandle (C4Socket *)
 Returns the opaque "native handle" associated with this object. More...
 
void c4socket_gotHTTPResponse (C4Socket *socket, int httpStatus, C4Slice responseHeadersFleece)
 Notification that a socket has received an HTTP response, with the given headers (encoded as a Fleece dictionary.) This should be called just before c4socket_opened or c4socket_closed. More...
 
void c4socket_received (C4Socket *socket, C4Slice data)
 Notifies LiteCore that data was received from the socket. More...
 
C4Socketc4socket_fromNative (C4SocketFactory factory, void *nativeHandle, const C4Address *address)
 Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory. More...
 
C4Socketc4socket_fromNative (C4SocketFactory factory, void *nativeHandle, const C4Address *address)
 Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory. More...
 
diff --git a/docs/C/html/c4_socket_8h_source.html b/docs/C/html/c4_socket_8h_source.html index 183d2ad6a5..f57532b1a0 100644 --- a/docs/C/html/c4_socket_8h_source.html +++ b/docs/C/html/c4_socket_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4Socket.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
c4Socket.h
+
c4Socket.h
-Go to the documentation of this file.
1 //
-
2 // c4Socket.h
-
3 //
-
4 // Copyright 2017-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 "c4SocketTypes.h"
-
15 
- - -
18 
-
23  // NOTE: C4Socket used to be a concrete struct containing a single field `nativeHandle`.
-
24  // As part of creating the C++ API, this struct declaration was removed so it could be
-
25  // declared in c4Struct.hh as a real C++ object.
-
26  // To fix client code that accessed `nativeHandle` directly, call `c4Socket_setNativeHandle`
-
27  // and/or `c4Socket_setNativeHandle` instead.
-
28 
-
29 
- -
33 
- -
37 
- -
40 
- -
51  int httpStatus,
-
52  C4Slice responseHeadersFleece) C4API;
-
53 
- -
58 
-
67  void c4socket_closed(C4Socket *socket, C4Error errorIfAny) C4API;
-
68 
-
76  void c4socket_closeRequested(C4Socket *socket, int status, C4String message) C4API;
-
77 
-
82  void c4socket_completedWrite(C4Socket *socket, size_t byteCount) C4API;
-
83 
-
93  void c4socket_received(C4Socket *socket, C4Slice data) C4API;
-
94 
-
95 
- -
108  void *nativeHandle,
-
109  const C4Address *address) C4API;
-
110 
-
111 
- - +Go to the documentation of this file.
1//
+
2// c4Socket.h
+
3//
+
4// Copyright 2017-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 "c4SocketTypes.h"
+
15
+ + +
18
+
23 // NOTE: C4Socket used to be a concrete struct containing a single field `nativeHandle`.
+
24 // As part of creating the C++ API, this struct declaration was removed so it could be
+
25 // declared in c4Struct.hh as a real C++ object.
+
26 // To fix client code that accessed `nativeHandle` directly, call `c4Socket_setNativeHandle`
+
27 // and/or `c4Socket_setNativeHandle` instead.
+
28
+
29
+ +
33
+ +
37
+ +
40
+ +
51 int httpStatus,
+
52 C4Slice responseHeadersFleece) C4API;
+
53
+ +
58
+
67 void c4socket_closed(C4Socket *socket, C4Error errorIfAny) C4API;
+
68
+
76 void c4socket_closeRequested(C4Socket *socket, int status, C4String message) C4API;
+
77
+
82 void c4socket_completedWrite(C4Socket *socket, size_t byteCount) C4API;
+
83
+ +
94
+
95
+ +
108 void *nativeHandle,
+
109 const C4Address *address) C4API;
+
110
+
111
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4API
Definition: c4Compat.h:93
#define C4_ASSUME_NONNULL_BEGIN
Definition: c4Compat.h:36
@@ -130,14 +130,14 @@
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:164
+
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:167
void c4socket_received(C4Socket *socket, C4Slice data)
Notifies LiteCore that data was received from the socket.
void c4Socket_setNativeHandle(C4Socket *, void *)
Associates an opaque "native handle" with this object.
void c4socket_closed(C4Socket *socket, C4Error errorIfAny)
Notifies LiteCore that a socket has finished closing, or disconnected, or failed to open.
void c4socket_closeRequested(C4Socket *socket, int status, C4String message)
Notifies LiteCore that the peer has requested to close the socket using the WebSocket protocol.
-
C4Socket * c4socket_fromNative(C4SocketFactory factory, void *nativeHandle, const C4Address *address)
Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory.
-
void * c4Socket_getNativeHandle(C4Socket *)
Returns the opaque "native handle" associated with this object.
void c4socket_opened(C4Socket *socket)
Notifies LiteCore that a socket has opened, i.e.
+
void * c4Socket_getNativeHandle(C4Socket *)
Returns the opaque "native handle" associated with this object.
+
C4Socket * c4socket_fromNative(C4SocketFactory factory, void *nativeHandle, const C4Address *address)
Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory.
void c4socket_gotHTTPResponse(C4Socket *socket, int httpStatus, C4Slice responseHeadersFleece)
Notification that a socket has received an HTTP response, with the given headers (encoded as a Fleece...
void c4socket_completedWrite(C4Socket *socket, size_t byteCount)
Notifies LiteCore that a C4SocketFactory.write request has been completed, i.e.
void c4socket_registerFactory(C4SocketFactory factory)
One-time registration of socket callbacks.
@@ -148,7 +148,7 @@
diff --git a/docs/C/html/c4_socket_types_8h.html b/docs/C/html/c4_socket_types_8h.html index 8819e62136..790dbff00f 100644 --- a/docs/C/html/c4_socket_types_8h.html +++ b/docs/C/html/c4_socket_types_8h.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4SocketTypes.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
c4SocketTypes.h File Reference
+
c4SocketTypes.h File Reference

#include "c4Base.h"

Go to the source code of this file.

-

+

Data Structures

struct  C4SocketFactory
 A group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API. More...
 
-

+

Enumerations

enum  C4WebSocketCloseCode : int32_t {
  kWebSocketCloseNormal = 1000 @@ -118,7 +118,7 @@ diff --git a/docs/C/html/c4_socket_types_8h_source.html b/docs/C/html/c4_socket_types_8h_source.html index 7766a696d1..b835d91abe 100644 --- a/docs/C/html/c4_socket_types_8h_source.html +++ b/docs/C/html/c4_socket_types_8h_source.html @@ -2,8 +2,8 @@ - - + + LiteCore: c4SocketTypes.h Source File @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
c4SocketTypes.h
+
c4SocketTypes.h
-Go to the documentation of this file.
1 //
-
2 // c4SocketTypes.h
-
3 //
-
4 // Copyright 2017-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 "c4Base.h"
-
15 
- - -
18 
-
24 typedef C4_ENUM(int32_t, C4WebSocketCloseCode) {
- -
26  kWebSocketCloseGoingAway = 1001, // Peer has to close, e.g. because host app is quitting
-
27  kWebSocketCloseProtocolError = 1002, // Protocol violation: invalid framing data
-
28  kWebSocketCloseDataError = 1003, // Message payload cannot be handled
-
29  kWebSocketCloseNoCode = 1005, // No status code in close frame
-
30  kWebSocketCloseAbnormal = 1006, // Peer closed socket unexpectedly w/o a close frame
-
31  kWebSocketCloseBadMessageFormat = 1007, // Unparseable message
- - -
34  kWebSocketCloseMissingExtension = 1010, // Peer doesn't provide a necessary extension
-
35  kWebSocketCloseCantFulfill = 1011, // Can't fulfill request due to "unexpected condition"
-
36  kWebSocketCloseTLSFailure = 1015, // Never sent, only received
-
37 
-
38  kWebSocketCloseAppTransient = 4001, // App-defined transient error
-
39  kWebSocketCloseAppPermanent = 4002, // App-defined permanent error
-
40 
-
41  kWebSocketCloseFirstAvailable = 5000, // First unregistered code for freeform use
-
42 };
-
43 
-
44 
-
47 typedef C4_ENUM(uint8_t, C4SocketFraming) {
- - - -
51 };
-
52 
-
53 
- - -
62 
- -
65 
-
79  void (*open)(C4Socket* socket,
-
80  const C4Address* addr,
-
81  C4Slice options,
-
82  void* C4NULLABLE context);
-
83 
-
96  void (*write)(C4Socket* socket, C4SliceResult allocatedData);
-
97 
-
111  void (*completedReceive)(C4Socket* socket, size_t byteCount);
-
112 
-
120  void (* C4NULLABLE close)(C4Socket* socket);
-
121 
-
141  void (* C4NULLABLE requestClose)(C4Socket* socket, int status, C4String message);
-
142 
-
150  void (* C4NULLABLE dispose)(C4Socket* socket);
-
151 };
-
152 
-
153 
- - +Go to the documentation of this file.
1//
+
2// c4SocketTypes.h
+
3//
+
4// Copyright 2017-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 "c4Base.h"
+
15
+ + +
18
+
24typedef C4_ENUM(int32_t, C4WebSocketCloseCode) {
+ +
26 kWebSocketCloseGoingAway = 1001, // Peer has to close, e.g. because host app is quitting
+
27 kWebSocketCloseProtocolError = 1002, // Protocol violation: invalid framing data
+
28 kWebSocketCloseDataError = 1003, // Message payload cannot be handled
+
29 kWebSocketCloseNoCode = 1005, // No status code in close frame
+
30 kWebSocketCloseAbnormal = 1006, // Peer closed socket unexpectedly w/o a close frame
+
31 kWebSocketCloseBadMessageFormat = 1007, // Unparseable message
+ + +
34 kWebSocketCloseMissingExtension = 1010, // Peer doesn't provide a necessary extension
+
35 kWebSocketCloseCantFulfill = 1011, // Can't fulfill request due to "unexpected condition"
+
36 kWebSocketCloseTLSFailure = 1015, // Never sent, only received
+
37
+
38 kWebSocketCloseAppTransient = 4001, // App-defined transient error
+
39 kWebSocketCloseAppPermanent = 4002, // App-defined permanent error
+
40
+
41 kWebSocketCloseFirstAvailable = 5000, // First unregistered code for freeform use
+
42};
+
43
+
44
+
47typedef C4_ENUM(uint8_t, C4SocketFraming) {
+ + + +
51};
+
52
+
53
+ + +
62
+ +
65
+
79 void (*open)(C4Socket* socket,
+
80 const C4Address* addr,
+
81 C4Slice options,
+
82 void* C4NULLABLE context);
+
83
+
96 void (*write)(C4Socket* socket, C4SliceResult allocatedData);
+
97
+
111 void (*completedReceive)(C4Socket* socket, size_t byteCount);
+
112
+
120 void (* C4NULLABLE close)(C4Socket* socket);
+
121
+
141 void (* C4NULLABLE requestClose)(C4Socket* socket, int status, C4String message);
+
142
+
150 void (* C4NULLABLE dispose)(C4Socket* socket);
+
151};
+
152
+
153
+ +
#define C4NULLABLE
Definition: c4Compat.h:38
#define C4_ENUM(_type, _name)
Definition: c4Compat.h:62
@@ -147,7 +147,7 @@
#define C4API_END_DECLS
Definition: c4Compat.h:95
#define C4API_BEGIN_DECLS
Definition: c4Compat.h:94
#define C4_ASSUME_NONNULL_END
Definition: c4Compat.h:37
-
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:164
+
struct C4Socket C4Socket
Represents an open bidirectional stream of bytes or messages (typically a TCP socket....
Definition: c4Base.h:167
C4SocketFraming
The type of message framing that should be applied to the socket's data (added to outgoing,...
Definition: c4SocketTypes.h:47
C4WebSocketCloseCode
Standard WebSocket close status codes, for use in C4Errors with WebSocketDomain.
Definition: c4SocketTypes.h:24
@ kC4WebSocketClientFraming
Frame as WebSocket client messages (masked)
Definition: c4SocketTypes.h:48
@@ -183,7 +183,7 @@
diff --git a/docs/C/html/classes.html b/docs/C/html/classes.html index 266474a7b9..8e039fcfbc 100644 --- a/docs/C/html/classes.html +++ b/docs/C/html/classes.html @@ -2,8 +2,8 @@ - - + + LiteCore: Data Structure Index @@ -30,21 +30,22 @@
- + +/* @license-end */ +

@@ -62,23 +63,22 @@

-
-
Data Structure Index
+
Data Structure Index
diff --git a/docs/C/html/dir_289a224c1eafdd3769b2074c585847fe.html b/docs/C/html/dir_289a224c1eafdd3769b2074c585847fe.html index 3688850da6..e213646f72 100644 --- a/docs/C/html/dir_289a224c1eafdd3769b2074c585847fe.html +++ b/docs/C/html/dir_289a224c1eafdd3769b2074c585847fe.html @@ -2,8 +2,8 @@ - - + + LiteCore: fleece Directory Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
fleece Directory Reference
+
fleece Directory Reference
- - + + + + + + + + + + + + + + + + + + + + + - + - + - +

+

Files

file  Base.h [code]
file  CompilerSupport.h [code]
 
file  FLBase.h [code]
 
file  FLCollections.h [code]
 
file  FLDeepIterator.h [code]
 
file  FLDoc.h [code]
 
file  Fleece+CoreFoundation.h [code]
 
file  Fleece.h [code]
 
file  FLEncoder.h [code]
 
file  FLExpert.h [code]
 
file  FLJSON.h [code]
 
file  FLKeyPath.h [code]
 
file  Fleece+CoreFoundation.h [code]
file  FLMutable.h [code]
 
file  Fleece.h [code]
file  FLSlice.h [code]
 
file  FLSlice.h [code]
file  FLValue.h [code]
 
diff --git a/docs/C/html/dir_7de30d8d6441eca96418c0d836f3a440.html b/docs/C/html/dir_7de30d8d6441eca96418c0d836f3a440.html index 09e9f46adb..38ee574d6b 100644 --- a/docs/C/html/dir_7de30d8d6441eca96418c0d836f3a440.html +++ b/docs/C/html/dir_7de30d8d6441eca96418c0d836f3a440.html @@ -2,8 +2,8 @@ - - + + LiteCore: include Directory Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
include Directory Reference
+
include Directory Reference
- - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +

+

Files

file  c4.h [code]
file  c4.h [code]
 
file  c4Base.h [code]
 
file  c4BlobStore.h [code]
 
file  c4Base.h [code]
file  c4BlobStoreTypes.h [code]
 
file  c4BlobStore.h [code]
file  c4Certificate.h [code]
 
file  c4BlobStoreTypes.h [code]
file  c4CertificateTypes.h [code]
 
file  c4Certificate.h [code]
file  c4Collection.h [code]
 
file  c4CertificateTypes.h [code]
file  c4Compat.h [code]
 
file  c4Collection.h [code]
file  c4ConnectedClient.h [code]
 
file  c4Compat.h [code]
file  c4ConnectedClientTypes.h [code]
 
file  c4Database.h [code]
file  c4Database.h [code]
 
file  c4DatabaseTypes.h [code]
file  c4DatabaseTypes.h [code]
 
file  c4DocEnumerator.h [code]
file  c4DocEnumerator.h [code]
 
file  c4DocEnumeratorTypes.h [code]
file  c4DocEnumeratorTypes.h [code]
 
file  c4Document+Fleece.h [code]
file  c4Document+Fleece.h [code]
 
file  c4Document.h [code]
file  c4Document.h [code]
 
file  c4DocumentStruct.h [code]
file  c4DocumentStruct.h [code]
 
file  c4DocumentTypes.h [code]
file  c4DocumentTypes.h [code]
 
file  c4Error.h [code]
file  c4Error.h [code]
 
file  c4Index.h [code]
file  c4Index.h [code]
 
file  c4IndexTypes.h [code]
file  c4IndexTypes.h [code]
 
file  c4Listener.h [code]
file  c4Listener.h [code]
 
file  c4ListenerTypes.h [code]
file  c4ListenerTypes.h [code]
 
file  c4Log.h [code]
file  c4Log.h [code]
 
file  c4Observer.h [code]
file  c4Observer.h [code]
 
file  c4PredictiveQuery.h [code]
file  c4PredictiveQuery.h [code]
 
file  c4Query.h [code]
file  c4Query.h [code]
 
file  c4QueryTypes.h [code]
file  c4QueryTypes.h [code]
 
file  c4Replicator.h [code]
file  c4Replicator.h [code]
 
file  c4ReplicatorTypes.h [code]
file  c4ReplicatorTypes.h [code]
 
file  c4Socket.h [code]
file  c4Socket.h [code]
 
file  c4SocketTypes.h [code]
file  c4SocketTypes.h [code]
 
diff --git a/docs/C/html/dir_b87361ce9f15ff16bfbc42d00c4394be.html b/docs/C/html/dir_b87361ce9f15ff16bfbc42d00c4394be.html index a60e8f03d0..78ecbde226 100644 --- a/docs/C/html/dir_b87361ce9f15ff16bfbc42d00c4394be.html +++ b/docs/C/html/dir_b87361ce9f15ff16bfbc42d00c4394be.html @@ -2,8 +2,8 @@ - - + + LiteCore: fleece Directory Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
fleece Directory Reference
+
fleece Directory Reference
- - +

+

Directories

directory  API
directory  API
 
diff --git a/docs/C/html/dir_bec413c7ab9ed2240c515d309fd0ae23.html b/docs/C/html/dir_bec413c7ab9ed2240c515d309fd0ae23.html index 8944f2bdd0..0270160729 100644 --- a/docs/C/html/dir_bec413c7ab9ed2240c515d309fd0ae23.html +++ b/docs/C/html/dir_bec413c7ab9ed2240c515d309fd0ae23.html @@ -2,8 +2,8 @@ - - + + LiteCore: API Directory Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
API Directory Reference
+
API Directory Reference
- - +

+

Directories

directory  fleece
directory  fleece
 
diff --git a/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html b/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html index 325d885d5c..1f227b3772 100644 --- a/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html +++ b/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html @@ -2,8 +2,8 @@ - - + + LiteCore: vendor Directory Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
vendor Directory Reference
+
vendor Directory Reference
- - +

+

Directories

directory  fleece
directory  fleece
 
diff --git a/docs/C/html/doxygen.css b/docs/C/html/doxygen.css index ffbff02249..8e9cca36af 100644 --- a/docs/C/html/doxygen.css +++ b/docs/C/html/doxygen.css @@ -1,4 +1,4 @@ -/* The standard CSS for doxygen 1.9.1 */ +/* The standard CSS for doxygen 1.9.2 */ body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; @@ -228,6 +228,33 @@ a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { color: #4665A2; } +a.code.hl_class { /* style for links to class names in code snippets */ } +a.code.hl_struct { /* style for links to struct names in code snippets */ } +a.code.hl_union { /* style for links to union names in code snippets */ } +a.code.hl_interface { /* style for links to interface names in code snippets */ } +a.code.hl_protocol { /* style for links to protocol names in code snippets */ } +a.code.hl_category { /* style for links to category names in code snippets */ } +a.code.hl_exception { /* style for links to exception names in code snippets */ } +a.code.hl_service { /* style for links to service names in code snippets */ } +a.code.hl_singleton { /* style for links to singleton names in code snippets */ } +a.code.hl_concept { /* style for links to concept names in code snippets */ } +a.code.hl_namespace { /* style for links to namespace names in code snippets */ } +a.code.hl_package { /* style for links to package names in code snippets */ } +a.code.hl_define { /* style for links to macro names in code snippets */ } +a.code.hl_function { /* style for links to function names in code snippets */ } +a.code.hl_variable { /* style for links to variable names in code snippets */ } +a.code.hl_typedef { /* style for links to typedef names in code snippets */ } +a.code.hl_enumvalue { /* style for links to enum value names in code snippets */ } +a.code.hl_enumeration { /* style for links to enumeration names in code snippets */ } +a.code.hl_signal { /* style for links to Qt signal names in code snippets */ } +a.code.hl_slot { /* style for links to Qt slot names in code snippets */ } +a.code.hl_friend { /* style for links to friend names in code snippets */ } +a.code.hl_dcop { /* style for links to KDE3 DCOP names in code snippets */ } +a.code.hl_property { /* style for links to property names in code snippets */ } +a.code.hl_event { /* style for links to event names in code snippets */ } +a.code.hl_sequence { /* style for links to sequence names in code snippets */ } +a.code.hl_dictionary { /* style for links to dictionary names in code snippets */ } + /* @end */ dl.el { @@ -313,6 +340,7 @@ div.line.glow { span.lineno { padding-right: 4px; + margin-right: 9px; text-align: right; border-right: 2px solid #0F0; background-color: #E8E8E8; @@ -439,6 +467,12 @@ img.footer { vertical-align: middle; } +.compoundTemplParams { + color: #4665A2; + font-size: 80%; + line-height: 120%; +} + /* @group Code Colorization */ span.keyword { @@ -1341,14 +1375,14 @@ dl.section dd { #projectname { - font: 300% Tahoma, Arial,sans-serif; + font: 200% Tahoma, Arial,sans-serif; margin: 0px; padding: 2px 0px; } #projectbrief { - font: 120% Tahoma, Arial,sans-serif; + font: 90% Tahoma, Arial,sans-serif; margin: 0px; padding: 0px; } diff --git a/docs/C/html/files.html b/docs/C/html/files.html index 27f0b76a84..4eb2b4a21e 100644 --- a/docs/C/html/files.html +++ b/docs/C/html/files.html @@ -2,8 +2,8 @@ - - + + LiteCore: File List @@ -30,21 +30,22 @@
- + +/* @license-end */ +
@@ -62,52 +63,63 @@
-
-
File List
+
File List
diff --git a/docs/C/html/functions.html b/docs/C/html/functions.html index 07a5bd6f8d..5caa1a419b 100644 --- a/docs/C/html/functions.html +++ b/docs/C/html/functions.html @@ -2,8 +2,8 @@ - - + + LiteCore: Data Fields @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,461 +65,206 @@
Here is a list of all struct and union fields with links to the structures/unions they belong to:
-

- _ -

diff --git a/docs/C/html/functions_vars.html b/docs/C/html/functions_vars.html index 1f24e0a761..f696bcfb6e 100644 --- a/docs/C/html/functions_vars.html +++ b/docs/C/html/functions_vars.html @@ -2,8 +2,8 @@ - - + + LiteCore: Data Fields - Variables @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,461 +65,206 @@
  -

- _ -

diff --git a/docs/C/html/globals.html b/docs/C/html/globals.html index e012a5398e..b5bb496b1a 100644 --- a/docs/C/html/globals.html +++ b/docs/C/html/globals.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,63 +65,40 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- _ -

diff --git a/docs/C/html/globals_c.html b/docs/C/html/globals_c.html index 120d4631b2..853c7b5d5e 100644 --- a/docs/C/html/globals_c.html +++ b/docs/C/html/globals_c.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,1068 +65,372 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- c -

diff --git a/docs/C/html/globals_defs.html b/docs/C/html/globals_defs.html index e30cc81490..47902450b7 100644 --- a/docs/C/html/globals_defs.html +++ b/docs/C/html/globals_defs.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,406 +65,182 @@
  -

- _ -

diff --git a/docs/C/html/globals_enum.html b/docs/C/html/globals_enum.html index f94f8a4a99..4b3af7802e 100644 --- a/docs/C/html/globals_enum.html +++ b/docs/C/html/globals_enum.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -63,95 +64,39 @@
 
diff --git a/docs/C/html/globals_eval.html b/docs/C/html/globals_eval.html index 6fc167f540..5f4f98bbb4 100644 --- a/docs/C/html/globals_eval.html +++ b/docs/C/html/globals_eval.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,595 +65,225 @@
  -

- f -

diff --git a/docs/C/html/globals_f.html b/docs/C/html/globals_f.html index 65f2127bca..8c5dc45890 100644 --- a/docs/C/html/globals_f.html +++ b/docs/C/html/globals_f.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,819 +65,283 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- f -

diff --git a/docs/C/html/globals_func.html b/docs/C/html/globals_func.html index 65c4272872..4ee99aab35 100644 --- a/docs/C/html/globals_func.html +++ b/docs/C/html/globals_func.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,18 +65,14 @@
  -

- _ -

diff --git a/docs/C/html/globals_func_c.html b/docs/C/html/globals_func_c.html index c78ca0ae04..83e761199c 100644 --- a/docs/C/html/globals_func_c.html +++ b/docs/C/html/globals_func_c.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -64,807 +65,281 @@
  -

- c -

diff --git a/docs/C/html/globals_func_f.html b/docs/C/html/globals_func_f.html index 6aa7d8cb49..cdfd7efc92 100644 --- a/docs/C/html/globals_func_f.html +++ b/docs/C/html/globals_func_f.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@
- + +/* @license-end */ + @@ -64,714 +65,249 @@
  -

- f -

diff --git a/docs/C/html/globals_h.html b/docs/C/html/globals_h.html index b82f1a9a28..20c6d8fc7e 100644 --- a/docs/C/html/globals_h.html +++ b/docs/C/html/globals_h.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,15 +65,13 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- h -

diff --git a/docs/C/html/globals_k.html b/docs/C/html/globals_k.html index cd63d2f5e7..6b8e2380d5 100644 --- a/docs/C/html/globals_k.html +++ b/docs/C/html/globals_k.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,768 +65,266 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- k -

diff --git a/docs/C/html/globals_l.html b/docs/C/html/globals_l.html index fa1185b41b..2fd280aa05 100644 --- a/docs/C/html/globals_l.html +++ b/docs/C/html/globals_l.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,24 +65,16 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- l -

diff --git a/docs/C/html/globals_m.html b/docs/C/html/globals_m.html index a513ef3456..007ccd2258 100644 --- a/docs/C/html/globals_m.html +++ b/docs/C/html/globals_m.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,18 +65,14 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- m -

diff --git a/docs/C/html/globals_n.html b/docs/C/html/globals_n.html index 5abee88bbd..2afe84fdb4 100644 --- a/docs/C/html/globals_n.html +++ b/docs/C/html/globals_n.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,18 +65,14 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- n -

diff --git a/docs/C/html/globals_p.html b/docs/C/html/globals_p.html index ad0f8a8bab..afc12efab3 100644 --- a/docs/C/html/globals_p.html +++ b/docs/C/html/globals_p.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,15 +65,13 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- p -

diff --git a/docs/C/html/globals_r.html b/docs/C/html/globals_r.html index 3bdb8351bd..834852c8d6 100644 --- a/docs/C/html/globals_r.html +++ b/docs/C/html/globals_r.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,15 +65,13 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- r -

diff --git a/docs/C/html/globals_s.html b/docs/C/html/globals_s.html index 342adfea29..2f7987fada 100644 --- a/docs/C/html/globals_s.html +++ b/docs/C/html/globals_s.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,18 +65,14 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- s -

diff --git a/docs/C/html/globals_type.html b/docs/C/html/globals_type.html index 7a664b03a2..51a089a9c0 100644 --- a/docs/C/html/globals_type.html +++ b/docs/C/html/globals_type.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,193 +65,79 @@
  -

- c -

diff --git a/docs/C/html/globals_vars.html b/docs/C/html/globals_vars.html index 85d0ede298..c73ded5f68 100644 --- a/docs/C/html/globals_vars.html +++ b/docs/C/html/globals_vars.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -63,53 +64,25 @@
 
diff --git a/docs/C/html/globals_w.html b/docs/C/html/globals_w.html index 069dd831b7..cc01c06dd1 100644 --- a/docs/C/html/globals_w.html +++ b/docs/C/html/globals_w.html @@ -2,8 +2,8 @@ - - + + LiteCore: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,18 +65,14 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- w -

diff --git a/docs/C/html/group___base.html b/docs/C/html/group___base.html index 2730600ad5..d46142c4e8 100644 --- a/docs/C/html/group___base.html +++ b/docs/C/html/group___base.html @@ -2,8 +2,8 @@ - - + + LiteCore: Data Types and Base Functions @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -67,25 +68,24 @@ Macros | Typedefs | Functions -
-
Data Types and Base Functions
+
Data Types and Base Functions
-

+

Data Structures

struct  C4ExtraInfo
 Client-defined metadata that can be associated with some objects like C4Database. More...
 
-

+

Macros

#define C4STR(STR)   FLSTR(STR)
 
#define kC4SliceNull   kFLSliceNull
 
- @@ -114,6 +114,9 @@ + + + @@ -153,7 +156,7 @@

+

Typedefs

typedef FLSlice C4Slice
 
typedef struct C4Collection C4Collection
 Opaque handle to a namespace of documents in an opened database. More...
 
typedef struct C4ConnectedClient C4ConnectedClient
 Opaque reference to a Connected Client. More...
 
typedef struct C4Database C4Database
 Opaque handle to an opened database. More...
 
 An open stream for writing data to a blob. More...
 
- @@ -161,26 +164,30 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -220,7 +227,7 @@

+

Functions

static C4INLINE C4Slice c4str (const char *str)
 
 
static void c4slice_free (C4SliceResult s)
 
void * c4base_retain (void *obj)
 
void * c4base_retain (void *obj)
 
void c4base_release (void *obj)
 
static C4Certc4cert_retain (C4Cert *r)
 
static C4KeyPairc4keypair_retain (C4KeyPair *r)
 
static C4Databasec4db_retain (C4Database *r)
 
static C4Queryc4query_retain (C4Query *r)
 
C4Documentc4doc_retain (C4Document *)
 
C4QueryEnumeratorc4queryenum_retain (C4QueryEnumerator *)
 
C4Socketc4socket_retain (C4Socket *)
 
static C4Certc4cert_retain (C4Cert *r)
 
static C4ConnectedClientc4client_retain (C4ConnectedClient *r)
 
static C4KeyPairc4keypair_retain (C4KeyPair *r)
 
static C4Databasec4db_retain (C4Database *r)
 
static C4Queryc4query_retain (C4Query *r)
 
C4Documentc4doc_retain (C4Document *)
 
C4QueryEnumeratorc4queryenum_retain (C4QueryEnumerator *)
 
C4Socketc4socket_retain (C4Socket *)
 
static void c4cert_release (C4Cert *r)
 
static void c4client_release (C4ConnectedClient *r)
 
static void c4keypair_release (C4KeyPair *r)
 
static void c4db_release (C4Database *r)

Detailed Description

Macro Definition Documentation

- +

◆ C4STR

@@ -238,7 +245,7 @@

+

◆ kC4SliceNull

@@ -253,7 +260,7 @@

Typedef Documentation

- +

◆ C4BlobStore

@@ -269,7 +276,7 @@

+

◆ C4Cert

@@ -285,7 +292,7 @@

+

◆ C4Collection

@@ -301,7 +308,7 @@

+

◆ C4CollectionObserver

@@ -317,7 +324,23 @@

+ +

◆ C4ConnectedClient

+ +
+
+ + + + +
typedef struct C4ConnectedClient C4ConnectedClient
+
+ +

Opaque reference to a Connected Client.

+ +
+
+

◆ C4Database

@@ -333,7 +356,7 @@

+

◆ C4DatabaseObserver

@@ -347,7 +370,7 @@

+

◆ C4DocEnumerator

@@ -363,7 +386,7 @@

+

◆ C4DocumentObserver

@@ -379,7 +402,7 @@

+

◆ C4HeapSlice

@@ -393,7 +416,7 @@

+

◆ C4HeapString

@@ -407,7 +430,7 @@

+

◆ C4KeyPair

@@ -423,7 +446,7 @@

+

◆ C4Listener

@@ -439,7 +462,7 @@

+

◆ C4Query

@@ -455,7 +478,7 @@

+

◆ C4QueryObserver

@@ -471,7 +494,7 @@

+

◆ C4ReadStream

@@ -487,7 +510,7 @@

+

◆ C4Replicator

@@ -503,7 +526,7 @@

+

◆ C4SequenceNumber

@@ -519,7 +542,7 @@

+

◆ C4Slice

@@ -533,7 +556,7 @@

+

◆ C4SliceResult

@@ -547,7 +570,7 @@

+

◆ C4Socket

@@ -563,7 +586,7 @@

+

◆ C4String

@@ -577,7 +600,7 @@

+

◆ C4StringResult

@@ -591,7 +614,7 @@

+

◆ C4Timestamp

@@ -607,7 +630,7 @@

+

◆ C4WriteStream

@@ -624,7 +647,7 @@

Function Documentation

- +

◆ c4_dumpInstances()

@@ -641,11 +664,11 @@

Logs information about object in memory.

-

Useful for debugging when c4_getObjectCount indicates there are leaks. (Note: In release builds this doesn't have much to say, because the instrumentation it needs is suppressed for performance purposes.)

+

Useful for debugging when c4_getObjectCount indicates there are leaks. (Note: In release builds this doesn't have much to say, because the instrumentation it needs is suppressed for performance purposes.)

- +

◆ c4_getObjectCount()

- +

◆ c4base_release()

@@ -684,14 +707,14 @@

-

◆ c4base_retain()

+ +

◆ c4base_retain()

- + @@ -702,7 +725,7 @@

+

◆ c4cert_release()

@@ -728,8 +751,8 @@

-

◆ c4cert_retain()

+ +

◆ c4cert_retain()

@@ -738,7 +761,7 @@

void* c4base_retain void * c4base_retain ( void *  obj)
- + @@ -754,7 +777,59 @@

+ +

◆ c4client_release()

+ +
+
+
static C4Cert* c4cert_retain static C4Cert * c4cert_retain ( C4Cert r)
+ + + + +
+ + + + + + + + +
static void c4client_release (C4ConnectedClientr)
+
+inlinestatic
+
+ +
+
+ +

◆ c4client_retain()

+ +
+
+ + + + + +
+ + + + + + + + +
static C4ConnectedClient * c4client_retain (C4ConnectedClientr)
+
+inlinestatic
+
+ +
+
+

◆ c4db_release()

@@ -780,8 +855,8 @@

-

◆ c4db_retain()

+ +

◆ c4db_retain()

@@ -790,7 +865,7 @@

- + @@ -806,7 +881,7 @@

+

◆ c4dbobs_free()

@@ -824,7 +899,7 @@

+

◆ c4doc_release()

@@ -842,14 +917,14 @@

-

◆ c4doc_retain()

+ +

◆ c4doc_retain()

static C4Database* c4db_retain static C4Database * c4db_retain ( C4Database r)
- + @@ -860,7 +935,7 @@

+

◆ c4docobs_free()

@@ -878,7 +953,7 @@

+

◆ c4enum_free()

@@ -896,7 +971,7 @@

+

◆ c4keypair_release()

@@ -922,8 +997,8 @@

-

◆ c4keypair_retain()

+ +

◆ c4keypair_retain()

@@ -932,7 +1007,7 @@

C4Document* c4doc_retain C4Document * c4doc_retain ( C4Document )
- + @@ -948,7 +1023,7 @@

+

◆ c4listener_free()

@@ -966,7 +1041,7 @@

+

◆ c4query_release()

@@ -992,8 +1067,8 @@

-

◆ c4query_retain()

+ +

◆ c4query_retain()

@@ -1002,7 +1077,7 @@

static C4KeyPair* c4keypair_retain static C4KeyPair * c4keypair_retain ( C4KeyPair r)
- + @@ -1018,7 +1093,7 @@

+

◆ c4queryenum_release()

@@ -1036,14 +1111,14 @@

-

◆ c4queryenum_retain()

+ +

◆ c4queryenum_retain()

static C4Query* c4query_retain static C4Query * c4query_retain ( C4Query r)
- + @@ -1054,7 +1129,7 @@

+

◆ c4queryobs_free()

@@ -1072,7 +1147,7 @@

+

◆ c4raw_free()

@@ -1090,7 +1165,7 @@

+

◆ c4repl_free()

@@ -1108,7 +1183,7 @@

+

◆ c4slice_free()

@@ -1134,7 +1209,7 @@

+

◆ c4SliceEqual()

@@ -1170,7 +1245,7 @@

+

◆ c4socket_release()

@@ -1188,14 +1263,14 @@

-

◆ c4socket_retain()

+ +

◆ c4socket_retain()

C4QueryEnumerator* c4queryenum_retain C4QueryEnumerator * c4queryenum_retain ( C4QueryEnumerator )
- + @@ -1206,7 +1281,7 @@

+

◆ c4str()

@@ -1232,7 +1307,7 @@

+

◆ c4stream_close()

@@ -1250,7 +1325,7 @@

+

◆ c4stream_closeWriter()

@@ -1271,7 +1346,7 @@

diff --git a/docs/C/html/group___blobs.html b/docs/C/html/group___blobs.html index 1165dfc400..5f439017a9 100644 --- a/docs/C/html/group___blobs.html +++ b/docs/C/html/group___blobs.html @@ -2,8 +2,8 @@ - - + + LiteCore: Blobs @@ -30,21 +30,22 @@

C4Socket* c4socket_retain C4Socket * c4socket_retain ( C4Socket )

- + +/* @license-end */ +
@@ -64,12 +65,11 @@
-
-
Blobs
+
Blobs
- @@ -84,12 +84,12 @@

+

Data Structures

struct  C4BlobKey
 A unique identifier of a blob based on a SHA-1 digest of its contents. More...
 
- - - - - - + + + + + + @@ -118,9 +118,9 @@

Blob Store API

C4BlobStorec4db_getBlobStore (C4Database *db, C4Error *outError)
 Returns the BlobStore associated with a bundled database. More...
 
C4BlobStorec4blob_openStore (C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
 Opens a BlobStore in a directory. More...
 
C4BlobStorec4db_getBlobStore (C4Database *db, C4Error *outError)
 Returns the BlobStore associated with a bundled database. More...
 
C4BlobStorec4blob_openStore (C4String dirPath, C4DatabaseFlags flags, const C4EncryptionKey *encryptionKey, C4Error *outError)
 Opens a BlobStore in a directory. More...
 
void c4blob_freeStore (C4BlobStore *)
 Closes/frees a BlobStore. More...
 
 
- - - + + + @@ -135,9 +135,9 @@

Streamed Reads

C4ReadStreamc4blob_openReadStream (C4BlobStore *, C4BlobKey, C4Error *)
 Opens a blob for reading, as a random-access byte stream. More...
 
C4ReadStreamc4blob_openReadStream (C4BlobStore *, C4BlobKey, C4Error *)
 Opens a blob for reading, as a random-access byte stream. More...
 
size_t c4stream_read (C4ReadStream *stream, void *buffer, size_t maxBytesToRead, C4Error *error)
 Reads from an open stream. More...
 
 
- - - + + + @@ -156,7 +156,7 @@

Streamed Writes

C4WriteStreamc4blob_openWriteStream (C4BlobStore *, C4Error *)
 Opens a write stream for creating a new blob. More...
 
C4WriteStreamc4blob_openWriteStream (C4BlobStore *, C4Error *)
 Opens a write stream for creating a new blob. More...
 
bool c4stream_write (C4WriteStream *, const void *bytes, size_t length, C4Error *)
 Writes data to a stream. More...
 

Detailed Description

Function Documentation

- +

◆ c4blob_computeKey()

- +

◆ c4blob_delete()

- +

◆ c4blob_getFilePath()

- +

◆ c4blob_getSize()

- +

◆ c4blob_keyFromString()

@@ -448,7 +448,7 @@

+

◆ c4blob_keyToString()

@@ -468,14 +468,14 @@

-

◆ c4blob_openReadStream()

+ +

◆ c4blob_openReadStream()

- + @@ -504,14 +504,14 @@

-

◆ c4blob_openStore()

+ +

◆ c4blob_openStore()

C4ReadStream* c4blob_openReadStream C4ReadStream * c4blob_openReadStream ( C4BlobStore ,
- + @@ -543,7 +543,7 @@

Opens a BlobStore in a directory.

-

If the flags allow creating, the directory will be created if necessary. Call c4blob_freeStore() when finished using the BlobStore.

Warning
This should only be used for unit testing. Naked BlobStores are not supported.
+

If the flags allow creating, the directory will be created if necessary. Call c4blob_freeStore() when finished using the BlobStore.

Warning
This should only be used for unit testing. Naked BlobStores are not supported.
Parameters

C4BlobStore* c4blob_openStore C4BlobStore * c4blob_openStore ( C4String  dirPath,
@@ -557,14 +557,14 @@

-

◆ c4blob_openWriteStream()

+ +

◆ c4blob_openWriteStream()

dirPathThe filesystem path of the directory holding the attachments.
- + @@ -584,18 +584,18 @@

Opens a write stream for creating a new blob.

-

You should then call c4stream_write to write the data, ending with c4stream_install to compute the blob's key and add it to the store, and then c4stream_closeWriter.

+

You should then call c4stream_write to write the data, ending with c4stream_install to compute the blob's key and add it to the store, and then c4stream_closeWriter.

-
-

◆ c4db_getBlobStore()

+ +

◆ c4db_getBlobStore()

C4WriteStream* c4blob_openWriteStream C4WriteStream * c4blob_openWriteStream ( C4BlobStore ,
- + @@ -615,11 +615,11 @@

Returns the BlobStore associated with a bundled database.

-

Fails if the database is not bundled. DO NOT call c4blob_freeStore on this! The C4Database will free it when it closes.

+

Fails if the database is not bundled. DO NOT call c4blob_freeStore on this! The C4Database will free it when it closes.

-
+

◆ c4stream_bytesWritten()

- +

◆ c4stream_closeWriter()

- +

◆ c4stream_computeBlobKey()

- +

◆ c4stream_getLength()

- +

◆ c4stream_read()

@@ -821,7 +821,7 @@

+

◆ c4stream_seek()

@@ -857,7 +857,7 @@

+

◆ c4stream_write()

@@ -902,7 +902,7 @@

diff --git a/docs/C/html/group___c_f.html b/docs/C/html/group___c_f.html index 547aa92a4c..0dc102c64a 100644 --- a/docs/C/html/group___c_f.html +++ b/docs/C/html/group___c_f.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece CoreFoundation and Objective-C Helpers @@ -30,21 +30,22 @@

C4BlobStore* c4db_getBlobStore C4BlobStore * c4db_getBlobStore ( C4Database db,
- + +/* @license-end */ +
@@ -64,26 +65,25 @@
-
-
Fleece CoreFoundation and Objective-C Helpers
+
Fleece CoreFoundation and Objective-C Helpers
- - + - +

+

Functions

bool FLEncoder_WriteCFObject (FLEncoder, CFTypeRef)
 Writes a Core Foundation (or Objective-C) object to an Encoder. More...
 
CFTypeRef FLValue_CopyCFObject (FLValue FL_NULLABLE)
CFTypeRef FLValue_CopyCFObject (FLValue FL_NULLABLE)
 Returns a Value as a corresponding CoreFoundation object. More...
 
FLValue FLDict_GetWithCFString (FLDict FL_NULLABLE, CFStringRef)
FLValue FLDict_GetWithCFString (FLDict FL_NULLABLE, CFStringRef)
 Same as FLDictGet, but takes the key as a CFStringRef. More...
 

Detailed Description

Function Documentation

- +

◆ FLDict_GetWithCFString()

- +

◆ FLValue_CopyCFObject()

diff --git a/docs/C/html/group___collection.html b/docs/C/html/group___collection.html index f111967a65..7ab8a7a1e6 100644 --- a/docs/C/html/group___collection.html +++ b/docs/C/html/group___collection.html @@ -2,8 +2,8 @@ - - + + LiteCore: Collections and Scopes @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -62,8 +63,7 @@

-
-
Collections and Scopes
+
Collections and Scopes
@@ -71,18 +71,18 @@ More...

- - - + + + - - - - - - + + + + + + @@ -97,9 +97,9 @@ - - - + + + @@ -108,18 +108,18 @@

Lifecycle

C4Collectionc4db_getDefaultCollection (C4Database *db)
 Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName). More...
 
C4Collectionc4db_getDefaultCollection (C4Database *db)
 Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName). More...
 
bool c4db_hasCollection (C4Database *db, C4CollectionSpec spec)
 Returns true if the collection exists. More...
 
C4Collectionc4db_getCollection (C4Database *db, C4CollectionSpec spec)
 Returns the existing collection with the given name & scope, or NULL if it doesn't exist. More...
 
C4Collectionc4db_createCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Creates and returns an empty collection with the given name & scope. More...
 
C4Collectionc4db_getCollection (C4Database *db, C4CollectionSpec spec)
 Returns the existing collection with the given name & scope, or NULL if it doesn't exist. More...
 
C4Collectionc4db_createCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Creates and returns an empty collection with the given name & scope. More...
 
bool c4db_deleteCollection (C4Database *db, C4CollectionSpec spec, C4Error *outError)
 Deletes the collection with the given name & scope. More...
 
C4CollectionSpec c4coll_getSpec (C4Collection *)
 Returns the name and scope of the collection. More...
 
C4Databasec4coll_getDatabase (C4Collection *)
 Returns the database containing the collection. More...
 
C4Databasec4coll_getDatabase (C4Collection *)
 Returns the database containing the collection. More...
 
uint64_t c4coll_getDocumentCount (C4Collection *)
 Returns the number of (undeleted) documents in the collection. More...
 
 
- - - - - - - - - - - - + + + + + + + + + + + + @@ -153,46 +153,46 @@

Documents

C4Documentc4coll_getDoc (C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the collection given its ID. More...
 
C4Documentc4coll_getDocBySequence (C4Collection *collection, C4SequenceNumber, C4Error *outError)
 Gets a document from the collection given its sequence number. More...
 
C4Documentc4coll_putDoc (C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4coll_createDoc (C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4coll_getDoc (C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the collection given its ID. More...
 
C4Documentc4coll_getDocBySequence (C4Collection *collection, C4SequenceNumber, C4Error *outError)
 Gets a document from the collection given its sequence number. More...
 
C4Documentc4coll_putDoc (C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4coll_createDoc (C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
bool c4coll_moveDoc (C4Collection *collection, C4String docID, C4Collection *toCollection, C4String newDocID, C4Error *error)
 Moves a document to another collection, possibly with a different docID. More...
 
 

Detailed Description

-

A C4Collection represents a Collection, a named grouping of documents in a database.

-

You can think of them as "folders" or "directories" for documents, or as like tables.

-

Each Collection provides:

- + +/* @license-end */ +

@@ -64,12 +65,11 @@
-
-
Databases
+
Databases
- @@ -134,12 +134,12 @@ - - - - - - + + + + + + @@ -166,9 +166,9 @@ - - - + + + @@ -215,7 +215,7 @@

+

Data Structures

struct  C4EncryptionKey
 Encryption key specified in a C4DatabaseConfig. More...
bool c4db_exists (C4String name, C4String inDirectory)
 Returns true if a database with the given name exists in the directory. More...
 
C4Databasec4db_openNamed (C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
 Opens a database given its name (without the ".cblite2" extension) and directory. More...
 
C4Databasec4db_openAgain (C4Database *db, C4Error *outError)
 Opens a new handle to the same database file as db. More...
 
C4Databasec4db_openNamed (C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
 Opens a database given its name (without the ".cblite2" extension) and directory. More...
 
C4Databasec4db_openAgain (C4Database *db, C4Error *outError)
 Opens a new handle to the same database file as db. More...
 
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, with the given name. More...
 
C4StringResult c4db_getPath (C4Database *)
 Returns the path of the database. More...
 
const C4DatabaseConfig2c4db_getConfig2 (C4Database *database)
 Returns the configuration the database was opened with. More...
 
const C4DatabaseConfig2c4db_getConfig2 (C4Database *database)
 Returns the configuration the database was opened with. More...
 
uint64_t c4db_getDocumentCount (C4Database *database)
 Returns the number of (undeleted) documents in the database. More...
 

Detailed Description

Macro Definition Documentation

- +

◆ kC4DefaultCollectionName

@@ -229,7 +229,7 @@

+

◆ kC4DefaultScopeID

@@ -244,7 +244,7 @@

Enumeration Type Documentation

- +

◆ C4DatabaseFlags

@@ -258,23 +258,23 @@

C4DatabaseConfig.

- - - - - -
Enumerator
kC4DB_Create 

Create the file if it doesn't exist.

+
Enumerator
kC4DB_Create 

Create the file if it doesn't exist.

kC4DB_ReadOnly 

Open file read-only.

+
kC4DB_ReadOnly 

Open file read-only.

kC4DB_AutoCompact 

Enable auto-compaction [UNIMPLEMENTED].

+
kC4DB_AutoCompact 

Enable auto-compaction [UNIMPLEMENTED].

kC4DB_VersionVectors 

Upgrade DB to version vectors instead of rev trees [EXPERIMENTAL].

+
kC4DB_VersionVectors 

Upgrade DB to version vectors instead of rev trees [EXPERIMENTAL].

kC4DB_NoUpgrade 

Disable upgrading an older-version database.

+
kC4DB_NoUpgrade 

Disable upgrading an older-version database.

kC4DB_NonObservable 

Disable database/collection observers, for slightly faster writes.

+
kC4DB_NonObservable 

Disable database/collection observers, for slightly faster writes.

- +

◆ C4EncryptionAlgorithm

@@ -288,15 +288,15 @@

-EnumeratorkC4EncryptionNone 

No encryption (default)

+EnumeratorkC4EncryptionNone 

No encryption (default)

-kC4EncryptionAES256 

AES with 256-bit key [ENTERPRISE EDITION ONLY].

+kC4EncryptionAES256 

AES with 256-bit key [ENTERPRISE EDITION ONLY].

- +

◆ C4EncryptionKeySize

@@ -310,12 +310,12 @@

-EnumeratorkC4EncryptionKeySizeAES256  +EnumeratorkC4EncryptionKeySizeAES256 

- +

◆ C4MaintenanceType

@@ -329,27 +329,27 @@

c4db_maintenance can perform.

- - - - -
Enumerator
kC4Compact 

Shrinks the database file by removing any empty pages, and deletes blobs that are no longer referenced by any documents.

-

(Runs SQLite PRAGMA incremental_vacuum; PRAGMA wal_checkpoint(TRUNCATE).)

+
Enumerator
kC4Compact 

Shrinks the database file by removing any empty pages, and deletes blobs that are no longer referenced by any documents.

+

(Runs SQLite PRAGMA incremental_vacuum; PRAGMA wal_checkpoint(TRUNCATE).)

kC4Reindex 

Rebuilds indexes from scratch.

-

Normally never needed, but can be used to help diagnose/troubleshoot cases of database corruption if only indexes are affected. (Runs SQLite REINDEX.)

+
kC4Reindex 

Rebuilds indexes from scratch.

+

Normally never needed, but can be used to help diagnose/troubleshoot cases of database corruption if only indexes are affected. (Runs SQLite REINDEX.)

kC4IntegrityCheck 

Checks for database corruption, as might be caused by a damaged filesystem, or memory corruption.

-

(Runs SQLite PRAGMA integrity_check.)

+
kC4IntegrityCheck 

Checks for database corruption, as might be caused by a damaged filesystem, or memory corruption.

+

(Runs SQLite PRAGMA integrity_check.)

kC4QuickOptimize 

Quickly updates database statistics that may help optimize queries that have been run by this Database since it was opened.

-

The more queries that have been run, the more effective this will be, but it tries to do its work quickly by scanning only portions of indexes. This operation is also performed automatically by c4db_close. (Runs SQLite PRAGMA analysis_limit=400; PRAGMA optimize.)

+
kC4QuickOptimize 

Quickly updates database statistics that may help optimize queries that have been run by this Database since it was opened.

+

The more queries that have been run, the more effective this will be, but it tries to do its work quickly by scanning only portions of indexes. This operation is also performed automatically by c4db_close. (Runs SQLite PRAGMA analysis_limit=400; PRAGMA optimize.)

kC4FullOptimize 

Fully scans all indexes to gather database statistics that help optimize queries.

-

This may take some time, depending on the size of the indexes, but it doesn't have to be redone unless the database changes drastically, or new indexes are created. (Runs SQLite PRAGMA analysis_limit=0; ANALYZE.)

+
kC4FullOptimize 

Fully scans all indexes to gather database statistics that help optimize queries.

+

This may take some time, depending on the size of the indexes, but it doesn't have to be redone unless the database changes drastically, or new indexes are created. (Runs SQLite PRAGMA analysis_limit=0; ANALYZE.)

Function Documentation

- +

◆ c4_shutdown()

- +

◆ c4db_beginTransaction()

- +

◆ c4db_close()

@@ -428,11 +428,11 @@

Closes the database.

-

Does not free the handle, although any operation other than c4db_release() will fail with an error.

+

Does not free the handle, although any operation other than c4db_release() will fail with an error.

- +

◆ c4db_copyNamed()

@@ -471,7 +471,7 @@

Copies a prebuilt database from the given source path and places it in the destination directory, with the given name.

-

If a database already exists there, it will be overwritten. However if there is a failure, the original database will be restored as if nothing happened.

Parameters
+

If a database already exists there, it will be overwritten. However if there is a failure, the original database will be restored as if nothing happened.

Parameters
@@ -484,7 +484,7 @@

+

◆ c4db_delete()

@@ -511,11 +511,11 @@

Closes the database and deletes the file/bundle.

-

Does not free the handle, although any operation other than c4db_release() will fail with an error.

+

Does not free the handle, although any operation other than c4db_release() will fail with an error.

- +

◆ c4db_deleteNamed()

- +

◆ c4db_endTransaction()

- +

◆ c4db_exists()

@@ -619,14 +619,14 @@

-

◆ c4db_getConfig2()

+ +

◆ c4db_getConfig2()

sourcePathThe path to the database to be copied.
destinationNameThe name (without filename extension) of the database to create.
- + @@ -639,7 +639,7 @@

+

◆ c4db_getDocumentCount()

@@ -659,7 +659,7 @@

+

◆ c4db_getExtraInfo()

@@ -679,7 +679,7 @@

+

◆ c4db_getLastSequence()

- +

◆ c4db_getPath()

- +

◆ c4db_isInTransaction()

@@ -803,7 +803,7 @@

+

◆ c4db_maintenance()

@@ -836,11 +836,11 @@

Performs database maintenance.

-

For more detail, see the descriptions of the C4MaintenanceType enum constants.

+

For more detail, see the descriptions of the C4MaintenanceType enum constants.

- +

◆ c4db_nextDocExpiration()

@@ -860,14 +860,14 @@

-

◆ c4db_openAgain()

+ +

◆ c4db_openAgain()

const C4DatabaseConfig2* c4db_getConfig2 const C4DatabaseConfig2 * c4db_getConfig2 ( C4Database database)
- + @@ -887,18 +887,18 @@

Opens a new handle to the same database file as db.

-

The new connection is completely independent and can be used on another thread.

+

The new connection is completely independent and can be used on another thread.

-
-

◆ c4db_openNamed()

+ +

◆ c4db_openNamed()

C4Database* c4db_openAgain C4Database * c4db_openAgain ( C4Database db,
- + @@ -927,7 +927,7 @@

+

◆ c4db_purgeExpiredDocs()

@@ -959,7 +959,7 @@

+

◆ c4db_rekey()

@@ -995,7 +995,7 @@

+

◆ c4db_setExtraInfo()

@@ -1022,12 +1022,12 @@

Associates an arbitrary pointer with this database instance, for client use.

-

For example, this could be a reference to the higher-level object wrapping the database.

-

The destructor field of the C4ExtraInfo can be used to provide a function that will be called when the C4Database is freed, so it can free any resources associated with the pointer.

+

For example, this could be a reference to the higher-level object wrapping the database.

+

The destructor field of the C4ExtraInfo can be used to provide a function that will be called when the C4Database is freed, so it can free any resources associated with the pointer.

- +

◆ c4key_setPassword()

@@ -1072,7 +1072,7 @@

+

◆ c4key_setPasswordSHA1()

@@ -1105,7 +1105,7 @@

Stores a password into a C4EncryptionKey, by using the key-derivation algorithm PBKDF2 to securely convert the password into a raw binary key.

-

Uses SHA1 for the hashing function as employed by PBKDF2.

Parameters
+

Uses SHA1 for the hashing function as employed by PBKDF2.

Parameters

C4Database* c4db_openNamed C4Database * c4db_openNamed ( C4String  name,
@@ -1118,7 +1118,7 @@

Variable Documentation

- +

◆ kC4DatabaseFilenameExtension

diff --git a/docs/C/html/group___doc_enumerator.html b/docs/C/html/group___doc_enumerator.html index 8e14e9ad3e..6bf9140bde 100644 --- a/docs/C/html/group___doc_enumerator.html +++ b/docs/C/html/group___doc_enumerator.html @@ -2,8 +2,8 @@ - - + +LiteCore: Document Enumeration @@ -30,21 +30,22 @@
encryptionKeyThe raw key will be stored here.
passwordThe password string.

- + +/* @license-end */ +

@@ -67,12 +68,11 @@ Enumerations | Functions | Variables

-
-
Document Enumeration
+
Document Enumeration

- @@ -81,7 +81,7 @@

+

Data Structures

struct  C4EnumeratorOptions
 Options for enumerating over all documents. More...
 Metadata about a document (actually about its current revision.) More...
 
-

+

Enumerations

enum  C4EnumeratorFlags : uint16_t {
  kC4Descending = 0x01 @@ -95,7 +95,7 @@ }
 
- @@ -103,29 +103,29 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + +

+

Functions

void c4enum_close (C4DocEnumerator *e)
 Closes an enumeration. More...
void c4enum_free (C4DocEnumerator *e)
 Frees a C4DocEnumerator handle. More...
 
C4DocEnumeratorc4db_enumerateChanges (C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4db_enumerateAllDocs (C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4coll_enumerateChanges (C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4coll_enumerateAllDocs (C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4db_enumerateChanges (C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4db_enumerateAllDocs (C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
C4DocEnumeratorc4coll_enumerateChanges (C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence. More...
 
C4DocEnumeratorc4coll_enumerateAllDocs (C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID. More...
 
bool c4enum_next (C4DocEnumerator *e, C4Error *outError)
 Advances the enumerator to the next document. More...
 
C4Documentc4enum_getDocument (C4DocEnumerator *e, C4Error *outError)
 Returns the current document, if any, from an enumerator. More...
 
C4Documentc4enum_getDocument (C4DocEnumerator *e, C4Error *outError)
 Returns the current document, if any, from an enumerator. More...
 
bool c4enum_getDocumentInfo (C4DocEnumerator *e, C4DocumentInfo *outInfo)
 Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct. More...
 
- @@ -133,7 +133,7 @@

+

Variables

CBL_CORE_API const C4EnumeratorOptions kC4DefaultEnumeratorOptions
 Default all-docs enumeration options. More...

Detailed Description

Enumeration Type Documentation

- +

◆ C4EnumeratorFlags

Function Documentation

-
-

◆ c4coll_enumerateAllDocs()

+ +

◆ c4coll_enumerateAllDocs()

- + @@ -195,7 +195,7 @@

Creates an enumerator ordered by docID.

-

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters
+

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters

C4DocEnumerator* c4coll_enumerateAllDocs C4DocEnumerator * c4coll_enumerateAllDocs ( C4Collection collection,
@@ -207,14 +207,14 @@

-

◆ c4coll_enumerateChanges()

+ +

◆ c4coll_enumerateChanges()

collectionThe collection.
optionsEnumeration options (NULL for defaults).
- + @@ -246,7 +246,7 @@

Creates an enumerator ordered by sequence.

-

Caller is responsible for freeing the enumerator when finished with it.

Parameters
+

Caller is responsible for freeing the enumerator when finished with it.

Parameters

C4DocEnumerator* c4coll_enumerateChanges C4DocEnumerator * c4coll_enumerateChanges ( C4Collection collection,
@@ -259,14 +259,14 @@

-

◆ c4db_enumerateAllDocs()

+ +

◆ c4db_enumerateAllDocs()

collectionThe collection.
sinceThe sequence number to start after. Pass 0 to start from the beginning.
- + @@ -292,7 +292,7 @@

Creates an enumerator ordered by docID.

-

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters
+

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters

C4DocEnumerator* c4db_enumerateAllDocs C4DocEnumerator * c4db_enumerateAllDocs ( C4Database database,
@@ -304,14 +304,14 @@

-

◆ c4db_enumerateChanges()

+ +

◆ c4db_enumerateChanges()

databaseThe database.
optionsEnumeration options (NULL for defaults).
- + @@ -343,7 +343,7 @@

Creates an enumerator ordered by sequence.

-

Caller is responsible for freeing the enumerator when finished with it.

Parameters
+

Caller is responsible for freeing the enumerator when finished with it.

Parameters

C4DocEnumerator* c4db_enumerateChanges C4DocEnumerator * c4db_enumerateChanges ( C4Database database,
@@ -356,7 +356,7 @@

+

◆ c4enum_close()

- +

◆ c4enum_free()

@@ -397,14 +397,14 @@

-

◆ c4enum_getDocument()

+ +

◆ c4enum_getDocument()

databaseThe database.
sinceThe sequence number to start after. Pass 0 to start from the beginning.
- + @@ -435,7 +435,7 @@

+

◆ c4enum_getDocumentInfo()

@@ -462,7 +462,7 @@

Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct.

-

Unlike c4enum_getDocument(), this allocates no memory.

Parameters
+

Unlike c4enum_getDocument(), this allocates no memory.

Parameters

C4Document* c4enum_getDocument C4Document * c4enum_getDocument ( C4DocEnumerator e,
@@ -473,7 +473,7 @@

+

◆ c4enum_next()

@@ -500,12 +500,12 @@

Advances the enumerator to the next document.

-

Returns false at the end, or on error; look at the C4Error to determine which occurred, and don't forget to free the enumerator.

+

Returns false at the end, or on error; look at the C4Error to determine which occurred, and don't forget to free the enumerator.

Variable Documentation

- +

◆ kC4DefaultEnumeratorOptions

diff --git a/docs/C/html/group___documents.html b/docs/C/html/group___documents.html index 933b6503d8..0ea0b6506b 100644 --- a/docs/C/html/group___documents.html +++ b/docs/C/html/group___documents.html @@ -2,8 +2,8 @@ - - + + LiteCore: Documents @@ -30,21 +30,22 @@

eThe enumerator.
outInfoA pointer to a C4DocumentInfo struct that will be filled in if a document is found.
- + +/* @license-end */ +
@@ -66,12 +67,11 @@ Data Structures | Typedefs | Enumerations

-
-
Documents
+
Documents

- @@ -80,13 +80,13 @@

+

Data Structures

struct  C4Revision
 Describes a revision of a document. More...
 Parameters for adding a revision using c4doc_put. More...
 
-

+

Typedefs

typedef uint32_t C4RemoteID
 Identifies a remote database being replicated with. More...
 
- - + - - - + + + - + @@ -169,7 +169,7 @@ - + @@ -195,18 +195,18 @@

+

Enumerations

enum  C4DocumentFlags : uint32_t { kDocDeleted = 0x01 , kDocConflicted = 0x02 @@ -125,22 +125,22 @@
FLDict c4doc_getProperties (C4Document *)
 Returns the properties of the selected revision, i.e. More...
 
FLDoc c4doc_createFleeceDoc (C4Document *)
FLDoc c4doc_createFleeceDoc (C4Document *)
 Returns a Fleece document reference created from the selected revision. More...
 
bool c4doc_resolveConflict2 (C4Document *doc, C4String winningRevID, C4String losingRevID, FLDict mergedProperties, C4RevisionFlags mergedFlags, C4Error *error)
 Resolves a conflict between two leaf revisions. More...
 
C4Documentc4doc_containingValue (FLValue value)
 Returns the C4Document, if any, that contains the given Fleece value. More...
 
C4Documentc4doc_containingValue (FLValue value)
 Returns the C4Document, if any, that contains the given Fleece value. More...
 
bool c4doc_isOldMetaProperty (C4String prop)
 Returns true if this is the name of a 1.x metadata property ("_id", "_rev", "_deleted".) Does NOT return true for "_attachments" because that property isn't obsolete. More...
 
bool c4doc_hasOldMetaProperties (FLDict doc)
 Returns true if the document contains 1.x metadata properties at top level. More...
 
C4SliceResult c4doc_encodeStrippingOldMetaProperties (FLDict doc, FLSharedKeys sk, C4Error *outError)
C4SliceResult c4doc_encodeStrippingOldMetaProperties (FLDict doc, FLSharedKeys sk, C4Error *outError)
 Re-encodes to Fleece, without any 1.x metadata properties. More...
 
bool c4doc_getDictBlobKey (FLDict dict, C4BlobKey *outKey)
C4SliceResult c4db_encodeJSON (C4Database *, C4String jsonData, C4Error *outError)
 Encodes JSON data to Fleece, to store into a document. More...
 
FLSharedKeys c4db_getFLSharedKeys (C4Database *db)
FLSharedKeys c4db_getFLSharedKeys (C4Database *db)
 Returns the FLSharedKeys object used by the given database. More...
 
#define kC4ObjectTypeProperty   "@type"
 
- - - - - - - - - - - - + + + + + + + + + + + + @@ -284,19 +284,19 @@

Lifecycle

char * c4doc_generateID (char *buffer, size_t bufferSize)
 Generates a random 23-byte C string suitable for use as a unique new document ID. More...
 
C4Documentc4db_getDoc (C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the database given its ID. More...
 
C4Documentc4doc_get (C4Database *database, C4String docID, bool mustExist, C4Error *outError)
 Gets a document from the database given its ID (semi-deprecated). More...
 
C4Documentc4doc_getBySequence (C4Database *database, C4SequenceNumber, C4Error *outError)
 Gets a document from the database given its sequence number. More...
 
char * c4doc_generateID (char *buffer, size_t bufferSize)
 Generates a random 23-byte C string suitable for use as a unique new document ID. More...
 
C4Documentc4db_getDoc (C4Database *database, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
 Gets a document from the database given its ID. More...
 
C4Documentc4doc_get (C4Database *database, C4String docID, bool mustExist, C4Error *outError)
 Gets a document from the database given its ID (semi-deprecated). More...
 
C4Documentc4doc_getBySequence (C4Database *database, C4SequenceNumber, C4Error *outError)
 Gets a document from the database given its sequence number. More...
 
bool c4doc_save (C4Document *doc, uint32_t maxRevTreeDepth, C4Error *outError)
 Saves changes to a C4Document. More...
 
 
- - - - - - - - - + + + + + + + + +

Creating and Updating Documents

C4Documentc4doc_put (C4Database *database, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4doc_create (C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4doc_update (C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
 Adds a revision to a document already in memory as a C4Document. More...
 
C4Documentc4doc_put (C4Database *database, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
 A high-level Put operation, to insert a new or downloaded revision. More...
 
C4Documentc4doc_create (C4Database *db, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
 Convenience function to create a new document. More...
 
C4Documentc4doc_update (C4Document *doc, C4Slice revisionBody, C4RevisionFlags revisionFlags, C4Error *error)
 Adds a revision to a document already in memory as a C4Document. More...
 

Detailed Description

Macro Definition Documentation

- +

◆ kC4BlobDataProperty

- +

◆ kC4BlobDigestProperty

- +

◆ kC4EncryptableValueProperty

- +

◆ kC4GeneratedIDLength

@@ -361,7 +361,7 @@

+

◆ kC4LegacyAttachmentsProperty

@@ -377,7 +377,7 @@

+

◆ kC4ObjectType_Blob

@@ -393,7 +393,7 @@

+

◆ kC4ObjectType_Encryptable

Typedef Documentation

-
+

◆ C4DocDeltaApplier

@@ -440,7 +440,7 @@

Optional callback to c4doc_put that generates the new revision body, based on an earlier revision body and the body of the C4DocPutRequest.

-

It's intended for use when the new revision is specified as a delta.

Parameters
+

It's intended for use when the new revision is specified as a delta.

Parameters
@@ -453,7 +453,7 @@

+

◆ C4RemoteID

@@ -470,7 +470,7 @@

Enumeration Type Documentation

- +

◆ C4DocContentLevel

@@ -484,17 +484,17 @@

-

- -
contextThe same value given in the C4DocPutRequest's deltaCBContext field.
docThe document; its selected revision is the one requested in the deltaSourceRevID.
Enumerator
kDocGetMetadata 

Only get revID and flags.

+
Enumerator
kDocGetMetadata 

Only get revID and flags.

kDocGetCurrentRev 

Get current revision body but not other revisions/remotes.

+
kDocGetCurrentRev 

Get current revision body but not other revisions/remotes.

kDocGetAll 

Get everything.

+
kDocGetAll 

Get everything.

- +

◆ C4DocumentFlags

@@ -508,19 +508,19 @@

-EnumeratorkDocDeleted 

The document's current revision is deleted.

+EnumeratorkDocDeleted 

The document's current revision is deleted.

-kDocConflicted 

The document is in conflict.

+kDocConflicted 

The document is in conflict.

-kDocHasAttachments 

The document's current revision has attachments.

+kDocHasAttachments 

The document's current revision has attachments.

-kDocExists 

The document exists (i.e. has revisions.)

+kDocExists 

The document exists (i.e. has revisions.)

- +

◆ C4RevisionFlags

@@ -534,28 +534,28 @@

-EnumeratorkRevDeleted 

Is this revision a deletion/tombstone?

+EnumeratorkRevDeleted 

Is this revision a deletion/tombstone?

-kRevLeaf 

Is this revision a leaf (no children?)

+kRevLeaf 

Is this revision a leaf (no children?)

-kRevNew 

Has this rev been inserted since the doc was read?

+kRevNew 

Has this rev been inserted since the doc was read?

-kRevHasAttachments 

Does this rev's body contain attachments?

+kRevHasAttachments 

Does this rev's body contain attachments?

-kRevKeepBody 

Revision's body should not be discarded when non-leaf.

+kRevKeepBody 

Revision's body should not be discarded when non-leaf.

-kRevIsConflict 

Unresolved conflicting revision; will never be current.

+kRevIsConflict 

Unresolved conflicting revision; will never be current.

-kRevClosed 

Rev is the (deleted) end of a closed conflicting branch.

+kRevClosed 

Rev is the (deleted) end of a closed conflicting branch.

-kRevPurged 

Revision is purged (this flag is never stored in the db)

+kRevPurged 

Revision is purged (this flag is never stored in the db)

Function Documentation

- +

◆ c4db_createFleeceEncoder()

@@ -575,7 +575,7 @@

+

◆ c4db_encodeJSON()

@@ -611,14 +611,14 @@

-

◆ c4db_getDoc()

+ +

◆ c4db_getDoc()

- + @@ -656,7 +656,7 @@

Gets a document from the database given its ID.

-

The current revision is selected (if the document exists.) You must call c4doc_release() when finished with the document.

Parameters
+

The current revision is selected (if the document exists.) You must call c4doc_release() when finished with the document.

Parameters

C4Document* c4db_getDoc C4Document * c4db_getDoc ( C4Database database,
@@ -670,14 +670,14 @@

+

◆ c4db_getFLSharedKeys()

databaseThe database to read from.
docIDThe document's ID.
- + @@ -690,7 +690,7 @@

+

◆ c4db_getRemoteDBAddress()

FLSharedKeys c4db_getFLSharedKeys FLSharedKeys c4db_getFLSharedKeys ( C4Database db)
- + @@ -914,14 +914,14 @@

-

◆ c4doc_create()

+ +

◆ c4doc_create()

C4Document* c4doc_containingValue C4Document * c4doc_containingValue ( FLValue  value)
- + @@ -959,7 +959,7 @@

Convenience function to create a new document.

-

This just a wrapper around c4doc_put. If the document already exists, it will fail with the error kC4ErrorConflict.

Parameters
+

This just a wrapper around c4doc_put. If the document already exists, it will fail with the error kC4ErrorConflict.

Parameters

C4Document* c4doc_create C4Document * c4doc_create ( C4Database db,
@@ -973,14 +973,14 @@

+

◆ c4doc_createFleeceDoc()

dbThe database to create the document in
docIDDocument ID to create; if null, a UUID will be generated
- + @@ -990,11 +990,11 @@

Returns a Fleece document reference created from the selected revision.

-

Caller must release the reference!

+

Caller must release the reference!

-
+

◆ c4doc_dictContainsBlobs()

- +

◆ c4doc_encodeStrippingOldMetaProperties()

@@ -1058,7 +1058,7 @@

- + @@ -1076,18 +1076,18 @@

Re-encodes to Fleece, without any 1.x metadata properties.

-

Old-style attachments that don't refer to blobs will be removed; others are kept.

+

Old-style attachments that don't refer to blobs will be removed; others are kept.

-
-

◆ c4doc_generateID()

+ +

◆ c4doc_generateID()

FLDoc c4doc_createFleeceDoc FLDoc c4doc_createFleeceDoc ( C4Document )FLSharedKeys FLSharedKeys  sk,
- + @@ -1118,14 +1118,14 @@

-

◆ c4doc_get()

+ +

◆ c4doc_get()

char* c4doc_generateID char * c4doc_generateID ( char *  buffer,
- + @@ -1157,11 +1157,11 @@

Gets a document from the database given its ID (semi-deprecated).

-

This is the same as c4db_getDoc with content equal to kDocGetCurrentRev.

+

This is the same as c4db_getDoc with content equal to kDocGetCurrentRev.

- +

◆ c4doc_getBlobData()

@@ -1207,14 +1207,14 @@

-

◆ c4doc_getBySequence()

+ +

◆ c4doc_getBySequence()

C4Document* c4doc_get C4Document * c4doc_get ( C4Database database,
- + @@ -1240,12 +1240,12 @@

Gets a document from the database given its sequence number.

-

You must call c4doc_release() when finished with the document.
+

You must call c4doc_release() when finished with the document.

- +

◆ c4doc_getDictBlobKey()

@@ -1272,11 +1272,11 @@

Decodes the dict's "digest" property to a C4BlobKey.

-

Returns false if there is no such property or it's not a valid blob key.

+

Returns false if there is no such property or it's not a valid blob key.

- +

◆ c4doc_getExpiration()

- +

◆ c4doc_getRemoteAncestor()

C4Document* c4doc_getBySequence C4Document * c4doc_getBySequence ( C4Database database,
@@ -1445,7 +1445,7 @@

+

◆ c4doc_getSelectedRevIDGlobalForm()

- +

◆ c4doc_hasOldMetaProperties()

- +

◆ c4doc_hasRevisionBody()

- +

◆ c4doc_isOldMetaProperty()

docThe document.
maxRevsThe maximum number of revisions to include in the result; or 0 for unlimited.
@@ -1603,14 +1603,14 @@

-

◆ c4doc_put()

+ +

◆ c4doc_put()

docThe document.
revIDThe ID of the revision to purge. If null, all revisions are purged.
- + @@ -1642,11 +1642,11 @@

A high-level Put operation, to insert a new or downloaded revision.

-

If request->existingRevision is true, then request->history must contain the revision's history, with the revision's ID as the first item. Otherwise, a new revision will be created and assigned a revID. The parent revision ID, if any, should be given as the single item of request->history. Either way, on success the document is returned with the inserted revision selected. Note that actually saving the document back to the database is optional – it only happens if request->save is true. You can set this to false if you want to review the changes before saving, e.g. to run them through a validation function.

+

If request->existingRevision is true, then request->history must contain the revision's history, with the revision's ID as the first item. Otherwise, a new revision will be created and assigned a revID. The parent revision ID, if any, should be given as the single item of request->history. Either way, on success the document is returned with the inserted revision selected. Note that actually saving the document back to the database is optional – it only happens if request->save is true. You can set this to false if you want to review the changes before saving, e.g. to run them through a validation function.

-
+

◆ c4doc_resolveConflict()

C4Document* c4doc_put C4Document * c4doc_put ( C4Database database,
@@ -1712,7 +1712,7 @@

+

◆ c4doc_resolveConflict2()

- +

◆ c4doc_save()

@@ -1800,11 +1800,11 @@

Saves changes to a C4Document.

-

Must be called within a transaction. The revision history will be pruned to the maximum depth given.

+

Must be called within a transaction. The revision history will be pruned to the maximum depth given.

- +

◆ c4doc_selectCommonAncestorRevision()

- +

◆ c4doc_selectCurrentRevision()

- +

◆ c4doc_selectNextLeafRevision()

- +

◆ c4doc_selectNextRevision()

- +

◆ c4doc_selectParentRevision()

docThe document.
winningRevIDThe conflicting revision to be kept (and optionally updated.)
@@ -2040,7 +2040,7 @@

+

◆ c4doc_setRemoteAncestor()

@@ -2082,14 +2082,14 @@

-

◆ c4doc_update()

+ +

◆ c4doc_update()

dbThe database to set the expiration date in
docIDThe ID of the document to set the expiration date for
- + @@ -2121,7 +2121,7 @@

Adds a revision to a document already in memory as a C4Document.

-

This is more efficient than c4doc_put because it doesn't have to read from the database before writing; but if the C4Document doesn't have the current state of the document, it will fail with the error kC4ErrorConflict – then you'll need to get the current document and try again. The new revision is added as a child of the currently selected revision.

Parameters
+

This is more efficient than c4doc_put because it doesn't have to read from the database before writing; but if the C4Document doesn't have the current state of the document, it will fail with the error kC4ErrorConflict – then you'll need to get the current document and try again. The new revision is added as a child of the currently selected revision.

Parameters

C4Document* c4doc_update C4Document * c4doc_update ( C4Document doc,
@@ -2134,7 +2134,7 @@

+

◆ c4rev_equal()

@@ -2168,7 +2168,7 @@

+

◆ c4rev_getGeneration()

@@ -2191,7 +2191,7 @@

diff --git a/docs/C/html/group___errors.html b/docs/C/html/group___errors.html index 1f158dae64..28f0eeeba5 100644 --- a/docs/C/html/group___errors.html +++ b/docs/C/html/group___errors.html @@ -2,8 +2,8 @@ - - + + LiteCore: Error Codes and Error Handling @@ -30,21 +30,22 @@

docThe document to update
revisionBodyThe body of the new revision
- + +/* @license-end */ +
@@ -64,20 +65,25 @@
-
-
Error Codes and Error Handling
+
Error Codes and Error Handling
-

+

Data Structures

struct  C4Error
 An error value. More...
 
- + + +

+

+Macros

#define kC4NoError   ((C4Error){ })
 
+

Enumerations

enum  C4ErrorDomain : uint8_t {
  LiteCoreDomain = 1 @@ -176,7 +182,7 @@
 Network error codes (potentially higher level than POSIX, lower level than HTTP.) The entries marked with a POSIX code mirror that code so that platform bindings have a stable cross platform error code to use for transient or network dependent errors, and will behave the same as if the errno in question was passed. More...
 
- @@ -184,9 +190,9 @@ - - - + + + @@ -215,8 +221,23 @@

+

Functions

FLStringResult c4error_getMessage (C4Error error)
 Returns an error message describing a C4Error. More...
FLSliceResult c4error_getDescription (C4Error error)
 Returns a description of an error, including the domain and code as well as the message. More...
 
char * c4error_getDescriptionC (C4Error error, char *outBuffer, size_t bufferSize)
 Returns a description of an error, including the domain and code as well as the message. More...
 
char * c4error_getDescriptionC (C4Error error, char *outBuffer, size_t bufferSize)
 Returns a description of an error, including the domain and code as well as the message. More...
 
void c4error_setCaptureBacktraces (bool)
 If set to true, then when a C4Error is created the current thread's stack backtrace will be captured along with it, and can later be examined by calling c4error_getBacktrace. More...
 
 

Detailed Description

+

Macro Definition Documentation

+ +

◆ kC4NoError

+ +
+
+ + + + +
#define kC4NoError   ((C4Error){ })
+
+ +
+

Enumeration Type Documentation

- +

◆ C4ErrorCode

@@ -228,44 +249,44 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
kC4ErrorAssertionFailed 
kC4ErrorUnimplemented 
kC4ErrorUnsupportedEncryption 
kC4ErrorBadRevisionID 
kC4ErrorCorruptRevisionData 
kC4ErrorNotOpen 
kC4ErrorNotFound 
kC4ErrorConflict 
kC4ErrorInvalidParameter 
kC4ErrorUnexpectedError 
kC4ErrorCantOpenFile 
kC4ErrorIOError 
kC4ErrorMemoryError 
kC4ErrorNotWriteable 
kC4ErrorCorruptData 
kC4ErrorBusy 
kC4ErrorNotInTransaction 
kC4ErrorTransactionNotClosed 
kC4ErrorUnsupported 
kC4ErrorNotADatabaseFile 
kC4ErrorWrongFormat 
kC4ErrorCrypto 
kC4ErrorInvalidQuery 
kC4ErrorMissingIndex 
kC4ErrorInvalidQueryParam 
kC4ErrorRemoteError 
kC4ErrorDatabaseTooOld 
kC4ErrorDatabaseTooNew 
kC4ErrorBadDocID 
kC4ErrorCantUpgradeDatabase 
kC4ErrorDeltaBaseUnknown 
kC4ErrorCorruptDelta 
kC4NumErrorCodesPlus1 
Enumerator
kC4ErrorAssertionFailed 
kC4ErrorUnimplemented 
kC4ErrorUnsupportedEncryption 
kC4ErrorBadRevisionID 
kC4ErrorCorruptRevisionData 
kC4ErrorNotOpen 
kC4ErrorNotFound 
kC4ErrorConflict 
kC4ErrorInvalidParameter 
kC4ErrorUnexpectedError 
kC4ErrorCantOpenFile 
kC4ErrorIOError 
kC4ErrorMemoryError 
kC4ErrorNotWriteable 
kC4ErrorCorruptData 
kC4ErrorBusy 
kC4ErrorNotInTransaction 
kC4ErrorTransactionNotClosed 
kC4ErrorUnsupported 
kC4ErrorNotADatabaseFile 
kC4ErrorWrongFormat 
kC4ErrorCrypto 
kC4ErrorInvalidQuery 
kC4ErrorMissingIndex 
kC4ErrorInvalidQueryParam 
kC4ErrorRemoteError 
kC4ErrorDatabaseTooOld 
kC4ErrorDatabaseTooNew 
kC4ErrorBadDocID 
kC4ErrorCantUpgradeDatabase 
kC4ErrorDeltaBaseUnknown 
kC4ErrorCorruptDelta 
kC4NumErrorCodesPlus1 

- +

◆ C4ErrorDomain

- +

◆ C4NetworkErrorCode

@@ -302,42 +323,42 @@

Network error codes (potentially higher level than POSIX, lower level than HTTP.) The entries marked with a POSIX code mirror that code so that platform bindings have a stable cross platform error code to use for transient or network dependent errors, and will behave the same as if the errno in question was passed.

-

Entries marked as retryable will cause a retry loop according to the configured retry rules.
+

Entries marked as retryable will cause a retry loop according to the configured retry rules.

- - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enumerator
kC4NetErrDNSFailure 
kC4NetErrUnknownHost 
kC4NetErrTimeout 
kC4NetErrInvalidURL 
kC4NetErrTooManyRedirects 
kC4NetErrTLSHandshakeFailed 
kC4NetErrTLSCertExpired 
kC4NetErrTLSCertUntrusted 
kC4NetErrTLSCertRequiredByPeer 
kC4NetErrTLSCertRejectedByPeer 
kC4NetErrTLSCertUnknownRoot 
kC4NetErrInvalidRedirect 
kC4NetErrUnknown 
kC4NetErrTLSCertRevoked 
kC4NetErrTLSCertNameMismatch 
kC4NetErrNetworkReset 
kC4NetErrConnectionAborted 
kC4NetErrConnectionReset 
kC4NetErrConnectionRefused 
kC4NetErrNetworkDown 
kC4NetErrNetworkUnreachable 
kC4NetErrNotConnected 
kC4NetErrHostDown 
kC4NetErrHostUnreachable 
kC4NetErrAddressNotAvailable 
kC4NetErrBrokenPipe 
kC4NumNetErrorCodesPlus1 
Enumerator
kC4NetErrDNSFailure 
kC4NetErrUnknownHost 
kC4NetErrTimeout 
kC4NetErrInvalidURL 
kC4NetErrTooManyRedirects 
kC4NetErrTLSHandshakeFailed 
kC4NetErrTLSCertExpired 
kC4NetErrTLSCertUntrusted 
kC4NetErrTLSCertRequiredByPeer 
kC4NetErrTLSCertRejectedByPeer 
kC4NetErrTLSCertUnknownRoot 
kC4NetErrInvalidRedirect 
kC4NetErrUnknown 
kC4NetErrTLSCertRevoked 
kC4NetErrTLSCertNameMismatch 
kC4NetErrNetworkReset 
kC4NetErrConnectionAborted 
kC4NetErrConnectionReset 
kC4NetErrConnectionRefused 
kC4NetErrNetworkDown 
kC4NetErrNetworkUnreachable 
kC4NetErrNotConnected 
kC4NetErrHostDown 
kC4NetErrHostUnreachable 
kC4NetErrAddressNotAvailable 
kC4NetErrBrokenPipe 
kC4NumNetErrorCodesPlus1 

Function Documentation

-
+

◆ c4error_getBacktrace()

@@ -354,11 +375,11 @@

Returns the stack backtrace, if any, associated with a C4Error.

-

This is formatted in human-readable form similar to a debugger or crash log.

+

This is formatted in human-readable form similar to a debugger or crash log.

- +

◆ c4error_getCaptureBacktraces()

- -

◆ c4error_getDescriptionC()

+ +

◆ c4error_getDescriptionC()

- + @@ -430,7 +451,7 @@

Returns a description of an error, including the domain and code as well as the message.

-

The description is copied to the buffer as a C string. It will not write past the end of the buffer; the message will be truncated if necessary.

Parameters
+

The description is copied to the buffer as a C string. It will not write past the end of the buffer; the message will be truncated if necessary.

Parameters

char* c4error_getDescriptionC char * c4error_getDescriptionC ( C4Error  error,
@@ -442,7 +463,7 @@

+

◆ c4error_getMessage()

@@ -459,11 +480,11 @@

Returns an error message describing a C4Error.

-

Remember to free the result.

+

Remember to free the result.

- +

◆ c4error_make()

- +

◆ c4error_mayBeTransient()

- +

◆ c4error_printf()

@@ -583,7 +604,7 @@

+

◆ c4error_return()

@@ -622,11 +643,11 @@

Creates and stores a C4Error in *outError, if not NULL.

-

Useful in functions that use the LiteCore error reporting convention of taking a C4Error *outError parameter.

+

Useful in functions that use the LiteCore error reporting convention of taking a C4Error *outError parameter.

- +

◆ c4error_setCaptureBacktraces()

@@ -643,11 +664,11 @@

If set to true, then when a C4Error is created the current thread's stack backtrace will be captured along with it, and can later be examined by calling c4error_getBacktrace.

-

Even if false, some errors (like assertion failures) will still have backtraces.

+

Even if false, some errors (like assertion failures) will still have backtraces.

- +

◆ c4error_vprintf()

@@ -692,7 +713,7 @@

diff --git a/docs/C/html/group___f_l_array.html b/docs/C/html/group___f_l_array.html index 43913f9c97..be9456bc6f 100644 --- a/docs/C/html/group___f_l_array.html +++ b/docs/C/html/group___f_l_array.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece Arrays @@ -30,21 +30,22 @@

errorThe error to describe
outBufferWhere to write the C string to
- + +/* @license-end */ +
@@ -66,178 +67,65 @@ Data Structures | Functions | Variables

-
-
Fleece Arrays
+
Fleece Arrays

FLArray is a "subclass" of FLValue, representing values that are arrays. More...

-

+

Data Structures

struct  FLArrayIterator
 Opaque array iterator. More...
 
- - + - + - + - +

+

Functions

uint32_t FLArray_Count (FLArray FL_NULLABLE) FLPURE
uint32_t FLArray_Count (FLArray FL_NULLABLE) FLPURE
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 
bool FLArray_IsEmpty (FLArray FL_NULLABLE) FLPURE
bool FLArray_IsEmpty (FLArray FL_NULLABLE) FLPURE
 Returns true if an array is empty (or NULL). More...
 
FLMutableArray FL_NULLABLE FLArray_AsMutable (FLArray FL_NULLABLE) FLPURE
FLMutableArray FL_NULLABLE FLArray_AsMutable (FLArray FL_NULLABLE) FLPURE
 If the array is mutable, returns it cast to FLMutableArray, else NULL. More...
 
FLValue FL_NULLABLE FLArray_Get (FLArray FL_NULLABLE, uint32_t index) FLPURE
FLValue FL_NULLABLE FLArray_Get (FLArray FL_NULLABLE, uint32_t index) FLPURE
 Returns an value at an array index, or NULL if the index is out of range. More...
 
- - + +

+

Variables

FLEECE_PUBLIC const FLArray kFLEmptyArray
FLEECE_PUBLIC const FLArray kFLEmptyArray
 A constant empty array value. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0 -, kFLDeepCopy = 1 -, kFLCopyImmutables = 2 -, kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) - }
 
FLMutableArray FL_NULLABLE FLArray_MutableCopy (FLArray FL_NULLABLE, FLCopyFlags)
 Creates a new mutable Array that's a copy of the source Array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_New (void)
 Creates a new empty mutable Array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_NewFromJSON (FLString json, FLError *FL_NULLABLE outError)
 Creates a new mutable Array from JSON. More...
 
static FLMutableArray FL_NULLABLE FLMutableArray_Retain (FLMutableArray FL_NULLABLE d)
 Increments the ref-count of a mutable Array. More...
 
static void FLMutableArray_Release (FLMutableArray FL_NULLABLE d)
 Decrements the refcount of (and possibly frees) a mutable Array. More...
 
FLArray FL_NULLABLE FLMutableArray_GetSource (FLMutableArray FL_NULLABLE)
 If the Array was created by FLArray_MutableCopy, returns the original source Array. More...
 
bool FLMutableArray_IsChanged (FLMutableArray FL_NULLABLE)
 Returns true if the Array has been changed from the source it was copied from. More...
 
void FLMutableArray_SetChanged (FLMutableArray FL_NULLABLE, bool)
 Sets or clears the mutable Array's "changed" flag. More...
 
void FLMutableArray_Insert (FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
 Inserts a contiguous range of JSON null values into the array. More...
 
void FLMutableArray_Remove (FLMutableArray FL_NULLABLE array, uint32_t firstIndex, uint32_t count)
 Removes contiguous items from the array. More...
 
void FLMutableArray_Resize (FLMutableArray FL_NULLABLE array, uint32_t size)
 Changes the size of an array. More...
 
FLMutableArray FL_NULLABLE FLMutableArray_GetMutableArray (FLMutableArray FL_NULLABLE, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FL_NULLABLE FLMutableArray_GetMutableDict (FLMutableArray FL_NULLABLE, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 
static void FLMutableArray_SetNull (FLMutableArray, uint32_t index)
 Stores a JSON null value into an array. More...
 
static void FLMutableArray_SetBool (FLMutableArray, uint32_t index, bool)
 Stores a boolean value into an array. More...
 
static void FLMutableArray_SetInt (FLMutableArray, uint32_t index, int64_t)
 Stores an integer into an array. More...
 
static void FLMutableArray_SetUInt (FLMutableArray, uint32_t index, uint64_t)
 Stores an unsigned integer into an array. More...
 
static void FLMutableArray_SetFloat (FLMutableArray, uint32_t index, float)
 Stores a 32-bit floating-point number into an array. More...
 
static void FLMutableArray_SetDouble (FLMutableArray, uint32_t index, double)
 Stores a 64-bit floating point number into an array. More...
 
static void FLMutableArray_SetString (FLMutableArray, uint32_t index, FLString)
 Stores a UTF-8-encoded string into an array. More...
 
static void FLMutableArray_SetData (FLMutableArray, uint32_t index, FLSlice)
 Stores a binary data blob into an array. More...
 
static void FLMutableArray_SetValue (FLMutableArray, uint32_t index, FLValue)
 Stores a Fleece value into an array. More...
 
static void FLMutableArray_SetArray (FLMutableArray, uint32_t index, FLArray)
 Stores a Fleece array into an array. More...
 
static void FLMutableArray_SetDict (FLMutableArray, uint32_t index, FLDict)
 Stores a Fleece dictionary into an array. More...
 
static void FLMutableArray_AppendNull (FLMutableArray)
 Appends a JSON null value to an array. More...
 
static void FLMutableArray_AppendBool (FLMutableArray, bool)
 Appends a boolean value to an array. More...
 
static void FLMutableArray_AppendInt (FLMutableArray, int64_t)
 Appends an integer to an array. More...
 
static void FLMutableArray_AppendUInt (FLMutableArray, uint64_t)
 Appends an unsigned integer to an array. More...
 
static void FLMutableArray_AppendFloat (FLMutableArray, float)
 Appends a 32-bit floating-point number to an array. More...
 
static void FLMutableArray_AppendDouble (FLMutableArray, double)
 Appends a 64-bit floating point number to an array. More...
 
static void FLMutableArray_AppendString (FLMutableArray, FLString)
 Appends a UTF-8-encoded string to an array. More...
 
static void FLMutableArray_AppendData (FLMutableArray, FLSlice)
 Appends a binary data blob to an array. More...
 
static void FLMutableArray_AppendValue (FLMutableArray, FLValue)
 Appends a Fleece value to an array. More...
 
static void FLMutableArray_AppendArray (FLMutableArray, FLArray)
 Appends a Fleece array to an array. More...
 
static void FLMutableArray_AppendDict (FLMutableArray, FLDict)
 Appends a Fleece dictionary to an array. More...
 
- - + - + - + - + @@ -245,38 +133,17 @@

Array iteration

Iterating an array typically looks like this:

-
-
FLArrayIterator_Begin(theArray, &iter);
-
FLValue value;
-
while (NULL != (value = FLArrayIterator_GetValue(&iter))) {
+

Iterating an array typically looks like this:

+
+
FLArrayIterator_Begin(theArray, &iter);
+
FLValue value;
+
while (NULL != (value = FLArrayIterator_GetValue(&iter))) {
// ...
- +
}
void FLArrayIterator_Begin(FLArray FL_NULLABLE, FLArrayIterator *)
Initializes a FLArrayIterator struct to iterate over an array.
bool FLArrayIterator_Next(FLArrayIterator *)
Advances the iterator to the next value, or returns false if at the end.
FLValue FL_NULLABLE FLArrayIterator_GetValue(const FLArrayIterator *) FLPURE
Returns the current value being iterated over.
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
-
Opaque array iterator.
Definition: Fleece.h:436
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:51
+
Opaque array iterator.
Definition: FLCollections.h:73
void FLArrayIterator_Begin (FLArray FL_NULLABLE, FLArrayIterator *)
void FLArrayIterator_Begin (FLArray FL_NULLABLE, FLArrayIterator *)
 Initializes a FLArrayIterator struct to iterate over an array. More...
 
FLValue FL_NULLABLE FLArrayIterator_GetValue (const FLArrayIterator *) FLPURE
FLValue FL_NULLABLE FLArrayIterator_GetValue (const FLArrayIterator *) FLPURE
 Returns the current value being iterated over. More...
 
FLValue FL_NULLABLE FLArrayIterator_GetValueAt (const FLArrayIterator *, uint32_t offset) FLPURE
FLValue FL_NULLABLE FLArrayIterator_GetValueAt (const FLArrayIterator *, uint32_t offset) FLPURE
 Returns a value in the array at the given offset from the current value. More...
 
uint32_t FLArrayIterator_GetCount (const FLArrayIterator *) FLPURE
uint32_t FLArrayIterator_GetCount (const FLArrayIterator *) FLPURE
 Returns the number of items remaining to be iterated, including the current one. More...
 
bool FLArrayIterator_Next (FLArrayIterator *)
 

Detailed Description

-

FLArray is a "subclass" of FLValue, representing values that are arrays.

-

It's always OK to pass an FLArray to a function parameter expecting an FLValue, even though the compiler makes you use an explicit type-cast. It's safe to type-cast the other direction, from FLValue to FLArray, only if you already know that the value is an array, e.g. by having called FLValue_GetType on it. But it's safer to call FLValue_AsArray instead, since it will return NULL if the value isn't an array.

-

Enumeration Type Documentation

- -

◆ FLCopyFlags

- -
-
- - - - -
enum FLCopyFlags
-
- - - - - -
Enumerator
kFLDefaultCopy 
kFLDeepCopy 
kFLCopyImmutables 
kFLDeepCopyImmutables 
- -
-
+

FLArray is a "subclass" of FLValue, representing values that are arrays.

+

It's always OK to pass an FLArray to a function parameter expecting an FLValue, even though the compiler makes you use an explicit type-cast. It's safe to type-cast the other direction, from FLValue to FLArray, only if you already know that the value is an array, e.g. by having called FLValue_GetType on it. But it's safer to call FLValue_AsArray instead, since it will return NULL if the value isn't an array.

Function Documentation

- +

◆ FLArray_AsMutable()

- + @@ -289,7 +156,7 @@

+

◆ FLArray_Count()

@@ -309,14 +176,14 @@

+

◆ FLArray_Get()

FLMutableArray FL_NULLABLE FLArray_AsMutable FLMutableArray FL_NULLABLE FLArray_AsMutable ( FLArray  FL_NULLABLE)
- + @@ -339,7 +206,7 @@

+

◆ FLArray_IsEmpty()

- - -

◆ FLArray_MutableCopy()

- -
-
-

FLValue FL_NULLABLE FLArray_Get FLValue FL_NULLABLE FLArray_Get ( FLArray  FL_NULLABLE,
- - - - - - - - - - - - - - - - - -
FLMutableArray FL_NULLABLE FLArray_MutableCopy (FLArray FL_NULLABLE,
FLCopyFlags  
)
-
- -

Creates a new mutable Array that's a copy of the source Array.

-

Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.

-

Copying an immutable Array is very cheap (only one small allocation) unless the flag kFLCopyImmutables is set.

-

Copying a mutable Array is cheap if it's a shallow copy, but if deepCopy is true, nested mutable Arrays and Dicts are also copied, recursively; if kFLCopyImmutables is also set, immutable values are also copied.

-

If the source Array is NULL, then NULL is returned.

+

Depending on the array's representation, this can be faster than FLArray_Count(a) == 0

- +

◆ FLArrayIterator_Begin()

@@ -421,11 +254,11 @@

Initializes a FLArrayIterator struct to iterate over an array.

-

Call FLArrayIteratorGetValue to get the first item, then FLArrayIteratorNext.

+

Call FLArrayIteratorGetValue to get the first item, then FLArrayIteratorNext.

- +

◆ FLArrayIterator_GetCount()

@@ -445,14 +278,14 @@

+

◆ FLArrayIterator_GetValue()

- + @@ -465,14 +298,14 @@

+

◆ FLArrayIterator_GetValueAt()

FLValue FL_NULLABLE FLArrayIterator_GetValue FLValue FL_NULLABLE FLArrayIterator_GetValue ( const FLArrayIterator )
- + @@ -495,7 +328,7 @@

+

◆ FLArrayIterator_Next()

@@ -515,274 +348,9 @@

-

◆ FLMutableArray_AppendArray()

- -
-
-

FLValue FL_NULLABLE FLArrayIterator_GetValueAt FLValue FL_NULLABLE FLArrayIterator_GetValueAt ( const FLArrayIterator ,
- - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendArray (FLMutableArray a,
FLArray val 
)
-
-inlinestatic
-
- -

Appends a Fleece array to an array.

- -
-
- -

◆ FLMutableArray_AppendBool()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendBool (FLMutableArray a,
bool val 
)
-
-inlinestatic
-
- -

Appends a boolean value to an array.

- -
-
- -

◆ FLMutableArray_AppendData()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendData (FLMutableArray a,
FLSlice val 
)
-
-inlinestatic
-
- -

Appends a binary data blob to an array.

- -
-
- -

◆ FLMutableArray_AppendDict()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendDict (FLMutableArray a,
FLDict val 
)
-
-inlinestatic
-
- -

Appends a Fleece dictionary to an array.

- -
-
- -

◆ FLMutableArray_AppendDouble()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendDouble (FLMutableArray a,
double val 
)
-
-inlinestatic
-
- -

Appends a 64-bit floating point number to an array.

- -
-
- -

◆ FLMutableArray_AppendFloat()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendFloat (FLMutableArray a,
float val 
)
-
-inlinestatic
-
- -

Appends a 32-bit floating-point number to an array.

- -
-
- -

◆ FLMutableArray_AppendInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendInt (FLMutableArray a,
int64_t val 
)
-
-inlinestatic
-
- -

Appends an integer to an array.

- -
-
- -

◆ FLMutableArray_AppendNull()

+

Variable Documentation

+ +

◆ kFLEmptyArray

- -

◆ FLMutableArray_AppendString()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendString (FLMutableArray a,
FLString val 
)
-
-inlinestatic
-
- -

Appends a UTF-8-encoded string to an array.

- -
-
- -

◆ FLMutableArray_AppendUInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendUInt (FLMutableArray a,
uint64_t val 
)
-
-inlinestatic
-
- -

Appends an unsigned integer to an array.

-
Note
: The only time this needs to be called, instead of FLMutableArray_AppendInt, is if the value is greater than or equal to 2^63 and won't fit in an int64_t.
- -
-
- -

◆ FLMutableArray_AppendValue()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_AppendValue (FLMutableArray a,
FLValue val 
)
-
-inlinestatic
-
- -

Appends a Fleece value to an array.

- -
-
- -

◆ FLMutableArray_GetMutableArray()

- -
-
- - - - - - - - - - - - - - - - - - -
FLMutableArray FL_NULLABLE FLMutableArray_GetMutableArray (FLMutableArray FL_NULLABLE,
uint32_t index 
)
-
- -

Convenience function for getting an array-valued property in mutable form.

-
    -
  • If the value for the key is not an array, returns NULL.
  • -
  • If the value is a mutable array, returns it.
  • -
  • If the value is an immutable array, this function makes a mutable copy, assigns the copy as the property value, and returns the copy.
  • -
- -
-
- -

◆ FLMutableArray_GetMutableDict()

- -
-
- - - - - - - - - - - - - - - - - - -
FLMutableDict FL_NULLABLE FLMutableArray_GetMutableDict (FLMutableArray FL_NULLABLE,
uint32_t index 
)
-
- -

Convenience function for getting an array-valued property in mutable form.

-
    -
  • If the value for the key is not an array, returns NULL.
  • -
  • If the value is a mutable array, returns it.
  • -
  • If the value is an immutable array, this function makes a mutable copy, assigns the copy as the property value, and returns the copy.
  • -
- -
-
- -

◆ FLMutableArray_GetSource()

- -
-
- - - - - - - - -
FLArray FL_NULLABLE FLMutableArray_GetSource (FLMutableArray FL_NULLABLE)
-
- -

If the Array was created by FLArray_MutableCopy, returns the original source Array.

- -
-
- -

◆ FLMutableArray_Insert()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
void FLMutableArray_Insert (FLMutableArray FL_NULLABLE array,
uint32_t firstIndex,
uint32_t count 
)
-
- -

Inserts a contiguous range of JSON null values into the array.

-
Parameters
- - - - -
arrayThe array to operate on.
firstIndexThe zero-based index of the first value to be inserted.
countThe number of items to insert.
-
-
- -
-
- -

◆ FLMutableArray_IsChanged()

- -
-
- - - - - - - - -
bool FLMutableArray_IsChanged (FLMutableArray FL_NULLABLE)
-
- -

Returns true if the Array has been changed from the source it was copied from.

- -
-
- -

◆ FLMutableArray_New()

- -
-
- - - - - - - - -
FLMutableArray FL_NULLABLE FLMutableArray_New (void )
-
- -

Creates a new empty mutable Array.

-

Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.
-

- -
-
- -

◆ FLMutableArray_NewFromJSON()

- -
-
- - - - - - - - - - - - - - - - - - -
FLMutableArray FL_NULLABLE FLMutableArray_NewFromJSON (FLString json,
FLError *FL_NULLABLE outError 
)
-
- -

Creates a new mutable Array from JSON.

-

The input json must represent a JSON array or NULL will be returned. Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.
-

- -
-
- -

◆ FLMutableArray_Release()

- -
-
- - - - - -
- - - - - - - - -
static void FLMutableArray_Release (FLMutableArray FL_NULLABLE d)
-
-inlinestatic
-
- -

Decrements the refcount of (and possibly frees) a mutable Array.

- -
-
- -

◆ FLMutableArray_Remove()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
void FLMutableArray_Remove (FLMutableArray FL_NULLABLE array,
uint32_t firstIndex,
uint32_t count 
)
-
- -

Removes contiguous items from the array.

-
Parameters
- - - - -
arrayThe array to operate on.
firstIndexThe zero-based index of the first item to remove.
countThe number of items to remove.
-
-
- -
-
- -

◆ FLMutableArray_Resize()

- -
-
- - - - - - - - - - - - - - - - - - -
void FLMutableArray_Resize (FLMutableArray FL_NULLABLE array,
uint32_t size 
)
-
- -

Changes the size of an array.

-

If the new size is larger, the array is padded with JSON null values. If it's smaller, values are removed from the end.

- -
-
- -

◆ FLMutableArray_Retain()

- -
-
- - - - - -
- - - - - - - - -
static FLMutableArray FL_NULLABLE FLMutableArray_Retain (FLMutableArray FL_NULLABLE d)
-
-inlinestatic
-
- -

Increments the ref-count of a mutable Array.

- -
-
- -

◆ FLMutableArray_SetArray()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetArray (FLMutableArray a,
uint32_t index,
FLArray val 
)
-
-inlinestatic
-
- -

Stores a Fleece array into an array.

- -
-
- -

◆ FLMutableArray_SetBool()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetBool (FLMutableArray a,
uint32_t index,
bool val 
)
-
-inlinestatic
-
- -

Stores a boolean value into an array.

- -
-
- -

◆ FLMutableArray_SetChanged()

- -
-
- - - - - - - - - - - - - - - - - - -
void FLMutableArray_SetChanged (FLMutableArray FL_NULLABLE,
bool  
)
-
- -

Sets or clears the mutable Array's "changed" flag.

- -
-
- -

◆ FLMutableArray_SetData()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetData (FLMutableArray a,
uint32_t index,
FLSlice val 
)
-
-inlinestatic
-
- -

Stores a binary data blob into an array.

- -
-
- -

◆ FLMutableArray_SetDict()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetDict (FLMutableArray a,
uint32_t index,
FLDict val 
)
-
-inlinestatic
-
- -

Stores a Fleece dictionary into an array.

- -
-
- -

◆ FLMutableArray_SetDouble()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetDouble (FLMutableArray a,
uint32_t index,
double val 
)
-
-inlinestatic
-
- -

Stores a 64-bit floating point number into an array.

- -
-
- -

◆ FLMutableArray_SetFloat()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetFloat (FLMutableArray a,
uint32_t index,
float val 
)
-
-inlinestatic
-
- -

Stores a 32-bit floating-point number into an array.

- -
-
- -

◆ FLMutableArray_SetInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetInt (FLMutableArray a,
uint32_t index,
int64_t val 
)
-
-inlinestatic
-
- -

Stores an integer into an array.

- -
-
- -

◆ FLMutableArray_SetNull()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetNull (FLMutableArray a,
uint32_t index 
)
-
-inlinestatic
-
- -

Stores a JSON null value into an array.

- -
-
- -

◆ FLMutableArray_SetString()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetString (FLMutableArray a,
uint32_t index,
FLString val 
)
-
-inlinestatic
-
- -

Stores a UTF-8-encoded string into an array.

- -
-
- -

◆ FLMutableArray_SetUInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetUInt (FLMutableArray a,
uint32_t index,
uint64_t val 
)
-
-inlinestatic
-
- -

Stores an unsigned integer into an array.

-
Note
: The only time this needs to be called, instead of FLMutableArray_SetInt, is if the value is greater than or equal to 2^63 and won't fit in an int64_t.
- -
-
- -

◆ FLMutableArray_SetValue()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableArray_SetValue (FLMutableArray a,
uint32_t index,
FLValue val 
)
-
-inlinestatic
-
- -

Stores a Fleece value into an array.

- -
-
-

Variable Documentation

- -

◆ kFLEmptyArray

- -
-
- - - - - -
- - - - -
FLEECE_PUBLIC const FLArray kFLEmptyArray
-
-extern
-
+

A constant empty array value.

diff --git a/docs/C/html/group___f_l_deep_iterator.html b/docs/C/html/group___f_l_deep_iterator.html index 5e11da319f..04132b2a80 100644 --- a/docs/C/html/group___f_l_deep_iterator.html +++ b/docs/C/html/group___f_l_deep_iterator.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece Deep Iterator @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -66,36 +67,35 @@ Data Structures | Typedefs | Functions

-
-
Fleece Deep Iterator
+
Fleece Deep Iterator

A deep iterator traverses every value contained in a dictionary, in depth-first order. More...

-

+

Data Structures

struct  FLPathComponent
 
-

+

Typedefs

typedef struct _FLDeepIterator * FLDeepIterator
 A reference to a deep iterator. More...
 
- - + - + - + - + @@ -113,7 +113,7 @@ - + @@ -124,10 +124,10 @@

+

Functions

FLDeepIterator FLDeepIterator_New (FLValue FL_NULLABLE)
FLDeepIterator FLDeepIterator_New (FLValue FL_NULLABLE)
 Creates a FLDeepIterator to iterate over a dictionary. More...
 
void FLDeepIterator_Free (FLDeepIterator FL_NULLABLE)
void FLDeepIterator_Free (FLDeepIterator FL_NULLABLE)
 
FLValue FL_NULLABLE FLDeepIterator_GetValue (FLDeepIterator)
FLValue FL_NULLABLE FLDeepIterator_GetValue (FLDeepIterator)
 Returns the current value being iterated over. More...
 
FLValue FL_NULLABLE FLDeepIterator_GetParent (FLDeepIterator)
FLValue FL_NULLABLE FLDeepIterator_GetParent (FLDeepIterator)
 Returns the parent/container of the current value, or NULL at the end of iteration. More...
 
FLSlice FLDeepIterator_GetKey (FLDeepIterator)
bool FLDeepIterator_Next (FLDeepIterator)
 Advances the iterator to the next value, or returns false if at the end. More...
 
void FLDeepIterator_GetPath (FLDeepIterator, FLPathComponent *FL_NONNULL *FL_NONNULL outPath, size_t *outDepth)
void FLDeepIterator_GetPath (FLDeepIterator, FLPathComponent *FL_NONNULL *FL_NONNULL outPath, size_t *outDepth)
 Returns the path as an array of FLPathComponents. More...
 
FLSliceResult FLDeepIterator_GetPathString (FLDeepIterator)
 

Detailed Description

-

A deep iterator traverses every value contained in a dictionary, in depth-first order.

-

You can skip any nested collection by calling FLDeepIterator_SkipChildren.

+

A deep iterator traverses every value contained in a dictionary, in depth-first order.

+

You can skip any nested collection by calling FLDeepIterator_SkipChildren.

Typedef Documentation

- +

◆ FLDeepIterator

@@ -144,7 +144,7 @@

Function Documentation

- +

◆ FLDeepIterator_Free()

@@ -162,7 +162,7 @@

+

◆ FLDeepIterator_GetDepth()

@@ -182,7 +182,7 @@

+

◆ FLDeepIterator_GetIndex()

@@ -202,7 +202,7 @@

+

◆ FLDeepIterator_GetJSONPointer()

@@ -222,7 +222,7 @@

+

◆ FLDeepIterator_GetKey()

@@ -242,14 +242,14 @@

+

◆ FLDeepIterator_GetParent()

- + @@ -262,7 +262,7 @@

+

◆ FLDeepIterator_GetPath()

@@ -277,7 +277,7 @@

- + @@ -298,7 +298,7 @@

+

◆ FLDeepIterator_GetPathString()

@@ -318,14 +318,14 @@

+

◆ FLDeepIterator_GetValue()

FLValue FL_NULLABLE FLDeepIterator_GetParent FLValue FL_NULLABLE FLDeepIterator_GetParent ( FLDeepIterator  )FLPathComponent *FL_NONNULL *FL_NONNULL FLPathComponent *FL_NONNULL *FL_NONNULL  outPath,
- + @@ -335,11 +335,11 @@

Returns the current value being iterated over.

-

or NULL at the end of iteration.

+

or NULL at the end of iteration.

-
+

◆ FLDeepIterator_New()

- +

◆ FLDeepIterator_Next()

@@ -380,7 +380,7 @@

+

◆ FLDeepIterator_SkipChildren()

@@ -403,7 +403,7 @@

diff --git a/docs/C/html/group___f_l_dict.html b/docs/C/html/group___f_l_dict.html index 1c2a02ecbd..5bc788464b 100644 --- a/docs/C/html/group___f_l_dict.html +++ b/docs/C/html/group___f_l_dict.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece Dictionaries @@ -30,21 +30,22 @@

FLValue FL_NULLABLE FLDeepIterator_GetValue FLValue FL_NULLABLE FLDeepIterator_GetValue ( FLDeepIterator  )
- + +/* @license-end */ +
@@ -66,12 +67,11 @@ Data Structures | Functions | Variables

-
-
Fleece Dictionaries
+
Fleece Dictionaries

- @@ -80,57 +80,58 @@

+

Data Structures

struct  FLDictIterator
 Opaque dictionary iterator. More...
 Opaque key for a dictionary. More...
 
- - + - + - + - +

+

Functions

uint32_t FLDict_Count (FLDict FL_NULLABLE) FLPURE
uint32_t FLDict_Count (FLDict FL_NULLABLE) FLPURE
 Returns the number of items in a dictionary, or 0 if the pointer is NULL. More...
 
bool FLDict_IsEmpty (FLDict FL_NULLABLE) FLPURE
bool FLDict_IsEmpty (FLDict FL_NULLABLE) FLPURE
 Returns true if a dictionary is empty (or NULL). More...
 
FLMutableDict FL_NULLABLE FLDict_AsMutable (FLDict FL_NULLABLE) FLPURE
FLMutableDict FL_NULLABLE FLDict_AsMutable (FLDict FL_NULLABLE) FLPURE
 If the dictionary is mutable, returns it cast to FLMutableDict, else NULL. More...
 
FLValue FL_NULLABLE FLDict_Get (FLDict FL_NULLABLE, FLSlice keyString) FLPURE
FLValue FL_NULLABLE FLDict_Get (FLDict FL_NULLABLE, FLSlice keyString) FLPURE
 Looks up a key in a dictionary, returning its value. More...
 
- - + +

+

Variables

FLEECE_PUBLIC const FLDict kFLEmptyDict
FLEECE_PUBLIC const FLDict kFLEmptyDict
 A constant empty array value. More...
 
- - + - + - + - + @@ -147,91 +148,20 @@ - + -

Dict iteration

Iterating a dictionary typically looks like this:

-
-
FLDictIterator_Begin(theDict, &iter);
-
FLValue value;
-
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
- +

Iterating a dictionary typically looks like this:

+
+
FLDictIterator_Begin(theDict, &iter);
+
FLValue value;
+
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
+
// ...
- +
}
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
FLValue FL_NULLABLE FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
void FLDictIterator_Begin(FLDict FL_NULLABLE, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:51
-
Opaque dictionary iterator.
Definition: Fleece.h:644
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:51
+
Opaque dictionary iterator.
Definition: FLCollections.h:144
A simple reference to a block of memory.
Definition: FLSlice.h:48
void FLDictIterator_Begin (FLDict FL_NULLABLE, FLDictIterator *)
void FLDictIterator_Begin (FLDict FL_NULLABLE, FLDictIterator *)
 Initializes a FLDictIterator struct to iterate over a dictionary. More...
 
FLValue FL_NULLABLE FLDictIterator_GetKey (const FLDictIterator *) FLPURE
FLValue FL_NULLABLE FLDictIterator_GetKey (const FLDictIterator *) FLPURE
 Returns the current key being iterated over. More...
 
FLString FLDictIterator_GetKeyString (const FLDictIterator *)
 Returns the current key's string value. More...
 
FLValue FL_NULLABLE FLDictIterator_GetValue (const FLDictIterator *) FLPURE
FLValue FL_NULLABLE FLDictIterator_GetValue (const FLDictIterator *) FLPURE
 Returns the current value being iterated over. More...
 
uint32_t FLDictIterator_GetCount (const FLDictIterator *) FLPURE
uint32_t FLDictIterator_GetCount (const FLDictIterator *) FLPURE
 Returns the number of items remaining to be iterated, including the current one. More...
 
bool FLDictIterator_Next (FLDictIterator *)
FLString FLDictKey_GetString (const FLDictKey *)
 Returns the string value of the key (which it was initialized with.) More...
 
FLValue FL_NULLABLE FLDict_GetWithKey (FLDict FL_NULLABLE, FLDictKey *)
FLValue FL_NULLABLE FLDict_GetWithKey (FLDict FL_NULLABLE, FLDictKey *)
 Looks up a key in a dictionary using an FLDictKey. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Mutable dictionaries

FLMutableDict FL_NULLABLE FLDict_MutableCopy (FLDict FL_NULLABLE source, FLCopyFlags)
 Creates a new mutable Dict that's a copy of the source Dict. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_New (void)
 Creates a new empty mutable Dict. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_NewFromJSON (FLString json, FLError *FL_NULLABLE outError)
 Creates a new mutable Dict from json. More...
 
static FLMutableDict FL_NULLABLE FLMutableDict_Retain (FLMutableDict FL_NULLABLE d)
 Increments the ref-count of a mutable Dict. More...
 
static void FLMutableDict_Release (FLMutableDict FL_NULLABLE d)
 Decrements the refcount of (and possibly frees) a mutable Dict. More...
 
FLDict FL_NULLABLE FLMutableDict_GetSource (FLMutableDict FL_NULLABLE)
 If the Dict was created by FLDict_MutableCopy, returns the original source Dict. More...
 
bool FLMutableDict_IsChanged (FLMutableDict FL_NULLABLE)
 Returns true if the Dict has been changed from the source it was copied from. More...
 
void FLMutableDict_SetChanged (FLMutableDict FL_NULLABLE, bool)
 Sets or clears the mutable Dict's "changed" flag. More...
 
void FLMutableDict_Remove (FLMutableDict FL_NULLABLE, FLString key)
 Removes the value for a key. More...
 
void FLMutableDict_RemoveAll (FLMutableDict FL_NULLABLE)
 Removes all keys and values. More...
 
FLMutableArray FL_NULLABLE FLMutableDict_GetMutableArray (FLMutableDict FL_NULLABLE, FLString key)
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FL_NULLABLE FLMutableDict_GetMutableDict (FLMutableDict FL_NULLABLE, FLString key)
 Convenience function for getting a dict-valued property in mutable form. More...
 
static void FLMutableDict_SetNull (FLMutableDict, FLString key)
 Stores a JSON null value into a mutable dictionary. More...
 
static void FLMutableDict_SetBool (FLMutableDict, FLString key, bool)
 Stores a boolean value into a mutable dictionary. More...
 
static void FLMutableDict_SetInt (FLMutableDict, FLString key, int64_t)
 Stores an integer into a mutable dictionary. More...
 
static void FLMutableDict_SetUInt (FLMutableDict, FLString key, uint64_t)
 Stores an unsigned integer into a mutable dictionary. More...
 
static void FLMutableDict_SetFloat (FLMutableDict, FLString key, float)
 Stores a 32-bit floating-point number into a mutable dictionary. More...
 
static void FLMutableDict_SetDouble (FLMutableDict, FLString key, double)
 Stores a 64-bit floating point number into a mutable dictionary. More...
 
static void FLMutableDict_SetString (FLMutableDict, FLString key, FLString)
 Stores a UTF-8-encoded string into a mutable dictionary. More...
 
static void FLMutableDict_SetData (FLMutableDict, FLString key, FLSlice)
 Stores a binary data blob into a mutable dictionary. More...
 
static void FLMutableDict_SetValue (FLMutableDict, FLString key, FLValue)
 Stores a Fleece value into a mutable dictionary. More...
 
static void FLMutableDict_SetArray (FLMutableDict, FLString key, FLArray)
 Stores a Fleece array into a mutable dictionary. More...
 
static void FLMutableDict_SetDict (FLMutableDict, FLString key, FLDict)
 Stores a Fleece dictionary into a mutable dictionary. More...
 

Detailed Description

Function Documentation

- +

◆ FLDict_AsMutable()

- + @@ -244,7 +174,7 @@

+

◆ FLDict_Count()

@@ -264,14 +194,14 @@

+

◆ FLDict_Get()

FLMutableDict FL_NULLABLE FLDict_AsMutable FLMutableDict FL_NULLABLE FLDict_AsMutable ( FLDict  FL_NULLABLE)
- + @@ -291,18 +221,18 @@

Looks up a key in a dictionary, returning its value.

-

Returns NULL if the value is not found or if the dictionary is NULL.

+

Returns NULL if the value is not found or if the dictionary is NULL.

-
+

◆ FLDict_GetWithKey()

FLValue FL_NULLABLE FLDict_Get FLValue FL_NULLABLE FLDict_Get ( FLDict  FL_NULLABLE,
- + @@ -322,11 +252,11 @@

Looks up a key in a dictionary using an FLDictKey.

-

If the key is found, "hint" data will be stored inside the FLDictKey that will speed up subsequent lookups.

+

If the key is found, "hint" data will be stored inside the FLDictKey that will speed up subsequent lookups.

- +

◆ FLDict_IsEmpty()

- - -

◆ FLDict_MutableCopy()

- -
-
-

FLValue FL_NULLABLE FLDict_GetWithKey FLValue FL_NULLABLE FLDict_GetWithKey ( FLDict  FL_NULLABLE,
- - - - - - - - - - - - - - - - - -
FLMutableDict FL_NULLABLE FLDict_MutableCopy (FLDict FL_NULLABLE source,
FLCopyFlags  
)
-
- -

Creates a new mutable Dict that's a copy of the source Dict.

-

Its initial ref-count is 1, so a call to FLMutableDict_Release will free it.

-

Copying an immutable Dict is very cheap (only one small allocation.) The deepCopy flag is ignored.

-

Copying a mutable Dict is cheap if it's a shallow copy, but if deepCopy is true, nested mutable Dicts and Arrays are also copied, recursively.

-

If the source dict is NULL, then NULL is returned.

+

Depending on the dictionary's representation, this can be faster than FLDict_Count(a) == 0

- +

◆ FLDictIterator_Begin()

@@ -408,11 +304,11 @@

Initializes a FLDictIterator struct to iterate over a dictionary.

-

Call FLDictIterator_GetKey and FLDictIterator_GetValue to get the first item, then FLDictIterator_Next.

+

Call FLDictIterator_GetKey and FLDictIterator_GetValue to get the first item, then FLDictIterator_Next.

- +

◆ FLDictIterator_End()

- +

◆ FLDictIterator_GetCount()

@@ -453,14 +349,14 @@

+

◆ FLDictIterator_GetKey()

- + @@ -470,11 +366,11 @@

Returns the current key being iterated over.

-

This Value will be a string or an integer.

+

This Value will be a string or an integer.

-
+

◆ FLDictIterator_GetKeyString()

@@ -494,14 +390,14 @@

+

◆ FLDictIterator_GetValue()

FLValue FL_NULLABLE FLDictIterator_GetKey FLValue FL_NULLABLE FLDictIterator_GetKey ( const FLDictIterator )
- + @@ -514,7 +410,7 @@

+

◆ FLDictIterator_Next()

@@ -534,7 +430,7 @@

+

◆ FLDictKey_GetString()

@@ -554,7 +450,7 @@

+

◆ FLDictKey_Init()

@@ -582,278 +478,9 @@

-

◆ FLMutableDict_GetMutableArray()

- -
-
-

FLValue FL_NULLABLE FLDictIterator_GetValue FLValue FL_NULLABLE FLDictIterator_GetValue ( const FLDictIterator )
- - - - - - - - - - - - - - - - - -
FLMutableArray FL_NULLABLE FLMutableDict_GetMutableArray (FLMutableDict FL_NULLABLE,
FLString key 
)
-
- -

Convenience function for getting an array-valued property in mutable form.

-
    -
  • If the value for the key is not an array, returns NULL.
  • -
  • If the value is a mutable array, returns it.
  • -
  • If the value is an immutable array, this function makes a mutable copy, assigns the copy as the property value, and returns the copy.
  • -
- -
-
- -

◆ FLMutableDict_GetMutableDict()

- -
-
- - - - - - - - - - - - - - - - - - -
FLMutableDict FL_NULLABLE FLMutableDict_GetMutableDict (FLMutableDict FL_NULLABLE,
FLString key 
)
-
- -

Convenience function for getting a dict-valued property in mutable form.

-
    -
  • If the value for the key is not a dict, returns NULL.
  • -
  • If the value is a mutable dict, returns it.
  • -
  • If the value is an immutable dict, this function makes a mutable copy, assigns the copy as the property value, and returns the copy.
  • -
- -
-
- -

◆ FLMutableDict_GetSource()

- -
-
- - - - - - - - -
FLDict FL_NULLABLE FLMutableDict_GetSource (FLMutableDict FL_NULLABLE)
-
- -

If the Dict was created by FLDict_MutableCopy, returns the original source Dict.

- -
-
- -

◆ FLMutableDict_IsChanged()

- -
-
- - - - - - - - -
bool FLMutableDict_IsChanged (FLMutableDict FL_NULLABLE)
-
- -

Returns true if the Dict has been changed from the source it was copied from.

- -
-
- -

◆ FLMutableDict_New()

- -
-
- - - - - - - - -
FLMutableDict FL_NULLABLE FLMutableDict_New (void )
-
- -

Creates a new empty mutable Dict.

-

Its initial ref-count is 1, so a call to FLMutableDict_Release will free it.
-

- -
-
- -

◆ FLMutableDict_NewFromJSON()

- -
-
- - - - - - - - - - - - - - - - - - -
FLMutableDict FL_NULLABLE FLMutableDict_NewFromJSON (FLString json,
FLError *FL_NULLABLE outError 
)
-
- -

Creates a new mutable Dict from json.

-

The input JSON must represent a JSON array, or NULL will be returned. Its initial ref-count is 1, so a call to FLMutableDict_Release will free it.
-

- -
-
- -

◆ FLMutableDict_Release()

- -
-
- - - - - -
- - - - - - - - -
static void FLMutableDict_Release (FLMutableDict FL_NULLABLE d)
-
-inlinestatic
-
- -

Decrements the refcount of (and possibly frees) a mutable Dict.

- -
-
- -

◆ FLMutableDict_Remove()

- -
-
- - - - - - - - - - - - - - - - - - -
void FLMutableDict_Remove (FLMutableDict FL_NULLABLE,
FLString key 
)
-
- -

Removes the value for a key.

- -
-
- -

◆ FLMutableDict_RemoveAll()

- -
-
- - - - - - - - -
void FLMutableDict_RemoveAll (FLMutableDict FL_NULLABLE)
-
- -

Removes all keys and values.

- -
-
- -

◆ FLMutableDict_Retain()

- -
-
- - - - - -
- - - - - - - - -
static FLMutableDict FL_NULLABLE FLMutableDict_Retain (FLMutableDict FL_NULLABLE d)
-
-inlinestatic
-
- -

Increments the ref-count of a mutable Dict.

- -
-
- -

◆ FLMutableDict_SetArray()

+

Variable Documentation

+ +

◆ kFLEmptyDict

- -

◆ FLMutableDict_SetBool()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetBool (FLMutableDict d,
FLString key,
bool val 
)
-
-inlinestatic
-
- -

Stores a boolean value into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetChanged()

- -
-
- - - - - - - - - - - - - - - - - - -
void FLMutableDict_SetChanged (FLMutableDict FL_NULLABLE,
bool  
)
-
- -

Sets or clears the mutable Dict's "changed" flag.

- -
-
- -

◆ FLMutableDict_SetData()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetData (FLMutableDict d,
FLString key,
FLSlice val 
)
-
-inlinestatic
-
- -

Stores a binary data blob into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetDict()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetDict (FLMutableDict d,
FLString key,
FLDict val 
)
-
-inlinestatic
-
- -

Stores a Fleece dictionary into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetDouble()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetDouble (FLMutableDict d,
FLString key,
double val 
)
-
-inlinestatic
-
- -

Stores a 64-bit floating point number into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetFloat()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetFloat (FLMutableDict d,
FLString key,
float val 
)
-
-inlinestatic
-
- -

Stores a 32-bit floating-point number into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetInt (FLMutableDict d,
FLString key,
int64_t val 
)
-
-inlinestatic
-
- -

Stores an integer into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetNull()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetNull (FLMutableDict d,
FLString key 
)
-
-inlinestatic
-
- -

Stores a JSON null value into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetString()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetString (FLMutableDict d,
FLString key,
FLString val 
)
-
-inlinestatic
-
- -

Stores a UTF-8-encoded string into a mutable dictionary.

- -
-
- -

◆ FLMutableDict_SetUInt()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetUInt (FLMutableDict d,
FLString key,
uint64_t val 
)
-
-inlinestatic
-
- -

Stores an unsigned integer into a mutable dictionary.

-
Note
: The only time this needs to be called, instead of FLMutableDict_SetInt, is if the value is greater than or equal to 2^63 and won't fit in an int64_t.
- -
-
- -

◆ FLMutableDict_SetValue()

- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
static void FLMutableDict_SetValue (FLMutableDict d,
FLString key,
FLValue val 
)
-
-inlinestatic
-
- -

Stores a Fleece value into a mutable dictionary.

- -
-
-

Variable Documentation

- -

◆ kFLEmptyDict

- -
-
- - - - - -
- - - - -
FLEECE_PUBLIC const FLDict kFLEmptyDict
-
-extern
-
+

A constant empty array value.

diff --git a/docs/C/html/group___f_l_encoder.html b/docs/C/html/group___f_l_encoder.html index b59fff369a..2955974d8b 100644 --- a/docs/C/html/group___f_l_encoder.html +++ b/docs/C/html/group___f_l_encoder.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece Encoders @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -62,8 +63,7 @@
-
-
Fleece Encoders
+
Fleece Encoders
@@ -86,39 +86,27 @@ FLEncoder FLEncoder_NewWritingToFile (FILE *, bool uniqueStrings)  Creates a new Fleece encoder that writes to a file, not to memory. More...
  -void FLEncoder_Free (FLEncoder FL_NULLABLE) +void FLEncoder_Free (FLEncoder FL_NULLABLE)  Frees the space used by an encoder. More...
  -void FLEncoder_SetSharedKeys (FLEncoder, FLSharedKeys FL_NULLABLE) +void FLEncoder_SetSharedKeys (FLEncoder, FLSharedKeys FL_NULLABLE)  Tells the encoder to use a shared-keys mapping when encoding dictionary keys. More...
  -void FLEncoder_SetExtraInfo (FLEncoder, void *FL_NULLABLE info) +void FLEncoder_SetExtraInfo (FLEncoder, void *FL_NULLABLE info)  Associates an arbitrary user-defined value with the encoder. More...
  -void * FLEncoder_GetExtraInfo (FLEncoder) - Returns the user-defined value associated with the encoder; NULL by default. More...
-  -void FLEncoder_Amend (FLEncoder e, FLSlice base, bool reuseStrings, bool externPointers) - Tells the encoder to logically append to the given Fleece document, rather than making a standalone document. More...
-  -FLSlice FLEncoder_GetBase (FLEncoder) - Returns the base value passed to FLEncoder_Amend. More...
-  -void FLEncoder_SuppressTrailer (FLEncoder) - Tells the encoder not to write the two-byte Fleece trailer at the end of the data. More...
-  +void * FLEncoder_GetExtraInfo (FLEncoder) + Returns the user-defined value associated with the encoder; NULL by default. More...
+  void FLEncoder_Reset (FLEncoder)  Resets the state of an encoder without freeing it. More...
  size_t FLEncoder_BytesWritten (FLEncoder)  Returns the number of bytes encoded so far. More...
  -size_t FLEncoder_GetNextWritePos (FLEncoder) - Returns the byte offset in the encoded data where the next value will be written. More...
-  - @@ -145,15 +133,15 @@ - + - - - + + + @@ -172,30 +160,15 @@ - - - - - - - - - - - - - - - + + +

Writing to the encoder

Note
The functions that write to the encoder do not return error codes, just a 'false' result on error. The actual error is attached to the encoder and can be accessed by calling FLEncoder_GetError or FLEncoder_End.
+

Note
The functions that write to the encoder do not return error codes, just a 'false' result on error. The actual error is attached to the encoder and can be accessed by calling FLEncoder_GetError or FLEncoder_End.

After an error occurs, the encoder will ignore all subsequent writes.

bool FLEncoder_WriteNull (FLEncoder)
bool FLEncoder_WriteString (FLEncoder, FLString)
 Writes a string to an encoder. More...
 
bool FLEncoder_WriteDateString (FLEncoder encoder, FLTimestamp ts, bool asUTC)
bool FLEncoder_WriteDateString (FLEncoder encoder, FLTimestamp ts, bool asUTC)
 Writes a timestamp to an encoder, as an ISO-8601 date string. More...
 
bool FLEncoder_WriteData (FLEncoder, FLSlice)
 Writes a binary data value (a blob) to an encoder. More...
 
bool FLEncoder_WriteRaw (FLEncoder, FLSlice)
 Writes raw data directly to the encoded output. More...
 
bool FLEncoder_WriteValue (FLEncoder, FLValue)
 Writes a Fleece Value to an Encoder. More...
 
bool FLEncoder_BeginArray (FLEncoder, size_t reserveCount)
 Begins writing an array value to an encoder. More...
 
bool FLEncoder_EndDict (FLEncoder)
 Ends writing a dictionary value; pops back the previous encoding state. More...
 
bool FLEncoder_WriteValue (FLEncoder, FLValue)
 Writes a Fleece Value to an Encoder. More...
 
intptr_t FLEncoder_LastValueWritten (FLEncoder)
 Returns an opaque reference to the last complete value written to the encoder, if possible. More...
 
void FLEncoder_WriteValueAgain (FLEncoder, intptr_t preWrittenValue)
 Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten. More...
 
FLSliceResult FLEncoder_Snip (FLEncoder)
 Returns the data written so far as a standalone Fleece document, whose root is the last value written. More...
 
bool FLEncoder_ConvertJSON (FLEncoder, FLSlice json)
 Parses JSON data and writes the object(s) to the encoder. More...
 
bool FLEncoder_WriteRaw (FLEncoder, FLSlice)
 Writes raw data directly to the encoded output. More...
 
- - - - + - +

Finishing up

size_t FLEncoder_FinishItem (FLEncoder)
 Finishes encoding the current item, and returns its offset in the output data. More...
 
MUST_USE_RESULT FLDoc FL_NULLABLE FLEncoder_FinishDoc (FLEncoder, FLError *FL_NULLABLE outError)
MUST_USE_RESULT FLDoc FL_NULLABLE FLEncoder_FinishDoc (FLEncoder, FLError *FL_NULLABLE outError)
 Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc. More...
 
MUST_USE_RESULT FLSliceResult FLEncoder_Finish (FLEncoder, FLError *FL_NULLABLE outError)
MUST_USE_RESULT FLSliceResult FLEncoder_Finish (FLEncoder, FLError *FL_NULLABLE outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null. More...
 
@@ -203,15 +176,15 @@ - - - + + +
FLError FLEncoder_GetError (FLEncoder)
 Returns the error code of an encoder, or NoError (0) if there's no error. More...
 
const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 

Detailed Description

-

An FLEncoder generates encoded Fleece or JSON data.

-

It's sort of a structured output stream, with nesting. There are functions for writing every type of scalar value, and for beginning and ending collections. To write a collection you begin it, write its values, then end it. (Of course a value in a collection can itself be another collection.) When writing a dictionary, you have to call writeKey before writing each value.

+

An FLEncoder generates encoded Fleece or JSON data.

+

It's sort of a structured output stream, with nesting. There are functions for writing every type of scalar value, and for beginning and ending collections. To write a collection you begin it, write its values, then end it. (Of course a value in a collection can itself be another collection.) When writing a dictionary, you have to call writeKey before writing each value.

Enumeration Type Documentation

- +

◆ FLEncoderFormat

@@ -225,69 +198,18 @@

-EnumeratorkFLEncodeFleece 

Fleece encoding.

+EnumeratorkFLEncodeFleece 

Fleece encoding.

-kFLEncodeJSON 

JSON encoding.

+kFLEncodeJSON 

JSON encoding.

-kFLEncodeJSON5 

JSON5, an extension of JSON with a more readable syntax

+kFLEncodeJSON5 

JSON5, an extension of JSON with a more readable syntax

Function Documentation

- -

◆ FLEncoder_Amend()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FLEncoder_Amend (FLEncoder e,
FLSlice base,
bool reuseStrings,
bool externPointers 
)
-
- -

Tells the encoder to logically append to the given Fleece document, rather than making a standalone document.

-

Any calls to FLEncoder_WriteValue() where the value points inside the base data will write a pointer back to the original value. The resulting data returned by FLEncoder_FinishDoc() will NOT be standalone; it can only be used by first appending it to the base data.

Parameters
- - - - - -
eThe FLEncoder affected.
baseThe base document to create an amendment of.
reuseStringsIf true, then writing a string that already exists in the base will just create a pointer back to the original. But the encoder has to scan the base for strings first.
externPointersIf true, pointers into the base will be marked with the extern flag. This allows them to be resolved using the FLResolver_Begin function, so that when the delta is used the base document can be anywhere in memory, not just immediately preceding the delta document.
-
-
- -
-
- +

◆ FLEncoder_BeginArray()

@@ -314,7 +236,7 @@

Begins writing an array value to an encoder.

-

This pushes a new state where each subsequent value written becomes an array item, until FLEncoder_EndArray is called.

Parameters
+

This pushes a new state where each subsequent value written becomes an array item, until FLEncoder_EndArray is called.

Parameters
reserveCountNumber of array elements to reserve space for. If you know the size of the array, providing it here speeds up encoding slightly. If you don't know, just use zero.
@@ -323,7 +245,7 @@

+

◆ FLEncoder_BeginDict()

@@ -350,7 +272,7 @@

Begins writing a dictionary value to an encoder.

-

This pushes a new state where each subsequent key and value written are added to the dictionary, until FLEncoder_EndDict is called. Before adding each value, you must call FLEncoder_WriteKey (not FLEncoder_WriteString!), to write the dictionary key.

Parameters
+

This pushes a new state where each subsequent key and value written are added to the dictionary, until FLEncoder_EndDict is called. Before adding each value, you must call FLEncoder_WriteKey (not FLEncoder_WriteString!), to write the dictionary key.

Parameters
reserveCountNumber of dictionary items to reserve space for. If you know the size of the dictionary, providing it here speeds up encoding slightly. If you don't know, just use zero.
@@ -359,7 +281,7 @@

+

◆ FLEncoder_BytesWritten()

@@ -379,38 +301,7 @@

-

◆ FLEncoder_ConvertJSON()

- -
-
- - - - - - - - - - - - - - - - - - -
bool FLEncoder_ConvertJSON (FLEncoder ,
FLSlice json 
)
-
- -

Parses JSON data and writes the object(s) to the encoder.

-

(This acts as a single write, like WriteInt; it's just that the value written is likely to be an entire dictionary of array.)

- -
-
- +

◆ FLEncoder_EndArray()

@@ -430,7 +321,7 @@

+

◆ FLEncoder_EndDict()

@@ -450,14 +341,14 @@

+

◆ FLEncoder_Finish()

- +

◆ FLEncoder_Free()

@@ -552,27 +423,7 @@

-

◆ FLEncoder_GetBase()

- -
-
- - - - - - - - -
FLSlice FLEncoder_GetBase (FLEncoder )
-
- -

Returns the base value passed to FLEncoder_Amend.

- -
-
- +

◆ FLEncoder_GetError()

@@ -592,14 +443,14 @@

-

◆ FLEncoder_GetErrorMessage()

+ +

◆ FLEncoder_GetErrorMessage()

- + @@ -612,14 +463,14 @@

-

◆ FLEncoder_GetExtraInfo()

+ +

◆ FLEncoder_GetExtraInfo()

const char* FL_NULLABLE FLEncoder_GetErrorMessage const char *FL_NULLABLE FLEncoder_GetErrorMessage ( FLEncoder  )
- + @@ -632,49 +483,7 @@

-

◆ FLEncoder_GetNextWritePos()

- -
-
-

void* FLEncoder_GetExtraInfo void * FLEncoder_GetExtraInfo ( FLEncoder  )
- - - - - - - -
size_t FLEncoder_GetNextWritePos (FLEncoder )
-
- -

Returns the byte offset in the encoded data where the next value will be written.

-

(Due to internal buffering, this is not the same as FLEncoder_BytesWritten.)

- -
-
- -

◆ FLEncoder_LastValueWritten()

- -
-
- - - - - - - - -
intptr_t FLEncoder_LastValueWritten (FLEncoder )
-
- -

Returns an opaque reference to the last complete value written to the encoder, if possible.

-

Fails (returning 0) if nothing has been written, or if the value is inline and can't be referenced this way – that only happens with small scalars or empty collections.

- -
-
- +

◆ FLEncoder_New()

- +

◆ FLEncoder_NewWithOptions()

@@ -739,7 +548,7 @@

+

◆ FLEncoder_NewWritingToFile()

- +

◆ FLEncoder_SetExtraInfo()

@@ -805,7 +614,7 @@

- void *FL_NULLABLE  + void *FL_NULLABLE  info  @@ -820,7 +629,7 @@

+

◆ FLEncoder_SetSharedKeys()

@@ -835,7 +644,7 @@

- FLSharedKeys  + FLSharedKeys  FL_NULLABLE  @@ -850,49 +659,7 @@

-

◆ FLEncoder_Snip()

- -
-
- - - - - - - - -
FLSliceResult FLEncoder_Snip (FLEncoder )
-
- -

Returns the data written so far as a standalone Fleece document, whose root is the last value written.

-

You can continue writing, and the final output returned by FLEncoder_Finish will consist of everything after this point. That second part can be used in the future by loading it as an FLDoc with the first part as its extern reference.

- -
-
- -

◆ FLEncoder_SuppressTrailer()

- -
-
- - - - - - - - -
void FLEncoder_SuppressTrailer (FLEncoder )
-
- -

Tells the encoder not to write the two-byte Fleece trailer at the end of the data.

-

This is only useful for certain special purposes.

- -
-
- +

◆ FLEncoder_WriteBool()

- +

◆ FLEncoder_WriteDateString()

@@ -968,7 +735,7 @@

- FLTimestamp  + FLTimestamp  ts, @@ -999,7 +766,7 @@

+

◆ FLEncoder_WriteDouble()

- +

◆ FLEncoder_WriteRaw()

- +

◆ FLEncoder_WriteString()

- +

◆ FLEncoder_WriteUInt()

- +

◆ FLEncoder_WriteValue()

@@ -1316,43 +1083,12 @@

-

◆ FLEncoder_WriteValueAgain()

- -
-
- - - - - - - - - - - - - - - - - - -
void FLEncoder_WriteValueAgain (FLEncoder ,
intptr_t preWrittenValue 
)
-
- -

Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten.

-

The effect is exactly the same as if you wrote the entire value again, except that the size of the encoded data only grows by 4 bytes.

-

diff --git a/docs/C/html/group___f_l_key_path.html b/docs/C/html/group___f_l_key_path.html index 61a7630047..ed58c2059f 100644 --- a/docs/C/html/group___f_l_key_path.html +++ b/docs/C/html/group___f_l_key_path.html @@ -2,8 +2,8 @@ - - + + LiteCore: Fleece Paths @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -65,32 +66,31 @@ -
-
Fleece Paths
+
Fleece Paths

An FLKeyPath Describes a location in a Fleece object tree, as a path from the root that follows dictionary properties and array elements. More...

-

+

Typedefs

typedef struct _FLKeyPath * FLKeyPath
 A reference to a key path. More...
 
- - + - + - + - + @@ -104,13 +104,13 @@

+

Functions

FLKeyPath FL_NULLABLE FLKeyPath_New (FLSlice specifier, FLError *FL_NULLABLE outError)
FLKeyPath FL_NULLABLE FLKeyPath_New (FLSlice specifier, FLError *FL_NULLABLE outError)
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 
void FLKeyPath_Free (FLKeyPath FL_NULLABLE)
void FLKeyPath_Free (FLKeyPath FL_NULLABLE)
 Frees a compiled FLKeyPath object. More...
 
FLValue FL_NULLABLE FLKeyPath_Eval (FLKeyPath, FLValue root)
FLValue FL_NULLABLE FLKeyPath_Eval (FLKeyPath, FLValue root)
 Evaluates a compiled key-path for a given Fleece root object. More...
 
FLValue FL_NULLABLE FLKeyPath_EvalOnce (FLSlice specifier, FLValue root, FLError *FL_NULLABLE outError)
FLValue FL_NULLABLE FLKeyPath_EvalOnce (FLSlice specifier, FLValue root, FLError *FL_NULLABLE outError)
 Evaluates a key-path from a specifier string, for a given Fleece root object. More...
 
FLStringResult FLKeyPath_ToString (FLKeyPath path)
 

Detailed Description

-

An FLKeyPath Describes a location in a Fleece object tree, as a path from the root that follows dictionary properties and array elements.

-

It's similar to a JSONPointer or an Objective-C KeyPath, but simpler (so far.) The path is compiled into an efficient form that can be traversed quickly.

-

It looks like foo.bar[2][-3].baz – that is, properties prefixed with a ., and array indexes in brackets. (Negative indexes count from the end of the array.)

-

A leading JSONPath-like $. is allowed but ignored.

-

A '\' can be used to escape a special character ('.', '[' or '$') at the start of a property name (but not yet in the middle of a name.)

+

An FLKeyPath Describes a location in a Fleece object tree, as a path from the root that follows dictionary properties and array elements.

+

It's similar to a JSONPointer or an Objective-C KeyPath, but simpler (so far.) The path is compiled into an efficient form that can be traversed quickly.

+

It looks like foo.bar[2][-3].baz – that is, properties prefixed with a ., and array indexes in brackets. (Negative indexes count from the end of the array.)

+

A leading JSONPath-like $. is allowed but ignored.

+

A '\' can be used to escape a special character ('.', '[' or '$') at the start of a property name (but not yet in the middle of a name.)

Typedef Documentation

- +

◆ FLKeyPath

@@ -127,7 +127,7 @@

Function Documentation

- +

◆ FLKeyPath_Equals()

@@ -157,14 +157,14 @@

+

◆ FLKeyPath_Eval()

- + @@ -187,14 +187,14 @@

+

◆ FLKeyPath_EvalOnce()

FLValue FL_NULLABLE FLKeyPath_Eval FLValue FL_NULLABLE FLKeyPath_Eval ( FLKeyPath  ,
- + @@ -208,7 +208,7 @@

- + @@ -220,11 +220,11 @@

Evaluates a key-path from a specifier string, for a given Fleece root object.

-

If you only need to evaluate the path once, this is a bit faster than creating an FLKeyPath object, evaluating, then freeing it.

+

If you only need to evaluate the path once, this is a bit faster than creating an FLKeyPath object, evaluating, then freeing it.

-
+

◆ FLKeyPath_Free()

- +

◆ FLKeyPath_GetElement()

@@ -287,14 +287,14 @@

+

◆ FLKeyPath_New()

FLValue FL_NULLABLE FLKeyPath_EvalOnce FLValue FL_NULLABLE FLKeyPath_EvalOnce ( FLSlice  specifier, FLError *FL_NULLABLE FLError *FL_NULLABLE  outError 
- + @@ -302,7 +302,7 @@

- + @@ -317,7 +317,7 @@

+

◆ FLKeyPath_ToString()

@@ -340,7 +340,7 @@

diff --git a/docs/C/html/group___f_l_slice.html b/docs/C/html/group___f_l_slice.html index f6ca0d6231..055e66536f 100644 --- a/docs/C/html/group___f_l_slice.html +++ b/docs/C/html/group___f_l_slice.html @@ -2,8 +2,8 @@ - - + + LiteCore: Slices @@ -30,21 +30,22 @@

FLKeyPath FL_NULLABLE FLKeyPath_New FLKeyPath FL_NULLABLE FLKeyPath_New ( FLSlice  specifier, FLError *FL_NULLABLE FLError *FL_NULLABLE  outError 
- + +/* @license-end */ +
@@ -67,12 +68,11 @@ Macros | Typedefs | Functions

-
-
Slices
+
Slices
- @@ -81,7 +81,7 @@

+

Data Structures

struct  FLSlice
 A simple reference to a block of memory. More...
 A heap-allocated block of memory returned from an API call. More...
 
- @@ -90,7 +90,7 @@

+

Macros

#define kFLSliceNull   ((FLSlice){NULL, 0})
 A convenient constant denoting a null slice. More...
 Macro version of FLStr, for use in initializing compile-time constants. More...
 
- @@ -100,24 +100,24 @@

+

Typedefs

typedef FLSlice FLHeapSlice
 A heap-allocated, reference-counted slice. More...
typedef FLSliceResult FLStringResult
 
- - + - + - + - + - + - + @@ -129,12 +129,12 @@ - + - + - + @@ -151,7 +151,7 @@

+

Functions

static FLPURE int FLMemCmp (const void *FL_NULLABLE a, const void *FL_NULLABLE b, size_t size)
static FLPURE int FLMemCmp (const void *FL_NULLABLE a, const void *FL_NULLABLE b, size_t size)
 Exactly like memcmp, but safely handles the case where a or b is NULL and size is 0 (by returning 0), instead of producing "undefined behavior" as per the C spec. More...
 
static void FLMemCpy (void *FL_NULLABLE dst, const void *FL_NULLABLE src, size_t size)
static void FLMemCpy (void *FL_NULLABLE dst, const void *FL_NULLABLE src, size_t size)
 Exactly like memcmp, but safely handles the case where dst or src is NULL and size is 0 (as a no-op), instead of producing "undefined behavior" as per the C spec. More...
 
static FLSlice FLStr (const char *FL_NULLABLE str)
static FLSlice FLStr (const char *FL_NULLABLE str)
 Returns a slice pointing to the contents of a C string. More...
 
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
 Equality test of two slices. More...
 
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
 Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences in length. More...
 
uint32_t FLSlice_Hash (FLSlice s) FLPURE
uint32_t FLSlice_Hash (FLSlice s) FLPURE
 Computes a 32-bit hash of a slice's data, suitable for use in hash tables. More...
 
bool FLSlice_ToCString (FLSlice s, char *buffer, size_t capacity)
FLSliceResult FLSlice_Copy (FLSlice)
 Allocates an FLSliceResult, copying the given slice. More...
 
static FLSliceResult FLSliceResult_CreateWith (const void *FL_NULLABLE bytes, size_t size)
static FLSliceResult FLSliceResult_CreateWith (const void *FL_NULLABLE bytes, size_t size)
 Allocates an FLSliceResult, copying size bytes starting at buf. More...
 
void _FLBuf_Retain (const void *FL_NULLABLE)
void _FLBuf_Retain (const void *FL_NULLABLE)
 
void _FLBuf_Release (const void *FL_NULLABLE)
void _FLBuf_Release (const void *FL_NULLABLE)
 
static FLSliceResult FLSliceResult_Retain (FLSliceResult s)
 Increments the ref-count of a FLSliceResult. More...

Detailed Description

Macro Definition Documentation

- +

◆ FLSTR

@@ -168,11 +168,11 @@

Macro version of FLStr, for use in initializing compile-time constants.

-

STR must be a C string literal. Has zero runtime overhead.

+

STR must be a C string literal. Has zero runtime overhead.

- +

◆ kFLSliceNull

@@ -189,7 +189,7 @@

Typedef Documentation

- +

◆ FLHeapSlice

@@ -202,11 +202,11 @@

A heap-allocated, reference-counted slice.

-

This type is really just a hint in an API that the data can be retained instead of copied, by assigning it to an alloc_slice. You can just treat it like FLSlice.

+

This type is really just a hint in an API that the data can be retained instead of copied, by assigning it to an alloc_slice. You can just treat it like FLSlice.

- +

◆ FLString

@@ -220,7 +220,7 @@

+

◆ FLStringResult

@@ -235,7 +235,7 @@

Function Documentation

- +

◆ _FLBuf_Release()

@@ -253,7 +253,7 @@

+

◆ _FLBuf_Retain()

- +

◆ FLMemCmp()

@@ -312,15 +312,15 @@

- + - + - + @@ -346,7 +346,7 @@

+

◆ FLMemCpy()

@@ -358,13 +358,13 @@

static void FLMemCpy

- + - + @@ -390,7 +390,7 @@

+

◆ FLSlice_Compare()

static FLPURE int FLMemCmp static FLPURE int FLMemCmp (const void *FL_NULLABLE const void *FL_NULLABLE  a,
const void *FL_NULLABLE const void *FL_NULLABLE  b,
(void *FL_NULLABLE void *FL_NULLABLE  dst,
const void *FL_NULLABLE const void *FL_NULLABLE  src,
@@ -535,7 +535,7 @@

+

◆ FLSliceResult_AsSlice()

@@ -563,7 +563,7 @@

+

◆ FLSliceResult_CreateWith()

@@ -575,7 +575,7 @@

static FLSliceResult FLSliceResult_CreateWith

- + @@ -601,7 +601,7 @@

+

◆ FLSliceResult_New()

@@ -621,7 +621,7 @@

+

◆ FLSliceResult_Release()

@@ -649,7 +649,7 @@

+

◆ FLSliceResult_Retain()

@@ -677,7 +677,7 @@

+

◆ FLStr()

@@ -689,7 +689,7 @@

static FLSlice FLStr

- + @@ -702,7 +702,7 @@

Returns a slice pointing to the contents of a C string.

-

It's OK to pass NULL; this returns an empty slice.

Note
If the string is a literal, it's more efficient to use FLSTR instead.
+

It's OK to pass NULL; this returns an empty slice.

Note
If the string is a literal, it's more efficient to use FLSTR instead.
Performance is O(n) with the length of the string, since it has to call strlen.
@@ -711,7 +711,7 @@

diff --git a/docs/C/html/group___f_l_value.html b/docs/C/html/group___f_l_value.html index fa89090d90..ed6ad4c227 100644 --- a/docs/C/html/group___f_l_value.html +++ b/docs/C/html/group___f_l_value.html @@ -2,10 +2,10 @@ - - + + -LiteCore: Fleece Value Accessors +LiteCore: Fleece Values @@ -30,21 +30,22 @@

sThe FLSlice to copy.
bufferWhere to copy the bytes. At least capacity bytes must be available.
(const void *FL_NULLABLE const void *FL_NULLABLE  bytes,
(const char *FL_NULLABLE const char *FL_NULLABLE  str)

- + +/* @license-end */ +

@@ -63,32 +64,16 @@
-
-
Fleece Value Accessors
+
Fleece Values

The core Fleece data type is FLValue: a reference to a value in Fleece-encoded data. More...

- - - - -

-Macros

#define FLTimestampNone   INT64_MIN
 A value representing a missing timestamp; returned when a date cannot be parsed. More...
 
- - - - -

-Typedefs

typedef int64_t FLTimestamp
 A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) More...
 
-

+

Enumerations

enum  FLValueType {
  kFLUndefined = -1 @@ -105,135 +90,103 @@
 Types of Fleece values. More...
 
- - - + + + + + + + +

-Functions

FLValueType FLValue_GetType (FLValue FL_NULLABLE) FLPURE
 Returns the data type of an arbitrary Value. More...

+Variables

FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (like a JSON null, not a NULL pointer!) More...
 
FLEECE_PUBLIC const FLValue kFLUndefinedValue
 A constant undefined value. More...
 
+ + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - -

Accessors

FLValueType FLValue_GetType (FLValue FL_NULLABLE) FLPURE
 Returns the data type of an arbitrary value. More...
 
bool FLValue_IsInteger (FLValue FL_NULLABLE) FLPURE
bool FLValue_IsInteger (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is non-NULL and represents an integer. More...
 
bool FLValue_IsUnsigned (FLValue FL_NULLABLE) FLPURE
bool FLValue_IsUnsigned (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is non-NULL and represents an integer >= 2^63. More...
 
bool FLValue_IsDouble (FLValue FL_NULLABLE)
bool FLValue_IsDouble (FLValue FL_NULLABLE)
 Returns true if the value is non-NULL and represents a 64-bit floating-point number. More...
 
bool FLValue_AsBool (FLValue FL_NULLABLE) FLPURE
bool FLValue_AsBool (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to boolean. More...
 
int64_t FLValue_AsInt (FLValue FL_NULLABLE) FLPURE
int64_t FLValue_AsInt (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to an integer. More...
 
uint64_t FLValue_AsUnsigned (FLValue FL_NULLABLE) FLPURE
uint64_t FLValue_AsUnsigned (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to an unsigned integer. More...
 
float FLValue_AsFloat (FLValue FL_NULLABLE) FLPURE
float FLValue_AsFloat (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 
double FLValue_AsDouble (FLValue FL_NULLABLE) FLPURE
double FLValue_AsDouble (FLValue FL_NULLABLE) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 
FLString FLValue_AsString (FLValue FL_NULLABLE) FLPURE
FLString FLValue_AsString (FLValue FL_NULLABLE) FLPURE
 Returns the exact contents of a string value, or null for all other types. More...
 
FLTimestamp FLValue_AsTimestamp (FLValue FL_NULLABLE) FLPURE
FLTimestamp FLValue_AsTimestamp (FLValue FL_NULLABLE) FLPURE
 Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure. More...
 
FLSlice FLValue_AsData (FLValue FL_NULLABLE) FLPURE
FLSlice FLValue_AsData (FLValue FL_NULLABLE) FLPURE
 Returns the exact contents of a data value, or null for all other types. More...
 
FLArray FL_NULLABLE FLValue_AsArray (FLValue FL_NULLABLE) FLPURE
FLArray FL_NULLABLE FLValue_AsArray (FLValue FL_NULLABLE) FLPURE
 If a FLValue represents an array, returns it cast to FLArray, else NULL. More...
 
FLDict FL_NULLABLE FLValue_AsDict (FLValue FL_NULLABLE) FLPURE
FLDict FL_NULLABLE FLValue_AsDict (FLValue FL_NULLABLE) FLPURE
 If a FLValue represents a dictionary, returns it as an FLDict, else NULL. More...
 
FLStringResult FLValue_ToString (FLValue FL_NULLABLE)
FLStringResult FLValue_ToString (FLValue FL_NULLABLE)
 Returns a string representation of any scalar value. More...
 
bool FLValue_IsEqual (FLValue FL_NULLABLE v1, FLValue FL_NULLABLE v2) FLPURE
bool FLValue_IsEqual (FLValue FL_NULLABLE v1, FLValue FL_NULLABLE v2) FLPURE
 Compares two values for equality. More...
 
bool FLValue_IsMutable (FLValue FL_NULLABLE) FLPURE
bool FLValue_IsMutable (FLValue FL_NULLABLE) FLPURE
 Returns true if the value is mutable. More...
 
FLValue FL_NULLABLE FLValue_NewString (FLString)
 Allocates a string value on the heap. More...
 
FLValue FL_NULLABLE FLValue_NewData (FLSlice)
 Allocates a data/blob value on the heap. More...
 
- - - - - - - -

-Variables

FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
FLEECE_PUBLIC const FLValue kFLUndefinedValue
 A constant undefined value. More...
 
- - - + + + + - - + + - + - + - + - +

Ref-counting (mutable values only)

FLValue FL_NULLABLE FLValue_Retain (FLValue FL_NULLABLE)
 If this value is mutable (and thus heap-based) its ref-count is incremented. More...

Reference-Counting

Retaining a value extends its lifespan (and that of any values contained in it) until at least such time that it's released.

+
    +
  • If the value comes from an FLDoc, the doc's ref-count will be incremented.
  • +
  • If the value is mutable (heap-based), it has its own ref-count that will be incremented.
    Warning
    Values obtained from FLValue_FromData don't match either of those critera. Their lifespan is entirely determined by the caller-provided data pointer, so the retain call can't do anything about it. In this situation Fleece will throw an exception like "Can't retain immutable Value that's not part of a Doc."
    +
  • +
+
FLValue FL_NULLABLE FLValue_Retain (FLValue FL_NULLABLE)
 Increments the ref-count of a mutable value, or of an immutable value's FLDoc. More...
 
void FLValue_Release (FLValue FL_NULLABLE)
 If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero the value is freed. More...
void FLValue_Release (FLValue FL_NULLABLE)
 Decrements the ref-count of a mutable value, or of an immutable value's FLDoc. More...
 
static FLArray FL_NULLABLE FLArray_Retain (FLArray FL_NULLABLE v)
static FLArray FL_NULLABLE FLArray_Retain (FLArray FL_NULLABLE v)
 
static void FLArray_Release (FLArray FL_NULLABLE v)
static void FLArray_Release (FLArray FL_NULLABLE v)
 
static FLDict FL_NULLABLE FLDict_Retain (FLDict FL_NULLABLE v)
static FLDict FL_NULLABLE FLDict_Retain (FLDict FL_NULLABLE v)
 
static void FLDict_Release (FLDict FL_NULLABLE v)
static void FLDict_Release (FLDict FL_NULLABLE v)
 

Detailed Description

-

The core Fleece data type is FLValue: a reference to a value in Fleece-encoded data.

-

An FLValue can represent any JSON type (plus binary data).

+

The core Fleece data type is FLValue: a reference to a value in Fleece-encoded data.

+

An FLValue can represent any JSON type (plus binary data).

  • Scalar data types – numbers, booleans, null, strings, data – can be accessed using individual functions of the form FLValue_As...; these return the scalar value, or a default zero/false/null value if the value is not of that type.
  • Collections – arrays and dictionaries – have their own "subclasses": FLArray and FLDict. These have the same pointer values as an FLValue but are not type-compatible in C. To coerce an FLValue to a collection type, call FLValue_AsArray or FLValue_AsDict. If the value is not of that type, NULL is returned. (FLArray and FLDict are documented fully in their own sections.)
-

It's always safe to pass a NULL value to an accessor; that goes for FLDict and FLArray as well as FLValue. The result will be a default value of that type, e.g. false or 0 or NULL, unless otherwise specified.

-

Macro Definition Documentation

- -

◆ FLTimestampNone

- -
-
- - - - -
#define FLTimestampNone   INT64_MIN
-
- -

A value representing a missing timestamp; returned when a date cannot be parsed.

- -
-
-

Typedef Documentation

- -

◆ FLTimestamp

- -
-
- - - - -
typedef int64_t FLTimestamp
-
- -

A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.)

- -
-
+
Note
It's safe to pass a NULL pointer to an FLValue, FLArray or FLDict function parameter, except where specifically noted.
+
+Conversion/accessor functions that take FLValue won't complain if the value isn't of the desired subtype; they'll just return some default like 0 or NULL. For example, FLValue_AsInt will return 0 if passed a non-integer value or NULL.

Enumeration Type Documentation

- +

◆ FLValueType

Function Documentation

-
+

◆ FLArray_Release()

@@ -281,7 +235,7 @@

static void FLArray_Release ( - FLArray FL_NULLABLE  + FLArray FL_NULLABLE  v) @@ -295,7 +249,7 @@

+

◆ FLArray_Retain()

@@ -305,9 +259,9 @@

- + - + @@ -321,7 +275,7 @@

+

◆ FLDict_Release()

@@ -333,7 +287,7 @@

static void FLDict_Release

- + @@ -347,7 +301,7 @@

+

◆ FLDict_Retain()

@@ -357,9 +311,9 @@

static FLArray FL_NULLABLE FLArray_Retain static FLArray FL_NULLABLE FLArray_Retain (FLArray FL_NULLABLE FLArray FL_NULLABLE  v)
(FLDict FL_NULLABLE FLDict FL_NULLABLE  v)
- + - + @@ -373,14 +327,14 @@

+

◆ FLValue_AsArray()

static FLDict FL_NULLABLE FLDict_Retain static FLDict FL_NULLABLE FLDict_Retain (FLDict FL_NULLABLE FLDict FL_NULLABLE  v)
- + @@ -393,7 +347,7 @@

+

◆ FLValue_AsBool()

- +

◆ FLValue_AsData()

@@ -434,14 +388,14 @@

+

◆ FLValue_AsDict()

FLArray FL_NULLABLE FLValue_AsArray FLArray FL_NULLABLE FLValue_AsArray ( FLValue  FL_NULLABLE)
- + @@ -454,7 +408,7 @@

+

◆ FLValue_AsDouble()

- +

◆ FLValue_AsFloat()

- +

◆ FLValue_AsInt()

- +

◆ FLValue_AsString()

@@ -537,14 +491,14 @@

+

◆ FLValue_AsTimestamp()

FLDict FL_NULLABLE FLValue_AsDict FLDict FL_NULLABLE FLValue_AsDict ( FLValue  FL_NULLABLE)
- + @@ -561,7 +515,7 @@

+

◆ FLValue_AsUnsigned()

- +

◆ FLValue_GetType()

- +

◆ FLValue_IsDouble()

@@ -623,7 +577,7 @@

+

◆ FLValue_IsEqual()

@@ -632,13 +586,13 @@

bool FLValue_IsEqual

- + - + @@ -650,11 +604,11 @@

Compares two values for equality.

-

This is a deep recursive comparison.

+

This is a deep recursive comparison.

-
+

◆ FLValue_IsInteger()

FLTimestamp FLValue_AsTimestamp FLTimestamp FLValue_AsTimestamp ( FLValue  FL_NULLABLE)(FLValue FL_NULLABLE FLValue FL_NULLABLE  v1,
FLValue FL_NULLABLE FLValue FL_NULLABLE  v2 
- - - - - - - -
FLValue FL_NULLABLE FLValue_NewData (FLSlice )
-

- -

Allocates a data/blob value on the heap.

-

This is rarely needed – usually you'd just add data to a mutable Array or Dict directly using one of their "...SetData or "...AppendData" methods.

- -
-

- -

◆ FLValue_NewString()

- -
-
- - - - - - - - -
FLValue FL_NULLABLE FLValue_NewString (FLString )
-
- -

Allocates a string value on the heap.

-

This is rarely needed – usually you'd just add a string to a mutable Array or Dict directly using one of their "...SetString" or "...AppendString" methods.

+

Such a value can't be represented in C as an int64_t, only a uint64_t, so you should access it by calling FLValueAsUnsigned, not FLValueAsInt, which would return an incorrect (negative) value.

- +

◆ FLValue_Release()

- +

◆ FLValue_Retain()

- +

◆ kFLUndefinedValue

diff --git a/docs/C/html/group___indexing.html b/docs/C/html/group___indexing.html index 69a415f400..da8f6ac5b1 100644 --- a/docs/C/html/group___indexing.html +++ b/docs/C/html/group___indexing.html @@ -2,8 +2,8 @@ - - + + LiteCore: Database Indexes @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -66,18 +67,17 @@ Data Structures | Enumerations | Functions

-
-
Database Indexes
+
Database Indexes

-

+

Data Structures

struct  C4IndexOptions
 Options for indexes; these each apply to specific types of indexes. More...
 
-

+

Enumerations

enum  C4IndexType : uint32_t { kC4ValueIndex , kC4FullTextIndex @@ -87,7 +87,7 @@
 Types of indexes. More...
 
- @@ -103,7 +103,7 @@

+

Functions

bool c4db_createIndex (C4Database *database, C4String name, C4String indexSpecJSON, C4IndexType indexType, const C4IndexOptions *indexOptions, C4Error *outError)
 Creates a database index, of the values of specific expressions across all documents. More...

Detailed Description

Enumeration Type Documentation

- +

◆ C4IndexType

@@ -117,20 +117,20 @@

-EnumeratorkC4ValueIndex 

Regular index of property value.

+EnumeratorkC4ValueIndex 

Regular index of property value.

-kC4FullTextIndex 

Full-text index.

+kC4FullTextIndex 

Full-text index.

-kC4ArrayIndex 

Index of array values, for use with UNNEST.

+kC4ArrayIndex 

Index of array values, for use with UNNEST.

-kC4PredictiveIndex 

Index of prediction() results (Enterprise Edition only)

+kC4PredictiveIndex 

Index of prediction() results (Enterprise Edition only)

Function Documentation

- +

◆ c4db_createIndex()

@@ -181,15 +181,15 @@

Creates a database index, of the values of specific expressions across all documents.

-

The name is used to identify the index for later updating or deletion; if an index with the same name already exists, it will be replaced unless it has the exact same expressions.

-

Currently four types of indexes are supported:

-

Value indexes speed up queries by making it possible to look up property (or expression) values without scanning every document. They're just like regular indexes in SQL or N1QL. Multiple expressions are supported; the first is the primary key, second is secondary. Expressions must evaluate to scalar types (boolean, number, string). Full-Text Search (FTS) indexes enable fast search of natural-language words or phrases by using the MATCH operator in a query. A FTS index is required for full-text search: a query with a MATCH operator will fail to compile unless there is already a FTS index for the property/expression being matched. Only a single expression is currently allowed, and it must evaluate to a string. Array indexes optimize UNNEST queries, by materializing an unnested array property (across all documents) as a table in the SQLite database, and creating a SQL index on it. Predictive indexes optimize queries that use the PREDICTION() function, by materializing the function's results as a table and creating a SQL index on a result property.

-

Note: If some documents are missing the values to be indexed, those documents will just be omitted from the index. It's not an error.

-

In an array index, the first expression must evaluate to an array to be unnested; it's usually a property path but could be some other expression type. If the array items are nonscalar (dictionaries or arrays), you should add a second expression defining the sub- property (or computed value) to index, relative to the array item.

-

In a predictive index, the expression is a PREDICTION() call in JSON query syntax, including the optional 3rd parameter that gives the result property to extract (and index.)

-

indexSpecJSON specifies the index as a JSON object, with properties: WHAT: An array of expressions in the JSON query syntax. (Note that each expression is already an array, so there are two levels of nesting.) WHERE: An optional expression. Including this creates a partial index: documents for which this expression returns false or null will be skipped.

-

For backwards compatibility, indexSpecJSON may be an array; this is treated as if it were a dictionary with a WHAT key mapping to that array.

-

Expressions are defined in JSON, as in a query, and wrapped in a JSON array. For example, [[".name.first"]] will index on the first-name property. Note the two levels of brackets, since an expression is already an array.

+

The name is used to identify the index for later updating or deletion; if an index with the same name already exists, it will be replaced unless it has the exact same expressions.

+

Currently four types of indexes are supported:

+

Value indexes speed up queries by making it possible to look up property (or expression) values without scanning every document. They're just like regular indexes in SQL or N1QL. Multiple expressions are supported; the first is the primary key, second is secondary. Expressions must evaluate to scalar types (boolean, number, string). Full-Text Search (FTS) indexes enable fast search of natural-language words or phrases by using the MATCH operator in a query. A FTS index is required for full-text search: a query with a MATCH operator will fail to compile unless there is already a FTS index for the property/expression being matched. Only a single expression is currently allowed, and it must evaluate to a string. Array indexes optimize UNNEST queries, by materializing an unnested array property (across all documents) as a table in the SQLite database, and creating a SQL index on it. Predictive indexes optimize queries that use the PREDICTION() function, by materializing the function's results as a table and creating a SQL index on a result property.

+

Note: If some documents are missing the values to be indexed, those documents will just be omitted from the index. It's not an error.

+

In an array index, the first expression must evaluate to an array to be unnested; it's usually a property path but could be some other expression type. If the array items are nonscalar (dictionaries or arrays), you should add a second expression defining the sub- property (or computed value) to index, relative to the array item.

+

In a predictive index, the expression is a PREDICTION() call in JSON query syntax, including the optional 3rd parameter that gives the result property to extract (and index.)

+

indexSpecJSON specifies the index as a JSON object, with properties: WHAT: An array of expressions in the JSON query syntax. (Note that each expression is already an array, so there are two levels of nesting.) WHERE: An optional expression. Including this creates a partial index: documents for which this expression returns false or null will be skipped.

+

For backwards compatibility, indexSpecJSON may be an array; this is treated as if it were a dictionary with a WHAT key mapping to that array.

+

Expressions are defined in JSON, as in a query, and wrapped in a JSON array. For example, [[".name.first"]] will index on the first-name property. Note the two levels of brackets, since an expression is already an array.

Parameters
@@ -205,7 +205,7 @@

+

◆ c4db_createIndex2()

databaseThe database to index.
@@ -362,7 +362,7 @@

diff --git a/docs/C/html/group___listener.html b/docs/C/html/group___listener.html index 3f4eda4d02..18aecd3d82 100644 --- a/docs/C/html/group___listener.html +++ b/docs/C/html/group___listener.html @@ -2,8 +2,8 @@ - - + + LiteCore: Network Listener: REST API and Sync Server @@ -30,21 +30,22 @@

databaseThe database to check
outErrorOn failure, will be set to the error status.

- + +/* @license-end */ +

@@ -67,12 +68,11 @@ Typedefs | Enumerations | Functions
-
-
Network Listener: REST API and Sync Server
+
Network Listener: REST API and Sync Server

- @@ -81,7 +81,7 @@

+

Data Structures

struct  C4TLSConfig
 TLS configuration for C4Listener. More...
 Configuration for a C4Listener. More...
 
- @@ -90,7 +90,7 @@

+

Typedefs

typedef bool(* C4ListenerCertAuthCallback) (C4Listener *listener, C4Slice clientCertData, void *context)
 Called when a client connects, during the TLS handshake, if a client certificate is received. More...
 Called when a client connects, after the TLS handshake (if any), when the initial HTTP request is received. More...
 
-

+

Enumerations

enum  C4ListenerAPIs : unsigned { kC4RESTAPI = 0x01 , kC4SyncAPI = 0x02 @@ -103,14 +103,14 @@
 Different ways to provide TLS private keys. More...
 
- - - - + + + @@ -135,7 +135,7 @@

+

Functions

C4ListenerAPIs c4listener_availableAPIs (void)
 Returns flags for the available APIs in this build (REST, sync, or both.) More...
 
C4Listenerc4listener_start (const C4ListenerConfig *config, C4Error *error)
 Starts a new listener. More...
 
C4Listenerc4listener_start (const C4ListenerConfig *config, C4Error *error)
 Starts a new listener. More...
 
void c4listener_free (C4Listener *listener)
 Closes and disposes a listener. More...
 

Detailed Description

Typedef Documentation

- +

◆ C4ListenerCertAuthCallback

@@ -160,7 +160,7 @@

+

◆ C4ListenerHTTPAuthCallback

@@ -186,7 +186,7 @@

Enumeration Type Documentation

- +

◆ C4ListenerAPIs

@@ -200,15 +200,15 @@

-EnumeratorkC4RESTAPI 

CouchDB-like REST API.

+EnumeratorkC4RESTAPI 

CouchDB-like REST API.

-kC4SyncAPI 

Replication server.

+kC4SyncAPI 

Replication server.

- +

◆ C4PrivateKeyRepresentation

@@ -222,16 +222,16 @@

-EnumeratorkC4PrivateKeyFromCert 

Key in secure storage, associated with certificate.

+EnumeratorkC4PrivateKeyFromCert 

Key in secure storage, associated with certificate.

-kC4PrivateKeyFromKey 

Key from the provided key pair.

+kC4PrivateKeyFromKey 

Key from the provided key pair.

Function Documentation

- +

◆ c4db_URINameFromPath()

@@ -263,7 +263,7 @@

+

◆ c4listener_availableAPIs()

- +

◆ c4listener_getURLs()

@@ -400,8 +400,8 @@

Returns the URL(s) of a database being shared, or of the root, separated by "\n" bytes.

-

The URLs will differ only in their hostname – there will be one for each IP address or known hostname of the computer, or of the network interface.

-

WARNING: Link-local IPv6 addresses are included in this list. However, due to IPv6 specification rules, a scope ID is also required to connect to these addresses. So if the address starts with fe80:: you will need to take care on the other side to also incorporate the scope of of the client network interface into the URL when connecting (in short, it's probably best to avoid these but they are there if you would like to try)

Parameters
+

The URLs will differ only in their hostname – there will be one for each IP address or known hostname of the computer, or of the network interface.

+

WARNING: Link-local IPv6 addresses are included in this list. However, due to IPv6 specification rules, a scope ID is also required to connect to these addresses. So if the address starts with fe80:: you will need to take care on the other side to also incorporate the scope of of the client network interface into the URL when connecting (in short, it's probably best to avoid these but they are there if you would like to try)

Parameters
@@ -414,7 +414,7 @@

+

◆ c4listener_shareDB()

@@ -466,14 +466,14 @@

-

◆ c4listener_start()

+ +

◆ c4listener_start()

listenerThe active listener.
dbA database being shared, or NULL to get the listener's root URL(s).
- + @@ -496,7 +496,7 @@

+

◆ c4listener_unshareDB()

@@ -535,7 +535,7 @@

diff --git a/docs/C/html/group___logging.html b/docs/C/html/group___logging.html index 68ba724a2b..2a6ad2adad 100644 --- a/docs/C/html/group___logging.html +++ b/docs/C/html/group___logging.html @@ -2,8 +2,8 @@ - - + + LiteCore: Logging @@ -30,21 +30,22 @@

C4Listener* c4listener_start C4Listener * c4listener_start ( const C4ListenerConfig config,

- + +/* @license-end */ +

@@ -69,18 +70,17 @@ Enumerations | Functions | Variables
-
-
Logging
+
Logging

-

+

Data Structures

struct  C4LogFileOptions
 Configuration for file-based logging. More...
 
- @@ -95,7 +95,7 @@

+

Macros

#define C4LogToAt(DOMAIN, LEVEL, FMT, ...)
 
#define C4WarnError(FMT, ...)   C4LogToAt(kC4DefaultLog, kC4LogError, FMT, ## __VA_ARGS__)
 
- @@ -104,7 +104,7 @@

+

Typedefs

typedef struct c4LogDomain * C4LogDomain
 Reference to a log domain: a specific source of logs that can be enabled or disabled. More...
 A logging callback that the application can register. More...
 
-

+

Enumerations

enum  C4LogLevel : int8_t {
  kC4LogDebug @@ -119,7 +119,7 @@
 Logging levels. More...
 
- @@ -151,9 +151,9 @@ - - - + + + @@ -182,7 +182,7 @@

+

Functions

bool c4log_writeToBinaryFile (C4LogFileOptions options, C4Error *error)
 Causes log messages to be written to a file, overwriting any previous contents. More...
C4LogDomain c4log_getDomain (const char *name, bool create)
 Looks up a named log domain. More...
 
const char * c4log_getDomainName (C4LogDomain)
 Returns the name of a log domain. More...
 
const char * c4log_getDomainName (C4LogDomain)
 Returns the name of a log domain. More...
 
C4LogLevel c4log_getLevel (C4LogDomain)
 Returns the current log level of a domain, the minimum level of message it will log. More...
 
 Same as c4log, except it accepts preformatted messages as FLSlices. More...
 
- @@ -202,7 +202,7 @@

+

Variables

CBL_CORE_API const C4LogDomain kC4DefaultLog
 Subsystems that produce logs. More...

Detailed Description

Macro Definition Documentation

- +

◆ C4Debug

@@ -230,7 +230,7 @@

+

◆ C4Log

@@ -258,7 +258,7 @@

+

◆ C4LogToAt

@@ -295,13 +295,13 @@

-Value:
do {if (c4log_willLog(DOMAIN, LEVEL)) \
+Value:
do {if (c4log_willLog(DOMAIN, LEVEL)) \
c4log(DOMAIN, LEVEL, FMT, ## __VA_ARGS__);} while (false)
bool c4log_willLog(C4LogDomain, C4LogLevel)
Returns true if logging to this domain at this level will have an effect.

- +

◆ C4LogVerbose

@@ -329,7 +329,7 @@

+

◆ C4Warn

@@ -357,7 +357,7 @@

+

◆ C4WarnError

@@ -386,7 +386,7 @@

Typedef Documentation

- +

◆ C4LogCallback

@@ -402,7 +402,7 @@

+

◆ C4LogDomain

@@ -419,7 +419,7 @@

Enumeration Type Documentation

- +

◆ C4LogLevel

@@ -433,24 +433,24 @@

-EnumeratorkC4LogDebug  -kC4LogVerbose 

Super-verbose messages that are only enabled in debug builds of LiteCore.

+EnumeratorkC4LogDebug  +kC4LogVerbose 

Super-verbose messages that are only enabled in debug builds of LiteCore.

-kC4LogInfo 

More info than you normally want.

+kC4LogInfo 

More info than you normally want.

-kC4LogWarning 

Informational messages.

+kC4LogWarning 

Informational messages.

-kC4LogError 

Warnings about something unusual that might be a problem.

+kC4LogError 

Warnings about something unusual that might be a problem.

-kC4LogNone 

Errors that occur; these might be handled internally.

-

Setting this level will disable logging entirely

+kC4LogNone 

Errors that occur; these might be handled internally.

+

Setting this level will disable logging entirely

Function Documentation

- +

◆ c4log()

@@ -489,7 +489,7 @@

Logs a message/warning/error to a specific domain, if its current level is less than or equal to the given level.

-

This message will then be written to the current callback and/or binary file, if their levels are less than or equal to the given level.

Parameters
+

This message will then be written to the current callback and/or binary file, if their levels are less than or equal to the given level.

Parameters
@@ -500,7 +500,7 @@

+

◆ c4log_binaryFileLevel()

@@ -520,7 +520,7 @@

+

◆ c4log_binaryFilePath()

@@ -540,7 +540,7 @@

+

◆ c4log_callbackLevel()

@@ -560,7 +560,7 @@

+

◆ c4log_enableFatalExceptionBacktrace()

@@ -580,7 +580,7 @@

+

◆ c4log_flushLogFiles()

@@ -600,7 +600,7 @@

+

◆ c4log_getCallback()

@@ -620,7 +620,7 @@

+

◆ c4log_getDomain()

@@ -658,14 +658,14 @@

-

◆ c4log_getDomainName()

+ +

◆ c4log_getDomainName()

domainThe domain to log to.
levelThe level of the message. If the domain's level is greater than this, nothing will be logged.
- + @@ -675,11 +675,11 @@

Returns the name of a log domain.

-

(The default domain's name is an empty string.)

+

(The default domain's name is an empty string.)

-
+

◆ c4log_getLevel()

@@ -699,7 +699,7 @@

+

◆ c4log_getWarnOnErrors()

@@ -716,11 +716,11 @@

Returns true if warn-on-errors is on; see c4log_warnOnErrors.

-

Default is false.

+

Default is false.

- +

◆ c4log_setBinaryFileLevel()

- +

◆ c4log_willLog()

- +

◆ c4log_writeToBinaryFile()

const char* c4log_getDomainName const char * c4log_getDomainName ( C4LogDomain  )
@@ -881,7 +881,7 @@

+

◆ c4log_writeToCallback()

optionsThe options to use when setting up the binary logger
errorOn failure, the filesystem error that caused the call to fail.
@@ -925,7 +925,7 @@

+

◆ c4slog()

@@ -961,7 +961,7 @@

+

◆ c4vlog()

@@ -1004,7 +1004,7 @@

Variable Documentation

- +

◆ kC4DatabaseLog

- +

◆ kC4QueryLog

@@ -1061,7 +1061,7 @@

+

◆ kC4SyncLog

@@ -1077,7 +1077,7 @@

+

◆ kC4WebSocketLog

@@ -1096,7 +1096,7 @@

diff --git a/docs/C/html/group___miscellaneous.html b/docs/C/html/group___miscellaneous.html index 4742ce391e..9849b35343 100644 --- a/docs/C/html/group___miscellaneous.html +++ b/docs/C/html/group___miscellaneous.html @@ -2,8 +2,8 @@ - - + + LiteCore: Miscellaneous Functions @@ -30,21 +30,22 @@

levelThe minimum level of message to log.
callbackThe logging callback, or NULL to disable logging entirely.

- + +/* @license-end */ +

@@ -65,19 +66,18 @@ -
-
Miscellaneous Functions
+
Miscellaneous Functions
-

+

Macros

#define kC4EnvironmentTimezoneKey   "tz"
 
#define kC4EnvironmentSupportedLocales   "supported_locales"
 
- @@ -100,7 +100,7 @@

+

Functions

C4StringResult c4_getBuildInfo (void)
 A string describing the version of LiteCore. More...

Detailed Description

Macro Definition Documentation

- +

◆ kC4EnvironmentSupportedLocales

- +

◆ c4_getVersion()

@@ -191,7 +191,7 @@

+

◆ c4_now()

@@ -211,7 +211,7 @@

+

◆ c4_runAsyncTask()

@@ -248,7 +248,7 @@

+

◆ c4_setTempDir()

- + +/* @license-end */ +

@@ -66,18 +67,17 @@ Modules | Enumerations | Enumerator

-
-
Mutable Values
+
Mutable Values

-

+

Modules

 Value Slots
 An FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions.
 
-

+

Enumerations

enum  FLCopyFlags { kFLDefaultCopy = 0 , kFLDeepCopy = 1 @@ -269,7 +269,7 @@

Detailed Description

Enumeration Type Documentation

- +

◆ FLCopyFlags

@@ -283,20 +283,20 @@

-EnumeratorkFLDefaultCopy 

Shallow copy. References immutables instead of copying.

+EnumeratorkFLDefaultCopy 

Shallow copy. References immutables instead of copying.

-kFLDeepCopy 

Deep copy of mutable values.

+kFLDeepCopy 

Deep copy of mutable values.

-kFLCopyImmutables 

Makes mutable copies of immutables instead of just refs.

+kFLCopyImmutables 

Makes mutable copies of immutables instead of just refs.

-kFLDeepCopyImmutables 

Both deep-copy and copy-immutables.

+kFLDeepCopyImmutables 

Both deep-copy and copy-immutables.

Function Documentation

- +

◆ FLArray_MutableCopy()

@@ -323,14 +323,14 @@

Creates a new mutable Array that's a copy of the source Array.

-

Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.

-

Copying an immutable Array is very cheap (only one small allocation) unless the flag kFLCopyImmutables is set.

-

Copying a mutable Array is cheap if it's a shallow copy; but if kFLDeepCopy is set, nested mutable Arrays and Dicts are also copied, recursively; if kFLCopyImmutables is also set, immutable values are also copied, recursively.

-

If the source Array is NULL, then NULL is returned.

+

Its initial ref-count is 1, so a call to FLMutableArray_Release will free it.

+

Copying an immutable Array is very cheap (only one small allocation) unless the flag kFLCopyImmutables is set.

+

Copying a mutable Array is cheap if it's a shallow copy; but if kFLDeepCopy is set, nested mutable Arrays and Dicts are also copied, recursively; if kFLCopyImmutables is also set, immutable values are also copied, recursively.

+

If the source Array is NULL, then NULL is returned.

- +

◆ FLDict_MutableCopy()

- +

◆ FLMutableArray_AppendArray()

@@ -402,7 +402,7 @@

+

◆ FLMutableArray_AppendBool()

@@ -440,7 +440,7 @@

+

◆ FLMutableArray_AppendData()

@@ -478,7 +478,7 @@

+

◆ FLMutableArray_AppendDict()

@@ -516,7 +516,7 @@

+

◆ FLMutableArray_AppendDouble()

@@ -554,7 +554,7 @@

+

◆ FLMutableArray_AppendFloat()

@@ -592,7 +592,7 @@

+

◆ FLMutableArray_AppendInt()

@@ -630,7 +630,7 @@

+

◆ FLMutableArray_AppendNull()

@@ -658,7 +658,7 @@

+

◆ FLMutableArray_AppendString()

@@ -696,7 +696,7 @@

+

◆ FLMutableArray_AppendUInt()

@@ -735,7 +735,7 @@

+

◆ FLMutableArray_AppendValue()

@@ -773,7 +773,7 @@

+

◆ FLMutableArray_GetMutableArray()

@@ -808,7 +808,7 @@

+

◆ FLMutableArray_GetMutableDict()

@@ -843,7 +843,7 @@

+

◆ FLMutableArray_GetSource()

@@ -863,7 +863,7 @@

+

◆ FLMutableArray_Insert()

@@ -907,7 +907,7 @@

+

◆ FLMutableArray_IsChanged()

- +

◆ FLMutableArray_Release()

@@ -977,7 +977,7 @@

+

◆ FLMutableArray_Remove()

- +

◆ FLMutableArray_Retain()

@@ -1080,7 +1080,7 @@

+

◆ FLMutableArray_SetArray()

@@ -1124,7 +1124,7 @@

+

◆ FLMutableArray_SetBool()

@@ -1168,7 +1168,7 @@

+

◆ FLMutableArray_SetChanged()

@@ -1198,7 +1198,7 @@

+

◆ FLMutableArray_SetData()

@@ -1242,7 +1242,7 @@

+

◆ FLMutableArray_SetDict()

@@ -1286,7 +1286,7 @@

+

◆ FLMutableArray_SetDouble()

@@ -1330,7 +1330,7 @@

+

◆ FLMutableArray_SetFloat()

@@ -1374,7 +1374,7 @@

+

◆ FLMutableArray_SetInt()

@@ -1418,7 +1418,7 @@

+

◆ FLMutableArray_SetNull()

@@ -1456,7 +1456,7 @@

+

◆ FLMutableArray_SetString()

@@ -1500,7 +1500,7 @@

+

◆ FLMutableArray_SetUInt()

@@ -1545,7 +1545,7 @@

+

◆ FLMutableArray_SetValue()

@@ -1589,7 +1589,7 @@

+

◆ FLMutableDict_GetMutableArray()

@@ -1624,7 +1624,7 @@

+

◆ FLMutableDict_GetMutableDict()

@@ -1659,7 +1659,7 @@

+

◆ FLMutableDict_GetSource()

@@ -1679,7 +1679,7 @@

+

◆ FLMutableDict_IsChanged()

- +

◆ FLMutableDict_Release()

@@ -1749,7 +1749,7 @@

+

◆ FLMutableDict_Remove()

@@ -1779,7 +1779,7 @@

+

◆ FLMutableDict_RemoveAll()

@@ -1799,7 +1799,7 @@

+

◆ FLMutableDict_Retain()

@@ -1827,7 +1827,7 @@

+

◆ FLMutableDict_SetArray()

@@ -1871,7 +1871,7 @@

+

◆ FLMutableDict_SetBool()

@@ -1915,7 +1915,7 @@

+

◆ FLMutableDict_SetChanged()

@@ -1945,7 +1945,7 @@

+

◆ FLMutableDict_SetData()

@@ -1989,7 +1989,7 @@

+

◆ FLMutableDict_SetDict()

@@ -2033,7 +2033,7 @@

+

◆ FLMutableDict_SetDouble()

@@ -2077,7 +2077,7 @@

+

◆ FLMutableDict_SetFloat()

@@ -2121,7 +2121,7 @@

+

◆ FLMutableDict_SetInt()

@@ -2165,7 +2165,7 @@

+

◆ FLMutableDict_SetNull()

@@ -2203,7 +2203,7 @@

+

◆ FLMutableDict_SetString()

diff --git a/docs/C/html/group___obscure.html b/docs/C/html/group___obscure.html index f730e9eeff..cf7d0c4545 100644 --- a/docs/C/html/group___obscure.html +++ b/docs/C/html/group___obscure.html @@ -2,8 +2,8 @@ - - + + LiteCore: Rarely-needed or advanced functions @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -62,15 +63,14 @@

-
-
Rarely-needed or advanced functions
+
Rarely-needed or advanced functions
- @@ -119,9 +119,9 @@

Shared Keys

FLSharedKeys represents a mapping from short strings to small integers in the range [0...2047].

-

It's used by FLDict to abbreviate dictionary keys. A shared key can be stored in a fixed two bytes and is faster to compare against. However, the same mapping has to be used when encoding and when accessing the Dict.

-

To use shared keys: Call FLSharedKeys_New to create a new empty mapping. After creating an FLEncoder, call FLEncoder_SetSharedKeys so dictionary keys will be added to the mapping and written in integer form. When loading Fleece data, use FLDoc_FromResultData and pass the FLSharedKeys as a parameter. Save the mapping somewhere by calling FLSharedKeys_GetStateData or FLSharedKeys_WriteState. You can later reconstitute the mapping by calling FLSharedKeys_LoadStateData or FLSharedKeys_LoadState on a new empty instance.

+

FLSharedKeys represents a mapping from short strings to small integers in the range [0...2047].

+

It's used by FLDict to abbreviate dictionary keys. A shared key can be stored in a fixed two bytes and is faster to compare against. However, the same mapping has to be used when encoding and when accessing the Dict.

+

To use shared keys: Call FLSharedKeys_New to create a new empty mapping. After creating an FLEncoder, call FLEncoder_SetSharedKeys so dictionary keys will be added to the mapping and written in integer form. When loading Fleece data, use FLDoc_FromResultData and pass the FLSharedKeys as a parameter. Save the mapping somewhere by calling FLSharedKeys_GetStateData or FLSharedKeys_WriteState. You can later reconstitute the mapping by calling FLSharedKeys_LoadStateData or FLSharedKeys_LoadState on a new empty instance.

typedef bool(* FLSharedKeysReadCallback) (void *FL_NULLABLE context, FLSharedKeys)
 
 
- @@ -176,19 +176,19 @@

Delta Compression

These functions implement a fairly-efficient "delta" encoding that encapsulates the changes needed to transform one Fleece value into another.

-

The delta is expressed in JSON form.

-

A delta can be stored or transmitted as an efficient way to produce the second value, when the first is already present. Deltas are frequently used in version-control systems and efficient network protocols.

+

These functions implement a fairly-efficient "delta" encoding that encapsulates the changes needed to transform one Fleece value into another.

+

The delta is expressed in JSON form.

+

A delta can be stored or transmitted as an efficient way to produce the second value, when the first is already present. Deltas are frequently used in version-control systems and efficient network protocols.

FLSliceResult FLCreateJSONDelta (FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
 Returns JSON that encodes the changes to turn the value old into nuu. More...
 
- - - - - - + + + + + +

Debugging Functions

const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that parses Fleece data and returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that parses Fleece data and returns a C string of JSON. More...
 
FLStringResult FLData_Dump (FLSlice data)
 Produces a human-readable dump of Fleece-encoded data. More...
 

Detailed Description

Typedef Documentation

- +

◆ FLSharedKeyScope

@@ -202,7 +202,7 @@

+

◆ FLSharedKeysReadCallback

@@ -217,7 +217,7 @@

Function Documentation

- +

◆ FLApplyJSONDelta()

@@ -262,7 +262,7 @@

+

◆ FLCreateJSONDelta()

@@ -289,7 +289,7 @@

Returns JSON that encodes the changes to turn the value old into nuu.

-

(The format is documented in Fleece.md, but you should treat it as a black box.)

Parameters
+

(The format is documented in Fleece.md, but you should treat it as a black box.)

Parameters
@@ -300,7 +300,7 @@

+

◆ FLData_ConvertJSON()

- +

◆ FLData_Dump()

- -

◆ FLDump()

+ +

◆ FLDump()

oldA value that's typically the old/original state of some data.
nuuA value that's typically the new/changed state of the old data.
- + @@ -369,18 +369,18 @@

Debugging function that returns a C string of JSON.

-

Does not free the string's memory!

+

Does not free the string's memory!

-
-

◆ FLDumpData()

+ +

◆ FLDumpData()

const char* FL_NULLABLE FLDump const char *FL_NULLABLE FLDump ( FLValue  FL_NULLABLE)
- + @@ -390,11 +390,11 @@

Debugging function that parses Fleece data and returns a C string of JSON.

-

Does not free the string's memory!

+

Does not free the string's memory!

-
+

◆ FLEncodeApplyingJSONDelta()

const char* FL_NULLABLE FLDumpData const char *FL_NULLABLE FLDumpData ( FLSlice  data)
@@ -484,7 +484,7 @@

+

◆ FLEncoder_Amend()

@@ -523,7 +523,7 @@

Tells the encoder to logically append to the given Fleece document, rather than making a standalone document.

-

Any calls to FLEncoder_WriteValue() where the value points inside the base data will write a pointer back to the original value. The resulting data returned by FLEncoder_FinishDoc() will NOT be standalone; it can only be used by first appending it to the base data.

Parameters
+

Any calls to FLEncoder_WriteValue() where the value points inside the base data will write a pointer back to the original value. The resulting data returned by FLEncoder_FinishDoc() will NOT be standalone; it can only be used by first appending it to the base data.

Parameters

oldA value that's typically the old/original state of some data.
nuuA value that's typically the new/changed state of the old data.
@@ -535,7 +535,7 @@

+

◆ FLEncoder_FinishItem()

- +

◆ FLEncoder_Snip()

@@ -634,11 +634,11 @@

Returns the data written so far as a standalone Fleece document, whose root is the last value written.

-

You can continue writing, and the final output returned by FLEncoder_Finish will consist of everything after this point. That second part can be used in the future by loading it as an FLDoc with the first part as its extern reference.

+

You can continue writing, and the final output returned by FLEncoder_Finish will consist of everything after this point. That second part can be used in the future by loading it as an FLDoc with the first part as its extern reference.

- +

◆ FLEncoder_SuppressTrailer()

- +

◆ FLEncoder_WriteValueAgain()

@@ -686,11 +686,11 @@

Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten.

-

The effect is exactly the same as if you wrote the entire value again, except that the size of the encoded data only grows by 4 bytes.

+

The effect is exactly the same as if you wrote the entire value again, except that the size of the encoded data only grows by 4 bytes.

- +

◆ FLJSON5_ToJSON()

@@ -729,7 +729,7 @@

Converts valid JSON5 https://json5.org to JSON.

-

Among other things, it converts single quotes to double, adds missing quotes around dictionary keys, removes trailing commas, and removes comments.

Note
If given invalid JSON5, it will usually return an error, but may just ouput comparably invalid JSON, in which case the caller's subsequent JSON parsing will detect the error. The types of errors it overlooks tend to be subtleties of string or number encoding.
+

Among other things, it converts single quotes to double, adds missing quotes around dictionary keys, removes trailing commas, and removes comments.

Note
If given invalid JSON5, it will usually return an error, but may just ouput comparably invalid JSON, in which case the caller's subsequent JSON parsing will detect the error. The types of errors it overlooks tend to be subtleties of string or number encoding.
Parameters

eThe FLEncoder affected.
baseThe base document to create an amendment of.
@@ -743,7 +743,7 @@

+

◆ FLSharedKeys_Count()

- +

◆ FLSharedKeys_Decode()

- +

◆ FLSharedKeys_GetStateData()

@@ -851,7 +851,7 @@

+

◆ FLSharedKeys_LoadState()

@@ -881,7 +881,7 @@

+

◆ FLSharedKeys_LoadStateData()

@@ -911,7 +911,7 @@

+

◆ FLSharedKeys_New()

@@ -931,7 +931,7 @@

+

◆ FLSharedKeys_NewWithRead()

@@ -959,7 +959,7 @@

+

◆ FLSharedKeys_Release()

@@ -979,7 +979,7 @@

+

◆ FLSharedKeys_Retain()

@@ -999,7 +999,7 @@

+

◆ FLSharedKeys_RevertToCount()

@@ -1029,7 +1029,7 @@

+

◆ FLSharedKeys_WriteState()

@@ -1059,7 +1059,7 @@

+

◆ FLSharedKeyScope_Free()

- +

◆ FLValue_FromData()

@@ -1137,16 +1137,16 @@

Returns a pointer to the root value in the encoded data, or NULL if validation failed.

-

You should generally use an FLDoc instead; it's safer. Here's why:

-

On the plus side, FLValue_FromData is extremely fast: it allocates no memory, only scans enough of the data to ensure it's valid (and if trust is set to kFLTrusted, it doesn't even do that.)

-

But it's potentially very dangerous: the FLValue, and all values found through it, are only valid as long as the input data remains intact and unchanged. If you violate that, the values will be pointing to garbage and Bad Things will happen when you access them...

+

You should generally use an FLDoc instead; it's safer. Here's why:

+

On the plus side, FLValue_FromData is extremely fast: it allocates no memory, only scans enough of the data to ensure it's valid (and if trust is set to kFLTrusted, it doesn't even do that.)

+

But it's potentially very dangerous: the FLValue, and all values found through it, are only valid as long as the input data remains intact and unchanged. If you violate that, the values will be pointing to garbage and Bad Things will happen when you access them...

diff --git a/docs/C/html/group___observer.html b/docs/C/html/group___observer.html index 7132ad2501..7c66151780 100644 --- a/docs/C/html/group___observer.html +++ b/docs/C/html/group___observer.html @@ -2,8 +2,8 @@ - - + + LiteCore: Database, Document, Query Observers @@ -30,21 +30,22 @@

json5The JSON5 to parse

- + +/* @license-end */ +

@@ -64,12 +65,11 @@
-
-
Database, Document, Query Observers
+
Database, Document, Query Observers
- @@ -85,12 +85,12 @@ - - - - - - + + + + + + @@ -105,20 +105,20 @@ - - - - - - + + + + + +

+

Data Structures

struct  C4CollectionChange
 Represents a change to a document in a collection, as returned from c4dbobs_getChanges. More...
 
typedef C4CollectionObserverCallback C4DatabaseObserverCallback
 
C4DatabaseObserverc4dbobs_create (C4Database *database, C4DatabaseObserverCallback callback, void *context)
 Creates a collection observer on the database's default collection. More...
 
C4CollectionObserverc4dbobs_createOnCollection (C4Collection *collection, C4CollectionObserverCallback callback, void *context)
 Creates a new collection observer, with a callback that will be invoked after one or more documents in the collection have changed. More...
 
C4DatabaseObserverc4dbobs_create (C4Database *database, C4DatabaseObserverCallback callback, void *context)
 Creates a collection observer on the database's default collection. More...
 
C4CollectionObserverc4dbobs_createOnCollection (C4Collection *collection, C4CollectionObserverCallback callback, void *context)
 Creates a new collection observer, with a callback that will be invoked after one or more documents in the collection have changed. More...
 
uint32_t c4dbobs_getChanges (C4CollectionObserver *observer, C4CollectionChange outChanges[], uint32_t maxChanges, bool *outExternal)
 Identifies which documents have changed in the collection since the last time this function was called, or since the observer was created. More...
 
typedef void(* C4DocumentObserverCallback) (C4DocumentObserver *observer, C4String docID, C4SequenceNumber sequence, void *context)
 Callback invoked by a document observer. More...
 
C4DocumentObserverc4docobs_create (C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context)
 Creates a new document observer, on a document in the database's default collection. More...
 
C4DocumentObserverc4docobs_createWithCollection (C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context)
 Creates a new document observer, with a callback that will be invoked when the document changes. More...
 
C4DocumentObserverc4docobs_create (C4Database *database, C4String docID, C4DocumentObserverCallback callback, void *context)
 Creates a new document observer, on a document in the database's default collection. More...
 
C4DocumentObserverc4docobs_createWithCollection (C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context)
 Creates a new document observer, with a callback that will be invoked when the document changes. More...
 
void c4docobs_free (C4DocumentObserver *)
 Stops an observer and frees the resources it's using. More...
 
- - - - + + + - - - + + +

Query Observer

A query observer, also called a "live query", notifies the client when the query's result set changes.

-

(Not just any time the database changes.)

-

This is done as follows, starting from when the first time an observer on a particular query is enabled:

+

A query observer, also called a "live query", notifies the client when the query's result set changes.

+

(Not just any time the database changes.)

+

This is done as follows, starting from when the first time an observer on a particular query is enabled:

  1. A separate C4Query instance is created, on a separate database instance (there's one of these background database instances per C4Database.)
  2. The copied query is run on a background thread, and it saves its results.
  3. @@ -131,28 +131,28 @@
  4. This background task stops when the last observer is disabled.
-

Some notes on performance:

-

All C4Queries on a single C4Database share a single background C4Database, which can only do one thing at a time. That means multiple live queries can bog down since they have to run one after the other. The first time any query observer is added in a given C4Database, the background database instance has to be opened, which takes a few milliseconds. The first time an observer is added to a C4Query, a copy of that query has to be created and compiled by the background database, which can also take a few millseconds. Running a C4Query before adding an observer is a bit of a waste, because the query will be run twice. It's more efficient to skip running it, and instead wait for the first call to the observer. The timing logic in step 4 is a heuristic to provide low latency on occasional database changes, but prevent rapid database changes (as happen during pull replication) from running the query constantly and/or spamming observers with notifications. (The specific times are not currently alterable; they're constants in LiveQuerier.cc.)

+

Some notes on performance:

+

All C4Queries on a single C4Database share a single background C4Database, which can only do one thing at a time. That means multiple live queries can bog down since they have to run one after the other. The first time any query observer is added in a given C4Database, the background database instance has to be opened, which takes a few milliseconds. The first time an observer is added to a C4Query, a copy of that query has to be created and compiled by the background database, which can also take a few millseconds. Running a C4Query before adding an observer is a bit of a waste, because the query will be run twice. It's more efficient to skip running it, and instead wait for the first call to the observer. The timing logic in step 4 is a heuristic to provide low latency on occasional database changes, but prevent rapid database changes (as happen during pull replication) from running the query constantly and/or spamming observers with notifications. (The specific times are not currently alterable; they're constants in LiveQuerier.cc.)

typedef void(* C4QueryObserverCallback) (C4QueryObserver *observer, C4Query *query, void *context)
 Callback invoked by a query observer, notifying that the query results have changed. More...
 
C4QueryObserverc4queryobs_create (C4Query *query, C4QueryObserverCallback callback, void *context)
 Creates a new query observer, with a callback that will be invoked when the query results change, with an enumerator containing the new results. More...
 
C4QueryObserverc4queryobs_create (C4Query *query, C4QueryObserverCallback callback, void *context)
 Creates a new query observer, with a callback that will be invoked when the query results change, with an enumerator containing the new results. More...
 
void c4queryobs_setEnabled (C4QueryObserver *obs, bool enabled)
 Enables a query observer so its callback can be called, or disables it to stop callbacks. More...
 
C4QueryEnumeratorc4queryobs_getEnumerator (C4QueryObserver *obs, bool forget, C4Error *error)
 Returns the current query results, if any. More...
 
C4QueryEnumeratorc4queryobs_getEnumerator (C4QueryObserver *obs, bool forget, C4Error *error)
 Returns the current query results, if any. More...
 
void c4queryobs_free (C4QueryObserver *)
 Stops an observer and frees the resources it's using. More...
 

Detailed Description

Typedef Documentation

- +

◆ C4CollectionObserverCallback

@@ -165,8 +165,8 @@

Callback invoked by a collection/database observer.

-

CAUTION: This callback is called when a transaction is committed, even one made by a different connection (C4Database instance) on the same file. This means that, if your application is multithreaded, the callback may be running on a different thread than the one this database instance uses. It is your responsibility to ensure thread safety.

-

In general, it is best to make no LiteCore calls from within this callback. Instead, use your platform event-handling API to schedule a later call from which you can read the changes. Since this callback may be invoked many times in succession, make sure you schedule only one call at a time.

+

CAUTION: This callback is called when a transaction is committed, even one made by a different connection (C4Database instance) on the same file. This means that, if your application is multithreaded, the callback may be running on a different thread than the one this database instance uses. It is your responsibility to ensure thread safety.

+

In general, it is best to make no LiteCore calls from within this callback. Instead, use your platform event-handling API to schedule a later call from which you can read the changes. Since this callback may be invoked many times in succession, make sure you schedule only one call at a time.

Parameters
@@ -177,7 +177,7 @@

+

◆ C4DatabaseChange

@@ -191,7 +191,7 @@

+

◆ C4DatabaseObserverCallback

@@ -205,7 +205,7 @@

+

◆ C4DocumentObserverCallback

@@ -230,7 +230,7 @@

+

◆ C4QueryObserverCallback

@@ -243,12 +243,12 @@

Callback invoked by a query observer, notifying that the query results have changed.

-

The actual enumerator is not passed to the callback, but can be retrieved by calling c4queryobs_getEnumerator.

Warning
This function is called on a random background thread! Be careful of thread safety. Do not spend too long in this callback or other observers may be delayed. It's best to do nothing except schedule a call on your preferred thread/queue.
+

The actual enumerator is not passed to the callback, but can be retrieved by calling c4queryobs_getEnumerator.

Warning
This function is called on a random background thread! Be careful of thread safety. Do not spend too long in this callback or other observers may be delayed. It's best to do nothing except schedule a call on your preferred thread/queue.
Parameters

observerThe observer that initiated the callback.
- +
observerThe observer triggering the callback.
queryThe C4Query that the observer belongs to.
contextThe context parameter you passed to c4queryobs_create.
contextThe context parameter you passed to c4queryobs_create.
@@ -256,14 +256,14 @@

Function Documentation

- -

◆ c4dbobs_create()

+ +

◆ c4dbobs_create()

- + @@ -292,14 +292,14 @@

-

◆ c4dbobs_createOnCollection()

+ +

◆ c4dbobs_createOnCollection()

C4DatabaseObserver* c4dbobs_create C4DatabaseObserver * c4dbobs_create ( C4Database database,
- + @@ -325,7 +325,7 @@

Creates a new collection observer, with a callback that will be invoked after one or more documents in the collection have changed.

-

This is exactly like c4dbobs_create, except that it acts on any collection.

Parameters
+

This is exactly like c4dbobs_create, except that it acts on any collection.

Parameters

C4CollectionObserver* c4dbobs_createOnCollection C4CollectionObserver * c4dbobs_createOnCollection ( C4Collection collection,
@@ -337,7 +337,7 @@

+

◆ c4dbobs_free()

collectionThe collection to observe.
callbackThe function to call after the collection changes.
@@ -413,7 +413,7 @@

+

◆ c4dbobs_releaseChanges()

@@ -450,14 +450,14 @@

-

◆ c4docobs_create()

+ +

◆ c4docobs_create()

- + @@ -492,14 +492,14 @@

-

◆ c4docobs_createWithCollection()

+ +

◆ c4docobs_createWithCollection()

C4DocumentObserver* c4docobs_create C4DocumentObserver * c4docobs_create ( C4Database database,
- + @@ -531,7 +531,7 @@

Creates a new document observer, with a callback that will be invoked when the document changes.

-
Note
This is exactly like c4docobs_create, except that it works on any collection.
+
Note
This is exactly like c4docobs_create, except that it works on any collection.
Parameters

C4DocumentObserver* c4docobs_createWithCollection C4DocumentObserver * c4docobs_createWithCollection ( C4Collection collection,
@@ -545,7 +545,7 @@

+

◆ c4docobs_free()

- -

◆ c4queryobs_create()

+ +

◆ c4queryobs_create()

collectionThe collection containing the document to observe.
- + @@ -605,7 +605,7 @@

+

◆ c4queryobs_free()

- -

◆ c4queryobs_getEnumerator()

+ +

◆ c4queryobs_getEnumerator()

C4QueryObserver* c4queryobs_create C4QueryObserver * c4queryobs_create ( C4Query query,
- + @@ -659,7 +659,7 @@

Returns the current query results, if any.

-

When the observer is created, the results are initially NULL until the query finishes running in the background. Once the observer callback is called, the results are available.

Note
You are responsible for releasing the returned reference.
+

When the observer is created, the results are initially NULL until the query finishes running in the background. Once the observer callback is called, the results are available.

Note
You are responsible for releasing the returned reference.
Parameters

C4QueryEnumerator* c4queryobs_getEnumerator C4QueryEnumerator * c4queryobs_getEnumerator ( C4QueryObserver obs,
@@ -672,7 +672,7 @@

+

◆ c4queryobs_setEnabled()

diff --git a/docs/C/html/group___predictive_query.html b/docs/C/html/group___predictive_query.html index 2a313073c9..f70430158c 100644 --- a/docs/C/html/group___predictive_query.html +++ b/docs/C/html/group___predictive_query.html @@ -2,8 +2,8 @@ - - + +LiteCore: Predictive (Machine-Learning) Query @@ -30,21 +30,22 @@
obsThe query observer.
- + +/* @license-end */ +
@@ -65,21 +66,20 @@ -
-
Predictive (Machine-Learning) Query
+
Predictive (Machine-Learning) Query

This API allows you to register a machine-learning model with LiteCore. More...

-

+

Data Structures

struct  C4PredictiveModel
 Configuration struct for registering a predictive model. More...
 
- @@ -89,14 +89,14 @@

+

Functions

void c4pred_registerModel (const char *name, C4PredictiveModel)
 Registers a predictive model, under a name. More...
 

Detailed Description

-

This API allows you to register a machine-learning model with LiteCore.

-

It can then be invoked from a query by the PREDICTION() function. The model results can be indexed, to speed up queries, using the index type kC4PredictiveIndex.

-

A model is implemented with a callback that will be invoked during a query. The callback takes as input a set of named parameters, which are passed as a Fleece dictionary. It produces a set of named results, which it returns as another Fleece dictionary, encoded as data. This matches the APIs of libraries like CoreML and TensorFlow.

-

ML models often expect or produce multi-dimensional numeric arrays, which obviously aren't directly supported by Fleece nor JSON. It's up to you to translate them appropriately. The most direct translation is of arrays of arrays (of arrays...) of numbers, but this representation is pretty verbose and expensive to translate. You may want to store the raw array data in a blob instead, but this has its own issues like endianness and the need to know the array dimensions up-front.

-

The most common use of a multi-dimensional array is as an image pixmap; in this case the natural Fleece input is a blob containing encoded image data in a common format like JPEG or PNG. Again, you're responsible for decoding the image data and rendering it into the appropriate binary array. (Your ML library may assist you here; for example, CoreML works with the Vision framework, so all you have to do is pass in the encoded image data and the frameworks do the rest.)

-

You must be vigilant about invalid data, since the prediction query may well be run on documents that don't have the expected schema. Obviously the callback should not crash nor corrupt memory. It should also probably not return an error if input parameters are missing or of the wrong type; instead it should return null without storing an error value in the error parameter. The reason is that, if it returns an error, this will propagate all the way up the query and cause the entire query to fail. Usually it's more appropriate to return a null slice, which equates to a result of MISSING, which will just cause this document to fail the query condition.

+

This API allows you to register a machine-learning model with LiteCore.

+

It can then be invoked from a query by the PREDICTION() function. The model results can be indexed, to speed up queries, using the index type kC4PredictiveIndex.

+

A model is implemented with a callback that will be invoked during a query. The callback takes as input a set of named parameters, which are passed as a Fleece dictionary. It produces a set of named results, which it returns as another Fleece dictionary, encoded as data. This matches the APIs of libraries like CoreML and TensorFlow.

+

ML models often expect or produce multi-dimensional numeric arrays, which obviously aren't directly supported by Fleece nor JSON. It's up to you to translate them appropriately. The most direct translation is of arrays of arrays (of arrays...) of numbers, but this representation is pretty verbose and expensive to translate. You may want to store the raw array data in a blob instead, but this has its own issues like endianness and the need to know the array dimensions up-front.

+

The most common use of a multi-dimensional array is as an image pixmap; in this case the natural Fleece input is a blob containing encoded image data in a common format like JPEG or PNG. Again, you're responsible for decoding the image data and rendering it into the appropriate binary array. (Your ML library may assist you here; for example, CoreML works with the Vision framework, so all you have to do is pass in the encoded image data and the frameworks do the rest.)

+

You must be vigilant about invalid data, since the prediction query may well be run on documents that don't have the expected schema. Obviously the callback should not crash nor corrupt memory. It should also probably not return an error if input parameters are missing or of the wrong type; instead it should return null without storing an error value in the error parameter. The reason is that, if it returns an error, this will propagate all the way up the query and cause the entire query to fail. Usually it's more appropriate to return a null slice, which equates to a result of MISSING, which will just cause this document to fail the query condition.

Function Documentation

- +

◆ c4pred_registerModel()

- +

◆ c4pred_unregisterModel()

@@ -150,7 +150,7 @@

diff --git a/docs/C/html/group___querying_d_b.html b/docs/C/html/group___querying_d_b.html index 40a637529f..94f04d92b1 100644 --- a/docs/C/html/group___querying_d_b.html +++ b/docs/C/html/group___querying_d_b.html @@ -2,8 +2,8 @@ - - + + LiteCore: Querying the Database @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -67,12 +68,11 @@ Enumerations | Functions | Variables
-
-
Querying the Database
+
Querying the Database

- @@ -84,7 +84,7 @@

+

Data Structures

struct  C4QueryOptions
 Options for running queries. More...
 A query result enumerator. More...
 
-

+

Enumerations

enum  C4QueryLanguage : uint32_t { kC4JSONQuery , kC4N1QLQuery @@ -92,11 +92,11 @@
 Supported query languages. More...
 
- - - - + + + @@ -107,11 +107,11 @@ - + - - - + + + @@ -127,14 +127,14 @@ - - - + + +

+

Functions

C4Queryc4query_new2 (C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
 Compiles a query from an expression given as JSON. More...
 
C4Queryc4query_new2 (C4Database *database, C4QueryLanguage language, C4String expression, int *outErrorPos, C4Error *error)
 Compiles a query from an expression given as JSON. More...
 
C4StringResult c4query_explain (C4Query *)
 Returns a string describing the implementation of the compiled query. More...
 
 Returns a suggested title for a column, which may be: An alias specified in an 'AS' modifier in the column definition A property name A function/operator that computes the column value, e.g. More...
 
void c4query_setParameters (C4Query *query, C4String encodedParameters)
 Sets the parameter values to use when running the query, if no parameters are given to c4query_run. More...
 Sets the parameter values to use when running the query, if no parameters are given to c4query_run. More...
 
C4QueryEnumeratorc4query_run (C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
 Runs a compiled query. More...
 
C4QueryEnumeratorc4query_run (C4Query *query, const C4QueryOptions *options, C4String encodedParameters, C4Error *outError)
 Runs a compiled query. More...
 
C4StringResult c4query_fullTextMatched (C4Query *query, const C4FullTextMatch *term, C4Error *outError)
 Given a C4FullTextMatch from the enumerator, returns the entire text of the property that was matched. More...
 
static bool c4queryenum_restart (C4QueryEnumerator *e, C4Error *outError)
 Restarts the enumeration, as though it had just been created: the next call to c4queryenum_next will read the first row, and so on from there. More...
 
C4QueryEnumeratorc4queryenum_refresh (C4QueryEnumerator *e, C4Error *outError)
 Checks whether the query results have changed since this enumerator was created; if so, returns a new enumerator. More...
 
C4QueryEnumeratorc4queryenum_refresh (C4QueryEnumerator *e, C4Error *outError)
 Checks whether the query results have changed since this enumerator was created; if so, returns a new enumerator. More...
 
void c4queryenum_close (C4QueryEnumerator *)
 Closes an enumerator without freeing it. More...
 
- @@ -142,7 +142,7 @@

+

Variables

CBL_CORE_API const C4QueryOptions kC4DefaultQueryOptions
 Default query options. More...

Detailed Description

Enumeration Type Documentation

- +

◆ C4QueryLanguage

@@ -156,16 +156,16 @@

-EnumeratorkC4JSONQuery 

JSON query schema as documented in LiteCore wiki.

+EnumeratorkC4JSONQuery 

JSON query schema as documented in LiteCore wiki.

-kC4N1QLQuery 

N1QL syntax (a large subset)

+kC4N1QLQuery 

N1QL syntax (a large subset)

Function Documentation

- +

◆ c4query_columnCount()

- +

◆ c4query_explain()

- +

◆ c4query_fullTextMatched()

@@ -270,18 +270,18 @@

Given a C4FullTextMatch from the enumerator, returns the entire text of the property that was matched.

-

(The result depends only on the term's dataSource and property fields, so if you get multiple matches of the same property in the same document, you can skip redundant calls with the same values.) To find the actual word that was matched, use the term's start and length fields to get a substring of the returned (UTF-8) string.

+

(The result depends only on the term's dataSource and property fields, so if you get multiple matches of the same property in the same document, you can skip redundant calls with the same values.) To find the actual word that was matched, use the term's start and length fields to get a substring of the returned (UTF-8) string.

- -

◆ c4query_new2()

+ +

◆ c4query_new2()

- + @@ -319,7 +319,7 @@

Compiles a query from an expression given as JSON.

-

The expression is a predicate that describes which documents should be returned. A separate, optional sort expression describes the ordering of the results.

Parameters
+

The expression is a predicate that describes which documents should be returned. A separate, optional sort expression describes the ordering of the results.

Parameters

C4Query* c4query_new2 C4Query * c4query_new2 ( C4Database database,
@@ -333,14 +333,14 @@

-

◆ c4query_run()

+ +

◆ c4query_run()

databaseThe database to be queried.
languageThe language (syntax) of the query expression.
- + @@ -372,7 +372,7 @@

Runs a compiled query.

-

NOTE: Queries will run much faster if the appropriate properties are indexed. Indexes must be created explicitly by calling c4db_createIndex.

Parameters
+

NOTE: Queries will run much faster if the appropriate properties are indexed. Indexes must be created explicitly by calling c4db_createIndex.

Parameters

C4QueryEnumerator* c4query_run C4QueryEnumerator * c4query_run ( C4Query query,
@@ -385,7 +385,7 @@

+

◆ c4query_setParameters()

@@ -411,7 +411,7 @@

-

Sets the parameter values to use when running the query, if no parameters are given to c4query_run.

+

Sets the parameter values to use when running the query, if no parameters are given to c4query_run.

Parameters

queryThe compiled query to run.
optionsQuery options; currently unused, just pass NULL.
@@ -422,7 +422,7 @@

+

◆ c4queryenum_close()

- +

◆ c4queryenum_getRowCount()

queryThe compiled query to run.
@@ -481,7 +481,7 @@

+

◆ c4queryenum_next()

- -

◆ c4queryenum_refresh()

+ +

◆ c4queryenum_refresh()

eThe query enumerator
outErrorOn failure, an error will be stored here (probably kC4ErrorUnsupported.)
- + @@ -539,11 +539,11 @@

Checks whether the query results have changed since this enumerator was created; if so, returns a new enumerator.

-

Otherwise returns NULL.

+

Otherwise returns NULL.

-
+

◆ c4queryenum_restart()

C4QueryEnumerator* c4queryenum_refresh C4QueryEnumerator * c4queryenum_refresh ( C4QueryEnumerator e,
@@ -627,7 +627,7 @@

Variable Documentation

- +

◆ kC4DefaultQueryOptions

diff --git a/docs/C/html/group___raw_docs.html b/docs/C/html/group___raw_docs.html index 2e7ca477e8..5ffe0f9227 100644 --- a/docs/C/html/group___raw_docs.html +++ b/docs/C/html/group___raw_docs.html @@ -2,8 +2,8 @@ - - + +LiteCore: Raw Documents @@ -30,21 +30,22 @@
eThe query enumerator
rowIndexThe number of the row, starting at 0, or -1 to restart before first row
- + +/* @license-end */ +
@@ -66,39 +67,38 @@ Data Structures | Macros | Functions

-
-
Raw Documents
+
Raw Documents

-

+

Data Structures

struct  C4RawDocument
 Contents of a raw document. More...
 
-

+

Macros

#define kC4InfoStore   C4STR("info")
 
#define kC4LocalDocStore   C4STR("_local")
 
- - - - + + +

+

Functions

void c4raw_free (C4RawDocument *rawDoc)
 Frees the storage occupied by a raw document. More...
 
C4RawDocumentc4raw_get (C4Database *database, C4String storeName, C4String docID, C4Error *outError)
 Reads a raw document from the database. More...
 
C4RawDocumentc4raw_get (C4Database *database, C4String storeName, C4String docID, C4Error *outError)
 Reads a raw document from the database. More...
 
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. More...
 

Detailed Description

Macro Definition Documentation

- +

◆ kC4InfoStore

@@ -112,7 +112,7 @@

+

◆ kC4LocalDocStore

@@ -127,7 +127,7 @@

Function Documentation

- +

◆ c4raw_free()

@@ -147,14 +147,14 @@

-

◆ c4raw_get()

+ +

◆ c4raw_get()

- + @@ -186,11 +186,11 @@

Reads a raw document from the database.

-

In Couchbase Lite the store named "info" is used for per-database key/value pairs, and the store "_local" is used for local documents.

+

In Couchbase Lite the store named "info" is used for per-database key/value pairs, and the store "_local" is used for local documents.

-
+

◆ c4raw_put()

@@ -247,7 +247,7 @@

diff --git a/docs/C/html/group___replicator.html b/docs/C/html/group___replicator.html index 97cc274388..e20a562973 100644 --- a/docs/C/html/group___replicator.html +++ b/docs/C/html/group___replicator.html @@ -2,8 +2,8 @@ - - + + LiteCore: Replicator @@ -30,21 +30,22 @@

C4RawDocument* c4raw_get C4RawDocument * c4raw_get ( C4Database database,
- + +/* @license-end */ +
@@ -69,12 +70,11 @@ Enumerations | Functions | Variables

-
-
Replicator
+
Replicator
- @@ -92,7 +92,7 @@

+

Data Structures

struct  C4Address
 A simple parsed-URL type. More...
 Parameters describing a replication, used when creating a C4Replicator. More...
 
- @@ -137,6 +137,9 @@ + + + @@ -225,7 +228,7 @@

+

Macros

#define kC4Replicator2Scheme   C4STR("ws")
 
#define kC4ReplicatorOptionAutoPurge   "autoPurge"
 Enables auto purge; default is true (bool) More...
 
#define kC4ReplicatorOptionAllowConnectedClient   "allowConnectedClient"
 Allow peer to use connected-client (CRUD) API. More...
 
#define kC4ReplicatorOptionRootCerts   "rootCerts"
 Trusted root certs (data) More...
 
 SOCKS proxy. More...
 
- @@ -244,7 +247,7 @@

+

Typedefs

typedef void(* C4ReplicatorStatusChangedCallback) (C4Replicator *, C4ReplicatorStatus, void *context)
 Callback a client can register, to get progress information. More...
typedef void * C4ReplicatorPropertyDecryptionCallback
 
-

+

Enumerations

enum  C4ReplicatorMode : int32_t { kC4Disabled , kC4Passive @@ -278,7 +281,7 @@
 An enumeration of the levels of progress callbacks the replicator can provide. More...
 
- @@ -292,12 +295,12 @@ - - - - - - + + + + + + @@ -331,9 +334,9 @@ - - - + + + @@ -347,7 +350,7 @@

+

Functions

bool c4repl_isValidDatabaseName (C4String dbName)
 Checks whether a database name is valid, for purposes of appearing in a replication URL. More...
C4StringResult c4address_toURL (C4Address address)
 Converts a C4Address to a URL. More...
 
C4Replicatorc4repl_new (C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
 Creates a new networked replicator. More...
 
C4Replicatorc4repl_newWithSocket (C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
 Creates a new replicator from an already-open C4Socket. More...
 
C4Replicatorc4repl_new (C4Database *db, C4Address remoteAddress, C4String remoteDatabaseName, C4ReplicatorParameters params, C4Error *outError)
 Creates a new networked replicator. More...
 
C4Replicatorc4repl_newWithSocket (C4Database *db, C4Socket *openSocket, C4ReplicatorParameters params, C4Error *outError)
 Creates a new replicator from an already-open C4Socket. More...
 
void c4repl_free (C4Replicator *repl)
 Frees a replicator reference. More...
 
bool c4repl_isDocumentPending (C4Replicator *repl, C4String docID, C4Error *outErr)
 Checks if the document with the given ID has revisions pending push. More...
 
C4Certc4repl_getPeerTLSCertificate (C4Replicator *repl, C4Error *outErr)
 Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when using BuiltInWebSocket) More...
 
C4Certc4repl_getPeerTLSCertificate (C4Replicator *repl, C4Error *outErr)
 Gets the TLS certificate, if any, that was sent from the remote server (NOTE: Only functions when using BuiltInWebSocket) More...
 
bool c4repl_setProgressLevel (C4Replicator *repl, C4ReplicatorProgressLevel level, C4Error *outErr)
 Sets the progress level of the replicator, indicating what information should be provided via callback. More...
 
 Removes all cookies from the database's cookie store. More...
 
- @@ -355,7 +358,7 @@

+

Variables

CBL_CORE_API const char *const kC4ReplicatorActivityLevelNames [6]
 For convenience, an array of C strings naming the C4ReplicatorActivityLevel values. More...

Detailed Description

Macro Definition Documentation

- +

◆ kC4AuthTypeBasic

@@ -371,7 +374,7 @@

+

◆ kC4AuthTypeClientCert

@@ -387,7 +390,7 @@

+

◆ kC4AuthTypeFacebook

@@ -403,7 +406,7 @@

+

◆ kC4AuthTypeOpenIDConnect

@@ -419,7 +422,7 @@

+

◆ kC4AuthTypeSession

@@ -435,7 +438,7 @@

+

◆ kC4ProxyTypeHTTP

@@ -451,7 +454,7 @@

+

◆ kC4ProxyTypeHTTPS

@@ -467,7 +470,7 @@

+

◆ kC4ProxyTypeNone

@@ -483,7 +486,7 @@

+

◆ kC4ProxyTypeSOCKS

@@ -499,7 +502,7 @@

+

◆ kC4Replicator2Scheme

@@ -513,7 +516,7 @@

+

◆ kC4Replicator2TLSScheme

@@ -527,7 +530,7 @@

+

◆ kC4ReplicatorAuthClientCert

@@ -543,7 +546,7 @@

+

◆ kC4ReplicatorAuthClientCertKey

@@ -559,7 +562,7 @@

+

◆ kC4ReplicatorAuthPassword

@@ -575,7 +578,7 @@

+

◆ kC4ReplicatorAuthToken

@@ -591,7 +594,7 @@

+

◆ kC4ReplicatorAuthType

@@ -607,7 +610,7 @@

+

◆ kC4ReplicatorAuthUserName

@@ -623,7 +626,7 @@

+

◆ kC4ReplicatorCheckpointInterval

@@ -639,7 +642,7 @@

+

◆ kC4ReplicatorCompressionLevel

@@ -655,7 +658,7 @@

+

◆ kC4ReplicatorHeartbeatInterval

@@ -671,7 +674,23 @@

+ +

◆ kC4ReplicatorOptionAllowConnectedClient

+ +
+
+ + + + +
#define kC4ReplicatorOptionAllowConnectedClient   "allowConnectedClient"
+
+ +

Allow peer to use connected-client (CRUD) API.

+ +
+
+

◆ kC4ReplicatorOptionAuthentication

@@ -687,7 +706,7 @@

+

◆ kC4ReplicatorOptionAutoPurge

@@ -703,7 +722,7 @@

+

◆ kC4ReplicatorOptionChannels

@@ -719,7 +738,7 @@

+

◆ kC4ReplicatorOptionCookies

@@ -735,7 +754,7 @@

+

◆ kC4ReplicatorOptionDisableDeltas

@@ -751,7 +770,7 @@

+

◆ kC4ReplicatorOptionDisablePropertyDecryption

@@ -767,7 +786,7 @@

+

◆ kC4ReplicatorOptionDocIDs

@@ -783,7 +802,7 @@

+

◆ kC4ReplicatorOptionExtraHeaders

@@ -799,7 +818,7 @@

+

◆ kC4ReplicatorOptionFilter

@@ -815,7 +834,7 @@

+

◆ kC4ReplicatorOptionFilterParams

@@ -831,7 +850,7 @@

+

◆ kC4ReplicatorOptionMaxRetries

@@ -847,7 +866,7 @@

+

◆ kC4ReplicatorOptionMaxRetryInterval

@@ -863,7 +882,7 @@

+

◆ kC4ReplicatorOptionNoIncomingConflicts

@@ -879,7 +898,7 @@

+

◆ kC4ReplicatorOptionOnlySelfSignedServerCert

@@ -895,7 +914,7 @@

+

◆ kC4ReplicatorOptionPinnedServerCert

@@ -911,7 +930,7 @@

+

◆ kC4ReplicatorOptionProxyServer

@@ -927,7 +946,7 @@

+

◆ kC4ReplicatorOptionRemoteDBUniqueID

@@ -943,7 +962,7 @@

+

◆ kC4ReplicatorOptionRootCerts

@@ -959,7 +978,7 @@

+

◆ kC4ReplicatorOptionSkipDeleted

@@ -975,7 +994,7 @@

+

◆ kC4ReplicatorProxyAuth

@@ -991,7 +1010,7 @@

+

◆ kC4ReplicatorProxyHost

@@ -1007,7 +1026,7 @@

+

◆ kC4ReplicatorProxyPort

@@ -1023,7 +1042,7 @@

+

◆ kC4ReplicatorProxyType

@@ -1039,7 +1058,7 @@

+

◆ kC4SocketOptionWSProtocols

@@ -1056,7 +1075,7 @@

Typedef Documentation

- +

◆ C4ReplicatorBlobProgressCallback

- +

◆ C4ReplicatorPropertyDecryptionCallback

Enumeration Type Documentation

-
+

◆ C4ReplicatorActivityLevel

@@ -1166,23 +1185,23 @@

-EnumeratorkC4Stopped 

Finished, or got a fatal error.

+EnumeratorkC4Stopped 

Finished, or got a fatal error.

-kC4Offline 

Connection failed, but waiting to retry. *‍/.

+kC4Offline 

Connection failed, but waiting to retry. *‍/.

-kC4Connecting 

Connection is in progress.

+kC4Connecting 

Connection is in progress.

-kC4Idle 

Continuous replicator has caught up and is waiting for changes.

+kC4Idle 

Continuous replicator has caught up and is waiting for changes.

-kC4Busy 

Connected and actively working.

+kC4Busy 

Connected and actively working.

-kC4Stopping 

Stopping or going offline.

+kC4Stopping 

Stopping or going offline.

- +

◆ C4ReplicatorMode

@@ -1196,15 +1215,15 @@

-EnumeratorkC4Disabled  -kC4Passive  -kC4OneShot  -kC4Continuous  +EnumeratorkC4Disabled  +kC4Passive  +kC4OneShot  +kC4Continuous 

- +

◆ C4ReplicatorProgressLevel

- +

◆ C4ReplicatorStatusFlags

@@ -1243,18 +1262,18 @@

-EnumeratorkC4WillRetry 

If true, will automatically reconnect when offline.

+EnumeratorkC4WillRetry 

If true, will automatically reconnect when offline.

-kC4HostReachable 

If false, it's not possible to connect to the host.

+kC4HostReachable 

If false, it's not possible to connect to the host.

-kC4Suspended 

If true, will not connect until unsuspended.

+kC4Suspended 

If true, will not connect until unsuspended.

Function Documentation

- +

◆ c4address_fromURL()

@@ -1287,7 +1306,7 @@

A simple URL parser that populates a C4Address from a URL string.

-

The fields of the address will point inside the url string.

Parameters
+

The fields of the address will point inside the url string.

Parameters
@@ -1299,7 +1318,7 @@

+

◆ c4address_toURL()

urlThe URL to be parsed.
addressOn sucess, the fields of the struct this points to will be populated with the address components. This that are slices will point into the appropriate substrings of url.
- + @@ -1475,7 +1494,7 @@

+

◆ c4repl_getPendingDocIDs()

C4Cert* c4repl_getPeerTLSCertificate C4Cert * c4repl_getPeerTLSCertificate ( C4Replicator repl,
@@ -1514,7 +1533,7 @@

+

◆ c4repl_getResponseHeaders()

- +

◆ c4repl_isDocumentPending()

replThe C4Replicator instance.
@@ -1604,7 +1623,7 @@

+

◆ c4repl_isValidDatabaseName()

- -

◆ c4repl_new()

+ +

◆ c4repl_new()

replThe C4Replicator instance.
- + @@ -1720,14 +1739,14 @@

-

◆ c4repl_newWithSocket()

+ +

◆ c4repl_newWithSocket()

C4Replicator* c4repl_new C4Replicator * c4repl_new ( C4Database db,
- + @@ -1759,7 +1778,7 @@

Creates a new replicator from an already-open C4Socket.

-

This is for use by listeners that accept incoming connections, wrap them by calling c4socket_fromNative(), then start a passive replication to service them.

Parameters
+

This is for use by listeners that accept incoming connections, wrap them by calling c4socket_fromNative(), then start a passive replication to service them.

Parameters

C4Replicator* c4repl_newWithSocket C4Replicator * c4repl_newWithSocket ( C4Database db,
@@ -1772,7 +1791,7 @@

+

◆ c4repl_retry()

- +

◆ c4repl_setOptions()

- +

◆ c4repl_setProgressLevel()

- +

◆ c4repl_start()

dbThe local database.
openSocketAn already-created C4Socket.
@@ -1988,7 +2007,7 @@

+

◆ c4repl_stop()

Variable Documentation

- +

◆ kC4ReplicatorActivityLevelNames

@@ -2038,7 +2057,7 @@

diff --git a/docs/C/html/group___slots.html b/docs/C/html/group___slots.html index 5012782d6a..30928ae7f4 100644 --- a/docs/C/html/group___slots.html +++ b/docs/C/html/group___slots.html @@ -2,8 +2,8 @@ - - + + LiteCore: Value Slots @@ -30,21 +30,22 @@

replThe C4Replicator instance.

- + +/* @license-end */ +

@@ -64,23 +65,22 @@
-
-
Value Slots
+
Value Slots

An FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions. More...

- - + - + - + @@ -116,18 +116,18 @@

+

Functions

MUST_USE_RESULT FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
MUST_USE_RESULT FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
 Returns an FLSlot that refers to the given index of the given array. More...
 
MUST_USE_RESULT FLSlot FLMutableArray_Append (FLMutableArray)
MUST_USE_RESULT FLSlot FLMutableArray_Append (FLMutableArray)
 Appends a null value to the array and returns an FLSlot that refers to that position. More...
 
MUST_USE_RESULT FLSlot FLMutableDict_Set (FLMutableDict, FLString key)
MUST_USE_RESULT FLSlot FLMutableDict_Set (FLMutableDict, FLString key)
 Returns an FLSlot that refers to the given key/value pair of the given dictionary. More...
 
void FLSlot_SetNull (FLSlot)
 

Detailed Description

-

An FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions.

-

Since there are three ways to store a value into a collection (array set, array append, dict set) and nine types of values that can be stored, that makes 27 setter functions. For efficiency, these are declared as inlines that call one of three functions to acquire a slot, and one of nine functions to store a value into it.

-

It's usually more convenient to use the typed functions like FLMutableArray_SetInt, but you might drop down to the lower level ones if you're creating an adapter between Fleece and a different data model, such as Apple's Foundation classes.

+

An FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions.

+

Since there are three ways to store a value into a collection (array set, array append, dict set) and nine types of values that can be stored, that makes 27 setter functions. For efficiency, these are declared as inlines that call one of three functions to acquire a slot, and one of nine functions to store a value into it.

+

It's usually more convenient to use the typed functions like FLMutableArray_SetInt, but you might drop down to the lower level ones if you're creating an adapter between Fleece and a different data model, such as Apple's Foundation classes.

Function Documentation

- +

◆ FLMutableArray_Append()

- + @@ -137,18 +137,18 @@

Appends a null value to the array and returns an FLSlot that refers to that position.

-

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the array invalidate it.
+

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the array invalidate it.
- +

◆ FLMutableArray_Set()

MUST_USE_RESULT FLSlot FLMutableArray_Append MUST_USE_RESULT FLSlot FLMutableArray_Append ( FLMutableArray  )
- + @@ -168,18 +168,18 @@

Returns an FLSlot that refers to the given index of the given array.

-

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the array invalidate it.
+

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the array invalidate it.
- +

◆ FLMutableDict_Set()

MUST_USE_RESULT FLSlot FLMutableArray_Set MUST_USE_RESULT FLSlot FLMutableArray_Set ( FLMutableArray  ,
- + @@ -199,11 +199,11 @@

Returns an FLSlot that refers to the given key/value pair of the given dictionary.

-

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the dictionary invalidate it.
+

You store a value to it by calling one of the nine FLSlot_Set... functions.

Warning
You should immediately store a value into the FLSlot. Do not keep it around; any changes to the dictionary invalidate it.
- +

◆ FLSlot_SetArray()

@@ -239,7 +239,7 @@

+

◆ FLSlot_SetBool()

@@ -269,7 +269,7 @@

+

◆ FLSlot_SetData()

@@ -299,7 +299,7 @@

+

◆ FLSlot_SetDict()

@@ -335,7 +335,7 @@

+

◆ FLSlot_SetDouble()

@@ -365,7 +365,7 @@

+

◆ FLSlot_SetFloat()

@@ -395,7 +395,7 @@

+

◆ FLSlot_SetInt()

@@ -425,7 +425,7 @@

+

◆ FLSlot_SetNull()

@@ -445,7 +445,7 @@

+

◆ FLSlot_SetString()

@@ -475,7 +475,7 @@

+

◆ FLSlot_SetUInt()

@@ -505,7 +505,7 @@

+

◆ FLSlot_SetValue()

@@ -538,7 +538,7 @@

diff --git a/docs/C/html/group___socket.html b/docs/C/html/group___socket.html index 9d0fc25756..aa9351dffe 100644 --- a/docs/C/html/group___socket.html +++ b/docs/C/html/group___socket.html @@ -2,8 +2,8 @@ - - + + LiteCore: Replication Socket Provider API @@ -30,21 +30,22 @@

MUST_USE_RESULT FLSlot FLMutableDict_Set MUST_USE_RESULT FLSlot FLMutableDict_Set ( FLMutableDict  ,
- + +/* @license-end */ +
@@ -66,18 +67,17 @@ Data Structures | Enumerations | Functions
-
-
Replication Socket Provider API
+
Replication Socket Provider API

-

+

Data Structures

struct  C4SocketFactory
 A group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API. More...
 
-

+

Enumerations

enum  C4WebSocketCloseCode : int32_t {
  kWebSocketCloseNormal = 1000 @@ -109,7 +109,7 @@
 The type of message framing that should be applied to the socket's data (added to outgoing, parsed out of incoming.) More...
 
- @@ -117,9 +117,9 @@ - - - + + + @@ -138,13 +138,13 @@ - - - + + +

+

Functions

void c4socket_registerFactory (C4SocketFactory factory)
 One-time registration of socket callbacks. More...
void c4Socket_setNativeHandle (C4Socket *, void *)
 Associates an opaque "native handle" with this object. More...
 
void * c4Socket_getNativeHandle (C4Socket *)
 Returns the opaque "native handle" associated with this object. More...
 
void * c4Socket_getNativeHandle (C4Socket *)
 Returns the opaque "native handle" associated with this object. More...
 
void c4socket_gotHTTPResponse (C4Socket *socket, int httpStatus, C4Slice responseHeadersFleece)
 Notification that a socket has received an HTTP response, with the given headers (encoded as a Fleece dictionary.) This should be called just before c4socket_opened or c4socket_closed. More...
 
void c4socket_received (C4Socket *socket, C4Slice data)
 Notifies LiteCore that data was received from the socket. More...
 
C4Socketc4socket_fromNative (C4SocketFactory factory, void *nativeHandle, const C4Address *address)
 Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory. More...
 
C4Socketc4socket_fromNative (C4SocketFactory factory, void *nativeHandle, const C4Address *address)
 Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory. More...
 

Detailed Description

Enumeration Type Documentation

- +

◆ C4SocketFraming

@@ -158,17 +158,17 @@

-EnumeratorkC4WebSocketClientFraming 

Frame as WebSocket client messages (masked)

+EnumeratorkC4WebSocketClientFraming 

Frame as WebSocket client messages (masked)

-kC4NoFraming 

No framing; use messages as-is.

+kC4NoFraming 

No framing; use messages as-is.

-kC4WebSocketServerFraming 

Frame as WebSocket server messages (not masked)

+kC4WebSocketServerFraming 

Frame as WebSocket server messages (not masked)

- +

◆ C4WebSocketCloseCode

@@ -181,29 +181,29 @@

Standard WebSocket close status codes, for use in C4Errors with WebSocketDomain.

-

These are defined at http://tools.ietf.org/html/rfc6455#section-7.4.1

+

These are defined at http://tools.ietf.org/html/rfc6455#section-7.4.1

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
Enumerator
kWebSocketCloseNormal 
kWebSocketCloseGoingAway 
kWebSocketCloseProtocolError 
kWebSocketCloseDataError 
kWebSocketCloseNoCode 
kWebSocketCloseAbnormal 
kWebSocketCloseBadMessageFormat 
kWebSocketClosePolicyError 
kWebSocketCloseMessageTooBig 
kWebSocketCloseMissingExtension 
kWebSocketCloseCantFulfill 
kWebSocketCloseTLSFailure 
kWebSocketCloseAppTransient 
kWebSocketCloseAppPermanent 
kWebSocketCloseFirstAvailable 
Enumerator
kWebSocketCloseNormal 
kWebSocketCloseGoingAway 
kWebSocketCloseProtocolError 
kWebSocketCloseDataError 
kWebSocketCloseNoCode 
kWebSocketCloseAbnormal 
kWebSocketCloseBadMessageFormat 
kWebSocketClosePolicyError 
kWebSocketCloseMessageTooBig 
kWebSocketCloseMissingExtension 
kWebSocketCloseCantFulfill 
kWebSocketCloseTLSFailure 
kWebSocketCloseAppTransient 
kWebSocketCloseAppPermanent 
kWebSocketCloseFirstAvailable 

Function Documentation

- +

◆ c4socket_closed()

@@ -245,7 +245,7 @@

+

◆ c4socket_closeRequested()

@@ -278,7 +278,7 @@

Notifies LiteCore that the peer has requested to close the socket using the WebSocket protocol.

-

(Should only be called by sockets whose factory's framing equals to kC4NoFraming.) LiteCore will call the factory's requestClose callback in response when it's ready to acknowledge the close.

Parameters
+

(Should only be called by sockets whose factory's framing equals to kC4NoFraming.) LiteCore will call the factory's requestClose callback in response when it's ready to acknowledge the close.

Parameters
@@ -289,7 +289,7 @@

+

◆ c4socket_completedWrite()

@@ -316,7 +316,7 @@

Notifies LiteCore that a C4SocketFactory.write request has been completed, i.e.

-

the bytes have been written to the socket.

Parameters
+

the bytes have been written to the socket.

Parameters

socketThe socket.
statusThe WebSocket status sent by the peer, typically 1000.
@@ -326,14 +326,14 @@

-

◆ c4socket_fromNative()

+ +

◆ c4socket_fromNative()

socketThe socket.
byteCountThe number of bytes that were written.
- + @@ -359,7 +359,7 @@

Constructs a C4Socket from a "native handle", whose interpretation is up to the C4SocketFactory.

-

This is used by listeners to handle an incoming replication connection.

Warning
You MUST immediately call c4socket_retain on this pointer (and the usual c4socket_release when done.) This is inconsistent with the general ref-counting convention, but fixing this function to return a retained value would cause all existing platforms to leak C4Sockets, so we're leaving it alone.
+

This is used by listeners to handle an incoming replication connection.

Warning
You MUST immediately call c4socket_retain on this pointer (and the usual c4socket_release when done.) This is inconsistent with the general ref-counting convention, but fixing this function to return a retained value would cause all existing platforms to leak C4Sockets, so we're leaving it alone.
Parameters

C4Socket* c4socket_fromNative C4Socket * c4socket_fromNative ( C4SocketFactory  factory,
@@ -372,14 +372,14 @@

-

◆ c4Socket_getNativeHandle()

+ +

◆ c4Socket_getNativeHandle()

factoryThe C4SocketFactory that will manage the socket.
- + @@ -392,7 +392,7 @@

+

◆ c4socket_gotHTTPResponse()

@@ -436,7 +436,7 @@

+

◆ c4socket_opened()

@@ -453,7 +453,7 @@

Notifies LiteCore that a socket has opened, i.e.

-

a C4SocketFactory.open request has completed successfully.

Parameters
+

a C4SocketFactory.open request has completed successfully.

Parameters

void* c4Socket_getNativeHandle void * c4Socket_getNativeHandle ( C4Socket )
socketThe socket.
@@ -462,7 +462,7 @@

+

◆ c4socket_received()

@@ -489,7 +489,7 @@

Notifies LiteCore that data was received from the socket.

-

If the factory's framing equals to kC4NoFraming, the data must be a single complete message; otherwise it's raw bytes that will be un-framed by LiteCore. LiteCore will acknowledge when it's received and processed the data, by calling C4SocketFactory.completedReceive. For flow-control purposes, the client should keep track of the number of unacknowledged bytes, and stop reading from the underlying stream if that grows too large.

Parameters
+

If the factory's framing equals to kC4NoFraming, the data must be a single complete message; otherwise it's raw bytes that will be un-framed by LiteCore. LiteCore will acknowledge when it's received and processed the data, by calling C4SocketFactory.completedReceive. For flow-control purposes, the client should keep track of the number of unacknowledged bytes, and stop reading from the underlying stream if that grows too large.

Parameters
@@ -499,7 +499,7 @@

+

◆ c4socket_registerFactory()

- +

◆ c4Socket_setNativeHandle()

diff --git a/docs/C/html/group__json.html b/docs/C/html/group__json.html index a289d6cfbb..1b2f42b8b9 100644 --- a/docs/C/html/group__json.html +++ b/docs/C/html/group__json.html @@ -2,10 +2,10 @@ - - + + -LiteCore: Converting Fleece To JSON +LiteCore: JSON Interoperability @@ -30,21 +30,22 @@

socketThe socket.
dataThe data received, either a message or raw bytes.

- + +/* @license-end */ +

@@ -62,219 +63,13 @@

- -
-
Converting Fleece To JSON
+
JSON Interoperability
- -

These are convenience functions that directly return JSON-encoded output. -More...

- - - - - - - - - - - - - - -

-Functions

FLStringResult FLValue_ToJSON (FLValue FL_NULLABLE)
 Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings. More...
 
FLStringResult FLValue_ToJSON5 (FLValue FL_NULLABLE)
 Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric. More...
 
FLStringResult FLValue_ToJSONX (FLValue FL_NULLABLE v, bool json5, bool canonicalForm)
 Most general Fleece to JSON converter. More...
 
FLStringResult FLJSON5_ToJSON (FLString json5, FLStringResult *FL_NULLABLE outErrorMessage, size_t *FL_NULLABLE outErrorPos, FLError *FL_NULLABLE outError)
 Converts valid JSON5 https://json5.org to JSON. More...
 
- - - - - - - -

Debugging Functions

const char *FL_NULLABLE FLDump (FLValue FL_NULLABLE)
 Debugging function that returns a C string of JSON. More...
 
const char *FL_NULLABLE FLDumpData (FLSlice data)
 Debugging function that returns a C string of JSON. More...
 
-

Detailed Description

-

These are convenience functions that directly return JSON-encoded output.

-

For more control over the encoding, use an FLEncoder.

-

Function Documentation

- -

◆ FLDump()

- -
-
- - - - - - - - -
const char* FL_NULLABLE FLDump (FLValue FL_NULLABLE)
-
- -

Debugging function that returns a C string of JSON.

-

Does not free the string's memory!

- -
-
- -

◆ FLDumpData()

- -
-
- - - - - - - - -
const char* FL_NULLABLE FLDumpData (FLSlice data)
-
- -

Debugging function that returns a C string of JSON.

-

Does not free the string's memory!

- -
-
- -

◆ FLJSON5_ToJSON()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FLStringResult FLJSON5_ToJSON (FLString json5,
FLStringResult *FL_NULLABLE outErrorMessage,
size_t *FL_NULLABLE outErrorPos,
FLError *FL_NULLABLE outError 
)
-
- -

Converts valid JSON5 https://json5.org to JSON.

-

Among other things, it converts single quotes to double, adds missing quotes around dictionary keys, removes trailing commas, and removes comments.

Note
If given invalid JSON5, it will usually return an error, but may just ouput comparably invalid JSON, in which case the caller's subsequent JSON parsing will detect the error. The types of errors it overlooks tend to be subtleties of string or number encoding.
-
Parameters
- - - - - -
json5The JSON5 to parse
outErrorMessageOn failure, the error message will be stored here (if not NULL.) As this is a FLStringResult, you will be responsible for freeing it.
outErrorPosOn a parse error, the byte offset in the input where the error occurred will be stored here (if it's not NULL.)
outErrorOn failure, the error code will be stored here (if it's not NULL.)
-
-
-
Returns
The converted JSON.
- -
-
- -

◆ FLValue_ToJSON()

- -
-
- - - - - - - - -
FLStringResult FLValue_ToJSON (FLValue FL_NULLABLE)
-
- -

Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings.

- -
-
- -

◆ FLValue_ToJSON5()

- -
-
- - - - - - - - -
FLStringResult FLValue_ToJSON5 (FLValue FL_NULLABLE)
-
- -

Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric.

-

This tends to be more readable.

- -
-
- -

◆ FLValue_ToJSONX()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
FLStringResult FLValue_ToJSONX (FLValue FL_NULLABLE v,
bool json5,
bool canonicalForm 
)
-
- -

Most general Fleece to JSON converter.

- -
-
diff --git a/docs/C/html/group__reading.html b/docs/C/html/group__reading.html index 5aef8c3c3c..ecce4001f1 100644 --- a/docs/C/html/group__reading.html +++ b/docs/C/html/group__reading.html @@ -2,8 +2,8 @@ - - + + LiteCore: Reading Fleece Data @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -62,220 +63,54 @@

-
-
Reading Fleece Data
+
Reading Fleece Data
- - - - - - - - - - - + - - - - + - + - + - + - + - + - + + + + - - - - - - -

FLDoc

An FLDoc points to (and often owns) Fleece-encoded data and provides access to its Fleece values.

+

An FLDoc points to (and often owns) Fleece-encoded data and provides access to its Fleece values.

enum  FLTrust { kFLUntrusted -, kFLTrusted - }
 Specifies whether not input data is trusted to be 100% valid Fleece. More...
 
typedef struct _FLDoc * FLDoc
 A reference to a document. More...
 
typedef struct _FLSharedKeys * FLSharedKeys
 A reference to a shared-keys mapping. More...
 
FLDoc FLDoc_FromResultData (FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
FLDoc FLDoc_FromResultData (FLSliceResult data, FLTrust, FLSharedKeys FL_NULLABLE, FLSlice externData)
 Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other API. More...
 
FLDoc FLDoc_FromJSON (FLSlice json, FLError *FL_NULLABLE outError)
 Creates an FLDoc from JSON-encoded data. More...
 
void FLDoc_Release (FLDoc FL_NULLABLE)
void FLDoc_Release (FLDoc FL_NULLABLE)
 Releases a reference to an FLDoc. More...
 
FLDoc FLDoc_Retain (FLDoc FL_NULLABLE)
FLDoc FLDoc_Retain (FLDoc FL_NULLABLE)
 Adds a reference to an FLDoc. More...
 
FLSlice FLDoc_GetData (FLDoc FL_NULLABLE) FLPURE
FLSlice FLDoc_GetData (FLDoc FL_NULLABLE) FLPURE
 Returns the encoded Fleece data backing the document. More...
 
FLSliceResult FLDoc_GetAllocedData (FLDoc FL_NULLABLE) FLPURE
FLSliceResult FLDoc_GetAllocedData (FLDoc FL_NULLABLE) FLPURE
 Returns the FLSliceResult data owned by the document, if any, else a null slice. More...
 
FLValue FLDoc_GetRoot (FLDoc FL_NULLABLE) FLPURE
FLValue FLDoc_GetRoot (FLDoc FL_NULLABLE) FLPURE
 Returns the root value in the FLDoc, usually an FLDict. More...
 
FLSharedKeys FLDoc_GetSharedKeys (FLDoc FL_NULLABLE) FLPURE
FLSharedKeys FLDoc_GetSharedKeys (FLDoc FL_NULLABLE) FLPURE
 Returns the FLSharedKeys used by this FLDoc, as specified when it was created. More...
 
bool FLDoc_SetAssociated (FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
FLDoc FL_NULLABLE FLValue_FindDoc (FLValue FL_NULLABLE) FLPURE
 Looks up the Doc containing the Value, or NULL if there is none. More...
 
bool FLDoc_SetAssociated (FLDoc FL_NULLABLE doc, void *FL_NULLABLE pointer, const char *type)
 Associates an arbitrary pointer value with a document, and thus its contained values. More...
 
void * FLDoc_GetAssociated (FLDoc FL_NULLABLE doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 
FLDoc FL_NULLABLE FLValue_FindDoc (FLValue FL_NULLABLE) FLPURE
 Looks up the Doc containing the Value, or NULL if the Value was created without a Doc. More...
 
- - - - - - - - - - + + +

Parsing And Converting Values Directly

FLValue FL_NULLABLE FLValue_FromData (FLSlice data, FLTrust) FLPURE
 Returns a pointer to the root value in the encoded data, or NULL if validation failed. More...
 
FLSliceResult FLData_ConvertJSON (FLSlice json, FLError *FL_NULLABLE outError)
 Directly converts JSON data to Fleece-encoded data. More...
 
FLStringResult FLData_Dump (FLSlice data)
 Produces a human-readable dump of the Value encoded in the data. More...
 
void * FLDoc_GetAssociated (FLDoc FL_NULLABLE doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 

Detailed Description

-

Typedef Documentation

- -

◆ FLDoc

- -
-
- - - - -
typedef struct _FLDoc* FLDoc
-
- -

A reference to a document.

- -
-
- -

◆ FLSharedKeys

- -
-
- - - - -
typedef struct _FLSharedKeys* FLSharedKeys
-
- -

A reference to a shared-keys mapping.

- -
-
-

Enumeration Type Documentation

- -

◆ FLTrust

- -
-
- - - - -
enum FLTrust
-
- -

Specifies whether not input data is trusted to be 100% valid Fleece.

- - - -
Enumerator
kFLUntrusted 

Input data is not trusted to be valid, and will be fully validated by the API call.

-
kFLTrusted 

Input data is trusted to be valid.

-

The API will perform only minimal validation when reading it. This is faster than kFLUntrusted, but should only be used if the data was generated by a trusted encoder and has not been altered or corrupted. For example, this can be used to parse Fleece data previously stored by your code in local storage. If invalid data is read by this call, subsequent calls to Value accessor functions can crash or return bogus results (including data from arbitrary memory locations.)

-
- -
-

Function Documentation

- -

◆ FLData_ConvertJSON()

- -
-
- - - - - - - - - - - - - - - - - - -
FLSliceResult FLData_ConvertJSON (FLSlice json,
FLError *FL_NULLABLE outError 
)
-
- -

Directly converts JSON data to Fleece-encoded data.

-

You can then call FLValue_FromData (in kFLTrusted mode) to get the root as a Value.

- -
-
- -

◆ FLData_Dump()

- -
-
- - - - - - - - -
FLStringResult FLData_Dump (FLSlice data)
-
- -

Produces a human-readable dump of the Value encoded in the data.

-

This is only useful if you already know, or want to learn, the encoding format.

- -
-
- -

◆ FLDoc_FromJSON()

- -
-
- - - - - - - - - - - - - - - - - - -
FLDoc FLDoc_FromJSON (FLSlice json,
FLError *FL_NULLABLE outError 
)
-
- -

Creates an FLDoc from JSON-encoded data.

-

The data is first encoded into Fleece, and the Fleece data is kept by the doc; the input JSON data is no longer needed after this function returns.

- -
-
- +

◆ FLDoc_FromResultData()

- + @@ -283,13 +118,13 @@

- + - + @@ -307,11 +142,11 @@

Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other API.

-

The resulting document retains the data, so you don't need to worry about it remaining valid.

+

The resulting document retains the data, so you don't need to worry about it remaining valid.

-
+

◆ FLDoc_GetAllocedData()

@@ -320,7 +155,7 @@

FLSliceResult FLDoc_GetAllocedData

- + @@ -331,16 +166,16 @@

-

◆ FLDoc_GetAssociated()

+ +

◆ FLDoc_GetAssociated()

FLDoc FLDoc_FromResultData FLDoc FLDoc_FromResultData ( FLSliceResult  data, FLTrust FLTrust  ,
FLSharedKeys FLSharedKeys  FL_NULLABLE,
(FLDoc FLDoc  FL_NULLABLE)
- + - + @@ -358,7 +193,7 @@

Returns the pointer associated with the document.

-

You can use this together with FLValue_FindDoc to associate your own object with Fleece values, for instance to find your object that "owns" a value: myDoc = (app::Document*)FLDoc_GetAssociated(FLValue_FindDoc(val), "app::Document");.

Parameters
+

You can use this together with FLValue_FindDoc to associate your own object with Fleece values, for instance to find your object that "owns" a value: myDoc = (app::Document*)FLDoc_GetAssociated(FLValue_FindDoc(val), "app::Document");.

Parameters

void* FLDoc_GetAssociated void * FLDoc_GetAssociated (FLDoc FL_NULLABLE FLDoc FL_NULLABLE  doc,
@@ -369,7 +204,7 @@

+

◆ FLDoc_GetData()

@@ -378,7 +213,7 @@

FLSlice FLDoc_GetData

- + @@ -389,7 +224,7 @@

+

◆ FLDoc_GetRoot()

@@ -398,7 +233,7 @@

FLValue FLDoc_GetRoot

- + @@ -409,16 +244,16 @@

+

◆ FLDoc_GetSharedKeys()

docThe FLDoc to get a pointer from.
typeThe type of object expected, i.e. the same string literal passed to FLDoc_SetAssociated.
(FLDoc FLDoc  FL_NULLABLE)
(FLDoc FLDoc  FL_NULLABLE)
- + - + @@ -429,7 +264,7 @@

+

◆ FLDoc_Release()

@@ -438,7 +273,7 @@

void FLDoc_Release

- + @@ -446,20 +281,20 @@

Releases a reference to an FLDoc.

-

This must be called once to free an FLDoc you created.

+

This must be called once to free an FLDoc you created.

-
+

◆ FLDoc_Retain()

FLSharedKeys FLDoc_GetSharedKeys FLSharedKeys FLDoc_GetSharedKeys (FLDoc FLDoc  FL_NULLABLE)
(FLDoc FLDoc  FL_NULLABLE)
- + - + @@ -467,11 +302,11 @@

Adds a reference to an FLDoc.

-

This extends its lifespan until at least such time as you call FLRelease to remove the reference.

+

This extends its lifespan until at least such time as you call FLRelease to remove the reference.

-
+

◆ FLDoc_SetAssociated()

@@ -480,13 +315,13 @@

bool FLDoc_SetAssociated

- + - + @@ -504,7 +339,7 @@

Associates an arbitrary pointer value with a document, and thus its contained values.

-

Allows client code to associate its own pointer with this FLDoc and its Values, which can later be retrieved with FLDoc_GetAssociated. For example, this could be a pointer to an app::Document object, of which this Doc's root FLDict is its properties. You would store it by calling FLDoc_SetAssociated(doc, myDoc, "app::Document");.

Parameters
+

Allows client code to associate its own pointer with this FLDoc and its Values, which can later be retrieved with FLDoc_GetAssociated. For example, this could be a pointer to an app::Document object, of which this Doc's root FLDict is its properties. You would store it by calling FLDoc_SetAssociated(doc, myDoc, "app::Document");.

Parameters

FLDoc FLDoc_Retain FLDoc FLDoc_Retain (FLDoc FLDoc  FL_NULLABLE)
(FLDoc FL_NULLABLE FLDoc FL_NULLABLE  doc,
void *FL_NULLABLE void *FL_NULLABLE  pointer,
@@ -519,14 +354,14 @@

+

◆ FLValue_FindDoc()

docThe FLDoc to store a pointer in.
pointerThe pointer to store in the FLDoc.
- + @@ -535,46 +370,15 @@

-

Looks up the Doc containing the Value, or NULL if the Value was created without a Doc.

+

Looks up the Doc containing the Value, or NULL if there is none.

Note
Caller must release the FLDoc reference!!
- - -
-

◆ FLValue_FromData()

- -
-
-

FLDoc FL_NULLABLE FLValue_FindDoc FLDoc FL_NULLABLE FLValue_FindDoc ( FLValue  FL_NULLABLE)
- - - - - - - - - - - - - - - - - -
FLValue FL_NULLABLE FLValue_FromData (FLSlice data,
FLTrust  
)
-
- -

Returns a pointer to the root value in the encoded data, or NULL if validation failed.

-

The FLValue, and all values found through it, are only valid as long as the encoded data remains intact and unchanged.

-
diff --git a/docs/C/html/group__types.html b/docs/C/html/group__types.html index 99aa01dc97..f99e88f5c9 100644 --- a/docs/C/html/group__types.html +++ b/docs/C/html/group__types.html @@ -2,8 +2,8 @@ - - + + LiteCore: Basic Fleece Data Types @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -65,12 +66,11 @@ -
-
Basic Fleece Data Types
+
Basic Fleece Data Types

- @@ -93,8 +93,14 @@ + + + + + +

+

Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
typedef struct _FLEncoder * FLEncoder
 A reference to an encoder. More...
 
typedef struct _FLDoc * FLDoc
 A reference to a document. More...
 
typedef struct _FLSharedKeys * FLSharedKeys
 A reference to a shared-keys mapping. More...
 
- + + + +

+

Enumerations

enum  FLError {
  kFLNoError = 0 @@ -115,10 +121,52 @@ }
 Error codes returned from some API calls. More...
 
enum  FLTrust { kFLUntrusted +, kFLTrusted + }
 Specifies whether not input data is trusted to be 100% valid Fleece. More...
 
+ + + + + + + + + + + + + + + + +

Timestamps

Fleece does not have a native type for dates or times; like JSON, they are represented as strings in ISO-8601 format, which look like "2008-08-07T05:18:51.589Z".

+

They can also be represented more compactly as numbers, interpreted as milliseconds since the Unix epoch (midnight at January 1 1970, UTC.)

+
typedef int64_t FLTimestamp
 A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) More...
 
FLTimestamp FLTimestamp_Now (void)
 Returns an FLTimestamp corresponding to the current time. More...
 
FLStringResult FLTimestamp_ToString (FLTimestamp timestamp, bool asUTC)
 Formats a timestamp as a date-time string in ISO-8601 format. More...
 
FLTimestamp FLTimestamp_FromString (FLString str)
 Parses an ISO-8601 date-time string to a timestamp. More...
 
#define FLTimestampNone   INT64_MIN
 A value representing a missing timestamp; returned when a date cannot be parsed. More...
 

Detailed Description

+

Macro Definition Documentation

+ +

◆ FLTimestampNone

+ +
+
+ + + + +
#define FLTimestampNone   INT64_MIN
+
+ +

A value representing a missing timestamp; returned when a date cannot be parsed.

+ +
+

Typedef Documentation

- +

◆ FLArray

@@ -134,7 +182,7 @@

+

◆ FLDict

@@ -150,7 +198,23 @@

+ +

◆ FLDoc

+ +
+
+ + + + +
typedef struct _FLDoc* FLDoc
+
+ +

A reference to a document.

+ +
+
+

◆ FLEncoder

@@ -166,7 +230,7 @@

+

◆ FLMutableArray

@@ -182,7 +246,7 @@

+

◆ FLMutableDict

@@ -198,7 +262,23 @@

+ +

◆ FLSharedKeys

+ +
+
+ + + + +
typedef struct _FLSharedKeys* FLSharedKeys
+
+ +

A reference to a shared-keys mapping.

+ +
+
+

◆ FLSlot

@@ -214,7 +294,23 @@

+ +

◆ FLTimestamp

+ +
+
+ + + + +
typedef int64_t FLTimestamp
+
+ +

A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.)

+ +
+
+

◆ FLValue

@@ -231,7 +327,7 @@

Enumeration Type Documentation

- +

◆ FLError

@@ -245,26 +341,130 @@

-EnumeratorkFLNoError  -kFLMemoryError  -kFLOutOfRange  -kFLInvalidData  -kFLEncodeError  -kFLJSONError  -kFLUnknownValue  -kFLInternalError  -kFLNotFound  -kFLSharedKeysStateError  -kFLPOSIXError  -kFLUnsupported  +EnumeratorkFLNoError  +kFLMemoryError  +kFLOutOfRange  +kFLInvalidData  +kFLEncodeError  +kFLJSONError  +kFLUnknownValue  +kFLInternalError  +kFLNotFound  +kFLSharedKeysStateError  +kFLPOSIXError  +kFLUnsupported  + + +

+
+ +

◆ FLTrust

+ +
+
+ + + + +
enum FLTrust
+
+ +

Specifies whether not input data is trusted to be 100% valid Fleece.

+ + +
Enumerator
kFLUntrusted 

Input data is not trusted to be valid, and will be fully validated by the API call.

+
kFLTrusted 

Input data is trusted to be valid.

+

The API will perform only minimal validation when reading it. This is faster than kFLUntrusted, but should only be used if the data was generated by a trusted encoder and has not been altered or corrupted. For example, this can be used to parse Fleece data previously stored by your code in local storage. If invalid data is read by this call, subsequent calls to Value accessor functions can crash or return bogus results (including data from arbitrary memory locations.)

+
+
+
+

Function Documentation

+ +

◆ FLTimestamp_FromString()

+ +
+
+ + + + + + + + +
FLTimestamp FLTimestamp_FromString (FLString str)
+
+ +

Parses an ISO-8601 date-time string to a timestamp.

+

On failure returns FLTimestampNone.

Note
See also FLValue_AsTimestamp, which takes an FLValue and interprets numeric representations as well as strings.
+ +
+
+ +

◆ FLTimestamp_Now()

+ +
+
+ + + + + + + + +
FLTimestamp FLTimestamp_Now (void )
+
+ +

Returns an FLTimestamp corresponding to the current time.

+ +
+
+ +

◆ FLTimestamp_ToString()

+ +
+
+ + + + + + + + + + + + + + + + + + +
FLStringResult FLTimestamp_ToString (FLTimestamp timestamp,
bool asUTC 
)
+
+ +

Formats a timestamp as a date-time string in ISO-8601 format.

+
Note
See also FLEncoder_WriteDateString, which writes a timestamp to an FLEncoder.
+
Parameters
+ + + +
timestampA time, given as milliseconds since the Unix epoch (1/1/1970 00:00 UTC.)
asUTCIf true, the timestamp will be given in universal time; if false, in the local timezone.
+
+
+
Returns
A heap-allocated string, which you are responsible for releasing.
+

diff --git a/docs/C/html/index.html b/docs/C/html/index.html index 465fed4bcb..fc29168dd0 100644 --- a/docs/C/html/index.html +++ b/docs/C/html/index.html @@ -2,8 +2,8 @@ - - + + LiteCore: Main Page @@ -30,21 +30,22 @@

- + +/* @license-end */ +

@@ -62,14 +63,13 @@

-
-
LiteCore Documentation
+
LiteCore Documentation
diff --git a/docs/C/html/jquery.js b/docs/C/html/jquery.js index 103c32d79b..c9ed3d99cb 100644 --- a/docs/C/html/jquery.js +++ b/docs/C/html/jquery.js @@ -1,5 +1,5 @@ -/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0
'); + searchBox='
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + '
'; } else { - $('#main-menu').append('
  • '); + searchBox='
    '+ + ''+ + ''+ + ''+ + ''+ + ''+ + '' + '' + '
    '; + } + } + + $('#main-nav').before('
    '+ + ''+ + ''+ + '
    '); + $('#main-nav').append(makeTree(menudata,relPath)); + $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); + if (searchBox) { + $('#main-menu').append('
  • '); + } + var $mainMenuState = $('#main-menu-state'); + var prevWidth = 0; + if ($mainMenuState.length) { + function initResizableIfExists() { + if (typeof initResizable==='function') initResizable(); + } + // animate mobile menu + $mainMenuState.change(function(e) { + var $menu = $('#main-menu'); + var options = { duration: 250, step: initResizableIfExists }; + if (this.checked) { + options['complete'] = function() { $menu.css('display', 'block') }; + $menu.hide().slideDown(options); + } else { + options['complete'] = function() { $menu.css('display', 'none') }; + $menu.show().slideUp(options); + } + }); + // set default menu visibility + function resetState() { + var $menu = $('#main-menu'); + var $mainMenuState = $('#main-menu-state'); + var newWidth = $(window).outerWidth(); + if (newWidth!=prevWidth) { + if ($(window).outerWidth()<768) { + $mainMenuState.prop('checked',false); $menu.hide(); + $('#searchBoxPos1').html(searchBox); + $('#searchBoxPos2').hide(); + } else { + $menu.show(); + $('#searchBoxPos1').empty(); + $('#searchBoxPos2').html(searchBox); + $('#searchBoxPos2').show(); + } + prevWidth = newWidth; + } } + $(window).ready(function() { resetState(); initResizableIfExists(); }); + $(window).resize(resetState); } $('#main-menu').smartmenus(); } diff --git a/docs/C/html/modules.html b/docs/C/html/modules.html index e1eb8bfe9f..da8eea02b0 100644 --- a/docs/C/html/modules.html +++ b/docs/C/html/modules.html @@ -2,8 +2,8 @@ - - + + LiteCore: Modules @@ -30,21 +30,22 @@

    - + +/* @license-end */ +

    @@ -62,49 +63,49 @@
    -
    -
    Modules
    +
    Modules
    Here is a list of all modules:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
    [detail level 12]
     Data Types and Base Functions
     Miscellaneous Functions
     Blobs
     Collections and ScopesA C4Collection represents a Collection, a named grouping of documents in a database
     Databases
     Raw Documents
     Document Enumeration
     Documents
     Database, Document, Query Observers
     Error Codes and Error Handling
     Database Indexes
     Network Listener: REST API and Sync Server
     Logging
     Predictive (Machine-Learning) QueryThis API allows you to register a machine-learning model with LiteCore
     Querying the Database
     Replicator
     Replication Socket Provider API
     Fleece CoreFoundation and Objective-C Helpers
     Basic Fleece Data Types
     Reading Fleece Data
     Converting Fleece To JSONThese are convenience functions that directly return JSON-encoded output
     Fleece Value AccessorsThe core Fleece data type is FLValue: a reference to a value in Fleece-encoded data
     Fleece ArraysFLArray is a "subclass" of FLValue, representing values that are arrays
     Fleece Dictionaries
     Fleece Deep IteratorA deep iterator traverses every value contained in a dictionary, in depth-first order
     Fleece PathsAn FLKeyPath Describes a location in a Fleece object tree, as a path from the root that follows dictionary properties and array elements
     Shared KeysFLSharedKeys represents a mapping from short strings to small integers in the range [0...2047]
     Fleece EncodersAn FLEncoder generates encoded Fleece or JSON data
     Fleece Delta CompressionThese functions implement a fairly-efficient "delta" encoding that encapsulates the changes needed to transform one Fleece value into another
     Value SlotsAn FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions
     Slices
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     Basic Fleece Data Types
     Blobs
     Collections and ScopesA C4Collection represents a Collection, a named grouping of documents in a database
     Connected Client (Remote Database)The Connected Client API allows you to get and put documents, and listen for changes, directly on a remote database server (Sync Gateway or a Couchbase Lite sync listener), without any local database
     Data Types and Base Functions
     Database Indexes
     Database, Document, Query Observers
     Databases
     Document Enumeration
     Documents
     Error Codes and Error Handling
     Fleece ArraysFLArray is a "subclass" of FLValue, representing values that are arrays
     Fleece CoreFoundation and Objective-C Helpers
     Fleece Deep IteratorA deep iterator traverses every value contained in a dictionary, in depth-first order
     Fleece Dictionaries
     Fleece EncodersAn FLEncoder generates encoded Fleece or JSON data
     Fleece PathsAn FLKeyPath Describes a location in a Fleece object tree, as a path from the root that follows dictionary properties and array elements
     Fleece ValuesThe core Fleece data type is FLValue: a reference to a value in Fleece-encoded data
     JSON Interoperability
     Logging
     Miscellaneous Functions
     Mutable Values
     Value SlotsAn FLSlot is a temporary reference to an element of a mutable Array/Dict; its only purpose is to let you store a value into it, using the FLSlot_... functions
     Network Listener: REST API and Sync Server
     Predictive (Machine-Learning) QueryThis API allows you to register a machine-learning model with LiteCore
     Querying the Database
     Rarely-needed or advanced functions
     Raw Documents
     Reading Fleece Data
     Replication Socket Provider API
     Replicator
     Slices
    diff --git a/docs/C/html/search/all_0.html b/docs/C/html/search/all_0.html index 1ec5b2d597..65f85b5b74 100644 --- a/docs/C/html/search/all_0.html +++ b/docs/C/html/search/all_0.html @@ -2,7 +2,7 @@ - + @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    @@ -12,14 +12,14 @@
    Loading...
    Searching...
    No Matches
    +/* @license-end */ +
    -
    -
    C4Address Struct Reference
    +
    C4Address Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ReplicatorTypes.h>

    - @@ -86,10 +86,10 @@

    +

    Data Fields

    C4String scheme
     
     

    Detailed Description

    -

    A simple parsed-URL type.

    -

    A simple parsed-URL struct.

    +

    A simple parsed-URL type.

    +

    A simple parsed-URL struct.

    Field Documentation

    - +

    ◆ hostname

    @@ -103,7 +103,7 @@

    +

    ◆ path

    @@ -117,7 +117,7 @@

    +

    ◆ port

    @@ -131,7 +131,7 @@

    +

    ◆ scheme

    @@ -151,7 +151,7 @@

    diff --git a/docs/C/html/struct_c4_blob_key.html b/docs/C/html/struct_c4_blob_key.html index 8e194a4a73..302e37b03e 100644 --- a/docs/C/html/struct_c4_blob_key.html +++ b/docs/C/html/struct_c4_blob_key.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4BlobKey Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4BlobKey Struct Reference
    +
    C4BlobKey Struct Reference
    @@ -74,16 +74,16 @@

    #include <c4BlobStoreTypes.h>

    -

    +

    Data Fields

    uint8_t bytes [20]
     

    Detailed Description

    -

    A unique identifier of a blob based on a SHA-1 digest of its contents.

    -

    A raw SHA-1 digest (20 bytes), used as the unique identifier of a blob.

    +

    A unique identifier of a blob based on a SHA-1 digest of its contents.

    +

    A raw SHA-1 digest (20 bytes), used as the unique identifier of a blob.

    Field Documentation

    - +

    ◆ bytes

    @@ -103,7 +103,7 @@

    diff --git a/docs/C/html/struct_c4_collection_change.html b/docs/C/html/struct_c4_collection_change.html index 27cd20c7c0..48c30fcb44 100644 --- a/docs/C/html/struct_c4_collection_change.html +++ b/docs/C/html/struct_c4_collection_change.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4CollectionChange Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4CollectionChange Struct Reference
    +
    C4CollectionChange Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DocumentTypes.h>

    - @@ -93,9 +93,9 @@

    +

    Data Fields

    C4HeapString docID
     The document's ID. More...
     

    Detailed Description

    -

    Represents a change to a document in a collection, as returned from c4dbobs_getChanges.

    +

    Represents a change to a document in a collection, as returned from c4dbobs_getChanges.

    Field Documentation

    - +

    ◆ bodySize

    @@ -111,7 +111,7 @@

    +

    ◆ docID

    @@ -127,7 +127,7 @@

    +

    ◆ flags

    @@ -143,7 +143,7 @@

    +

    ◆ revID

    @@ -159,7 +159,7 @@

    +

    ◆ sequence

    @@ -181,7 +181,7 @@

    diff --git a/docs/C/html/struct_c4_collection_spec.html b/docs/C/html/struct_c4_collection_spec.html index 848aaff021..52040a5edc 100644 --- a/docs/C/html/struct_c4_collection_spec.html +++ b/docs/C/html/struct_c4_collection_spec.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4CollectionSpec Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4CollectionSpec Struct Reference
    +
    C4CollectionSpec Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DatabaseTypes.h>

    - @@ -82,9 +82,9 @@

    +

    Data Fields

    C4String name
     
     

    Detailed Description

    -

    Full identifier of a collection in a database, including its scope.

    +

    Full identifier of a collection in a database, including its scope.

    Field Documentation

    - +

    ◆ name

    @@ -98,7 +98,7 @@

    +

    ◆ scope

    @@ -118,7 +118,7 @@

    diff --git a/docs/C/html/struct_c4_connected_client_parameters.html b/docs/C/html/struct_c4_connected_client_parameters.html new file mode 100644 index 0000000000..a427088066 --- /dev/null +++ b/docs/C/html/struct_c4_connected_client_parameters.html @@ -0,0 +1,206 @@ + + + + + + + +LiteCore: C4ConnectedClientParameters Struct Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LiteCore +
    +
    Couchbase Lite cross-platform core implementation
    +
    +
    + + + + + + + + +
    +
    + + +
    + +
    + +
    +
    + +
    C4ConnectedClientParameters Struct Reference
    +
    +
    + +

    Parameters describing a connected client, used when creating a C4ConnectedClient. + More...

    + +

    #include <c4ConnectedClientTypes.h>

    + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    C4Slice url
     URL with database to connect. More...
     
    C4Slice optionsDictFleece
     Fleece-encoded dictionary of optional parameters. More...
     
    C4ReplicatorPropertyEncryptionCallback propertyEncryptor
     Encryption callback. More...
     
    C4ReplicatorPropertyDecryptionCallback propertyDecryptor
     Decryption callback. More...
     
    void * callbackContext
     Value passed to callbacks. More...
     
    const C4SocketFactorysocketFactory
     Custom C4SocketFactory. More...
     
    +

    Detailed Description

    +

    Parameters describing a connected client, used when creating a C4ConnectedClient.

    +

    Field Documentation

    + +

    ◆ callbackContext

    + +
    +
    + + + + +
    void* C4ConnectedClientParameters::callbackContext
    +
    + +

    Value passed to callbacks.

    + +
    +
    + +

    ◆ optionsDictFleece

    + +
    +
    + + + + +
    C4Slice C4ConnectedClientParameters::optionsDictFleece
    +
    + +

    Fleece-encoded dictionary of optional parameters.

    + +
    +
    + +

    ◆ propertyDecryptor

    + +
    +
    + + + + +
    C4ReplicatorPropertyDecryptionCallback C4ConnectedClientParameters::propertyDecryptor
    +
    + +

    Decryption callback.

    + +
    +
    + +

    ◆ propertyEncryptor

    + +
    +
    + + + + +
    C4ReplicatorPropertyEncryptionCallback C4ConnectedClientParameters::propertyEncryptor
    +
    + +

    Encryption callback.

    + +
    +
    + +

    ◆ socketFactory

    + +
    +
    + + + + +
    const C4SocketFactory* C4ConnectedClientParameters::socketFactory
    +
    + +

    Custom C4SocketFactory.

    + +
    +
    + +

    ◆ url

    + +
    +
    + + + + +
    C4Slice C4ConnectedClientParameters::url
    +
    + +

    URL with database to connect.

    + +
    +
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/docs/C/html/struct_c4_database_config.html b/docs/C/html/struct_c4_database_config.html index e2f8878870..fd6dedd00e 100644 --- a/docs/C/html/struct_c4_database_config.html +++ b/docs/C/html/struct_c4_database_config.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4DatabaseConfig Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4DatabaseConfig Struct Reference
    +
    C4DatabaseConfig Struct Reference

    #include <c4DatabaseTypes.h>

    - @@ -87,7 +87,7 @@

    +

    Data Fields

    C4DatabaseFlags flags
     Create, ReadOnly, AutoCompact, Bundled... More...
     

    Field Documentation

    - +

    ◆ encryptionKey

    @@ -103,7 +103,7 @@

    +

    ◆ flags

    @@ -119,7 +119,7 @@

    +

    ◆ storageEngine

    @@ -135,7 +135,7 @@

    +

    ◆ versioning

    @@ -157,7 +157,7 @@

    diff --git a/docs/C/html/struct_c4_database_config2.html b/docs/C/html/struct_c4_database_config2.html index 49a7741eb6..e9aa59b8b1 100644 --- a/docs/C/html/struct_c4_database_config2.html +++ b/docs/C/html/struct_c4_database_config2.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4DatabaseConfig2 Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4DatabaseConfig2 Struct Reference
    +
    C4DatabaseConfig2 Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DatabaseTypes.h>

    - @@ -87,9 +87,9 @@

    +

    Data Fields

    C4Slice parentDirectory
     Directory for databases. More...
     

    Detailed Description

    -

    Main database configuration struct (version 2) for use with c4db_openNamed etc.

    +

    Main database configuration struct (version 2) for use with c4db_openNamed etc.

    Field Documentation

    - +

    ◆ encryptionKey

    @@ -105,7 +105,7 @@

    +

    ◆ flags

    @@ -121,7 +121,7 @@

    +

    ◆ parentDirectory

    @@ -143,7 +143,7 @@

    diff --git a/docs/C/html/struct_c4_doc_put_request.html b/docs/C/html/struct_c4_doc_put_request.html index a0c9e5b173..168952349b 100644 --- a/docs/C/html/struct_c4_doc_put_request.html +++ b/docs/C/html/struct_c4_doc_put_request.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4DocPutRequest Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4DocPutRequest Struct Reference
    +
    C4DocPutRequest Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DocumentTypes.h>

    - @@ -120,9 +120,9 @@

    +

    Data Fields

    C4String body
     Revision's body. More...
     

    Detailed Description

    -

    Parameters for adding a revision using c4doc_put.

    +

    Parameters for adding a revision using c4doc_put.

    Field Documentation

    - +

    ◆ allocedBody

    @@ -138,7 +138,7 @@

    +

    ◆ allowConflict

    @@ -154,7 +154,7 @@

    +

    ◆ body

    @@ -170,7 +170,7 @@

    +

    ◆ deltaCB

    @@ -186,7 +186,7 @@

    +

    ◆ deltaCBContext

    @@ -202,7 +202,7 @@

    +

    ◆ deltaSourceRevID

    @@ -218,7 +218,7 @@

    +

    ◆ docID

    @@ -234,7 +234,7 @@

    +

    ◆ existingRevision

    @@ -250,7 +250,7 @@

    +

    ◆ history

    @@ -266,7 +266,7 @@

    +

    ◆ historyCount

    @@ -282,7 +282,7 @@

    +

    ◆ maxRevTreeDepth

    @@ -298,7 +298,7 @@

    +

    ◆ remoteDBID

    @@ -314,7 +314,7 @@

    +

    ◆ revFlags

    @@ -330,7 +330,7 @@

    +

    ◆ save

    @@ -352,7 +352,7 @@

    diff --git a/docs/C/html/struct_c4_doc_response.html b/docs/C/html/struct_c4_doc_response.html new file mode 100644 index 0000000000..0a2e83f3f9 --- /dev/null +++ b/docs/C/html/struct_c4_doc_response.html @@ -0,0 +1,168 @@ + + + + + + + +LiteCore: C4DocResponse Struct Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LiteCore +
    +
    Couchbase Lite cross-platform core implementation
    +
    +
    + + + + + + + + +
    +
    + + +
    + +
    + +
    +
    + +
    C4DocResponse Struct Reference
    +
    +
    + +

    Result of a successful c4client_getDoc call. + More...

    + +

    #include <c4ConnectedClientTypes.h>

    + + + + + + + + + + + + + + +

    +Data Fields

    C4HeapSlice docID
     The document ID. More...
     
    C4HeapSlice revID
     The revision ID. More...
     
    C4HeapSlice body
     The document body (Fleece or JSON, as requested) More...
     
    bool deleted
     True if the document is deleted. More...
     
    +

    Detailed Description

    +

    Result of a successful c4client_getDoc call.

    +

    Field Documentation

    + +

    ◆ body

    + +
    +
    + + + + +
    C4HeapSlice C4DocResponse::body
    +
    + +

    The document body (Fleece or JSON, as requested)

    + +
    +
    + +

    ◆ deleted

    + +
    +
    + + + + +
    bool C4DocResponse::deleted
    +
    + +

    True if the document is deleted.

    + +
    +
    + +

    ◆ docID

    + +
    +
    + + + + +
    C4HeapSlice C4DocResponse::docID
    +
    + +

    The document ID.

    + +
    +
    + +

    ◆ revID

    + +
    +
    + + + + +
    C4HeapSlice C4DocResponse::revID
    +
    + +

    The revision ID.

    + +
    +
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/docs/C/html/struct_c4_document.html b/docs/C/html/struct_c4_document.html index b6851bec92..d5565b277f 100644 --- a/docs/C/html/struct_c4_document.html +++ b/docs/C/html/struct_c4_document.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4Document Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4Document Struct Reference
    +
    C4Document Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DocumentStruct.h>

    - @@ -100,9 +100,9 @@

    +

    Data Fields

    void * _internal1
     
     

    Detailed Description

    -

    Describes a version-controlled document.

    +

    Describes a version-controlled document.

    Field Documentation

    - +

    ◆ _internal1

    @@ -116,7 +116,7 @@

    +

    ◆ _internal2

    @@ -130,7 +130,7 @@

    +

    ◆ docID

    @@ -146,7 +146,7 @@

    +

    ◆ extraInfo

    @@ -162,7 +162,7 @@

    +

    ◆ flags

    @@ -178,7 +178,7 @@

    +

    ◆ revID

    @@ -194,7 +194,7 @@

    +

    ◆ selectedRev

    @@ -210,7 +210,7 @@

    +

    ◆ sequence

    @@ -232,7 +232,7 @@

    diff --git a/docs/C/html/struct_c4_document_ended.html b/docs/C/html/struct_c4_document_ended.html index 8b3652af42..e5f24ede7e 100644 --- a/docs/C/html/struct_c4_document_ended.html +++ b/docs/C/html/struct_c4_document_ended.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4DocumentEnded Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4DocumentEnded Struct Reference
    +
    C4DocumentEnded Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ReplicatorTypes.h>

    - @@ -92,9 +92,9 @@

    +

    Data Fields

    C4HeapString collectionName
     
     

    Detailed Description

    -

    Information about a document that's been pushed or pulled.

    +

    Information about a document that's been pushed or pulled.

    Field Documentation

    - +

    ◆ collectionName

    @@ -108,7 +108,7 @@

    +

    ◆ docID

    @@ -122,7 +122,7 @@

    +

    ◆ error

    @@ -136,7 +136,7 @@

    +

    ◆ errorIsTransient

    @@ -150,7 +150,7 @@

    +

    ◆ flags

    @@ -164,7 +164,7 @@

    +

    ◆ revID

    @@ -178,7 +178,7 @@

    +

    ◆ sequence

    @@ -198,7 +198,7 @@

    diff --git a/docs/C/html/struct_c4_document_info.html b/docs/C/html/struct_c4_document_info.html index cfdbcfce66..de64c8980f 100644 --- a/docs/C/html/struct_c4_document_info.html +++ b/docs/C/html/struct_c4_document_info.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4DocumentInfo Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4DocumentInfo Struct Reference
    +
    C4DocumentInfo Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DocEnumeratorTypes.h>

    - @@ -99,9 +99,9 @@

    +

    Data Fields

    C4DocumentFlags flags
     Document flags. More...
     

    Detailed Description

    -

    Metadata about a document (actually about its current revision.)

    +

    Metadata about a document (actually about its current revision.)

    Field Documentation

    - +

    ◆ bodySize

    @@ -117,7 +117,7 @@

    +

    ◆ docID

    @@ -133,7 +133,7 @@

    +

    ◆ expiration

    @@ -149,7 +149,7 @@

    +

    ◆ flags

    @@ -165,7 +165,7 @@

    +

    ◆ metaSize

    @@ -181,7 +181,7 @@

    +

    ◆ revID

    @@ -197,7 +197,7 @@

    +

    ◆ sequence

    @@ -219,7 +219,7 @@

    diff --git a/docs/C/html/struct_c4_encryption_key.html b/docs/C/html/struct_c4_encryption_key.html index e9b6872f83..5048d37983 100644 --- a/docs/C/html/struct_c4_encryption_key.html +++ b/docs/C/html/struct_c4_encryption_key.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4EncryptionKey Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4EncryptionKey Struct Reference
    +
    C4EncryptionKey Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DatabaseTypes.h>

    - @@ -82,9 +82,9 @@

    +

    Data Fields

    C4EncryptionAlgorithm algorithm
     
     

    Detailed Description

    -

    Encryption key specified in a C4DatabaseConfig.

    +

    Encryption key specified in a C4DatabaseConfig.

    Field Documentation

    - +

    ◆ algorithm

    @@ -98,7 +98,7 @@

    +

    ◆ bytes

    @@ -118,7 +118,7 @@

    diff --git a/docs/C/html/struct_c4_enumerator_options.html b/docs/C/html/struct_c4_enumerator_options.html index dc1c04904e..fb50a4336f 100644 --- a/docs/C/html/struct_c4_enumerator_options.html +++ b/docs/C/html/struct_c4_enumerator_options.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4EnumeratorOptions Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4EnumeratorOptions Struct Reference
    +
    C4EnumeratorOptions Struct Reference
    @@ -74,16 +74,16 @@

    #include <c4DocEnumeratorTypes.h>

    -

    +

    Data Fields

    C4EnumeratorFlags flags
     Option flags *‍/. More...
     

    Detailed Description

    -

    Options for enumerating over all documents.

    +

    Options for enumerating over all documents.

    Field Documentation

    - +

    ◆ flags

    @@ -105,7 +105,7 @@

    diff --git a/docs/C/html/struct_c4_error.html b/docs/C/html/struct_c4_error.html index 6746ac2593..4de9370416 100644 --- a/docs/C/html/struct_c4_error.html +++ b/docs/C/html/struct_c4_error.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4Error Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4Error Struct Reference
    +
    C4Error Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4Error.h>

    - @@ -84,10 +84,10 @@

    +

    Data Fields

    C4ErrorDomain domain
     
     

    Detailed Description

    -

    An error value.

    -

    These are returned by reference from API calls whose last parameter is a C4Error*. The semantics are based on Cocoa's usage of NSError: A caller can pass NULL if it doesn't care about the error. The error is filled in only if the function fails, as indicated by its return value (e.g. false or NULL.) If the function doesn't fail, it does NOT zero out the error, so its contents should be considered uninitialized garbage.

    +

    An error value.

    +

    These are returned by reference from API calls whose last parameter is a C4Error*. The semantics are based on Cocoa's usage of NSError: A caller can pass NULL if it doesn't care about the error. The error is filled in only if the function fails, as indicated by its return value (e.g. false or NULL.) If the function doesn't fail, it does NOT zero out the error, so its contents should be considered uninitialized garbage.

    Field Documentation

    - +

    ◆ code

    @@ -101,7 +101,7 @@

    +

    ◆ domain

    @@ -115,7 +115,7 @@

    +

    ◆ internal_info

    @@ -135,7 +135,7 @@

    diff --git a/docs/C/html/struct_c4_extra_info.html b/docs/C/html/struct_c4_extra_info.html index fcf43256a6..2e87231975 100644 --- a/docs/C/html/struct_c4_extra_info.html +++ b/docs/C/html/struct_c4_extra_info.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4ExtraInfo Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4ExtraInfo Struct Reference
    +
    C4ExtraInfo Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4Base.h>

    - @@ -83,11 +83,11 @@

    +

    Data Fields

    void * pointer
     
     

    Detailed Description

    -

    Client-defined metadata that can be associated with some objects like C4Database.

    -

    (See c4db_setExtraInfo, c4db_getExtraInfo.) For example, if you have your own "Database" class, you could store a pointer to it in the ExtraInfo of the corresponding C4Database so you can map from it back to your object.

    -

    The destructor callback is optional, but gives you a chance to clean up (e.g. release) your own object when the containing C4 object is freed.

    +

    Client-defined metadata that can be associated with some objects like C4Database.

    +

    (See c4db_setExtraInfo, c4db_getExtraInfo.) For example, if you have your own "Database" class, you could store a pointer to it in the ExtraInfo of the corresponding C4Database so you can map from it back to your object.

    +

    The destructor callback is optional, but gives you a chance to clean up (e.g. release) your own object when the containing C4 object is freed.

    Field Documentation

    - +

    ◆ destructor

    @@ -103,7 +103,7 @@

    +

    ◆ pointer

    @@ -123,7 +123,7 @@

    diff --git a/docs/C/html/struct_c4_full_text_match.html b/docs/C/html/struct_c4_full_text_match.html index 6a126cccdd..0d84650f8a 100644 --- a/docs/C/html/struct_c4_full_text_match.html +++ b/docs/C/html/struct_c4_full_text_match.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4FullTextMatch Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4FullTextMatch Struct Reference
    +
    C4FullTextMatch Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4QueryTypes.h>

    - @@ -93,9 +93,9 @@

    +

    Data Fields

    uint64_t dataSource
     Opaque identifier of where text is stored. More...
     

    Detailed Description

    -

    Info about a match of a full-text query term.

    +

    Info about a match of a full-text query term.

    Field Documentation

    - +

    ◆ dataSource

    @@ -111,7 +111,7 @@

    +

    ◆ length

    @@ -127,7 +127,7 @@

    +

    ◆ property

    @@ -143,7 +143,7 @@

    +

    ◆ start

    @@ -159,7 +159,7 @@

    +

    ◆ term

    @@ -181,7 +181,7 @@

    diff --git a/docs/C/html/struct_c4_index_options.html b/docs/C/html/struct_c4_index_options.html index 8c52acad08..d45bb3de6f 100644 --- a/docs/C/html/struct_c4_index_options.html +++ b/docs/C/html/struct_c4_index_options.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4IndexOptions Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4IndexOptions Struct Reference
    +
    C4IndexOptions Struct Reference
    - +

    ◆ language

    - +

    ◆ stopWords

    @@ -166,7 +166,7 @@

    diff --git a/docs/C/html/struct_c4_listener_config.html b/docs/C/html/struct_c4_listener_config.html index e66977e72b..e85957b982 100644 --- a/docs/C/html/struct_c4_listener_config.html +++ b/docs/C/html/struct_c4_listener_config.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4ListenerConfig Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4ListenerConfig Struct Reference
    +
    C4ListenerConfig Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ListenerTypes.h>

    - @@ -114,9 +114,9 @@

    +

    Data Fields

    uint16_t port
     TCP port to listen on. More...
     

    Detailed Description

    -

    Configuration for a C4Listener.

    +

    Configuration for a C4Listener.

    Field Documentation

    - +

    ◆ allowCreateDBs

    @@ -132,7 +132,7 @@

    +

    ◆ allowDeleteDBs

    @@ -148,7 +148,7 @@

    +

    ◆ allowPull

    @@ -164,7 +164,7 @@

    +

    ◆ allowPush

    @@ -180,7 +180,7 @@

    +

    ◆ apis

    @@ -196,7 +196,7 @@

    +

    ◆ callbackContext

    @@ -212,7 +212,7 @@

    +

    ◆ directory

    @@ -228,7 +228,7 @@

    +

    ◆ enableDeltaSync

    @@ -244,7 +244,7 @@

    +

    ◆ httpAuthCallback

    @@ -260,7 +260,7 @@

    +

    ◆ networkInterface

    @@ -276,7 +276,7 @@

    +

    ◆ port

    @@ -292,7 +292,7 @@

    +

    ◆ tlsConfig

    @@ -314,7 +314,7 @@

    diff --git a/docs/C/html/struct_c4_log_file_options.html b/docs/C/html/struct_c4_log_file_options.html index 77c377b009..9b70f6c487 100644 --- a/docs/C/html/struct_c4_log_file_options.html +++ b/docs/C/html/struct_c4_log_file_options.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4LogFileOptions Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4LogFileOptions Struct Reference
    +
    C4LogFileOptions Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4Log.h>

    - @@ -96,9 +96,9 @@

    +

    Data Fields

    C4LogLevel log_level
     The minimum level of message to be logged. More...
     

    Detailed Description

    -

    Configuration for file-based logging.

    +

    Configuration for file-based logging.

    Field Documentation

    - +

    ◆ base_path

    @@ -114,7 +114,7 @@

    +

    ◆ header

    @@ -130,7 +130,7 @@

    +

    ◆ log_level

    @@ -146,7 +146,7 @@

    +

    ◆ max_rotate_count

    @@ -162,7 +162,7 @@

    +

    ◆ max_size_bytes

    @@ -178,7 +178,7 @@

    +

    ◆ use_plaintext

    @@ -200,7 +200,7 @@

    diff --git a/docs/C/html/struct_c4_predictive_model.html b/docs/C/html/struct_c4_predictive_model.html index 7896a88c82..ad1fa4a647 100644 --- a/docs/C/html/struct_c4_predictive_model.html +++ b/docs/C/html/struct_c4_predictive_model.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4PredictiveModel Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4PredictiveModel Struct Reference
    +
    C4PredictiveModel Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4PredictiveQuery.h>

    - @@ -87,9 +87,9 @@

    +

    Data Fields

    void * context
     A pointer to any external data needed by the prediction callback, which will receive this as its first parameter. More...
     

    Detailed Description

    -

    Configuration struct for registering a predictive model.

    +

    Configuration struct for registering a predictive model.

    Field Documentation

    - +

    ◆ context

    @@ -105,7 +105,7 @@

    +

    ◆ prediction

    @@ -132,7 +132,7 @@

    +

    ◆ unregistered

    @@ -154,7 +154,7 @@

    diff --git a/docs/C/html/struct_c4_progress.html b/docs/C/html/struct_c4_progress.html index 4f9a01e47a..4df793129b 100644 --- a/docs/C/html/struct_c4_progress.html +++ b/docs/C/html/struct_c4_progress.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4Progress Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4Progress Struct Reference
    +
    C4Progress Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ReplicatorTypes.h>

    - @@ -87,10 +87,10 @@

    +

    Data Fields

    uint64_t unitsCompleted
     Abstract number of work units completed so far. More...
     

    Detailed Description

    -

    Represents the current progress of a replicator.

    -

    The units fields should not be used directly, but divided (unitsCompleted/unitsTotal) to give a very approximate progress fraction.

    +

    Represents the current progress of a replicator.

    +

    The units fields should not be used directly, but divided (unitsCompleted/unitsTotal) to give a very approximate progress fraction.

    Field Documentation

    - +

    ◆ documentCount

    @@ -106,7 +106,7 @@

    +

    ◆ unitsCompleted

    @@ -122,7 +122,7 @@

    +

    ◆ unitsTotal

    @@ -144,7 +144,7 @@

    diff --git a/docs/C/html/struct_c4_query_enumerator.html b/docs/C/html/struct_c4_query_enumerator.html index 86ab7e81ea..25f0183469 100644 --- a/docs/C/html/struct_c4_query_enumerator.html +++ b/docs/C/html/struct_c4_query_enumerator.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4QueryEnumerator Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4QueryEnumerator Struct Reference
    +
    C4QueryEnumerator Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4QueryTypes.h>

    - @@ -90,10 +90,10 @@

    +

    Data Fields

    FLArrayIterator columns
     The columns of this result, in the same order as in the query's WHAT clause. More...
     

    Detailed Description

    -

    A query result enumerator.

    -

    Created by c4db_query. Must be freed with c4queryenum_release. The fields of this struct represent the current matched index row, and are valid until the next call to c4queryenum_next or c4queryenum_release.

    +

    A query result enumerator.

    +

    Created by c4db_query. Must be freed with c4queryenum_release. The fields of this struct represent the current matched index row, and are valid until the next call to c4queryenum_next or c4queryenum_release.

    Field Documentation

    - +

    ◆ columns

    - +

    ◆ fullTextMatches

    @@ -165,7 +165,7 @@

    diff --git a/docs/C/html/struct_c4_query_options.html b/docs/C/html/struct_c4_query_options.html index b1206c9295..bcfe9636b4 100644 --- a/docs/C/html/struct_c4_query_options.html +++ b/docs/C/html/struct_c4_query_options.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4QueryOptions Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4QueryOptions Struct Reference
    +
    C4QueryOptions Struct Reference
    @@ -74,16 +74,16 @@

    #include <c4QueryTypes.h>

    -

    +

    Data Fields

    bool rankFullText_DEPRECATED
     Ignored; use the rank() query function instead. More...
     

    Detailed Description

    -

    Options for running queries.

    +

    Options for running queries.

    Field Documentation

    - +

    ◆ rankFullText_DEPRECATED

    @@ -105,7 +105,7 @@

    diff --git a/docs/C/html/struct_c4_raw_document.html b/docs/C/html/struct_c4_raw_document.html index 21d41c57ec..2044f74bfe 100644 --- a/docs/C/html/struct_c4_raw_document.html +++ b/docs/C/html/struct_c4_raw_document.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4RawDocument Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4RawDocument Struct Reference
    +
    C4RawDocument Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DatabaseTypes.h>

    - @@ -87,9 +87,9 @@

    +

    Data Fields

    C4String key
     The key (document ID) More...
     

    Detailed Description

    -

    Contents of a raw document.

    +

    Contents of a raw document.

    Field Documentation

    - +

    ◆ body

    @@ -105,7 +105,7 @@

    +

    ◆ key

    @@ -121,7 +121,7 @@

    +

    ◆ meta

    @@ -143,7 +143,7 @@

    diff --git a/docs/C/html/struct_c4_replicator_parameters.html b/docs/C/html/struct_c4_replicator_parameters.html index 7675eaecc4..c19ff2a40f 100644 --- a/docs/C/html/struct_c4_replicator_parameters.html +++ b/docs/C/html/struct_c4_replicator_parameters.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4ReplicatorParameters Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4ReplicatorParameters Struct Reference
    +
    C4ReplicatorParameters Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ReplicatorTypes.h>

    - @@ -112,9 +112,9 @@

    +

    Data Fields

    C4ReplicatorMode push
     Push mode (from db to remote/other db) More...
     

    Detailed Description

    -

    Parameters describing a replication, used when creating a C4Replicator.

    +

    Parameters describing a replication, used when creating a C4Replicator.

    Field Documentation

    - +

    ◆ callbackContext

    @@ -130,7 +130,7 @@

    +

    ◆ onBlobProgress

    @@ -146,7 +146,7 @@

    +

    ◆ onDocumentsEnded

    @@ -162,7 +162,7 @@

    +

    ◆ onStatusChanged

    @@ -178,7 +178,7 @@

    +

    ◆ optionsDictFleece

    @@ -194,7 +194,7 @@

    +

    ◆ propertyDecryptor

    @@ -208,7 +208,7 @@

    +

    ◆ propertyEncryptor

    @@ -222,7 +222,7 @@

    +

    ◆ pull

    @@ -238,7 +238,7 @@

    +

    ◆ push

    @@ -254,7 +254,7 @@

    +

    ◆ pushFilter

    @@ -270,7 +270,7 @@

    +

    ◆ socketFactory

    @@ -286,7 +286,7 @@

    +

    ◆ validationFunc

    @@ -308,7 +308,7 @@

    diff --git a/docs/C/html/struct_c4_replicator_status.html b/docs/C/html/struct_c4_replicator_status.html index 5ba78c9618..e5bc6298c1 100644 --- a/docs/C/html/struct_c4_replicator_status.html +++ b/docs/C/html/struct_c4_replicator_status.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4ReplicatorStatus Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4ReplicatorStatus Struct Reference
    +
    C4ReplicatorStatus Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ReplicatorTypes.h>

    - @@ -86,10 +86,10 @@

    +

    Data Fields

    C4ReplicatorActivityLevel level
     
     

    Detailed Description

    -

    Current status of replication.

    -

    Passed to C4ReplicatorStatusChangedCallback.

    +

    Current status of replication.

    +

    Passed to C4ReplicatorStatusChangedCallback.

    Field Documentation

    - +

    ◆ error

    @@ -103,7 +103,7 @@

    +

    ◆ flags

    @@ -117,7 +117,7 @@

    +

    ◆ level

    @@ -131,7 +131,7 @@

    +

    ◆ progress

    @@ -151,7 +151,7 @@

    diff --git a/docs/C/html/struct_c4_revision.html b/docs/C/html/struct_c4_revision.html index 7e20e20743..d09b355036 100644 --- a/docs/C/html/struct_c4_revision.html +++ b/docs/C/html/struct_c4_revision.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4Revision Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4Revision Struct Reference
    +
    C4Revision Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4DocumentTypes.h>

    - @@ -87,10 +87,10 @@

    +

    Data Fields

    C4HeapString revID
     Revision ID. More...
     

    Detailed Description

    -

    Describes a revision of a document.

    -

    A sub-struct of C4Document.

    +

    Describes a revision of a document.

    +

    A sub-struct of C4Document.

    Field Documentation

    - +

    ◆ flags

    @@ -106,7 +106,7 @@

    +

    ◆ revID

    @@ -122,7 +122,7 @@

    +

    ◆ sequence

    @@ -144,7 +144,7 @@

    diff --git a/docs/C/html/struct_c4_socket_factory.html b/docs/C/html/struct_c4_socket_factory.html index e0c314abf2..8e45a1e4de 100644 --- a/docs/C/html/struct_c4_socket_factory.html +++ b/docs/C/html/struct_c4_socket_factory.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4SocketFactory Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4SocketFactory Struct Reference
    +
    C4SocketFactory Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4SocketTypes.h>

    - @@ -102,11 +102,11 @@

    +

    Data Fields

    C4SocketFraming framing
     This should be set to kC4NoFraming if the socket factory acts as a stream of messages, kC4WebSocketClientFraming or kC4WebSocketServerFraming if it's a byte stream. More...
     

    Detailed Description

    -

    A group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API.

    -

    A group of callbacks that define the implementation of sockets.

    -

    These callbacks will be invoked on arbitrary background threads owned by LiteCore. They should return quickly, and perform the operation asynchronously without blocking.

    +

    A group of callbacks that define the implementation of sockets; the client must fill this out and pass it to c4socket_registerFactory() before using any socket-based API.

    +

    A group of callbacks that define the implementation of sockets.

    +

    These callbacks will be invoked on arbitrary background threads owned by LiteCore. They should return quickly, and perform the operation asynchronously without blocking.

    Field Documentation

    - +

    ◆ close

    @@ -119,7 +119,7 @@

    Called to close the socket.

    -

    This is only called if framing doesn't equal kC4NoFraming, i.e. the socket operates at the byte level. Otherwise it may be left NULL. No more write calls will be made; you should process any remaining incoming bytes by calling c4socket_received, then call c4socket_closed when the socket closes.

    Warning
    You MUST call c4socket_closed, or the replicator will wait forever!
    +

    This is only called if framing doesn't equal kC4NoFraming, i.e. the socket operates at the byte level. Otherwise it may be left NULL. No more write calls will be made; you should process any remaining incoming bytes by calling c4socket_received, then call c4socket_closed when the socket closes.

    Warning
    You MUST call c4socket_closed, or the replicator will wait forever!
    Parameters
    @@ -129,7 +129,7 @@

    +

    ◆ completedReceive

    @@ -142,7 +142,7 @@

    Called to inform the socket that LiteCore has finished processing the data from a c4socket_received call.

    -

    This can be used for flow control: you should keep track of the number of bytes you've sent to LiteCore, incrementing the number when you call c4socket_received, and decrementing it when completedReceived is called. If the number goes above some threshold, you should take measures to stop receiving more data, e.g. by not reading more bytes from the socket. Otherwise memory usage can balloon as more and more data arrives and must be buffered in memory.

    +

    This can be used for flow control: you should keep track of the number of bytes you've sent to LiteCore, incrementing the number when you call c4socket_received, and decrementing it when completedReceived is called. If the number goes above some threshold, you should take measures to stop receiving more data, e.g. by not reading more bytes from the socket. Otherwise memory usage can balloon as more and more data arrives and must be buffered in memory.

    Parameters

    socketThe socket to close.
    @@ -153,7 +153,7 @@

    +

    ◆ context

    socketThe socket that whose incoming data was processed.
    socketThe socket being disposed.
    @@ -194,7 +194,7 @@

    +

    ◆ framing

    @@ -210,7 +210,7 @@

    +

    ◆ open

    @@ -223,7 +223,7 @@

    Called to open a socket to a destination address.

    -

    This function should operate asynchronously, returning immediately. When the socket opens, call c4socket_opened, or if it fails to open, call c4socket_closed with an appropriate error.

    +

    This function should operate asynchronously, returning immediately. When the socket opens, call c4socket_opened, or if it fails to open, call c4socket_closed with an appropriate error.

    Parameters
    @@ -236,7 +236,7 @@

    +

    ◆ requestClose

    @@ -249,15 +249,15 @@

    Called to close the socket.

    -

    This is only called if framing equals to kC4NoFraming, i.e. the socket operates at the message level. Otherwise it may be left NULL.

    -

    Your implementation should:

      +

      This is only called if framing equals to kC4NoFraming, i.e. the socket operates at the message level. Otherwise it may be left NULL.

      +

      Your implementation should:

      1. send a message that tells the remote peer that it's closing the connection;
      2. wait for acknowledgement;
      3. while waiting, handle any further incoming messages by calling c4socket_received;
      4. after 5 seconds of waiting, give up and go to step 5;
      5. upon acknowledgement or timeout, close its connection and call c4socket_closed.
      -

      This call can also occur before the socket has opened, if the replicator decides to time out. In this situation – i.e. if you have not yet called c4socket_opened – you should tear down your connection and call c4socket_closed.

      +

      This call can also occur before the socket has opened, if the replicator decides to time out. In this situation – i.e. if you have not yet called c4socket_opened – you should tear down your connection and call c4socket_closed.

      Warning
      You MUST call c4socket_closed, or the replicator will wait forever!
      Parameters

    socketA new C4Socket instance to be opened. Its nativeHandle will be NULL; the implementation of this function will probably store a native socket reference there.
    @@ -270,7 +270,7 @@

    +

    ◆ write

    @@ -283,8 +283,8 @@

    Called to write to the socket.

    -

    If framing equals kC4NoFraming, the data is a complete message, and your socket implementation is responsible for framing it; otherwise, it's just raw bytes to write to the stream, including the necessary WebSocket framing.

    -

    After data has been written, you must call c4socket_completedWrite. (You can call this once after all the data is written, or multiple times with smaller numbers, as long as the total byte count equals the size of the allocatedData.)

    +

    If framing equals kC4NoFraming, the data is a complete message, and your socket implementation is responsible for framing it; otherwise, it's just raw bytes to write to the stream, including the necessary WebSocket framing.

    +

    After data has been written, you must call c4socket_completedWrite. (You can call this once after all the data is written, or multiple times with smaller numbers, as long as the total byte count equals the size of the allocatedData.)

    Parameters

    @@ -301,7 +301,7 @@

    diff --git a/docs/C/html/struct_c4_t_l_s_config.html b/docs/C/html/struct_c4_t_l_s_config.html index db32c68dd9..3d67a7c82c 100644 --- a/docs/C/html/struct_c4_t_l_s_config.html +++ b/docs/C/html/struct_c4_t_l_s_config.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4TLSConfig Struct Reference @@ -30,21 +30,22 @@

    socketThe socket to write to.

    - + +/* @license-end */ +
    -
    -
    C4TLSConfig Struct Reference
    +
    C4TLSConfig Struct Reference
    @@ -74,7 +74,7 @@

    #include <c4ListenerTypes.h>

    - @@ -98,9 +98,9 @@

    +

    Data Fields

    C4PrivateKeyRepresentation privateKeyRepresentation
     Interpretation of privateKey More...
     

    Detailed Description

    -

    TLS configuration for C4Listener.

    +

    TLS configuration for C4Listener.

    Field Documentation

    - +

    ◆ certAuthCallback

    @@ -116,7 +116,7 @@

    +

    ◆ certificate

    @@ -132,7 +132,7 @@

    +

    ◆ key

    @@ -148,7 +148,7 @@

    +

    ◆ privateKeyRepresentation

    @@ -164,7 +164,7 @@

    +

    ◆ requireClientCerts

    @@ -180,7 +180,7 @@

    +

    ◆ rootClientCerts

    @@ -196,7 +196,7 @@

    +

    ◆ tlsCallbackContext

    @@ -216,7 +216,7 @@

    diff --git a/docs/C/html/struct_c4_u_u_i_d.html b/docs/C/html/struct_c4_u_u_i_d.html index ab88482103..6e0ee41d59 100644 --- a/docs/C/html/struct_c4_u_u_i_d.html +++ b/docs/C/html/struct_c4_u_u_i_d.html @@ -2,8 +2,8 @@ - - + + LiteCore: C4UUID Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    C4UUID Struct Reference
    +
    C4UUID Struct Reference

    #include <c4DatabaseTypes.h>

    -

    +

    Data Fields

    uint8_t bytes [16]
     

    Field Documentation

    - +

    ◆ bytes

    @@ -97,7 +97,7 @@

    diff --git a/docs/C/html/struct_f_l_array_iterator.html b/docs/C/html/struct_f_l_array_iterator.html index 33f7cf92c4..9d9b8a3a7e 100644 --- a/docs/C/html/struct_f_l_array_iterator.html +++ b/docs/C/html/struct_f_l_array_iterator.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLArrayIterator Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    FLArrayIterator Struct Reference
    +
    FLArrayIterator Struct Reference

    Opaque array iterator. More...

    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLCollections.h>

    Detailed Description

    -

    Opaque array iterator.

    -

    Declare one on the stack and pass its address to FLArrayIteratorBegin.

    +

    Opaque array iterator.

    +

    Declare one on the stack and pass its address to FLArrayIteratorBegin.


    The documentation for this struct was generated from the following file:
    diff --git a/docs/C/html/struct_f_l_dict_iterator.html b/docs/C/html/struct_f_l_dict_iterator.html index 615776d70f..dd6aad18a9 100644 --- a/docs/C/html/struct_f_l_dict_iterator.html +++ b/docs/C/html/struct_f_l_dict_iterator.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDictIterator Struct Reference @@ -30,21 +30,22 @@
    - + +/* @license-end */ +
    -
    -
    FLDictIterator Struct Reference
    +
    FLDictIterator Struct Reference

    Opaque dictionary iterator. More...

    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLCollections.h>

    Detailed Description

    -

    Opaque dictionary iterator.

    -

    Declare one on the stack, and pass its address to FLDictIterator_Begin.

    +

    Opaque dictionary iterator.

    +

    Declare one on the stack, and pass its address to FLDictIterator_Begin.


    The documentation for this struct was generated from the following file:
    diff --git a/docs/C/html/struct_f_l_dict_key.html b/docs/C/html/struct_f_l_dict_key.html index 9e5bec5d47..40d62eba96 100644 --- a/docs/C/html/struct_f_l_dict_key.html +++ b/docs/C/html/struct_f_l_dict_key.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLDictKey Struct Reference @@ -30,21 +30,22 @@
    - + +/* @license-end */ +
    -
    -
    FLDictKey Struct Reference
    +
    FLDictKey Struct Reference

    Opaque key for a dictionary. More...

    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLCollections.h>

    Detailed Description

    -

    Opaque key for a dictionary.

    -

    You are responsible for creating space for these; they can go on the stack, on the heap, inside other objects, anywhere. Be aware that the lookup operations that use these will write into the struct to store "hints" that speed up future searches.

    +

    Opaque key for a dictionary.

    +

    You are responsible for creating space for these; they can go on the stack, on the heap, inside other objects, anywhere. Be aware that the lookup operations that use these will write into the struct to store "hints" that speed up future searches.


    The documentation for this struct was generated from the following file:
    diff --git a/docs/C/html/struct_f_l_path_component.html b/docs/C/html/struct_f_l_path_component.html index 1918ec4237..896c1f344b 100644 --- a/docs/C/html/struct_f_l_path_component.html +++ b/docs/C/html/struct_f_l_path_component.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLPathComponent Struct Reference @@ -30,21 +30,22 @@
    - + +/* @license-end */ +
    -
    -
    FLPathComponent Struct Reference
    +
    FLPathComponent Struct Reference
    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLDeepIterator.h>

    - @@ -81,7 +81,7 @@

    +

    Data Fields

    FLSlice key
     Dict key, or kFLSliceNull if none. More...
     

    Field Documentation

    - +

    ◆ index

    @@ -97,7 +97,7 @@

    +

    ◆ key

    @@ -114,12 +114,12 @@

    Fleece.h +
  • FLDeepIterator.h
  • diff --git a/docs/C/html/struct_f_l_slice.html b/docs/C/html/struct_f_l_slice.html index 05a354690c..3f6b769c9d 100644 --- a/docs/C/html/struct_f_l_slice.html +++ b/docs/C/html/struct_f_l_slice.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLSlice Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    FLSlice Struct Reference
    +
    FLSlice Struct Reference

    A simple reference to a block of memory. More...

    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

    - - +

    +

    Data Fields

    const void *FL_NULLABLE buf
    const void *FL_NULLABLE buf
     
    size_t size
     

    Detailed Description

    -

    A simple reference to a block of memory.

    -

    Does not imply ownership. (This is equivalent to the C++ class slice.)

    +

    A simple reference to a block of memory.

    +

    Does not imply ownership. (This is equivalent to the C++ class slice.)

    Field Documentation

    - +

    ◆ buf

    - +
    const void* FL_NULLABLE FLSlice::bufconst void* FL_NULLABLE FLSlice::buf
    - +

    ◆ size

    @@ -119,7 +119,7 @@

    diff --git a/docs/C/html/struct_f_l_slice_result.html b/docs/C/html/struct_f_l_slice_result.html index ca76ed229e..4dcc9413f0 100644 --- a/docs/C/html/struct_f_l_slice_result.html +++ b/docs/C/html/struct_f_l_slice_result.html @@ -2,8 +2,8 @@ - - + + LiteCore: FLSliceResult Struct Reference @@ -30,21 +30,22 @@

    - + +/* @license-end */ +
    -
    -
    FLSliceResult Struct Reference
    +
    FLSliceResult Struct Reference

    A heap-allocated block of memory returned from an API call. More...

    -

    #include </Users/jzhao/work/Git/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

    +

    #include </Users/snej/Projects/vendor/couchbase-mobile-tools/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

    - - +

    +

    Data Fields

    const void *FL_NULLABLE buf
    const void *FL_NULLABLE buf
     
    size_t size
     

    Detailed Description

    -

    A heap-allocated block of memory returned from an API call.

    -

    The caller takes ownership, and must call FLSliceResult_Release when done with it.

    Warning
    The contents of the block must not be modified, since others may be using it.
    +

    A heap-allocated block of memory returned from an API call.

    +

    The caller takes ownership, and must call FLSliceResult_Release when done with it.

    Warning
    The contents of the block must not be modified, since others may be using it.
    Note
    This is equivalent to the C++ class alloc_slice. In C++ the easiest way to deal with a FLSliceResult return value is to construct an alloc_slice from it, which will adopt the reference, and release it in its destructor. For example: alloc_slice foo( CopyFoo() );

    Field Documentation

    - +

    ◆ buf

    - +
    const void* FL_NULLABLE FLSliceResult::bufconst void* FL_NULLABLE FLSliceResult::buf
    - +

    ◆ size

    @@ -120,7 +120,7 @@

    diff --git a/docs/C/html/tabs.css b/docs/C/html/tabs.css index 85a0cd5b58..00d1c60249 100644 --- a/docs/C/html/tabs.css +++ b/docs/C/html/tabs.css @@ -1 +1 @@ -.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace!important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0!important;-webkit-border-radius:0;border-radius:0!important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px!important;-webkit-border-radius:5px;border-radius:5px!important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0!important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px!important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} \ No newline at end of file +.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.main-menu-btn{position:relative;display:inline-block;width:36px;height:36px;text-indent:36px;margin-left:8px;white-space:nowrap;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.main-menu-btn-icon,.main-menu-btn-icon:before,.main-menu-btn-icon:after{position:absolute;top:50%;left:2px;height:2px;width:24px;background:#666;-webkit-transition:all .25s;transition:all .25s}.main-menu-btn-icon:before{content:'';top:-7px;left:0}.main-menu-btn-icon:after{content:'';top:7px;left:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon{height:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:before{top:0;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:after{top:0;-webkit-transform:rotate(45deg);transform:rotate(45deg)}#main-menu-state{position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(1px,1px,1px,1px)}#main-menu-state:not(:checked) ~ #main-menu{display:none}#main-menu-state:checked ~ #main-menu{display:block}@media(min-width:768px){.main-menu-btn{position:absolute;top:-99999px}#main-menu-state:not(:checked) ~ #main-menu{display:block}}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a span.sub-arrow:before{display:block;content:'+'}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0 !important;-webkit-border-radius:0;border-radius:0 !important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px !important;-webkit-border-radius:5px;border-radius:5px !important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0 !important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} \ No newline at end of file diff --git a/docs/Result.md b/docs/Result.md new file mode 100644 index 0000000000..0eaebaaa65 --- /dev/null +++ b/docs/Result.md @@ -0,0 +1,133 @@ +# The Useful `Result` Type + +(Last updated March 4 2022 by Jens) + +**Result is a utility class template for improving error handling without exceptions, inspired by languages like Swift, Kotlin and Rust.** + +## 1. Why? + +We still use exceptions inside LiteCore, but in some places it’s better to manage errors as `C4Error` values, usually when the error isn’t considered an “exceptional” situation where something’s gone unexpectedly wrong. An example of this is when saving a document — it’s entirely possible to get a kC4ErrorConflict in normal operation, so it shouldn’t be thrown. And in the case of asynchronous operations (`Async`), exceptions don’t make sense at all. + +In these situations we’ve been using the same calling convention we use in the C API: a special return value like `NULL` or `0` indicating failure, and a `C4Error*` parameter that the callee copies the error to. But that’s kind of awkward. We can do better. + +## 2. What’s a `Result`? + +`Result`, defined in the header `Result.hh`, is **a container that can hold either a value of type `T` or a `C4Error`.** (It’s implemented using `std::variant`.) + +- You can construct one from either a `T` or a `C4Error`. +- Boolean methods `ok()` and `isError()` tell you which it holds. +- `value()` returns the value … but if there’s an error it throws it instead. (So check first!) +- `error()` returns the error if there is one, or else a default error with `code==0`. + +**Result’s main job is as the return value of a function that can fail:** + +```c++ +Result squareRoot(double n) { + if (n >= 0) + return sqrt(n); + else + return C4Error{LiteCoreDomain, kC4ErrorInvalidParameter}; +} +``` + +> Note that one branch returns a `double` and the other a `C4Error`. That’s fine since they both convert implicitly to the actual return type, `Result`. + +### `Result` + +`Result` is a special case where there isn’t any value to return, just “no error”. This subtype has no `value()` method, but you can otherwise treat it like other Results. + +## 3. What Do You Do With One? + +If you called a function that returned a Result, you can check what it holds and do the appropriate thing: + +```c++ +if (auto r = squareRoot(n); r.ok()) { + cout << "√n = " << r.value() << endl; +} else { + cerr << "squareRoot failed: " << r.error().description() << endl; +} +``` + +If you’re doing this inside a function that itself returns a `Result`, you can just pass the buck: + +```c++ +Result showSquareRoot(double n) { + if (auto r = squareRoot(n); r.ok()) { + cout << "√n = " << r.value() << endl; + return {}; + } else { + return r.error(); + } +} +``` + +### CatchResult() + +`CatchResult` lets you safely call a function that may throw an exception. Itakes a function/lambda that returns `T` (or `Result`), calls it, and returns the result as a `Result`. If the function throws an exception, it is caught and returned as the `error` in the result. + +```c++ +extern string read_line(stream*); // throws exception on I/O error + +Result input = CatchResult( []{ return read_line(in); }); +``` + +### then() + +The `Result::then()` method lets you chain together operations that return Results. You can also look at it as a kind of functional “map” operation that transforms one type of Result into another. + +It takes a function/lambda with a parameter of type `T` (or optimally, `T&&`) that returns some type `U`. + +- If the receiver contains a value, it passes it to the function, then returns the function’s result wrapped in a `Result`. + - Bonus: if the function throws an exception, it’s caught and returned as the Result’s error. +- Otherwise, it just returns its error in a `Result`. + +Here `T` is `double`, `U` is `string`, and the function returns `U`: + +```c++ +Result str = squareRoot(n).then( [](double root) {return to_string(root);} ); +``` + +Here’s an example that goes the other direction, `string` to `double`, and the function returns a `Result`: + +```c++ +Result root = parseDouble(str).then( [](double n) {return sqareRoot(n);} ); +``` + +### onError() + +The `onError` method is sort of the opposite of `then`: it takes a function/lambda and calls it with the _error_ value, if there is one; otherwise it does nothing. + +`onError` returns itself (`*this`) since it hasn’t dealt with the non-error value and you need to do so. However, `Result::onError` returns `void` because there’s no non-error value. + +You can chain `then` and `onError` to handle both cases: + +```c++ +squareRoot(n).then( [](double root) { + cout << "√n = " << root.value() << endl; +}).onError( [](C4Error error) { + cerr << "squareRoot failed: " << error.description() << endl; +}); +``` + +### TRY() + +This one’s sort of an experiment to emulate Swift’s `try` statement (`try mightFail()`). Here’s an example: + +```c++ +Result rootStr(double n) { + TRY(double root, squareRoot(n)); + return std::to_string(root); +} +``` + +TRY calls `squareRoot(n)`; if it succeeds, it declares `root` and assigns the value to it. If it fails, though, it *returns the error from the enclosing function* (`rootStr`). + +The `TRY` expression in the example is equivalent to: + +```c++ +auto __ = squareRoot(n); +if (__.isError()) return __.error(); +double root = __.value(); +``` + +> The syntax is ugly, but I think it’s the best that can be done in standard C++. (GCC and Clang have a “statement expression” extension that would let us say `double root = TRY(squareRoot(n));`, but MSVC doesn’t support it.) diff --git a/docs/overview/ConnectedClientProtocol.md b/docs/overview/ConnectedClientProtocol.md new file mode 100644 index 0000000000..98964895e6 --- /dev/null +++ b/docs/overview/ConnectedClientProtocol.md @@ -0,0 +1,115 @@ +# Connected Client Protocol + +Couchbase Mobile 3.x + +Jens Alfke — 11 April 2022 + +## 1. Introduction + +The Connected Client protocol allows mobile clients to access a server-side database (bucket) directly, without needing a local database replica. In its first incarnation it supports document CRUD operations and database change listeners. + +Sync Gateway already supports a REST API (inherited from CouchDB) that allows this, but our past experience with version 1.x showed that this API is difficult to support properly and inherits significant overhead from HTTP. As a result **we’ve chosen to implement Connected Client over BLIP, using an extension of the replicator protocol**. + +This document describes those extensions. + +## 2. Connecting + +Opening a client connection is identical to opening a replicator connection. It’s the same WebSocket endpoint (`/dbname/_blipsync`), the same BLIP protocol, and the same authentication. + +## 3. Message Types + +These are the only messages the Connected Client implementation currently sends. + +### 3.1. `getRev` + +Requests a document’s current revision from the peer. + +> **Note**: This is very much like the replicator protocol’s `rev` message, except that it’s sent as a *request* for a revision, not an announcement of one. + +**Request**: + +* `id`: Document ID +* `ifNotRev`: (optional) If present, and its value is equal to the document’s current revision ID, the peer SHOULD respond with a HTTP/304 error instead of sending the revision + +**Response**: + +* `rev`: The current revision ID +* Body: The current revision body as JSON + +### 3.2. `getAttachment` + +Exactly as in the replicator protocol. + +### 3.3. `putRev` + +Uploads a new revision to the peer. + +The properties and behavior are identical to the replicator protocol’s `rev` message. The reason for a new message type is because the LiteCore replicator assumes that incoming `rev` messages are caused by prior `changes` responses, and would become confused if it received a standalone `rev` message. This made it apparent that it would be cleaner to treat this as a separate type of request. + +**Request**: *same as existing `rev` message* + +**Response**: *same as existing `rev` message* (never sent no-reply) + +> **Note:** As usual, the receiving peer may send one or more getAttachment requests back to the originator if it needs the contents of any blobs/attachments in the revision. + +### 3.4. `subChanges` + +As in the replicator protocol, with one addition: + +**Request**: + +* `future`: (Optional) If `true`, the receiving peer MUST not send any existing sequences, only future changes. In other words, this has the same effect as a `since` property whose value is the current sequence ID. (The message SHOULD NOT also contain a `since` property, and the recipient MUST ignore it if present.) + +> **Note**: `future` will always combined with `continuous`, since otherwise no changes would be sent at all! + +### 3.5. `unsubChanges` + +This terminates the effect of `subChanges`: the receiving peer MUST stop sending `changes` messages as soon as possible. + +The sender MAY send another `subChanges` message later, to start a new feed. + +_(No request properties or body defined.)_ + +### 3.6 `query` + +Runs a query on the peer, identified by a name. Queries take zero or more named parameters, each of which is a JSON value. + +Optionally, a server MAY allow a client to run arbitrary queries. (Sync Gateway will not support this for security and performance reasons, but Couchbase Lite applications can choose to.) + +The result of a query is a list of zero or more rows. Each row is a JSON object. Rows are separated by single newline (ASCII 0A) characters. There MAY be a trailing newline at the end. + + Note that the entire result is not parseable as JSON (unless there's only one row.) But it's easy to split up by newlines. This format is easier to parse incrementally if results are being streamed. + +**Request**: + +* `name`: The name of the query (if named) +* `src`: N1QL or JSON query source (if not named) +* Body: A JSON object mapping parameter names to values + +**Response**: + +* Body: Zero or more JSON objects (`{...}`) separated by newlines. + +**Errors**: + +- HTTP, 400 — Missing `name` or `src`, or both were given, or the body is not a JSON object, or a N1QL syntax error. +- HTTP, 403 — Arbitrary queries are not allowed +- HTTP, 404 — Query name is not registered + +### 3.7 `allDocs` + +Requests the IDs of all documents, or those matching a pattern. + +Deleted documents are ignored. + +**Request:** + +- `idPattern`: (optional) A pattern for the returned docIDs to match. Uses Unix shell “glob” syntax, with `?` matching a single character, `*` matching any number of characters, and `\` escaping the next character. + +**Response**: + +- Body: A JSON array of docIDs. Each item is a string. The order of the docIDs is arbitrary. + +**Errors:** + +- HTTP, 400 — If patterns are not supported. diff --git a/vendor/fleece b/vendor/fleece index af4f74cc54..ceb8c531ef 160000 --- a/vendor/fleece +++ b/vendor/fleece @@ -1 +1 @@ -Subproject commit af4f74cc54042974379d18fdd67be7a0f3093895 +Subproject commit ceb8c531efc1480c2089fce94bf15afddf2bc901