From ce71dbd70ff3b5e6258c8f924111605c5e73ebcf Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Thu, 2 Sep 2021 07:05:44 +0900 Subject: [PATCH 01/90] Update to correct LiteCore for Lithium --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index d705ae2a..f1f28c2b 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit d705ae2ad680fa9228d28ab8a07594587f889b84 +Subproject commit f1f28c2bad1d42e530d1e909cd75a0b0b2562216 From 7583cf4e76c44c470a032beda52364867ad4b7e8 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Thu, 2 Sep 2021 07:33:47 +0900 Subject: [PATCH 02/90] CBL-2317: Update doxygen docs. Closes #92 --- docs/C/html/_base_8h.html | 168 ++- docs/C/html/_base_8h_source.html | 228 ++- docs/C/html/_c_b_l___compat_8h.html | 126 +- docs/C/html/_c_b_l___compat_8h_source.html | 152 +- docs/C/html/_c_b_l_base_8h.html | 186 +-- docs/C/html/_c_b_l_base_8h_source.html | 324 ++-- docs/C/html/_c_b_l_blob_8h.html | 152 +- docs/C/html/_c_b_l_blob_8h_source.html | 234 ++- docs/C/html/_c_b_l_database_8h.html | 158 +- docs/C/html/_c_b_l_database_8h_source.html | 285 +++- docs/C/html/_c_b_l_document_8h.html | 172 +-- docs/C/html/_c_b_l_document_8h_source.html | 247 ++- docs/C/html/_c_b_l_encryptable_8h.html | 154 ++ docs/C/html/_c_b_l_encryptable_8h_source.html | 197 +++ docs/C/html/_c_b_l_log_8h.html | 75 +- docs/C/html/_c_b_l_log_8h_source.html | 177 ++- docs/C/html/_c_b_l_platform_8h.html | 82 + docs/C/html/_c_b_l_platform_8h_source.html | 121 ++ docs/C/html/_c_b_l_query_8h.html | 159 +- docs/C/html/_c_b_l_query_8h_source.html | 243 ++- docs/C/html/_c_b_l_replicator_8h.html | 174 +-- docs/C/html/_c_b_l_replicator_8h_source.html | 443 ++++-- docs/C/html/_couchbase_lite_8h.html | 26 +- docs/C/html/_couchbase_lite_8h_source.html | 68 +- docs/C/html/_f_l_slice_8h.html | 46 +- docs/C/html/_f_l_slice_8h_source.html | 223 ++- .../C/html/_fleece_09_core_foundation_8h.html | 24 +- .../_fleece_09_core_foundation_8h_source.html | 111 +- docs/C/html/_fleece_8h.html | 393 +++-- docs/C/html/_fleece_8h_source.html | 1295 ++++++++++++---- docs/C/html/annotated.html | 58 +- docs/C/html/classes.html | 43 +- .../dir_17ad6c03ac95e637f87755575f40449e.html | 26 +- .../dir_2ecb5472ec723897fff4bd7d3317a27a.html | 32 +- .../dir_42eeca32d5bbc87802b2b9475842edbd.html | 46 +- .../dir_644f78e2d6809b3b77fed6ee8030c9f9.html | 26 +- .../dir_b346636a750f54d78818ae1d73f9fdd0.html | 26 +- .../dir_c5da75fdc1d6c57999112ed830c87a3c.html | 26 +- .../dir_d44c64559bbebec7f509842c48db8b23.html | 26 +- .../dir_f77815f292c27e5d3b6029f59ba49998.html | 26 +- docs/C/html/doxygen.css | 203 ++- docs/C/html/doxygen.svg | 26 + docs/C/html/dynsections.js | 33 +- docs/C/html/files.html | 34 +- docs/C/html/functions.html | 272 +--- docs/C/html/functions_vars.html | 272 +--- docs/C/html/globals.html | 86 +- docs/C/html/globals_c.html | 931 +++--------- docs/C/html/globals_defs.html | 175 +-- docs/C/html/globals_enum.html | 101 +- docs/C/html/globals_eval.html | 496 ++---- docs/C/html/globals_f.html | 953 ++++-------- docs/C/html/globals_func.html | 29 +- docs/C/html/globals_func_c.html | 558 ++----- docs/C/html/globals_func_f.html | 840 +++-------- docs/C/html/globals_h.html | 77 + docs/C/html/globals_k.html | 363 ++--- docs/C/html/globals_m.html | 25 +- docs/C/html/globals_n.html | 25 +- docs/C/html/globals_r.html | 25 +- docs/C/html/globals_s.html | 77 + docs/C/html/globals_type.html | 198 +-- docs/C/html/globals_vars.html | 61 +- docs/C/html/globals_w.html | 77 + docs/C/html/group___c_f.html | 40 +- docs/C/html/group___f_l_array.html | 1335 ++++++++++++++--- docs/C/html/group___f_l_deep_iterator.html | 109 +- docs/C/html/group___f_l_dict.html | 695 +++++++-- docs/C/html/group___f_l_encoder.html | 278 ++-- docs/C/html/group___f_l_key_path.html | 72 +- docs/C/html/group___f_l_shared_keys.html | 90 +- docs/C/html/group___f_l_slice.html | 219 ++- docs/C/html/group___f_l_value.html | 225 +-- docs/C/html/group___slots.html | 243 ++- docs/C/html/group__blobs.html | 589 +++++--- docs/C/html/group__database.html | 377 +++-- docs/C/html/group__delta.html | 50 +- docs/C/html/group__documents.html | 590 ++++---- docs/C/html/group__encryptables.html | 659 ++++++++ docs/C/html/group__errors.html | 280 ++-- docs/C/html/group__json.html | 79 +- docs/C/html/group__listeners.html | 97 +- docs/C/html/group__logging.html | 171 +-- docs/C/html/group__other__types.html | 34 +- docs/C/html/group__queries.html | 512 ++++--- docs/C/html/group__reading.html | 206 ++- docs/C/html/group__refcounting.html | 93 +- docs/C/html/group__replication.html | 787 ++++------ docs/C/html/group__types.html | 108 +- docs/C/html/index.html | 22 +- docs/C/html/jquery.js | 94 +- docs/C/html/menu.js | 119 +- docs/C/html/menudata.js | 46 +- docs/C/html/modules.html | 42 +- docs/C/html/search/all_0.html | 23 +- docs/C/html/search/all_0.js | 32 +- docs/C/html/search/all_1.html | 23 +- docs/C/html/search/all_1.js | 7 +- docs/C/html/search/all_10.html | 23 +- docs/C/html/search/all_10.js | 11 +- docs/C/html/search/all_11.html | 23 +- docs/C/html/search/all_11.js | 7 +- docs/C/html/search/all_12.html | 23 +- docs/C/html/search/all_12.js | 5 +- docs/C/html/search/all_13.html | 23 +- docs/C/html/search/all_13.js | 4 +- docs/C/html/search/all_14.html | 23 +- docs/C/html/search/all_14.js | 2 +- docs/C/html/search/all_15.html | 37 + docs/C/html/search/all_15.js | 4 + docs/C/html/search/all_2.html | 23 +- docs/C/html/search/all_2.js | 10 +- docs/C/html/search/all_3.html | 23 +- docs/C/html/search/all_3.js | 492 +++--- docs/C/html/search/all_4.html | 23 +- docs/C/html/search/all_4.js | 14 +- docs/C/html/search/all_5.html | 23 +- docs/C/html/search/all_5.js | 11 +- docs/C/html/search/all_6.html | 23 +- docs/C/html/search/all_6.js | 520 ++++--- docs/C/html/search/all_7.html | 23 +- docs/C/html/search/all_7.js | 6 +- docs/C/html/search/all_8.html | 23 +- docs/C/html/search/all_8.js | 8 +- docs/C/html/search/all_9.html | 23 +- docs/C/html/search/all_9.js | 201 ++- docs/C/html/search/all_a.html | 23 +- docs/C/html/search/all_a.js | 8 +- docs/C/html/search/all_b.html | 23 +- docs/C/html/search/all_b.js | 8 +- docs/C/html/search/all_c.html | 23 +- docs/C/html/search/all_c.js | 3 +- docs/C/html/search/all_d.html | 23 +- docs/C/html/search/all_d.js | 2 +- docs/C/html/search/all_e.html | 23 +- docs/C/html/search/all_e.js | 17 +- docs/C/html/search/all_f.html | 23 +- docs/C/html/search/all_f.js | 2 +- docs/C/html/search/classes_0.html | 23 +- docs/C/html/search/classes_0.js | 24 +- docs/C/html/search/classes_1.html | 23 +- docs/C/html/search/classes_1.js | 12 +- docs/C/html/search/close.svg | 31 + docs/C/html/search/defines_0.html | 23 +- docs/C/html/search/defines_0.js | 28 +- docs/C/html/search/defines_1.html | 23 +- docs/C/html/search/defines_1.js | 15 +- docs/C/html/search/defines_2.html | 23 +- docs/C/html/search/defines_2.js | 9 +- docs/C/html/search/defines_3.html | 23 +- docs/C/html/search/defines_3.js | 2 +- docs/C/html/search/defines_4.html | 23 +- docs/C/html/search/defines_4.js | 2 +- docs/C/html/search/defines_5.html | 23 +- docs/C/html/search/defines_5.js | 2 +- docs/C/html/search/defines_6.html | 37 + docs/C/html/search/defines_6.js | 4 + docs/C/html/search/defines_7.html | 37 + docs/C/html/search/defines_7.js | 4 + docs/C/html/search/defines_8.html | 37 + docs/C/html/search/defines_8.js | 4 + docs/C/html/search/enums_0.html | 23 +- docs/C/html/search/enums_0.js | 30 +- docs/C/html/search/enums_1.html | 23 +- docs/C/html/search/enums_1.js | 10 +- docs/C/html/search/enumvalues_0.html | 23 +- docs/C/html/search/enumvalues_0.js | 171 ++- docs/C/html/search/files_0.html | 23 +- docs/C/html/search/files_0.js | 2 +- docs/C/html/search/files_1.html | 23 +- docs/C/html/search/files_1.js | 22 +- docs/C/html/search/files_2.html | 23 +- docs/C/html/search/files_2.js | 6 +- docs/C/html/search/functions_0.html | 23 +- docs/C/html/search/functions_0.js | 4 +- docs/C/html/search/functions_1.html | 23 +- docs/C/html/search/functions_1.js | 271 ++-- docs/C/html/search/functions_2.html | 23 +- docs/C/html/search/functions_2.js | 433 +++--- docs/C/html/search/groups_0.html | 23 +- docs/C/html/search/groups_0.js | 4 +- docs/C/html/search/groups_1.html | 23 +- docs/C/html/search/groups_1.js | 3 +- docs/C/html/search/groups_2.html | 23 +- docs/C/html/search/groups_2.js | 4 +- docs/C/html/search/groups_3.html | 23 +- docs/C/html/search/groups_3.js | 3 +- docs/C/html/search/groups_4.html | 23 +- docs/C/html/search/groups_4.js | 16 +- docs/C/html/search/groups_5.html | 23 +- docs/C/html/search/groups_5.js | 4 +- docs/C/html/search/groups_6.html | 23 +- docs/C/html/search/groups_6.js | 2 +- docs/C/html/search/groups_7.html | 23 +- docs/C/html/search/groups_7.js | 2 +- docs/C/html/search/groups_8.html | 23 +- docs/C/html/search/groups_8.js | 6 +- docs/C/html/search/groups_9.html | 23 +- docs/C/html/search/groups_9.js | 4 +- docs/C/html/search/groups_a.html | 23 +- docs/C/html/search/groups_a.js | 2 +- docs/C/html/search/mag_sel.svg | 74 + docs/C/html/search/nomatches.html | 3 +- docs/C/html/search/search.css | 110 +- docs/C/html/search/search.js | 118 +- docs/C/html/search/searchdata.js | 8 +- docs/C/html/search/typedefs_0.html | 23 +- docs/C/html/search/typedefs_0.js | 53 +- docs/C/html/search/typedefs_1.html | 23 +- docs/C/html/search/typedefs_1.js | 34 +- docs/C/html/search/variables_0.html | 23 +- docs/C/html/search/variables_0.js | 7 +- docs/C/html/search/variables_1.html | 23 +- docs/C/html/search/variables_1.js | 4 +- docs/C/html/search/variables_2.html | 23 +- docs/C/html/search/variables_2.js | 15 +- docs/C/html/search/variables_3.html | 23 +- docs/C/html/search/variables_3.js | 11 +- docs/C/html/search/variables_4.html | 23 +- docs/C/html/search/variables_4.js | 8 +- docs/C/html/search/variables_5.html | 23 +- docs/C/html/search/variables_5.js | 3 +- docs/C/html/search/variables_6.html | 23 +- docs/C/html/search/variables_6.js | 5 +- docs/C/html/search/variables_7.html | 23 +- docs/C/html/search/variables_7.js | 8 +- docs/C/html/search/variables_8.html | 23 +- docs/C/html/search/variables_8.js | 23 +- docs/C/html/search/variables_9.html | 23 +- docs/C/html/search/variables_9.js | 4 +- docs/C/html/search/variables_a.html | 23 +- docs/C/html/search/variables_a.js | 6 +- docs/C/html/search/variables_b.html | 23 +- docs/C/html/search/variables_b.js | 10 +- docs/C/html/search/variables_c.html | 23 +- docs/C/html/search/variables_c.js | 9 +- docs/C/html/search/variables_d.html | 23 +- docs/C/html/search/variables_d.js | 3 +- docs/C/html/search/variables_e.html | 23 +- docs/C/html/search/variables_e.js | 3 +- docs/C/html/search/variables_f.html | 23 +- docs/C/html/search/variables_f.js | 5 +- .../struct_c_b_l_database_configuration.html | 61 +- docs/C/html/struct_c_b_l_encryption_key.html | 34 +- docs/C/html/struct_c_b_l_error.html | 50 +- ...t_c_b_l_full_text_index_configuration.html | 173 +++ .../struct_c_b_l_log_file_configuration.html | 46 +- docs/C/html/struct_c_b_l_proxy_settings.html | 46 +- .../struct_c_b_l_replicated_document.html | 38 +- ...struct_c_b_l_replicator_configuration.html | 273 +++- .../struct_c_b_l_replicator_progress.html | 52 +- .../html/struct_c_b_l_replicator_status.html | 38 +- ...truct_c_b_l_value_index_configuration.html | 131 ++ docs/C/html/struct_f_l_array_iterator.html | 28 +- docs/C/html/struct_f_l_dict_iterator.html | 28 +- docs/C/html/struct_f_l_dict_key.html | 28 +- docs/C/html/struct_f_l_path_component.html | 34 +- docs/C/html/struct_f_l_slice.html | 34 +- docs/C/html/struct_f_l_slice_result.html | 34 +- docs/C/html/tabs.css | 2 +- include/cbl/CBLBlob.h | 4 +- include/cbl/CBLDatabase.h | 3 +- include/cbl/CBLEncryptable.h | 6 +- include/cbl/CBLLog.h | 2 +- include/cbl/CBLReplicator.h | 4 +- 265 files changed, 15878 insertions(+), 10970 deletions(-) create mode 100644 docs/C/html/_c_b_l_encryptable_8h.html create mode 100644 docs/C/html/_c_b_l_encryptable_8h_source.html create mode 100644 docs/C/html/_c_b_l_platform_8h.html create mode 100644 docs/C/html/_c_b_l_platform_8h_source.html create mode 100644 docs/C/html/doxygen.svg create mode 100644 docs/C/html/globals_h.html create mode 100644 docs/C/html/globals_s.html create mode 100644 docs/C/html/globals_w.html create mode 100644 docs/C/html/group__encryptables.html create mode 100644 docs/C/html/search/all_15.html create mode 100644 docs/C/html/search/all_15.js create mode 100644 docs/C/html/search/close.svg create mode 100644 docs/C/html/search/defines_6.html create mode 100644 docs/C/html/search/defines_6.js create mode 100644 docs/C/html/search/defines_7.html create mode 100644 docs/C/html/search/defines_7.js create mode 100644 docs/C/html/search/defines_8.html create mode 100644 docs/C/html/search/defines_8.js create mode 100644 docs/C/html/search/mag_sel.svg create mode 100644 docs/C/html/struct_c_b_l_full_text_index_configuration.html create mode 100644 docs/C/html/struct_c_b_l_value_index_configuration.html diff --git a/docs/C/html/_base_8h.html b/docs/C/html/_base_8h.html index f8ed88b6..786fbe36 100644 --- a/docs/C/html/_base_8h.html +++ b/docs/C/html/_base_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/Base.h File Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
Base.h File Reference
+
Base.h File Reference

Go to the source code of this file.

- @@ -101,9 +101,37 @@ + + + + + + + + + + + + + +

+

Macros

#define FLEECE_BASE_H
 
 
#define FLCONST
 
#define STEPOVER
 
#define __optimize(ops)
 
#define HOTLEVEL   "O3"
 
#define COLDLEVEL   "Os"
 
#define __hot
 
#define __cold
 
#define WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)   0
 

Macro Definition Documentation

- + +

◆ __cold

+ +
+
+ + + + +
#define __cold
+
+ +
+
+

◆ __has_attribute

@@ -121,7 +149,7 @@

+

◆ __has_builtin

@@ -139,7 +167,7 @@

+

◆ __has_extension

@@ -157,7 +185,7 @@

+

◆ __has_feature

@@ -175,7 +203,39 @@

+ +

◆ __hot

+ +
+
+ + + + +
#define __hot
+
+ +
+
+ +

◆ __optimize

+ +
+
+ + + + + + + + +
#define __optimize( ops)
+
+ +
+
+

◆ _usuallyFalse

@@ -193,7 +253,7 @@

+

◆ _usuallyTrue

@@ -211,7 +271,21 @@

+ +

◆ COLDLEVEL

+ +
+
+ + + + +
#define COLDLEVEL   "Os"
+
+ +
+
+

◆ FLCONST

@@ -225,7 +299,7 @@

+

◆ FLEECE_BASE_H

@@ -239,7 +313,7 @@

+

◆ FLPURE

@@ -253,7 +327,21 @@

+ +

◆ HOTLEVEL

+ +
+
+ + + + +
#define HOTLEVEL   "O3"
+
+ +
+
+

◆ MUST_USE_RESULT

@@ -267,7 +355,7 @@

+

◆ NONNULL

@@ -281,7 +369,7 @@

+

◆ RETURNS_NONNULL

@@ -293,14 +381,44 @@

+

+

+ +

◆ STEPOVER

+ +
+
+ + + + +
#define STEPOVER
+
+ +
+
+ +

◆ WINAPI_FAMILY_PARTITION

+ +
+
+ + + + + + + + +
#define WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_APP)   0
+
+

diff --git a/docs/C/html/_base_8h_source.html b/docs/C/html/_base_8h_source.html index a784a6d0..5c429ee0 100644 --- a/docs/C/html/_base_8h_source.html +++ b/docs/C/html/_base_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/Base.h Source File @@ -30,21 +30,22 @@

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

diff --git a/docs/C/html/_c_b_l___compat_8h.html b/docs/C/html/_c_b_l___compat_8h.html index 24d9d2c6..81901fd0 100644 --- a/docs/C/html/_c_b_l___compat_8h.html +++ b/docs/C/html/_c_b_l___compat_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBL_Compat.h File Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBL_Compat.h File Reference
+
CBL_Compat.h File Reference

Go to the source code of this file.

- @@ -85,27 +85,33 @@ - - - - + + + + + + - - + + + + + +

+

Macros

#define __has_feature(x)   0
 
 
#define CBLINLINE   inline
 
#define _cbl_returns_nonnull   __attribute__((returns_nonnull))
 
#define _cbl_warn_unused   __attribute__((warn_unused_result))
 
#define _cbl_nonnull   /* GCC does not support the way we use nonnull */
 
#define _cbl_deprecated   __attribute__((deprecated()))
 
#define CBL_ENUM(_type, _name)   enum _name : _type _name; enum _name : _type
 
#define CBL_OPTIONS(_type, _name)   enum _name : _type _name; enum _name : _type
 
#define CBL_ASSUME_NONNULL_BEGIN
 
#define CBL_ASSUME_NONNULL_END
 
#define _cbl_nullable
 
#define CBLAPI
 
#define CBL_CORE_API
 
#define CBL_CAPI_BEGIN   CBL_ASSUME_NONNULL_BEGIN
 
#define CBL_CAPI_END   CBL_ASSUME_NONNULL_END
 
#define CBL_PUBLIC
 
#define __printflike(fmtarg, firstvararg)   __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 

Macro Definition Documentation

- +

◆ __has_attribute

@@ -123,7 +129,7 @@

+

◆ __has_extension

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

+

◆ __has_feature

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

+

◆ __printflike

@@ -187,7 +193,7 @@

+

◆ _cbl_deprecated

@@ -201,63 +207,91 @@

-

◆ _cbl_nonnull

+ +

◆ _cbl_nullable

- +
#define _cbl_nonnull   /* GCC does not support the way we use nonnull */#define _cbl_nullable
- -

◆ _cbl_returns_nonnull

+ +

◆ _cbl_warn_unused

- +
#define _cbl_returns_nonnull   __attribute__((returns_nonnull))#define _cbl_warn_unused   __attribute__((warn_unused_result))
- -

◆ _cbl_warn_unused

+ +

◆ CBL_ASSUME_NONNULL_BEGIN

- + + +
#define _cbl_warn_unused   __attribute__((warn_unused_result))#define CBL_ASSUME_NONNULL_BEGIN
+
+ +
+
+ +

◆ CBL_ASSUME_NONNULL_END

+ +
+
+ + +
#define CBL_ASSUME_NONNULL_END
- -

◆ CBL_CORE_API

+ +

◆ CBL_CAPI_BEGIN

- +
#define CBL_CORE_API#define CBL_CAPI_BEGIN   CBL_ASSUME_NONNULL_BEGIN
- + +

◆ CBL_CAPI_END

+ +
+
+ + + + +
#define CBL_CAPI_END   CBL_ASSUME_NONNULL_END
+
+ +
+
+

◆ CBL_ENUM

@@ -285,7 +319,7 @@

+

◆ CBL_OPTIONS

@@ -313,7 +347,21 @@

+ +

◆ CBL_PUBLIC

+ +
+
+ + + + +
#define CBL_PUBLIC
+
+ +
+
+

◆ CBLAPI

@@ -327,7 +375,7 @@

+

◆ CBLINLINE

@@ -344,9 +392,7 @@

diff --git a/docs/C/html/_c_b_l___compat_8h_source.html b/docs/C/html/_c_b_l___compat_8h_source.html index c14f6655..2b635cb0 100644 --- a/docs/C/html/_c_b_l___compat_8h_source.html +++ b/docs/C/html/_c_b_l___compat_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBL_Compat.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBL_Compat.h
+
CBL_Compat.h
-Go to the documentation of this file.
1 //
2 // CBL_Compat.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 
21 
22 #ifndef __has_feature
23  #define __has_feature(x) 0
24 #endif
25 #ifndef __has_attribute
26  #define __has_attribute(x) 0
27 #endif
28 #ifndef __has_extension
29  #define __has_extension(x) 0
30 #endif
31 
32 
33 #ifdef _MSC_VER
34  #include <sal.h>
35  #define CBLINLINE __forceinline
36  #define _cbl_nonnull _In_
37  #define _cbl_returns_nonnull _Ret_notnull_
38  #define _cbl_warn_unused _Check_return_
39  #define _cbl_deprecated
40 #else
41  #define CBLINLINE inline
42  #define _cbl_returns_nonnull __attribute__((returns_nonnull))
43  #define _cbl_warn_unused __attribute__((warn_unused_result))
44  #ifdef __clang__
45  #define _cbl_nonnull __attribute((nonnull))
46  #else
47  #define _cbl_nonnull /* GCC does not support the way we use nonnull */
48  #endif
49  #define _cbl_deprecated __attribute__((deprecated()))
50 #endif
51 
52 // Macros for defining typed enumerations and option flags.
53 // To define an enumeration whose values won't be combined:
54 // typedef CBL_ENUM(baseIntType, name) { ... };
55 // To define an enumeration of option flags that will be ORed together:
56 // typedef CBL_OPTIONS(baseIntType, name) { ... };
57 // These aren't just a convenience; they are required for Swift bindings.
58 #if __APPLE__
59  #include <CoreFoundation/CFBase.h> /* for CF_ENUM and CF_OPTIONS macros */
60  #define CBL_ENUM CF_ENUM
61  #define CBL_OPTIONS CF_OPTIONS
62 #elif DOXYGEN_PARSING
63  #define CBL_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
64  #define CBL_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
65 #else
66  #if (__cplusplus && _MSC_VER) || (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
67  #define CBL_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
68  #if (__cplusplus)
69  #define CBL_OPTIONS(_type, _name) _type _name; enum : _type
70  #else
71  #define CBL_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
72  #endif
73  #else
74  #define CBL_ENUM(_type, _name) _type _name; enum
75  #define CBL_OPTIONS(_type, _name) _type _name; enum
76  #endif
77 #endif
78 
79 
80 #ifdef __cplusplus
81  #define CBLAPI noexcept
82 #else
83  #define CBLAPI
84 #endif
85 
86 
87 // Export/import stuff:
88 #ifdef _MSC_VER
89  #ifdef LITECORE_EXPORTS
90  #define CBL_CORE_API __declspec(dllexport)
91  #else
92  #define CBL_CORE_API __declspec(dllimport)
93  #endif
94 #else // _MSC_VER
95  #define CBL_CORE_API
96 #endif
97 
98 // Type-checking for printf-style vararg functions:
99 #ifdef _MSC_VER
100  #define __printflike(A, B)
101 #else
102  #ifndef __printflike
103  #define __printflike(fmtarg, firstvararg) __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
104  #endif
105 #endif
+Go to the documentation of this file.
1//
+
2// CBL_Compat.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20
+
21
+
22#ifndef __has_feature
+
23 #define __has_feature(x) 0
+
24#endif
+
25#ifndef __has_attribute
+
26 #define __has_attribute(x) 0
+
27#endif
+
28#ifndef __has_extension
+
29 #define __has_extension(x) 0
+
30#endif
+
31
+
32
+
33#ifdef _MSC_VER
+
34 #include <sal.h>
+
35 #define CBLINLINE __forceinline
+
36 #define _cbl_nonnull _In_
+
37 #define _cbl_warn_unused _Check_return_
+
38 #define _cbl_deprecated
+
39#else
+
40 #define CBLINLINE inline
+
41 #define _cbl_warn_unused __attribute__((warn_unused_result))
+
42 #define _cbl_deprecated __attribute__((deprecated()))
+
43#endif
+
44
+
45// Macros for defining typed enumerations and option flags.
+
46// To define an enumeration whose values won't be combined:
+
47// typedef CBL_ENUM(baseIntType, name) { ... };
+
48// To define an enumeration of option flags that will be ORed together:
+
49// typedef CBL_OPTIONS(baseIntType, name) { ... };
+
50// These aren't just a convenience; they are required for Swift bindings.
+
51#if __APPLE__
+
52 #include <CoreFoundation/CFBase.h> /* for CF_ENUM and CF_OPTIONS macros */
+
53 #define CBL_ENUM CF_ENUM
+
54 #define CBL_OPTIONS CF_OPTIONS
+
55#elif DOXYGEN_PARSING
+
56 #define CBL_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+
57 #define CBL_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+
58#else
+
59 #if (__cplusplus && _MSC_VER) || (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
+
60 #define CBL_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+
61 #if (__cplusplus)
+
62 #define CBL_OPTIONS(_type, _name) _type _name; enum : _type
+
63 #else
+
64 #define CBL_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+
65 #endif
+
66 #else
+
67 #define CBL_ENUM(_type, _name) _type _name; enum
+
68 #define CBL_OPTIONS(_type, _name) _type _name; enum
+
69 #endif
+
70#endif
+
71
+
72
+
73// Non-null annotations, for function parameters and struct fields.
+
74// In between CBL_ASSUME_NONNULL_BEGIN and CBL_ASSUME_NONNULL_END, all pointer declarations implicitly
+
75// disallow NULL values, unless annotated with _cbl_nullable (which must come after the `*`.)
+
76// (_cbl_nonnull is occasionally necessary when there are C arrays or multiple levels of pointers.)
+
77// NOTE: Only supported in Clang, so far.
+
78#if __has_feature(nullability)
+
79# define CBL_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
+
80# define CBL_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
+
81# define _cbl_nullable _Nullable
+
82# define _cbl_nonnull _Nonnull
+
83#else
+
84# define CBL_ASSUME_NONNULL_BEGIN
+
85# define CBL_ASSUME_NONNULL_END
+
86# define _cbl_nullable
+
87#ifndef _cbl_nonnull
+
88# define _cbl_nonnull
+
89#endif
+
90#endif
+
91
+
92
+
93#ifdef __cplusplus
+
94 #define CBLAPI noexcept
+
95 #define CBL_CAPI_BEGIN extern "C" { CBL_ASSUME_NONNULL_BEGIN
+
96 #define CBL_CAPI_END CBL_ASSUME_NONNULL_END }
+
97#else
+
98 #define CBLAPI
+
99 #define CBL_CAPI_BEGIN CBL_ASSUME_NONNULL_BEGIN
+
100 #define CBL_CAPI_END CBL_ASSUME_NONNULL_END
+
101#endif
+
102
+
103
+
104// On Windows, CBL_PUBLIC marks symbols as being exported from the shared library.
+
105// However, this is not the whole list of things that are exported. The API methods
+
106// are exported using a definition list, but it is not possible to correctly include
+
107// initialized global variables, so those need to be marked (both in the header and
+
108// implementation) with CBL_PUBLIC. See kCBLTypeProperty in CBLBlob.h and CBLBlob_CPI.cc
+
109// for an example.
+
110#ifdef _MSC_VER
+
111 #ifdef CBL_EXPORTS
+
112 #define CBL_PUBLIC __declspec(dllexport)
+
113 #else
+
114 #define CBL_PUBLIC __declspec(dllimport)
+
115 #endif
+
116#else // _MSC_VER
+
117 #define CBL_PUBLIC
+
118#endif
+
119
+
120// Type-checking for printf-style vararg functions:
+
121#ifdef _MSC_VER
+
122 #define __printflike(A, B)
+
123#else
+
124 #ifndef __printflike
+
125 #define __printflike(fmtarg, firstvararg) __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+
126 #endif
+
127#endif
+
128
+

diff --git a/docs/C/html/_c_b_l_base_8h.html b/docs/C/html/_c_b_l_base_8h.html index 2f6b9fea..d92fdcc8 100644 --- a/docs/C/html/_c_b_l_base_8h.html +++ b/docs/C/html/_c_b_l_base_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLBase.h File Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
Typedefs | Enumerations | Functions
-
-
CBLBase.h File Reference
+
CBLBase.h File Reference

-
#include "CBL_Compat.h"
+
#include "CBL_Edition.h"
+#include "CBL_Compat.h"
#include "fleece/FLSlice.h"
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

-

+

Data Structures

struct  CBLError
 A struct holding information about an error. More...
 
-

+

Macros

#define CBL_REFCOUNTED(TYPE, NAME)
 
- @@ -119,120 +120,121 @@ + + +

+

Typedefs

typedef int64_t CBLTimestamp
 A date/time representation used for document expiration (and in date/time queries.) Measured in milliseconds since the Unix epoch (1/1/1970, midnight UTC.) More...
typedef struct CBLReplicator CBLReplicator
 A background task that syncs a CBLDatabase with a remote server or peer. More...
 
typedef struct CBLEncryptable CBLEncryptable
 An encryptable value. More...
 
typedef struct CBLListenerToken CBLListenerToken
 An opaque 'cookie' representing a registered listener callback. More...
 
-

+

Enumerations

enum  CBLErrorDomain : uint8_t {
-  CBLDomain = 1, -CBLPOSIXDomain, -CBLSQLiteDomain, -CBLFleeceDomain, -
-  CBLNetworkDomain, -CBLWebSocketDomain +  kCBLDomain = 1 +, kCBLPOSIXDomain +, kCBLSQLiteDomain +, kCBLFleeceDomain +,
+  kCBLNetworkDomain +, kCBLWebSocketDomain
}
 Error domains, serving as namespaces for numeric error codes. More...
 
enum  CBLErrorCode : int32_t {
-  CBLErrorAssertionFailed = 1, -CBLErrorUnimplemented, -CBLErrorUnsupportedEncryption, -CBLErrorBadRevisionID, -
-  CBLErrorCorruptRevisionData, -CBLErrorNotOpen, -CBLErrorNotFound, -CBLErrorConflict, -
-  CBLErrorInvalidParameter, -CBLErrorUnexpectedError, -CBLErrorCantOpenFile, -CBLErrorIOError, -
-  CBLErrorMemoryError, -CBLErrorNotWriteable, -CBLErrorCorruptData, -CBLErrorBusy, -
-  CBLErrorNotInTransaction, -CBLErrorTransactionNotClosed, -CBLErrorUnsupported, -CBLErrorNotADatabaseFile, -
-  CBLErrorWrongFormat, -CBLErrorCrypto, -CBLErrorInvalidQuery, -CBLErrorMissingIndex, -
-  CBLErrorInvalidQueryParam, -CBLErrorRemoteError, -CBLErrorDatabaseTooOld, -CBLErrorDatabaseTooNew, -
-  CBLErrorBadDocID, -CBLErrorCantUpgradeDatabase +  kCBLErrorAssertionFailed = 1 +, kCBLErrorUnimplemented +, kCBLErrorUnsupportedEncryption +, kCBLErrorBadRevisionID +,
+  kCBLErrorCorruptRevisionData +, kCBLErrorNotOpen +, kCBLErrorNotFound +, kCBLErrorConflict +,
+  kCBLErrorInvalidParameter +, kCBLErrorUnexpectedError +, kCBLErrorCantOpenFile +, kCBLErrorIOError +,
+  kCBLErrorMemoryError +, kCBLErrorNotWriteable +, kCBLErrorCorruptData +, kCBLErrorBusy +,
+  kCBLErrorNotInTransaction +, kCBLErrorTransactionNotClosed +, kCBLErrorUnsupported +, kCBLErrorNotADatabaseFile +,
+  kCBLErrorWrongFormat +, kCBLErrorCrypto +, kCBLErrorInvalidQuery +, kCBLErrorMissingIndex +,
+  kCBLErrorInvalidQueryParam +, kCBLErrorRemoteError +, kCBLErrorDatabaseTooOld +, kCBLErrorDatabaseTooNew +,
+  kCBLErrorBadDocID +, kCBLErrorCantUpgradeDatabase
}
 Couchbase Lite error codes, in the CBLDomain. More...
 
enum  CBLNetworkErrorCode : int32_t {
-  CBLNetErrDNSFailure = 1, -CBLNetErrUnknownHost, -CBLNetErrTimeout, -CBLNetErrInvalidURL, -
-  CBLNetErrTooManyRedirects, -CBLNetErrTLSHandshakeFailed, -CBLNetErrTLSCertExpired, -CBLNetErrTLSCertUntrusted, -
-  CBLNetErrTLSClientCertRequired, -CBLNetErrTLSClientCertRejected, -CBLNetErrTLSCertUnknownRoot, -CBLNetErrInvalidRedirect, -
-  CBLNetErrUnknown, -CBLNetErrTLSCertRevoked, -CBLNetErrTLSCertNameMismatch +  kCBLNetErrDNSFailure = 1 +, kCBLNetErrUnknownHost +, kCBLNetErrTimeout +, kCBLNetErrInvalidURL +,
+  kCBLNetErrTooManyRedirects +, kCBLNetErrTLSHandshakeFailed +, kCBLNetErrTLSCertExpired +, kCBLNetErrTLSCertUntrusted +,
+  kCBLNetErrTLSClientCertRequired +, kCBLNetErrTLSClientCertRejected +, kCBLNetErrTLSCertUnknownRoot +, kCBLNetErrInvalidRedirect +,
+  kCBLNetErrUnknown +, kCBLNetErrTLSCertRevoked +, kCBLNetErrTLSCertNameMismatch
}
 Network error codes, in the CBLNetworkDomain. More...
 
- - - - + + + - - - - - - + + + + + + - - - + + +

+

Functions

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

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

Go to the source code of this file.

- @@ -88,18 +88,18 @@

+

Typedefs

typedef struct CBLBlobReadStream CBLBlobReadStream
 A stream for reading a blob's content. More...
 A stream for writing a new blob to the database. More...
 
- - - + + - - - - - - + + + + + + @@ -112,70 +112,74 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+

Functions

static const CBLBlobCBLBlob_Retain (const CBLBlob *t)
 
static const CBLBlobCBLBlob_Retain (const CBLBlob *t)
 
static void CBLBlob_Release (const CBLBlob *t)
 
bool FLDict_IsBlob (FLDict)
 Returns true if a dictionary in a document is a blob reference. More...
 
const CBLBlobFLDict_GetBlob (FLDict blobDict)
 Returns a CBLBlob object corresponding to a blob dictionary in a document. More...
 
bool FLDict_IsBlob (FLDict _cbl_nullable)
 Returns true if a dictionary in a document is a blob reference. More...
 
const CBLBlob *_cbl_nullable FLDict_GetBlob (FLDict _cbl_nullable blobDict)
 Returns a CBLBlob object corresponding to a blob dictionary in a document. More...
 
uint64_t CBLBlob_Length (const CBLBlob *)
 Returns the length in bytes of a blob's content (from its length property). More...
 
FLDict CBLBlob_Properties (const CBLBlob *)
 Returns a blob's metadata. More...
 
_cbl_warn_unused FLStringResult CBLBlob_ToJSON (const CBLBlob *blob)
 Returns a blob's metadata as JSON. More...
 
_cbl_warn_unused FLSliceResult CBLBlob_Content (const CBLBlob *, CBLError *outError)
 Reads the blob's contents into memory and returns them. More...
 
_cbl_warn_unused CBLBlobReadStreamCBLBlob_OpenContentStream (const CBLBlob *, CBLError *outError)
 Opens a stream for reading a blob's content. More...
 
int CBLBlobReader_Read (CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *outError)
 Reads data from a blob. More...
 
void CBLBlobReader_Close (CBLBlobReadStream *)
 Closes a CBLBlobReadStream. More...
 
_cbl_warn_unused CBLBlobCBLBlob_NewWithData (FLString contentType, FLSlice contents)
 Creates a new blob given its contents as a single block of data. More...
 
_cbl_warn_unused CBLBlobWriteStreamCBLBlobWriter_New (CBLDatabase *db, CBLError *outError)
 Opens a stream for writing a new blob. More...
 
void CBLBlobWriter_Close (CBLBlobWriteStream *)
 Closes a blob-writing stream, if you need to give up without creating a CBLBlob. More...
 
bool CBLBlobWriter_Write (CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *outError)
 Writes data to a new blob. More...
 
_cbl_warn_unused CBLBlobCBLBlob_NewWithStream (FLString contentType, CBLBlobWriteStream *writer)
 Creates a new blob after its data has been written to a CBLBlobWriteStream. More...
 
static bool FLValue_IsBlob (FLValue v)
 Returns true if a value in a document is a blob reference. More...
 
static const CBLBlobFLValue_GetBlob (FLValue value)
 Instantiates a CBLBlob object corresponding to a blob dictionary in a document. More...
 
_cbl_warn_unused FLStringResult CBLBlob_CreateJSON (const CBLBlob *blob)
 Returns a blob's metadata as JSON. More...
 
_cbl_warn_unused FLSliceResult CBLBlob_Content (const CBLBlob *blob, CBLError *_cbl_nullable outError)
 Reads the blob's contents into memory and returns them. More...
 
_cbl_warn_unused CBLBlobReadStream *_cbl_nullable CBLBlob_OpenContentStream (const CBLBlob *blob, CBLError *_cbl_nullable)
 Opens a stream for reading a blob's content. More...
 
int CBLBlobReader_Read (CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *_cbl_nullable outError)
 Reads data from a blob. More...
 
void CBLBlobReader_Close (CBLBlobReadStream *_cbl_nullable)
 Closes a CBLBlobReadStream. More...
 
bool CBLBlob_Equals (CBLBlob *blob, CBLBlob *anotherBlob)
 Compares whether the two given blobs are equal based on their content. More...
 
_cbl_warn_unused CBLBlobCBLBlob_CreateWithData (FLString contentType, FLSlice contents)
 Creates a new blob given its contents as a single block of data. More...
 
_cbl_warn_unused CBLBlobWriteStream *_cbl_nullable CBLBlobWriter_Create (CBLDatabase *db, CBLError *_cbl_nullable)
 Opens a stream for writing a new blob. More...
 
void CBLBlobWriter_Close (CBLBlobWriteStream *_cbl_nullable)
 Closes a blob-writing stream, if you need to give up without creating a CBLBlob. More...
 
bool CBLBlobWriter_Write (CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *_cbl_nullable outError)
 Writes data to a new blob. More...
 
_cbl_warn_unused CBLBlobCBLBlob_CreateWithStream (FLString contentType, CBLBlobWriteStream *writer)
 Creates a new blob after its data has been written to a CBLBlobWriteStream. More...
 
static bool FLValue_IsBlob (FLValue _cbl_nullable v)
 Returns true if a value in a document is a blob reference. More...
 
static const CBLBlob *_cbl_nullable FLValue_GetBlob (FLValue _cbl_nullable value)
 Instantiates a CBLBlob object corresponding to a blob dictionary in a document. More...
 
void FLSlot_SetBlob (FLSlot slot, CBLBlob *blob)
 Stores a blob reference in a Fleece mutable Array or Dict. More...
 
const CBLBlob *_cbl_nullable CBLDatabase_GetBlob (CBLDatabase *db, FLDict properties, CBLError *_cbl_nullable outError)
 Get a CBLBlob object from the database using the CBLBlob properties. More...
 
bool CBLDatabase_SaveBlob (CBLDatabase *db, CBLBlob *blob, CBLError *_cbl_nullable outError)
 Save a new CBLBlob object into the database without associating it with any documents. More...
 
- - - - - - - - - - - - - - - - + + + + + + + + + + + +

+

Variables

CBL_CORE_API const FLSlice kCBLTypeProperty
 "@type" More...
 
CBL_CORE_API const FLSlice kCBLBlobType
 "blob" More...
 
CBL_CORE_API const FLSlice kCBLBlobDigestProperty
 "digest" More...
 
CBL_CORE_API const FLSlice kCBLBlobLengthProperty
 "length" More...
 
CBL_CORE_API const FLSlice kCBLBlobContentTypeProperty
 "content_type" More...
 
CBL_PUBLIC const FLSlice kCBLBlobType
 "blob" More...
 
CBL_PUBLIC const FLSlice kCBLBlobDigestProperty
 "digest" More...
 
CBL_PUBLIC const FLSlice kCBLBlobLengthProperty
 "length" More...
 
CBL_PUBLIC const FLSlice kCBLBlobContentTypeProperty
 "content_type" More...
 
diff --git a/docs/C/html/_c_b_l_blob_8h_source.html b/docs/C/html/_c_b_l_blob_8h_source.html index 42913a04..1830b32b 100644 --- a/docs/C/html/_c_b_l_blob_8h_source.html +++ b/docs/C/html/_c_b_l_blob_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLBlob.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLBlob.h
+
CBLBlob.h
-Go to the documentation of this file.
1 //
2 // CBLBlob.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "fleece/Fleece.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
60  CBL_CORE_API extern const FLSlice kCBLBlobType;
61 
65 
66 
68 
69 
75 
79  const CBLBlob* FLDict_GetBlob(FLDict blobDict) CBLAPI;
80 
81 
82 #pragma mark - BLOB METADATA:
83 
85  uint64_t CBLBlob_Length(const CBLBlob* _cbl_nonnull) CBLAPI;
86 
89 
92 
96 
100 
101 #pragma mark - READING:
102 
107 
110 
114 
122  void *dst _cbl_nonnull,
123  size_t maxLength,
124  CBLError *outError) CBLAPI;
125 
128 
129 
130 #pragma mark - CREATING:
131 
139  CBLBlob* CBLBlob_NewWithData(FLString contentType,
140  FLSlice contents) CBLAPI;
141 
144 
152  CBLError *outError) CBLAPI;
153 
156 
164  const void *data _cbl_nonnull,
165  size_t length,
166  CBLError *outError) CBLAPI;
167 
179 
180 #pragma mark - FLEECE UTILITIES:
181 
184  static inline bool FLValue_IsBlob(FLValue v) {
185  return FLDict_IsBlob(FLValue_AsDict(v));
186  }
187 
192  static inline const CBLBlob* FLValue_GetBlob(FLValue value) {
193  return FLDict_GetBlob(FLValue_AsDict(value));
194  }
195 
201  CBLBlob* blob _cbl_nonnull) CBLAPI;
202 
203 
206 #ifdef __cplusplus
207 }
208 #endif
void CBLBlobWriter_Close(CBLBlobWriteStream *)
Closes a blob-writing stream, if you need to give up without creating a CBLBlob.
-
static bool FLValue_IsBlob(FLValue v)
Returns true if a value in a document is a blob reference.
Definition: CBLBlob.h:184
-
CBL_CORE_API const FLSlice kCBLBlobContentTypeProperty
"content_type"
-
void FLSlot_SetBlob(FLSlot slot, CBLBlob *blob)
Stores a blob reference in a Fleece mutable Array or Dict.
-
bool FLDict_IsBlob(FLDict)
Returns true if a dictionary in a document is a blob reference.
-
FLString CBLBlob_Digest(const CBLBlob *)
Returns the cryptographic digest of a blob's content (from its digest property).
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
- -
struct CBLBlobWriteStream CBLBlobWriteStream
A stream for writing a new blob to the database.
Definition: CBLBlob.h:143
-
CBL_CORE_API const FLSlice kCBLBlobType
"blob"
-
_cbl_warn_unused CBLBlob * CBLBlob_NewWithData(FLString contentType, FLSlice contents)
Creates a new blob given its contents as a single block of data.
-
_cbl_warn_unused CBLBlob * CBLBlob_NewWithStream(FLString contentType, CBLBlobWriteStream *writer)
Creates a new blob after its data has been written to a CBLBlobWriteStream.
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
struct CBLBlob CBLBlob
A binary data value associated with a CBLDocument.
Definition: CBLBase.h:199
- -
FLString CBLBlob_ContentType(const CBLBlob *)
Returns a blob's MIME type, if its metadata has a content_type property.
-
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:184
-
_cbl_warn_unused CBLBlobReadStream * CBLBlob_OpenContentStream(const CBLBlob *, CBLError *outError)
Opens a stream for reading a blob's content.
-
CBL_CORE_API const FLSlice kCBLBlobLengthProperty
"length"
-
FLDict CBLBlob_Properties(const CBLBlob *)
Returns a blob's metadata.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
void CBLBlobReader_Close(CBLBlobReadStream *)
Closes a CBLBlobReadStream.
-
FLDict FLValue_AsDict(FLValue) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
-
int CBLBlobReader_Read(CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *outError)
Reads data from a blob.
-
#define _cbl_warn_unused
Definition: CBL_Compat.h:43
-
uint64_t CBLBlob_Length(const CBLBlob *)
Returns the length in bytes of a blob's content (from its length property).
-
struct CBLBlobReadStream CBLBlobReadStream
A stream for reading a blob's content.
Definition: CBLBlob.h:109
-
CBL_CORE_API const FLSlice kCBLTypeProperty
"@type"
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:39
-
_cbl_warn_unused FLSliceResult CBLBlob_Content(const CBLBlob *, CBLError *outError)
Reads the blob's contents into memory and returns them.
-
CBL_CORE_API const FLSlice kCBLBlobDigestProperty
"digest"
-
_cbl_warn_unused CBLBlobWriteStream * CBLBlobWriter_New(CBLDatabase *db, CBLError *outError)
Opens a stream for writing a new blob.
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
#define CBL_CORE_API
Definition: CBL_Compat.h:95
-
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:42
-
static const CBLBlob * FLValue_GetBlob(FLValue value)
Instantiates a CBLBlob object corresponding to a blob dictionary in a document.
Definition: CBLBlob.h:192
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
const CBLBlob * FLDict_GetBlob(FLDict blobDict)
Returns a CBLBlob object corresponding to a blob dictionary in a document.
-
_cbl_warn_unused FLStringResult CBLBlob_ToJSON(const CBLBlob *blob)
Returns a blob's metadata as JSON.
-
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:172
-
bool CBLBlobWriter_Write(CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *outError)
Writes data to a new blob.
+Go to the documentation of this file.
1//
+
2// CBLBlob.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/Fleece.h"
+
22
+ +
24
+
58 CBL_PUBLIC extern const FLSlice kCBLBlobType;
+ + + +
62
+
63
+ +
65
+
66
+ +
72
+ +
77
+
78#ifdef __APPLE__
+
79#pragma mark - BLOB METADATA:
+
80#endif
+
81
+
83 uint64_t CBLBlob_Length(const CBLBlob*) CBLAPI;
+
84
+ +
87
+ +
90
+ +
94
+ + +
98
+
99#ifdef __APPLE__
+
100#pragma mark - READING:
+
101#endif
+
102
+ + +
107 CBLError* _cbl_nullable outError) CBLAPI;
+
108
+ +
111
+ + + +
116
+ +
124 void *dst,
+
125 size_t maxLength,
+
126 CBLError* _cbl_nullable outError) CBLAPI;
+
127
+ +
130
+
132 bool CBLBlob_Equals(CBLBlob* blob, CBLBlob* anotherBlob) CBLAPI;
+
133
+
134#ifdef __APPLE__
+
135#pragma mark - CREATING:
+
136#endif
+
137
+ + +
146
+ +
149
+ + + +
158
+ +
161
+ +
169 const void *data,
+
170 size_t length,
+
171 CBLError* _cbl_nullable outError) CBLAPI;
+
172
+ + +
183 CBLBlobWriteStream* writer) CBLAPI;
+
184
+
185#ifdef __APPLE__
+
186#pragma mark - FLEECE UTILITIES:
+
187#endif
+
188
+
191 static inline bool FLValue_IsBlob(FLValue _cbl_nullable v) {
+
192 return FLDict_IsBlob(FLValue_AsDict(v));
+
193 }
+
194
+ +
200 return FLDict_GetBlob(FLValue_AsDict(value));
+
201 }
+
202
+ +
208
+
209#ifdef __APPLE__
+
210#pragma mark - BINDING DEV SUPPORT FOR BLOB:
+
211#endif
+
212
+ +
228 CBLError* _cbl_nullable outError) CBLAPI;
+
229
+ +
245 CBLError* _cbl_nullable outError) CBLAPI;
+
246
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_PUBLIC
Definition: CBL_Compat.h:117
+
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
+ + +
FLDict FLValue_AsDict(FLValue) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
+
_cbl_warn_unused CBLBlob * CBLBlob_CreateWithData(FLString contentType, FLSlice contents)
Creates a new blob given its contents as a single block of data.
+
CBL_PUBLIC const FLSlice kCBLBlobContentTypeProperty
"content_type"
+
bool CBLBlob_Equals(CBLBlob *blob, CBLBlob *anotherBlob)
Compares whether the two given blobs are equal based on their content.
+
bool CBLDatabase_SaveBlob(CBLDatabase *db, CBLBlob *blob, CBLError *_cbl_nullable outError)
Save a new CBLBlob object into the database without associating it with any documents.
+
bool FLDict_IsBlob(FLDict _cbl_nullable)
Returns true if a dictionary in a document is a blob reference.
+
static bool FLValue_IsBlob(FLValue _cbl_nullable v)
Returns true if a value in a document is a blob reference.
Definition: CBLBlob.h:191
+
_cbl_warn_unused CBLBlob * CBLBlob_CreateWithStream(FLString contentType, CBLBlobWriteStream *writer)
Creates a new blob after its data has been written to a CBLBlobWriteStream.
+
int CBLBlobReader_Read(CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *_cbl_nullable outError)
Reads data from a blob.
+
FLString CBLBlob_Digest(const CBLBlob *)
Returns the cryptographic digest of a blob's content (from its digest property).
+
_cbl_warn_unused FLStringResult CBLBlob_CreateJSON(const CBLBlob *blob)
Returns a blob's metadata as JSON.
+
FLString CBLBlob_ContentType(const CBLBlob *)
Returns a blob's MIME type, if its metadata has a content_type property.
+
void CBLBlobWriter_Close(CBLBlobWriteStream *_cbl_nullable)
Closes a blob-writing stream, if you need to give up without creating a CBLBlob.
+
const CBLBlob *_cbl_nullable CBLDatabase_GetBlob(CBLDatabase *db, FLDict properties, CBLError *_cbl_nullable outError)
Get a CBLBlob object from the database using the CBLBlob properties.
+
void FLSlot_SetBlob(FLSlot slot, CBLBlob *blob)
Stores a blob reference in a Fleece mutable Array or Dict.
+
struct CBLBlobReadStream CBLBlobReadStream
A stream for reading a blob's content.
Definition: CBLBlob.h:110
+
FLDict CBLBlob_Properties(const CBLBlob *)
Returns a blob's metadata.
+
CBL_PUBLIC const FLSlice kCBLBlobLengthProperty
"length"
+
struct CBLBlobWriteStream CBLBlobWriteStream
A stream for writing a new blob to the database.
Definition: CBLBlob.h:148
+
CBL_PUBLIC const FLSlice kCBLBlobType
"blob"
+
_cbl_warn_unused CBLBlobReadStream *_cbl_nullable CBLBlob_OpenContentStream(const CBLBlob *blob, CBLError *_cbl_nullable)
Opens a stream for reading a blob's content.
+
CBL_PUBLIC const FLSlice kCBLBlobDigestProperty
"digest"
+
const CBLBlob *_cbl_nullable FLDict_GetBlob(FLDict _cbl_nullable blobDict)
Returns a CBLBlob object corresponding to a blob dictionary in a document.
+
_cbl_warn_unused CBLBlobWriteStream *_cbl_nullable CBLBlobWriter_Create(CBLDatabase *db, CBLError *_cbl_nullable)
Opens a stream for writing a new blob.
+
struct CBLBlob CBLBlob
A binary data value associated with a CBLDocument.
Definition: CBLBase.h:197
+
_cbl_warn_unused FLSliceResult CBLBlob_Content(const CBLBlob *blob, CBLError *_cbl_nullable outError)
Reads the blob's contents into memory and returns them.
+
uint64_t CBLBlob_Length(const CBLBlob *)
Returns the length in bytes of a blob's content (from its length property).
+
void CBLBlobReader_Close(CBLBlobReadStream *_cbl_nullable)
Closes a CBLBlobReadStream.
+
static const CBLBlob *_cbl_nullable FLValue_GetBlob(FLValue _cbl_nullable value)
Instantiates a CBLBlob object corresponding to a blob dictionary in a document.
Definition: CBLBlob.h:199
+
bool CBLBlobWriter_Write(CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *_cbl_nullable outError)
Writes data to a new blob.
+
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:58
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/_c_b_l_database_8h.html b/docs/C/html/_c_b_l_database_8h.html index f90a9f8e..ab197411 100644 --- a/docs/C/html/_c_b_l_database_8h.html +++ b/docs/C/html/_c_b_l_database_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLDatabase.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
CBLDatabase.h File Reference
+
CBLDatabase.h File Reference
#include "CBLBase.h"
@@ -77,7 +77,7 @@

Go to the source code of this file.

- @@ -86,22 +86,22 @@

+

Data Structures

struct  CBLEncryptionKey
 Encryption key specified in a CBLDatabaseConfiguration. More...
 Database configuration options. More...
 
- - - - - - - - + + + + + + - @@ -116,17 +116,9 @@

+

Functions

Database file operations

These functions operate on database files without opening them.

+

These functions operate on database files without opening them.

bool CBL_DatabaseExists (FLString name, FLString inDirectory)
 Returns true if a database with the given name exists in the given directory. More...
 
bool CBL_CopyDatabase (FLString fromPath, FLString toName, const CBLDatabaseConfiguration *config, CBLError *)
 Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from the original database when replicating. More...
 
bool CBL_DeleteDatabase (FLString name, FLString inDirectory, CBLError *outError)
 Deletes a database file. More...
 
bool CBL_CopyDatabase (FLString fromPath, FLString toName, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
 Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from the original database when replicating. More...
 
bool CBL_DeleteDatabase (FLString name, FLString inDirectory, CBLError *_cbl_nullable outError)
 Deletes a database file. More...
 
Database accessors

Getting information about a database.

+

Getting information about a database.

FLString CBLDatabase_Name (const CBLDatabase *)
 Returns the database's name. More...
 Returns the database's configuration, as given when it was opened. More...
 
- - - - - + @@ -141,67 +133,69 @@

-Database configuration

enum  CBLDatabaseFlags : uint32_t { kCBLDatabase_Create = 1, -kCBLDatabase_ReadOnly = 2, -kCBLDatabase_NoUpgrade = 4, -kCBLDatabase_VersionVectors = 0x8000 - }
 Flags for how to open a database. More...
 
enum  CBLEncryptionAlgorithm : uint32_t { kCBLEncryptionNone = 0, -kCBLEncryptionAES256 +

Database configuration

enum  CBLEncryptionAlgorithm : uint32_t { kCBLEncryptionNone = 0 +, kCBLEncryptionAES256 }
 Database encryption algorithms (available only in the Enterprise Edition). More...
 
 Derives an encryption key from a password. More...
 
- - + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +

-Database lifecycle

Opening, closing, and managing open databases.

+

Database lifecycle

Opening, closing, and managing open databases.

enum  CBLMaintenanceType : uint32_t { kCBLMaintenanceTypeCompact = 0, -kCBLMaintenanceTypeReindex, -kCBLMaintenanceTypeIntegrityCheck +
enum  CBLMaintenanceType : uint32_t {
+  kCBLMaintenanceTypeCompact = 0 +, kCBLMaintenanceTypeReindex +, kCBLMaintenanceTypeIntegrityCheck +, kCBLMaintenanceTypeOptimize +,
+  kCBLMaintenanceTypeFullOptimize +
}
 Maintenance Type used when performing database maintenance. More...
 
_cbl_warn_unused CBLDatabaseCBLDatabase_Open (FLSlice name, const CBLDatabaseConfiguration *config, CBLError *error)
 Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance. More...
 
bool CBLDatabase_Close (CBLDatabase *, CBLError *)
 Closes an open database. More...
 
static const CBLDatabaseCBLDatabase_Retain (const CBLDatabase *t)
 
_cbl_warn_unused CBLDatabase *_cbl_nullable CBLDatabase_Open (FLSlice name, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
 Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance. More...
 
bool CBLDatabase_Close (CBLDatabase *, CBLError *_cbl_nullable outError)
 Closes an open database. More...
 
static const CBLDatabaseCBLDatabase_Retain (const CBLDatabase *t)
 
static void CBLDatabase_Release (const CBLDatabase *t)
 
bool CBLDatabase_Delete (CBLDatabase *, CBLError *)
 Closes and deletes a database. More...
 
bool CBLDatabase_BeginBatch (CBLDatabase *, CBLError *)
 Begins a batch operation, similar to a transaction. More...
 
bool CBLDatabase_EndBatch (CBLDatabase *, CBLError *)
 Ends a batch operation. More...
 
bool CBLDatabase_ChangeEncryptionKey (CBLDatabase *, const CBLEncryptionKey *newKey, CBLError *outError)
 Encrypts or decrypts a database, or changes its encryption key. More...
 
bool CBLDatabase_PerformMaintenance (CBLDatabase *db, CBLMaintenanceType type, CBLError *outError)
 Performs database maintenance. More...
 
bool CBLDatabase_Delete (CBLDatabase *, CBLError *_cbl_nullable outError)
 Closes and deletes a database. More...
 
bool CBLDatabase_BeginTransaction (CBLDatabase *, CBLError *_cbl_nullable outError)
 Begins a transaction. More...
 
bool CBLDatabase_EndTransaction (CBLDatabase *, bool commit, CBLError *_cbl_nullable outError)
 Ends a transaction, either committing or aborting. More...
 
bool CBLDatabase_ChangeEncryptionKey (CBLDatabase *, const CBLEncryptionKey *_cbl_nullable newKey, CBLError *outError)
 Encrypts or decrypts a database, or changes its encryption key. More...
 
bool CBLDatabase_PerformMaintenance (CBLDatabase *db, CBLMaintenanceType type, CBLError *_cbl_nullable outError)
 Performs database maintenance. More...
 
- - + - - - - - - + + + + + +

-Database listeners

A database change listener lets you detect changes made to all documents in a database.

-

(If you only want to observe specific documents, use a CBLDocumentChangeListener instead.)

Note
If there are multiple CBLDatabase instances on the same database file, each one's listeners will be notified of changes made by other database instances.
+

Database listeners

A database change listener lets you detect changes made to all documents in a database.

+

(If you only want to observe specific documents, use a CBLDocumentChangeListener instead.)

Note
If there are multiple CBLDatabase instances on the same database file, each one's listeners will be notified of changes made by other database instances.
Warning
Changes made to the database file by other processes will not be notified.
typedef void(* CBLDatabaseChangeListener) (void *context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
 A database change listener callback, invoked after one or more documents are changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddChangeListener (const CBLDatabase *db, CBLDatabaseChangeListener listener, void *context)
 Registers a database change listener callback. More...
 
typedef void(* CBLDatabaseChangeListener) (void *_cbl_nullable context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
 A database change listener callback, invoked after one or more documents are changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddChangeListener (const CBLDatabase *db, CBLDatabaseChangeListener listener, void *_cbl_nullable context)
 Registers a database change listener callback. More...
 
- - + - - - - - - + + + + + + @@ -209,9 +203,7 @@ diff --git a/docs/C/html/_c_b_l_database_8h_source.html b/docs/C/html/_c_b_l_database_8h_source.html index 1cff502e..4f29f022 100644 --- a/docs/C/html/_c_b_l_database_8h_source.html +++ b/docs/C/html/_c_b_l_database_8h_source.html @@ -2,8 +2,8 @@ - - + +Couchbase Lite C: include/cbl/CBLDatabase.h Source File @@ -30,21 +30,22 @@

-Scheduling notifications

Applications may want control over when Couchbase Lite notifications (listener callbacks) happen.

-

They may want them called on a specific thread, or at certain times during an event loop. This behavior may vary by database, if for instance each database is associated with a separate thread.

-

The API calls here enable this. When notifications are "buffered" for a database, calls to listeners will be deferred until the application explicitly allows them. Instead, a single callback will be issued when the first notification becomes available; this gives the app a chance to schedule a time when the notifications should be sent and callbacks called.

+

Scheduling notifications

Applications may want control over when Couchbase Lite notifications (listener callbacks) happen.

+

They may want them called on a specific thread, or at certain times during an event loop. This behavior may vary by database, if for instance each database is associated with a separate thread.

+

The API calls here enable this. When notifications are "buffered" for a database, calls to listeners will be deferred until the application explicitly allows them. Instead, a single callback will be issued when the first notification becomes available; this gives the app a chance to schedule a time when the notifications should be sent and callbacks called.

typedef void(* CBLNotificationsReadyCallback) (void *context, CBLDatabase *db)
 Callback indicating that the database (or an object belonging to it) is ready to call one or more listeners. More...
 
void CBLDatabase_BufferNotifications (CBLDatabase *db, CBLNotificationsReadyCallback callback, void *context)
 Switches the database to buffered-notification mode. More...
 
typedef void(* CBLNotificationsReadyCallback) (void *_cbl_nullable context, CBLDatabase *db)
 Callback indicating that the database (or an object belonging to it) is ready to call one or more listeners. More...
 
void CBLDatabase_BufferNotifications (CBLDatabase *db, CBLNotificationsReadyCallback callback, void *_cbl_nullable context)
 Switches the database to buffered-notification mode. More...
 
void CBLDatabase_SendNotifications (CBLDatabase *db)
 Immediately issues all pending notifications for this database, by calling their listener callbacks. More...
 
- + +/* @license-end */ +
-
-
CBLDatabase.h
+
CBLDatabase.h
-Go to the documentation of this file.
1 //
2 // CBLDatabase.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "fleece/FLSlice.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
32 #pragma mark - CONFIGURATION
33 
37 typedef CBL_OPTIONS(uint32_t, CBLDatabaseFlags) {
41 
43 };
44 
46 typedef CBL_ENUM(uint32_t, CBLEncryptionAlgorithm) {
48 #ifdef COUCHBASE_ENTERPRISE
50 #endif
51 };
52 
54 typedef CBL_ENUM(uint64_t, CBLEncryptionKeySize) {
56 };
57 
59 typedef struct CBLEncryptionKey {
61  uint8_t bytes[32];
63 
65 typedef struct {
70 
71 
74 
75 #ifdef COUCHBASE_ENTERPRISE
76 
83 #endif
84 
89 #pragma mark - FILE OPERATIONS
90 
99 bool CBL_DatabaseExists(FLString name, FLString inDirectory) CBLAPI;
100 
106 bool CBL_CopyDatabase(FLString fromPath,
107  FLString toName,
108  const CBLDatabaseConfiguration* config,
109  CBLError*) CBLAPI;
110 
118 bool CBL_DeleteDatabase(FLString name,
119  FLString inDirectory,
120  CBLError *outError) CBLAPI;
121 
126 #pragma mark - LIFECYCLE
127 
142  const CBLDatabaseConfiguration* config,
143  CBLError* error) CBLAPI;
144 
147 
149 
153 
161 
164 
165 #ifdef COUCHBASE_ENTERPRISE
166 
172  const CBLEncryptionKey *newKey,
173  CBLError* outError) CBLAPI;
174 #endif
175 
177 typedef CBL_ENUM(uint32_t, CBLMaintenanceType) {
181 };
182 
185  CBLMaintenanceType type,
186  CBLError* outError) CBLAPI;
187 
192 #pragma mark - ACCESSORS
193 
200 
204 
207 
211 
216 #pragma mark - LISTENERS
217 
233 typedef void (*CBLDatabaseChangeListener)(void *context,
234  const CBLDatabase* db _cbl_nonnull,
235  unsigned numDocs,
236  FLString docIDs[] _cbl_nonnull);
237 
248  void *context) CBLAPI;
249  // end of outer \defgroup
252 
253 
254 
255 #pragma mark - NOTIFICATION SCHEDULING
256 
279 typedef void (*CBLNotificationsReadyCallback)(void *context,
281 
290  void *context) CBLAPI;
291 
295  // end of outer \defgroup
298 
299 #ifdef __cplusplus
300 }
301 #endif
uint8_t bytes[32]
Raw key data.
Definition: CBLDatabase.h:61
-
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:251
-
Create the file if it doesn't exist.
Definition: CBLDatabase.h:38
-
bool CBLEncryptionKey_FromPassword(CBLEncryptionKey *key, FLString password)
Derives an encryption key from a password.
-
No encryption (default)
Definition: CBLDatabase.h:47
-
EXPERIMENTAL: Upgrade DB to use version vectors.
Definition: CBLDatabase.h:42
-
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:63
-
bool CBLDatabase_ChangeEncryptionKey(CBLDatabase *, const CBLEncryptionKey *newKey, CBLError *outError)
Encrypts or decrypts a database, or changes its encryption key.
-
FLString directory
The parent directory of the database.
Definition: CBLDatabase.h:66
-
Database configuration options.
Definition: CBLDatabase.h:65
-
bool CBL_DatabaseExists(FLString name, FLString inDirectory)
Returns true if a database with the given name exists in the given directory.
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
-
bool CBLDatabase_EndBatch(CBLDatabase *, CBLError *)
Ends a batch operation.
- -
FLString CBLDatabase_Name(const CBLDatabase *)
Returns the database's name.
-
_cbl_warn_unused FLStringResult CBLDatabase_Path(const CBLDatabase *)
Returns the database's full filesystem path.
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
bool CBLDatabase_BeginBatch(CBLDatabase *, CBLError *)
Begins a batch operation, similar to a transaction.
-
CBLEncryptionAlgorithm algorithm
Encryption algorithm.
Definition: CBLDatabase.h:60
-
bool CBLDatabase_PerformMaintenance(CBLDatabase *db, CBLMaintenanceType type, CBLError *outError)
Performs database maintenance.
-
CBLDatabaseConfiguration CBLDatabaseConfiguration_Default(void)
Returns the default database configuration.
-
void(* CBLDatabaseChangeListener)(void *context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
A database change listener callback, invoked after one or more documents are changed on disk.
Definition: CBLDatabase.h:233
-
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:184
-
bool CBLDatabase_Delete(CBLDatabase *, CBLError *)
Closes and deletes a database.
-
bool CBL_DeleteDatabase(FLString name, FLString inDirectory, CBLError *outError)
Deletes a database file.
-
Disable upgrading an older-version database.
Definition: CBLDatabase.h:40
-
CBLEncryptionKey * encryptionKey
The database's encryption key (if any)
Definition: CBLDatabase.h:68
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
_cbl_warn_unused CBLListenerToken * CBLDatabase_AddChangeListener(const CBLDatabase *db, CBLDatabaseChangeListener listener, void *context)
Registers a database change listener callback.
-
Check for the database’s corruption. If found, an error will be returned.
Definition: CBLDatabase.h:180
-
CBLMaintenanceType
Maintenance Type used when performing database maintenance.
Definition: CBLDatabase.h:177
-
#define _cbl_warn_unused
Definition: CBL_Compat.h:43
-
void(* CBLNotificationsReadyCallback)(void *context, CBLDatabase *db)
Callback indicating that the database (or an object belonging to it) is ready to call one or more lis...
Definition: CBLDatabase.h:279
-
CBLEncryptionAlgorithm
Database encryption algorithms (available only in the Enterprise Edition).
Definition: CBLDatabase.h:46
-
#define CBL_OPTIONS(_type, _name)
Definition: CBL_Compat.h:64
-
Open file read-only.
Definition: CBLDatabase.h:39
-
AES with 256-bit key.
Definition: CBLDatabase.h:49
-
CBLDatabaseFlags
Flags for how to open a database.
Definition: CBLDatabase.h:37
-
_cbl_warn_unused CBLDatabase * CBLDatabase_Open(FLSlice name, const CBLDatabaseConfiguration *config, CBLError *error)
Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance.
-
bool CBLDatabase_Close(CBLDatabase *, CBLError *)
Closes an open database.
-
CBLEncryptionKeySize
Encryption key sizes (in bytes).
Definition: CBLDatabase.h:54
-
Compact the database file and delete unused attachments.
Definition: CBLDatabase.h:178
-
CBLDatabaseFlags flags
Options for opening the database.
Definition: CBLDatabase.h:67
- -
const CBLDatabaseConfiguration CBLDatabase_Config(const CBLDatabase *)
Returns the database's configuration, as given when it was opened.
-
Key size for kCBLEncryptionAES256.
Definition: CBLDatabase.h:55
-
Encryption key specified in a CBLDatabaseConfiguration.
Definition: CBLDatabase.h:59
-
bool CBL_CopyDatabase(FLString fromPath, FLString toName, const CBLDatabaseConfiguration *config, CBLError *)
Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from t...
-
void CBLDatabase_BufferNotifications(CBLDatabase *db, CBLNotificationsReadyCallback callback, void *context)
Switches the database to buffered-notification mode.
-
uint64_t CBLDatabase_Count(const CBLDatabase *)
Returns the number of documents in the database.
-
void CBLDatabase_SendNotifications(CBLDatabase *db)
Immediately issues all pending notifications for this database, by calling their listener callbacks.
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:172
-
Rebuild the entire database's indexes.
Definition: CBLDatabase.h:179
+Go to the documentation of this file.
1//
+
2// CBLDatabase.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/FLSlice.h"
+
22
+ +
24
+
30#ifdef __APPLE__
+
31#pragma mark - CONFIGURATION
+
32#endif
+
33
+
37#ifdef COUCHBASE_ENTERPRISE
+
39typedef CBL_ENUM(uint32_t, CBLEncryptionAlgorithm) {
+ + +
42};
+
43
+
45typedef CBL_ENUM(uint64_t, CBLEncryptionKeySize) {
+ +
47};
+
48
+
50typedef struct {
+ +
52 uint8_t bytes[32];
+ +
54#endif
+
55
+
57typedef struct {
+ +
59#ifdef COUCHBASE_ENTERPRISE
+ +
61#endif
+ +
63
+ +
66
+
67#ifdef COUCHBASE_ENTERPRISE
+ +
75#endif
+
76
+
80#ifdef __APPLE__
+
81#pragma mark - FILE OPERATIONS
+
82#endif
+ +
93
+ +
101 FLString toName,
+ +
103 CBLError* _cbl_nullable outError) CBLAPI;
+
104
+ +
113 FLString inDirectory,
+
114 CBLError* _cbl_nullable outError) CBLAPI;
+
115
+
119#ifdef __APPLE__
+
120#pragma mark - LIFECYCLE
+
121#endif
+ + + +
138 CBLError* _cbl_nullable outError) CBLAPI;
+
139
+ +
142 CBLError* _cbl_nullable outError) CBLAPI;
+
143
+ +
145
+ +
149 CBLError* _cbl_nullable outError) CBLAPI;
+
150
+ +
158 CBLError* _cbl_nullable outError) CBLAPI;
+
159
+ +
162 bool commit,
+
163 CBLError* _cbl_nullable outError) CBLAPI;
+
164
+
165#ifdef COUCHBASE_ENTERPRISE
+ +
172 const CBLEncryptionKey* _cbl_nullable newKey,
+
173 CBLError* outError) CBLAPI;
+
174#endif
+
175
+
177typedef CBL_ENUM(uint32_t, CBLMaintenanceType) {
+ +
180
+ +
183
+ +
186
+ +
190
+ + +
196
+ + +
200 CBLError* _cbl_nullable outError) CBLAPI;
+
201
+
205#ifdef __APPLE__
+
206#pragma mark - ACCESSORS
+
207#endif
+ +
215
+ + +
219
+ +
222
+ +
226
+
230#ifdef __APPLE__
+
231#pragma mark - LISTENERS
+
232#endif
+
249typedef void (*CBLDatabaseChangeListener)(void* _cbl_nullable context,
+
250 const CBLDatabase* db,
+
251 unsigned numDocs,
+
252 FLString docIDs[_cbl_nonnull]);
+
253
+ + + +
264 void* _cbl_nullable context) CBLAPI;
+
265 // end of outer \defgroup
+
268
+
269
+
270#ifdef __APPLE__
+
271#pragma mark - NOTIFICATION SCHEDULING
+
272#endif
+
296typedef void (*CBLNotificationsReadyCallback)(void* _cbl_nullable context,
+
297 CBLDatabase* db);
+
298
+ + +
307 void* _cbl_nullable context) CBLAPI;
+
308
+ +
312 // end of outer \defgroup
+
315
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
+
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
+ + +
bool CBL_CopyDatabase(FLString fromPath, FLString toName, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from t...
+
bool CBLDatabase_EndTransaction(CBLDatabase *, bool commit, CBLError *_cbl_nullable outError)
Ends a transaction, either committing or aborting.
+
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
+
bool CBLEncryptionKey_FromPassword(CBLEncryptionKey *key, FLString password)
Derives an encryption key from a password.
+
bool CBLDatabase_Delete(CBLDatabase *, CBLError *_cbl_nullable outError)
Closes and deletes a database.
+
bool CBLDatabase_Close(CBLDatabase *, CBLError *_cbl_nullable outError)
Closes an open database.
+
bool CBL_DatabaseExists(FLString name, FLString inDirectory)
Returns true if a database with the given name exists in the given directory.
+
bool CBLDatabase_ChangeEncryptionKey(CBLDatabase *, const CBLEncryptionKey *_cbl_nullable newKey, CBLError *outError)
Encrypts or decrypts a database, or changes its encryption key.
+
_cbl_warn_unused CBLDatabase *_cbl_nullable CBLDatabase_Open(FLSlice name, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance.
+
bool CBL_DeleteDatabase(FLString name, FLString inDirectory, CBLError *_cbl_nullable outError)
Deletes a database file.
+
const CBLDatabaseConfiguration CBLDatabase_Config(const CBLDatabase *)
Returns the database's configuration, as given when it was opened.
+
void(* CBLDatabaseChangeListener)(void *_cbl_nullable context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
A database change listener callback, invoked after one or more documents are changed on disk.
Definition: CBLDatabase.h:249
+
_cbl_warn_unused CBLListenerToken * CBLDatabase_AddChangeListener(const CBLDatabase *db, CBLDatabaseChangeListener listener, void *_cbl_nullable context)
Registers a database change listener callback.
+
CBLEncryptionAlgorithm
Database encryption algorithms (available only in the Enterprise Edition).
Definition: CBLDatabase.h:39
+
bool CBLDatabase_PerformMaintenance(CBLDatabase *db, CBLMaintenanceType type, CBLError *_cbl_nullable outError)
Performs database maintenance.
+
_cbl_warn_unused FLStringResult CBLDatabase_Path(const CBLDatabase *)
Returns the database's full filesystem path.
+
CBLDatabaseConfiguration CBLDatabaseConfiguration_Default(void)
Returns the default database configuration.
+
CBLMaintenanceType
Maintenance Type used when performing database maintenance.
Definition: CBLDatabase.h:177
+
bool CBLDatabase_BeginTransaction(CBLDatabase *, CBLError *_cbl_nullable outError)
Begins a transaction.
+
uint64_t CBLDatabase_Count(const CBLDatabase *)
Returns the number of documents in the database.
+
CBLEncryptionKeySize
Encryption key sizes (in bytes).
Definition: CBLDatabase.h:45
+
FLString CBLDatabase_Name(const CBLDatabase *)
Returns the database's name.
+
@ kCBLEncryptionNone
No encryption (default)
Definition: CBLDatabase.h:40
+
@ kCBLEncryptionAES256
AES with 256-bit key.
Definition: CBLDatabase.h:41
+
@ kCBLMaintenanceTypeIntegrityCheck
Check for the database’s corruption. If found, an error will be returned.
Definition: CBLDatabase.h:185
+
@ kCBLMaintenanceTypeCompact
Compact the database file and delete unused attachments.
Definition: CBLDatabase.h:179
+
@ kCBLMaintenanceTypeOptimize
Partially scan indexes to gather database statistics that help optimize queries.
Definition: CBLDatabase.h:189
+
@ kCBLMaintenanceTypeReindex
Rebuild the entire database's indexes.
Definition: CBLDatabase.h:182
+
@ kCBLMaintenanceTypeFullOptimize
Fully scans all indexes to gather database statistics that help optimize queries.
Definition: CBLDatabase.h:194
+
@ kCBLEncryptionKeySizeAES256
Key size for kCBLEncryptionAES256.
Definition: CBLDatabase.h:46
+
void(* CBLNotificationsReadyCallback)(void *_cbl_nullable context, CBLDatabase *db)
Callback indicating that the database (or an object belonging to it) is ready to call one or more lis...
Definition: CBLDatabase.h:296
+
void CBLDatabase_SendNotifications(CBLDatabase *db)
Immediately issues all pending notifications for this database, by calling their listener callbacks.
+
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
+
void CBLDatabase_BufferNotifications(CBLDatabase *db, CBLNotificationsReadyCallback callback, void *_cbl_nullable context)
Switches the database to buffered-notification mode.
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
Database configuration options.
Definition: CBLDatabase.h:57
+
FLString directory
The parent directory of the database.
Definition: CBLDatabase.h:58
+
CBLEncryptionKey encryptionKey
The database's encryption key (if any)
Definition: CBLDatabase.h:60
+
Encryption key specified in a CBLDatabaseConfiguration.
Definition: CBLDatabase.h:50
+
CBLEncryptionAlgorithm algorithm
Encryption algorithm.
Definition: CBLDatabase.h:51
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/_c_b_l_document_8h.html b/docs/C/html/_c_b_l_document_8h.html index 00c7c2e7..1a13ee5c 100644 --- a/docs/C/html/_c_b_l_document_8h.html +++ b/docs/C/html/_c_b_l_document_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLDocument.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
CBLDocument.h File Reference
+ +
CBLDocument.h File Reference
#include "CBLBase.h"
@@ -75,27 +77,27 @@

Go to the source code of this file.

- - - - - - - - - - - - - - + + + + + + + + + + + + - @@ -109,84 +111,84 @@ - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + +

+

Functions

Mutable documents

The type CBLDocument* without a const qualifier refers to a mutable document instance.

-

A mutable document exposes its properties as a mutable dictionary, so you can change them in place and then call CBLDatabase_SaveDocument to persist the changes.

+

The type CBLDocument* without a const qualifier refers to a mutable document instance.

+

A mutable document exposes its properties as a mutable dictionary, so you can change them in place and then call CBLDatabase_SaveDocument to persist the changes.

_cbl_warn_unused CBLDocumentCBLDatabase_GetMutableDocument (CBLDatabase *database, FLString docID)
 Reads a document from the database, in mutable form that can be updated and saved. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_New (void) _cbl_returns_nonnull
 Creates a new, empty document in memory, with a randomly-generated unique ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_NewWithID (FLString docID) _cbl_returns_nonnull
 Creates a new, empty document in memory, with the given ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_ToMutable (const CBLDocument *original) _cbl_returns_nonnull
 Creates a new mutable CBLDocument instance that refers to the same document as the original. More...
 
_cbl_warn_unused CBLDocument *_cbl_nullable CBLDatabase_GetMutableDocument (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Reads a document from the database, in mutable form that can be updated and saved. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_Create (void)
 Creates a new, empty document in memory, with a randomly-generated unique ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_CreateWithID (FLString docID)
 Creates a new, empty document in memory, with the given ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_MutableCopy (const CBLDocument *original)
 Creates a new mutable CBLDocument instance that refers to the same document as the original. More...
 
Document properties and metadata

A document's body is essentially a JSON object.

-

The properties are accessed in memory using the Fleece API, with the body itself being a dictionary).

+

A document's body is essentially a JSON object.

+

The properties are accessed in memory using the Fleece API, with the body itself being a dictionary).

FLString CBLDocument_ID (const CBLDocument *)
 Returns a document's ID. More...
FLDict CBLDocument_Properties (const CBLDocument *)
 Returns a document's properties as a dictionary. More...
 
FLMutableDict CBLDocument_MutableProperties (CBLDocument *) _cbl_returns_nonnull
 Returns a mutable document's properties as a mutable dictionary. More...
 
FLMutableDict CBLDocument_MutableProperties (CBLDocument *)
 Returns a mutable document's properties as a mutable dictionary. More...
 
void CBLDocument_SetProperties (CBLDocument *, FLMutableDict properties)
 Sets a mutable document's properties. More...
 
FLDoc CBLDocument_ToFleeceDoc (const CBLDocument *)
 
_cbl_warn_unused FLSliceResult CBLDocument_ToJSON (const CBLDocument *)
 Returns a document's properties as JSON. More...
 
bool CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *)
 Sets a mutable document's properties from a JSON string. More...
 
CBLTimestamp CBLDatabase_GetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLError *error)
 Returns the time, if any, at which a given document will expire and be purged. More...
 
bool CBLDatabase_SetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *error)
 Sets or clears the expiration time of a document. More...
 
_cbl_warn_unused FLSliceResult CBLDocument_CreateJSON (const CBLDocument *)
 Returns a document's properties as JSON. More...
 
bool CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *_cbl_nullable outError)
 Sets a mutable document's properties from a JSON string. More...
 
CBLTimestamp CBLDatabase_GetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLError *_cbl_nullable outError)
 Returns the time, if any, at which a given document will expire and be purged. More...
 
bool CBLDatabase_SetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *_cbl_nullable outError)
 Sets or clears the expiration time of a document. More...
 
+ + + +

+Variables

CBL_PUBLIC const FLSlice kCBLTypeProperty
 "@type" More...
 
- - + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +

-Document lifecycle

enum  CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins, -kCBLConcurrencyControlFailOnConflict +

Document lifecycle

enum  CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins +, kCBLConcurrencyControlFailOnConflict }
 Conflict-handling options when saving or deleting a document. More...
 
typedef bool(* CBLConflictHandler) (void *context, CBLDocument *documentBeingSaved, const CBLDocument *conflictingDocument)
 Custom conflict handler for use when saving or deleting a document. More...
 
_cbl_warn_unused const CBLDocumentCBLDatabase_GetDocument (const CBLDatabase *database, FLString docID)
 Reads a document from the database, creating a new (immutable) CBLDocument object. More...
 
static const CBLDocumentCBLDocument_Retain (const CBLDocument *t)
 
typedef bool(* CBLConflictHandler) (void *_cbl_nullable context, CBLDocument *_cbl_nullable documentBeingSaved, const CBLDocument *_cbl_nullable conflictingDocument)
 Custom conflict handler for use when saving or deleting a document. More...
 
_cbl_warn_unused const CBLDocument *_cbl_nullable CBLDatabase_GetDocument (const CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Reads a document from the database, creating a new (immutable) CBLDocument object. More...
 
static const CBLDocumentCBLDocument_Retain (const CBLDocument *t)
 
static void CBLDocument_Release (const CBLDocument *t)
 
bool CBLDatabase_SaveDocument (CBLDatabase *db, CBLDocument *doc, CBLError *error)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConcurrencyControl (CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *error)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConflictHandler (CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *context, CBLError *error)
 Saves a (mutable) document to the database, allowing for custom conflict handling in the event that the document has been updated since doc was loaded. More...
 
bool CBLDatabase_DeleteDocument (CBLDatabase *db, const CBLDocument *document, CBLError *error)
 Deletes a document from the database. More...
 
bool CBLDatabase_DeleteDocumentWithConcurrencyControl (CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *error)
 Deletes a document from the database. More...
 
bool CBLDatabase_PurgeDocument (CBLDatabase *db, const CBLDocument *document, CBLError *error)
 Purges a document. More...
 
bool CBLDatabase_PurgeDocumentByID (CBLDatabase *database, FLString docID, CBLError *error)
 Purges a document, given only its ID. More...
 
bool CBLDatabase_SaveDocument (CBLDatabase *db, CBLDocument *doc, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConcurrencyControl (CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConflictHandler (CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *_cbl_nullable context, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database, allowing for custom conflict handling in the event that the document has been updated since doc was loaded. More...
 
bool CBLDatabase_DeleteDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
 Deletes a document from the database. More...
 
bool CBLDatabase_DeleteDocumentWithConcurrencyControl (CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
 Deletes a document from the database. More...
 
bool CBLDatabase_PurgeDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
 Purges a document. More...
 
bool CBLDatabase_PurgeDocumentByID (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Purges a document, given only its ID. More...
 
- - + - - - + + +

-Document listeners

A document change listener lets you detect changes made to a specific document after they are persisted to the database.

+

Document listeners

A document change listener lets you detect changes made to a specific document after they are persisted to the database.

Note
If there are multiple CBLDatabase instances on the same database file, each one's document listeners will be notified of changes made by other database instances.
typedef void(* CBLDocumentChangeListener) (void *context, const CBLDatabase *db, FLString docID)
 A document change listener callback, invoked after a specific document is changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddDocumentChangeListener (const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
 Registers a document change listener callback. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddDocumentChangeListener (const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
 Registers a document change listener callback. More...
 
diff --git a/docs/C/html/_c_b_l_document_8h_source.html b/docs/C/html/_c_b_l_document_8h_source.html index 9072c958..74080e43 100644 --- a/docs/C/html/_c_b_l_document_8h_source.html +++ b/docs/C/html/_c_b_l_document_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLDocument.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLDocument.h
+
CBLDocument.h
-Go to the documentation of this file.
1 //
2 // CBLDocument.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "fleece/Fleece.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
36 typedef CBL_ENUM(uint8_t, CBLConcurrencyControl) {
41 };
42 
43 
57 typedef bool (*CBLConflictHandler)(void *context,
58  CBLDocument *documentBeingSaved,
59  const CBLDocument *conflictingDocument);
60 
61 
71  FLString docID) CBLAPI;
72 
74 
86  CBLError* error) CBLAPI;
87 
100  CBLConcurrencyControl concurrency,
101  CBLError* error) CBLAPI;
102 
113  CBLConflictHandler conflictHandler,
114  void *context,
115  CBLError* error) CBLAPI;
116 
124  const CBLDocument* document _cbl_nonnull,
125  CBLError* error) CBLAPI;
126 
135  const CBLDocument* document _cbl_nonnull,
136  CBLConcurrencyControl concurrency,
137  CBLError* error) CBLAPI;
138 
150  const CBLDocument* document _cbl_nonnull,
151  CBLError* error) CBLAPI;
152 
162  FLString docID,
163  CBLError* error) CBLAPI;
164 
184  FLString docID) CBLAPI;
185 
191 
201 
210 
223 
228 
234 
245 
255 
261  FLMutableDict properties _cbl_nonnull) CBLAPI;
262 
264 
269 
272  FLSlice json,
273  CBLError*) CBLAPI;
274 
285  FLSlice docID,
286  CBLError* error) CBLAPI;
287 
296  FLSlice docID,
297  CBLTimestamp expiration,
298  CBLError* error) CBLAPI;
299 
319 typedef void (*CBLDocumentChangeListener)(void *context,
320  const CBLDatabase* db _cbl_nonnull,
321  FLString docID);
322 
333  FLString docID,
335  void *context) CBLAPI;
336 
340 #ifdef __cplusplus
341 }
342 #endif
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:251
-
FLDoc CBLDocument_ToFleeceDoc(const CBLDocument *)
-
The current save/delete will overwrite a conflicting revision if there is a conflict.
Definition: CBLDocument.h:38
-
bool CBLDatabase_SaveDocument(CBLDatabase *db, CBLDocument *doc, CBLError *error)
Saves a (mutable) document to the database.
-
CBLTimestamp CBLDatabase_GetDocumentExpiration(CBLDatabase *db, FLSlice docID, CBLError *error)
Returns the time, if any, at which a given document will expire and be purged.
-
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:63
-
#define _cbl_returns_nonnull
Definition: CBL_Compat.h:42
-
uint64_t CBLDocument_Sequence(const CBLDocument *)
Returns a document's current sequence in the local database.
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
- -
struct _FLDoc * FLDoc
A reference to a document.
Definition: Fleece.h:79
-
The current save/delete will fail if there is a conflict.
Definition: CBLDocument.h:40
-
bool CBLDatabase_PurgeDocument(CBLDatabase *db, const CBLDocument *document, CBLError *error)
Purges a document.
-
FLString CBLDocument_RevisionID(const CBLDocument *)
Returns a document's revision ID, which is a short opaque string that's guaranteed to be unique to ev...
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
_cbl_warn_unused CBLDocument * CBLDocument_NewWithID(FLString docID) _cbl_returns_nonnull
Creates a new, empty document in memory, with the given ID.
-
bool CBLDatabase_DeleteDocument(CBLDatabase *db, const CBLDocument *document, CBLError *error)
Deletes a document from the database.
-
FLString CBLDocument_ID(const CBLDocument *)
Returns a document's ID.
-
bool CBLDatabase_PurgeDocumentByID(CBLDatabase *database, FLString docID, CBLError *error)
Purges a document, given only its ID.
-
bool CBLDocument_SetJSON(CBLDocument *, FLSlice json, CBLError *)
Sets a mutable document's properties from a JSON string.
- -
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:184
-
_cbl_warn_unused FLSliceResult CBLDocument_ToJSON(const CBLDocument *)
Returns a document's properties as JSON.
-
_cbl_warn_unused CBLListenerToken * CBLDatabase_AddDocumentChangeListener(const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
Registers a document change listener callback.
-
struct _FLDict * FLMutableDict
A reference to a mutable dictionary.
Definition: Fleece.h:44
-
void CBLDocument_SetProperties(CBLDocument *, FLMutableDict properties)
Sets a mutable document's properties.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
_cbl_warn_unused CBLDocument * CBLDocument_ToMutable(const CBLDocument *original) _cbl_returns_nonnull
Creates a new mutable CBLDocument instance that refers to the same document as the original.
-
#define _cbl_warn_unused
Definition: CBL_Compat.h:43
-
bool CBLDatabase_SaveDocumentWithConcurrencyControl(CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *error)
Saves a (mutable) document to the database.
-
bool(* CBLConflictHandler)(void *context, CBLDocument *documentBeingSaved, const CBLDocument *conflictingDocument)
Custom conflict handler for use when saving or deleting a document.
Definition: CBLDocument.h:57
-
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:193
-
FLMutableDict CBLDocument_MutableProperties(CBLDocument *) _cbl_returns_nonnull
Returns a mutable document's properties as a mutable dictionary.
-
bool CBLDatabase_SaveDocumentWithConflictHandler(CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *context, CBLError *error)
Saves a (mutable) document to the database, allowing for custom conflict handling in the event that t...
-
FLDict CBLDocument_Properties(const CBLDocument *)
Returns a document's properties as a dictionary.
-
_cbl_warn_unused CBLDocument * CBLDocument_New(void) _cbl_returns_nonnull
Creates a new, empty document in memory, with a randomly-generated unique ID.
-
bool CBLDatabase_DeleteDocumentWithConcurrencyControl(CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *error)
Deletes a document from the database.
-
void(* CBLDocumentChangeListener)(void *context, const CBLDatabase *db, FLString docID)
A document change listener callback, invoked after a specific document is changed on disk.
Definition: CBLDocument.h:319
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
int64_t CBLTimestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: CBLBase.h:125
-
_cbl_warn_unused const CBLDocument * CBLDatabase_GetDocument(const CBLDatabase *database, FLString docID)
Reads a document from the database, creating a new (immutable) CBLDocument object.
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:172
-
bool CBLDatabase_SetDocumentExpiration(CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *error)
Sets or clears the expiration time of a document.
-
_cbl_warn_unused CBLDocument * CBLDatabase_GetMutableDocument(CBLDatabase *database, FLString docID)
Reads a document from the database, in mutable form that can be updated and saved.
-
CBLConcurrencyControl
Conflict-handling options when saving or deleting a document.
Definition: CBLDocument.h:36
+Go to the documentation of this file.
1//
+
2// CBLDocument.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/Fleece.h"
+
22
+ +
24
+ +
31
+ + + +
41};
+
42
+
43
+
57typedef bool (*CBLConflictHandler)(void* _cbl_nullable context,
+
58 CBLDocument* _cbl_nullable documentBeingSaved,
+
59 const CBLDocument* _cbl_nullable conflictingDocument);
+
60
+
61
+ + +
73 FLString docID,
+
74 CBLError* _cbl_nullable outError) CBLAPI;
+
75
+ +
77
+ +
88 CBLDocument* doc,
+
89 CBLError* _cbl_nullable outError) CBLAPI;
+
90
+ +
102 CBLDocument* doc,
+
103 CBLConcurrencyControl concurrency,
+
104 CBLError* _cbl_nullable outError) CBLAPI;
+
105
+ +
115 CBLDocument* doc,
+
116 CBLConflictHandler conflictHandler,
+
117 void* _cbl_nullable context,
+
118 CBLError* _cbl_nullable outError) CBLAPI;
+
119
+ +
127 const CBLDocument* document,
+
128 CBLError* _cbl_nullable outError) CBLAPI;
+
129
+ +
138 const CBLDocument* document,
+
139 CBLConcurrencyControl concurrency,
+
140 CBLError* _cbl_nullable outError) CBLAPI;
+
141
+ +
153 const CBLDocument* document,
+
154 CBLError* _cbl_nullable outError) CBLAPI;
+
155
+ +
165 FLString docID,
+
166 CBLError* _cbl_nullable outError) CBLAPI;
+
167
+ + +
189 FLString docID,
+
190 CBLError* _cbl_nullable outError) CBLAPI;
+
191
+ + +
197
+ + +
207
+ + +
215
+ +
228
+ +
233
+ +
239
+ +
250
+ +
260
+ +
266 FLMutableDict properties) CBLAPI;
+
267
+ + +
272
+ +
275 FLSlice json,
+
276 CBLError* _cbl_nullable outError) CBLAPI;
+
277
+ +
288 FLSlice docID,
+
289 CBLError* _cbl_nullable outError) CBLAPI;
+
290
+ +
299 FLSlice docID,
+
300 CBLTimestamp expiration,
+
301 CBLError* _cbl_nullable outError) CBLAPI;
+
302
+
322typedef void (*CBLDocumentChangeListener)(void *context,
+
323 const CBLDatabase* db,
+
324 FLString docID);
+
325
+ + +
336 FLString docID,
+ +
338 void *context) CBLAPI;
+
339
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_PUBLIC
Definition: CBL_Compat.h:117
+
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
+
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
+ + +
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
+
_cbl_warn_unused FLSliceResult CBLDocument_CreateJSON(const CBLDocument *)
Returns a document's properties as JSON.
+
bool CBLDatabase_DeleteDocumentWithConcurrencyControl(CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
Deletes a document from the database.
+
_cbl_warn_unused CBLDocument * CBLDocument_MutableCopy(const CBLDocument *original)
Creates a new mutable CBLDocument instance that refers to the same document as the original.
+
_cbl_warn_unused const CBLDocument *_cbl_nullable CBLDatabase_GetDocument(const CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
Reads a document from the database, creating a new (immutable) CBLDocument object.
+
_cbl_warn_unused CBLDocument * CBLDocument_Create(void)
Creates a new, empty document in memory, with a randomly-generated unique ID.
+
CBLConcurrencyControl
Conflict-handling options when saving or deleting a document.
Definition: CBLDocument.h:36
+
CBLTimestamp CBLDatabase_GetDocumentExpiration(CBLDatabase *db, FLSlice docID, CBLError *_cbl_nullable outError)
Returns the time, if any, at which a given document will expire and be purged.
+
FLString CBLDocument_ID(const CBLDocument *)
Returns a document's ID.
+
bool CBLDocument_SetJSON(CBLDocument *, FLSlice json, CBLError *_cbl_nullable outError)
Sets a mutable document's properties from a JSON string.
+
CBL_PUBLIC const FLSlice kCBLTypeProperty
"@type"
+
bool(* CBLConflictHandler)(void *_cbl_nullable context, CBLDocument *_cbl_nullable documentBeingSaved, const CBLDocument *_cbl_nullable conflictingDocument)
Custom conflict handler for use when saving or deleting a document.
Definition: CBLDocument.h:57
+
bool CBLDatabase_PurgeDocumentByID(CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
Purges a document, given only its ID.
+
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:191
+
bool CBLDatabase_SaveDocumentWithConflictHandler(CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *_cbl_nullable context, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the database, allowing for custom conflict handling in the event that t...
+
void(* CBLDocumentChangeListener)(void *context, const CBLDatabase *db, FLString docID)
A document change listener callback, invoked after a specific document is changed on disk.
Definition: CBLDocument.h:322
+
uint64_t CBLDocument_Sequence(const CBLDocument *)
Returns a document's current sequence in the local database.
+
FLString CBLDocument_RevisionID(const CBLDocument *)
Returns a document's revision ID, which is a short opaque string that's guaranteed to be unique to ev...
+
FLMutableDict CBLDocument_MutableProperties(CBLDocument *)
Returns a mutable document's properties as a mutable dictionary.
+
_cbl_warn_unused CBLDocument *_cbl_nullable CBLDatabase_GetMutableDocument(CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
Reads a document from the database, in mutable form that can be updated and saved.
+
bool CBLDatabase_SetDocumentExpiration(CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *_cbl_nullable outError)
Sets or clears the expiration time of a document.
+
bool CBLDatabase_DeleteDocument(CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
Deletes a document from the database.
+
FLDict CBLDocument_Properties(const CBLDocument *)
Returns a document's properties as a dictionary.
+
bool CBLDatabase_SaveDocumentWithConcurrencyControl(CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the database.
+
_cbl_warn_unused CBLListenerToken * CBLDatabase_AddDocumentChangeListener(const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
Registers a document change listener callback.
+
_cbl_warn_unused CBLDocument * CBLDocument_CreateWithID(FLString docID)
Creates a new, empty document in memory, with the given ID.
+
void CBLDocument_SetProperties(CBLDocument *, FLMutableDict properties)
Sets a mutable document's properties.
+
bool CBLDatabase_SaveDocument(CBLDatabase *db, CBLDocument *doc, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the database.
+
bool CBLDatabase_PurgeDocument(CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
Purges a document.
+
@ kCBLConcurrencyControlLastWriteWins
The current save/delete will overwrite a conflicting revision if there is a conflict.
Definition: CBLDocument.h:38
+
@ kCBLConcurrencyControlFailOnConflict
The current save/delete will fail if there is a conflict.
Definition: CBLDocument.h:40
+
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
+
int64_t CBLTimestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: CBLBase.h:123
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
struct _FLDict * FLMutableDict
A reference to a mutable dictionary.
Definition: Fleece.h:60
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/_c_b_l_encryptable_8h.html b/docs/C/html/_c_b_l_encryptable_8h.html new file mode 100644 index 00000000..abe14f71 --- /dev/null +++ b/docs/C/html/_c_b_l_encryptable_8h.html @@ -0,0 +1,154 @@ + + + + + + + +Couchbase Lite C: include/cbl/CBLEncryptable.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
CBLEncryptable.h File Reference
+
+
+
#include "CBLBase.h"
+#include "fleece/Fleece.h"
+
+

Go to the source code of this file.

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

+Functions

static const CBLEncryptableCBLEncryptable_Retain (const CBLEncryptable *t)
 
static void CBLEncryptable_Release (const CBLEncryptable *t)
 
CBLEncryptableCBLEncryptable_CreateWithNull (void)
 Creates CBLEncryptable object with null value. More...
 
CBLEncryptableCBLEncryptable_CreateWithBool (bool value)
 Creates CBLEncryptable object with a boolean value. More...
 
CBLEncryptableCBLEncryptable_CreateWithInt (int64_t value)
 Creates CBLEncryptable object with an int value. More...
 
CBLEncryptableCBLEncryptable_CreateWithUInt (uint64_t value)
 Creates CBLEncryptable object with an unsigned int value. More...
 
CBLEncryptableCBLEncryptable_CreateWithFloat (float value)
 Creates CBLEncryptable object with a float value. More...
 
CBLEncryptableCBLEncryptable_CreateWithDouble (double value)
 Creates CBLEncryptable object with a double value. More...
 
CBLEncryptableCBLEncryptable_CreateWithString (FLString value)
 Creates CBLEncryptable object with a string value. More...
 
CBLEncryptableCBLEncryptable_CreateWithValue (FLValue value)
 Creates CBLEncryptable object with an FLValue value. More...
 
CBLEncryptableCBLEncryptable_CreateWithArray (FLArray value)
 Creates CBLEncryptable object with an FLArray value. More...
 
CBLEncryptableCBLEncryptable_CreateWithDict (FLDict value)
 Creates CBLEncryptable object with an FLDict value. More...
 
FLValue CBLEncryptable_Value (const CBLEncryptable *encryptable)
 Returns the value to be encrypted by the push replicator. More...
 
FLDict CBLEncryptable_Properties (const CBLEncryptable *encryptable)
 Returns the dictionary format of the CBLEncryptable object. More...
 
bool FLDict_IsEncryptableValue (FLDict _cbl_nullable)
 Checks whether the given dictionary is a CBLEncryptable or not. More...
 
static bool FLValue_IsEncryptableValue (FLValue _cbl_nullable value)
 Checks whether the given FLValue is a CBLEncryptable or not. More...
 
const CBLEncryptable *_cbl_nullable FLDict_GetEncryptableValue (FLDict _cbl_nullable encryptableDict)
 Returns a CBLEncryptable object corresponding to the given encryptable dictionary in a document or NULL if the dictionary is not a CBLEncryptable. More...
 
static const CBLEncryptable *_cbl_nullable FLValue_GetEncryptableValue (FLValue _cbl_nullable value)
 Returns a CBLEncryptable object corresponding to the given Fleece Value Accessors in a document or NULL if the value is not a CBLEncryptable. More...
 
void FLSlot_SetEncryptableValue (FLSlot slot, const CBLEncryptable *encryptable)
 Set a CBLEncryptable's dictionary in a Fleece mutable Dict. More...
 
+ + + + + + + +

+Variables

CBL_PUBLIC const FLSlice kCBLEncryptableType
 "encryptable" More...
 
CBL_PUBLIC const FLSlice kCBLEncryptableValueProperty
 "value" More...
 
+
+ + + + diff --git a/docs/C/html/_c_b_l_encryptable_8h_source.html b/docs/C/html/_c_b_l_encryptable_8h_source.html new file mode 100644 index 00000000..6691f39e --- /dev/null +++ b/docs/C/html/_c_b_l_encryptable_8h_source.html @@ -0,0 +1,197 @@ + + + + + + + +Couchbase Lite C: include/cbl/CBLEncryptable.h Source File + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
CBLEncryptable.h
+
+
+Go to the documentation of this file.
1//
+
2// CBLEncryptable.h
+
3//
+
4// Copyright (c) 2021 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/Fleece.h"
+
22
+
23#ifdef COUCHBASE_ENTERPRISE
+
24
+ +
26
+ + +
89
+ +
91
+
92#ifdef __APPLE__
+
93#pragma mark - CREATING:
+
94#endif
+
95
+ +
98
+ +
101
+ +
104
+ +
107
+ +
110
+ +
113
+ +
116
+ +
119
+ +
122
+ +
125
+
126#ifdef __APPLE__
+
127#pragma mark - READING:
+
128#endif
+
129
+ +
132
+ +
135
+
136#ifdef __APPLE__
+
137#pragma mark - FLEECE:
+
138#endif
+
139
+ +
142
+ + +
146}
+
147
+ +
152
+ + +
158}
+
159
+ +
162
+ +
166
+
167#endif
+
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_PUBLIC
Definition: CBL_Compat.h:117
+ + +
FLDict FLValue_AsDict(FLValue) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
+
const CBLEncryptable *_cbl_nullable FLDict_GetEncryptableValue(FLDict _cbl_nullable encryptableDict)
Returns a CBLEncryptable object corresponding to the given encryptable dictionary in a document or NU...
+
CBLEncryptable * CBLEncryptable_CreateWithValue(FLValue value)
Creates CBLEncryptable object with an FLValue value.
+
CBLEncryptable * CBLEncryptable_CreateWithUInt(uint64_t value)
Creates CBLEncryptable object with an unsigned int value.
+
CBLEncryptable * CBLEncryptable_CreateWithInt(int64_t value)
Creates CBLEncryptable object with an int value.
+
static const CBLEncryptable *_cbl_nullable FLValue_GetEncryptableValue(FLValue _cbl_nullable value)
Returns a CBLEncryptable object corresponding to the given Fleece Value Accessors in a document or NU...
Definition: CBLEncryptable.h:156
+
CBLEncryptable * CBLEncryptable_CreateWithBool(bool value)
Creates CBLEncryptable object with a boolean value.
+
CBLEncryptable * CBLEncryptable_CreateWithDict(FLDict value)
Creates CBLEncryptable object with an FLDict value.
+
CBLEncryptable * CBLEncryptable_CreateWithNull(void)
Creates CBLEncryptable object with null value.
+
CBLEncryptable * CBLEncryptable_CreateWithString(FLString value)
Creates CBLEncryptable object with a string value.
+
CBL_PUBLIC const FLSlice kCBLEncryptableValueProperty
"value"
+
CBLEncryptable * CBLEncryptable_CreateWithArray(FLArray value)
Creates CBLEncryptable object with an FLArray value.
+
FLDict CBLEncryptable_Properties(const CBLEncryptable *encryptable)
Returns the dictionary format of the CBLEncryptable object.
+
void FLSlot_SetEncryptableValue(FLSlot slot, const CBLEncryptable *encryptable)
Set a CBLEncryptable's dictionary in a Fleece mutable Dict.
+
CBL_PUBLIC const FLSlice kCBLEncryptableType
"encryptable"
+
struct CBLEncryptable CBLEncryptable
An encryptable value.
Definition: CBLBase.h:223
+
bool FLDict_IsEncryptableValue(FLDict _cbl_nullable)
Checks whether the given dictionary is a CBLEncryptable or not.
+
CBLEncryptable * CBLEncryptable_CreateWithFloat(float value)
Creates CBLEncryptable object with a float value.
+
static bool FLValue_IsEncryptableValue(FLValue _cbl_nullable value)
Checks whether the given FLValue is a CBLEncryptable or not.
Definition: CBLEncryptable.h:144
+
CBLEncryptable * CBLEncryptable_CreateWithDouble(double value)
Creates CBLEncryptable object with a double value.
+
FLValue CBLEncryptable_Value(const CBLEncryptable *encryptable)
Returns the value to be encrypted by the push replicator.
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:58
+
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:56
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
+ + + + diff --git a/docs/C/html/_c_b_l_log_8h.html b/docs/C/html/_c_b_l_log_8h.html index 7620013b..541e240b 100644 --- a/docs/C/html/_c_b_l_log_8h.html +++ b/docs/C/html/_c_b_l_log_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLLog.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Data Structures | Enumerations | Functions
-
-
CBLLog.h File Reference
+
CBLLog.h File Reference

#include "CBLBase.h"

Go to the source code of this file.

-

+

Data Structures

struct  CBLLogFileConfiguration
 The properties for configuring logging to files. More...
 
- -

+

Enumerations

enum  CBLLogDomain : uint8_t {
-  kCBLLogDomainAll, -kCBLLogDomainDatabase, -kCBLLogDomainQuery, -kCBLLogDomainReplicator, -
-  kCBLLogDomainNetwork -
+
enum  CBLLogDomain : uint8_t { kCBLLogDomainDatabase +, kCBLLogDomainQuery +, kCBLLogDomainReplicator +, kCBLLogDomainNetwork }
 Subsystems that log information. More...
 
enum  CBLLogLevel : uint8_t {
-  CBLLogDebug, -CBLLogVerbose, -CBLLogInfo, -CBLLogWarning, -
-  CBLLogError, -CBLLogNone +  kCBLLogDebug +, kCBLLogVerbose +, kCBLLogInfo +, kCBLLogWarning +,
+  kCBLLogError +, kCBLLogNone
}
 Levels of log messages. More...
 
- @@ -119,15 +115,14 @@ - - - - - - + + + + + +

+

Functions

void CBL_Log (CBLLogDomain domain, CBLLogLevel level, const char *format,...) __printflike(3
 Formats and writes a message to the log, in the given domain at the given level. More...
 Writes a pre-formatted message to the log, exactly as given. More...
 
Log File Configuration
const CBLLogFileConfigurationCBLLog_FileConfig (void)
 Gets the current file logging configuration, or NULL if none is configured. More...
 
bool CBLLog_SetFileConfig (CBLLogFileConfiguration, CBLError *outError)
 Sets the file logging configuration, and begins logging to files. More...
 
const CBLLogFileConfiguration *_cbl_nullable CBLLog_FileConfig (void)
 Gets the current file logging configuration, or NULL if none is configured. More...
 
bool CBLLog_SetFileConfig (CBLLogFileConfiguration, CBLError *_cbl_nullable outError)
 Sets the file logging configuration, and begins logging to files. More...
 
- + @@ -146,16 +141,14 @@ - - - + + +

-Console Logging and Custom Logging

Console Logging and Custom Logging

typedef void(* CBLLogCallback) (CBLLogDomain domain, CBLLogLevel level, FLString message)
 A logging callback that the application can register. More...
 
CBLLogCallback CBLLog_Callback (void)
 Gets the current log callback. More...
 
void CBLLog_SetCallback (CBLLogCallback)
 Sets the callback for receiving log messages. More...
 
void CBLLog_SetCallback (CBLLogCallback _cbl_nullable callback)
 Sets the callback for receiving log messages. More...
 
diff --git a/docs/C/html/_c_b_l_log_8h_source.html b/docs/C/html/_c_b_l_log_8h_source.html index 6aae3bd0..aae5fecc 100644 --- a/docs/C/html/_c_b_l_log_8h_source.html +++ b/docs/C/html/_c_b_l_log_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLLog.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLLog.h
+
CBLLog.h
-Go to the documentation of this file.
1 //
2 // CBLLog.h
3 //
4 // Copyright © 2019 Couchbase. All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
32 typedef CBL_ENUM(uint8_t, CBLLogDomain) {
38 };
39 
41 typedef CBL_ENUM(uint8_t, CBLLogLevel) {
48 };
49 
50 
62 void CBL_Log(CBLLogDomain domain,
63  CBLLogLevel level,
64  const char *format _cbl_nonnull, ...) CBLAPI __printflike(3, 4);
65 
71 void CBL_LogMessage(CBLLogDomain domain,
72  CBLLogLevel level,
73  FLSlice message) CBLAPI;
74 
75 
76 
84 typedef void (*CBLLogCallback)(CBLLogDomain domain,
85  CBLLogLevel level,
86  FLString message);
87 
91 
95 
99 
103 
106 
109 
120 typedef struct {
123  uint32_t maxRotateCount;
124  size_t maxSize;
127 
130 
133 
138 #ifdef __cplusplus
139 }
140 #endif
bool usePlaintext
Whether or not to log in plaintext (as opposed to binary.) Plaintext logging is slower and bigger.
Definition: CBLLog.h:125
-
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:63
-
Definition: CBLLog.h:35
-
const CBLLogFileConfiguration * CBLLog_FileConfig(void)
Gets the current file logging configuration, or NULL if none is configured.
-
Disables logging entirely.
Definition: CBLLog.h:47
-
Messages about ordinary behavior.
Definition: CBLLog.h:44
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
- -
Messages warning about unlikely and possibly bad stuff.
Definition: CBLLog.h:45
-
The properties for configuring logging to files.
Definition: CBLLog.h:120
-
Detailed messages about normally-unimportant stuff.
Definition: CBLLog.h:43
-
Definition: CBLLog.h:36
-
CBLLogLevel CBLLog_ConsoleLevel(void)
Gets the current log level for debug console logging.
-
void void CBL_LogMessage(CBLLogDomain domain, CBLLogLevel level, FLSlice message)
Writes a pre-formatted message to the log, exactly as given.
-
CBLLogCallback CBLLog_Callback(void)
Gets the current log callback.
-
uint32_t maxRotateCount
Max number of older log files to keep (in addition to current one.)
Definition: CBLLog.h:123
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
FLString directory
The directory where log files will be created.
Definition: CBLLog.h:122
-
size_t maxSize
The size in bytes at which a file will be rotated out (best effort).
Definition: CBLLog.h:124
-
void(* CBLLogCallback)(CBLLogDomain domain, CBLLogLevel level, FLString message)
A logging callback that the application can register.
Definition: CBLLog.h:84
-
Definition: CBLLog.h:33
-
Extremely detailed messages, only written by debug builds of CBL.
Definition: CBLLog.h:42
-
Definition: CBLLog.h:37
-
void CBL_Log(CBLLogDomain domain, CBLLogLevel level, const char *format,...) __printflike(3
Formats and writes a message to the log, in the given domain at the given level.
-
CBLLogDomain
Subsystems that log information.
Definition: CBLLog.h:32
-
Definition: CBLLog.h:34
-
void CBLLog_SetCallback(CBLLogCallback)
Sets the callback for receiving log messages.
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
CBLLogLevel CBLLog_CallbackLevel(void)
Gets the current log level for debug console logging.
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
bool CBLLog_SetFileConfig(CBLLogFileConfiguration, CBLError *outError)
Sets the file logging configuration, and begins logging to files.
-
void CBLLog_SetCallbackLevel(CBLLogLevel)
Sets the detail level of logging.
-
CBLLogLevel
Levels of log messages.
Definition: CBLLog.h:41
-
Messages about errors.
Definition: CBLLog.h:46
-
void CBLLog_SetConsoleLevel(CBLLogLevel)
Sets the detail level of logging.
-
#define __printflike(fmtarg, firstvararg)
Definition: CBL_Compat.h:103
-
CBLLogLevel level
The minimum level of message to write.
Definition: CBLLog.h:121
+Go to the documentation of this file.
1//
+
2// CBLLog.h
+
3//
+
4// Copyright © 2019 Couchbase. All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21
+ +
23
+
24
+
30typedef CBL_ENUM(uint8_t, CBLLogDomain) {
+ + + + +
35};
+
36
+
38typedef CBL_ENUM(uint8_t, CBLLogLevel) {
+ + + + + + +
45};
+
46
+
47
+ +
60 CBLLogLevel level,
+
61 const char *format, ...) CBLAPI __printflike(3, 4);
+
62
+ +
69 CBLLogLevel level,
+
70 FLSlice message) CBLAPI;
+
71
+
72
+
73
+
81typedef void (*CBLLogCallback)(CBLLogDomain domain,
+
82 CBLLogLevel level,
+
83 FLString message);
+
84
+ +
88
+ +
92
+ +
96
+ +
100
+ +
103
+ +
106
+
117typedef struct {
+ + +
120 uint32_t maxRotateCount;
+
121 size_t maxSize;
+ + +
124
+ +
127
+ +
130
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define __printflike(fmtarg, firstvararg)
Definition: CBL_Compat.h:125
+
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
+ +
const CBLLogFileConfiguration *_cbl_nullable CBLLog_FileConfig(void)
Gets the current file logging configuration, or NULL if none is configured.
+
void CBLLog_SetCallbackLevel(CBLLogLevel)
Sets the detail level of logging.
+
void(* CBLLogCallback)(CBLLogDomain domain, CBLLogLevel level, FLString message)
A logging callback that the application can register.
Definition: CBLLog.h:81
+
CBLLogLevel CBLLog_CallbackLevel(void)
Gets the current log level for debug console logging.
+
void void CBL_LogMessage(CBLLogDomain domain, CBLLogLevel level, FLSlice message)
Writes a pre-formatted message to the log, exactly as given.
+
CBLLogCallback CBLLog_Callback(void)
Gets the current log callback.
+
bool CBLLog_SetFileConfig(CBLLogFileConfiguration, CBLError *_cbl_nullable outError)
Sets the file logging configuration, and begins logging to files.
+
CBLLogLevel CBLLog_ConsoleLevel(void)
Gets the current log level for debug console logging.
+
void CBLLog_SetCallback(CBLLogCallback _cbl_nullable callback)
Sets the callback for receiving log messages.
+
void CBL_Log(CBLLogDomain domain, CBLLogLevel level, const char *format,...) __printflike(3
Formats and writes a message to the log, in the given domain at the given level.
+
CBLLogDomain
Subsystems that log information.
Definition: CBLLog.h:30
+
CBLLogLevel
Levels of log messages.
Definition: CBLLog.h:38
+
void CBLLog_SetConsoleLevel(CBLLogLevel)
Sets the detail level of logging.
+
@ kCBLLogDomainDatabase
Definition: CBLLog.h:31
+
@ kCBLLogDomainReplicator
Definition: CBLLog.h:33
+
@ kCBLLogDomainNetwork
Definition: CBLLog.h:34
+
@ kCBLLogDomainQuery
Definition: CBLLog.h:32
+
@ kCBLLogWarning
Messages warning about unlikely and possibly bad stuff.
Definition: CBLLog.h:42
+
@ kCBLLogVerbose
Detailed messages about normally-unimportant stuff.
Definition: CBLLog.h:40
+
@ kCBLLogDebug
Extremely detailed messages, only written by debug builds of CBL.
Definition: CBLLog.h:39
+
@ kCBLLogNone
Disables logging entirely.
Definition: CBLLog.h:44
+
@ kCBLLogInfo
Messages about ordinary behavior.
Definition: CBLLog.h:41
+
@ kCBLLogError
Messages about errors.
Definition: CBLLog.h:43
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
The properties for configuring logging to files.
Definition: CBLLog.h:117
+
uint32_t maxRotateCount
Max number of older log files to keep (in addition to current one.)
Definition: CBLLog.h:120
+
size_t maxSize
The size in bytes at which a file will be rotated out (best effort).
Definition: CBLLog.h:121
+
bool usePlaintext
Whether or not to log in plaintext (as opposed to binary.) Plaintext logging is slower and bigger.
Definition: CBLLog.h:122
+
CBLLogLevel level
The minimum level of message to write.
Definition: CBLLog.h:118
+
FLString directory
The directory where log files will be created.
Definition: CBLLog.h:119
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
diff --git a/docs/C/html/_c_b_l_platform_8h.html b/docs/C/html/_c_b_l_platform_8h.html new file mode 100644 index 00000000..823db600 --- /dev/null +++ b/docs/C/html/_c_b_l_platform_8h.html @@ -0,0 +1,82 @@ + + + + + + + +Couchbase Lite C: include/cbl/CBLPlatform.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
CBLPlatform.h File Reference
+
+ + + + + diff --git a/docs/C/html/_c_b_l_platform_8h_source.html b/docs/C/html/_c_b_l_platform_8h_source.html new file mode 100644 index 00000000..ae7bd39c --- /dev/null +++ b/docs/C/html/_c_b_l_platform_8h_source.html @@ -0,0 +1,121 @@ + + + + + + + +Couchbase Lite C: include/cbl/CBLPlatform.h Source File + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
CBLPlatform.h
+
+
+Go to the documentation of this file.
1//
+
2// CBLPlatform.h
+
3//
+
4// Copyright © 2019 Couchbase. All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21
+ +
23
+
24#ifdef __ANDROID__
+
25
+
31typedef struct {
+
32 const char* filesDir;
+
35
+
36 const char* tempDir;
+
39} CBLInitContext;
+
40
+
48bool CBL_Init(CBLInitContext context, CBLError* _cbl_nullable outError) CBLAPI;
+
49
+
52#endif
+
53
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+ +
A struct holding information about an error.
Definition: CBLBase.h:104
+
+ + + + diff --git a/docs/C/html/_c_b_l_query_8h.html b/docs/C/html/_c_b_l_query_8h.html index 3a094908..1477a9c9 100644 --- a/docs/C/html/_c_b_l_query_8h.html +++ b/docs/C/html/_c_b_l_query_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLQuery.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ + -
-
CBLQuery.h File Reference
+
CBLQuery.h File Reference
#include "CBLBase.h"
@@ -78,39 +78,42 @@

Go to the source code of this file.

- - - + + + + +

+

Data Structures

struct  CBLIndexSpec
 Parameters for creating a database index. More...
struct  CBLValueIndexConfiguration
 Value Index Configuration. More...
 
struct  CBLFullTextIndexConfiguration
 Full-Text Index Configuration. More...
 
- -

+

Enumerations

enum  CBLQueryLanguage : uint32_t { kCBLJSONLanguage, -kCBLN1QLLanguage +
enum  CBLQueryLanguage : uint32_t { kCBLJSONLanguage +, kCBLN1QLLanguage }
 Query languages. More...
 
- - - - - - + + + + + - - - - - - + + + + + + @@ -121,10 +124,23 @@ - + @@ -140,59 +156,52 @@ - - - - - + + + + + + + + + + + + + + + + + + +

+

Functions

Query objects
_cbl_warn_unused CBLQueryCBLQuery_New (const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *outErrorPos, CBLError *error)
 Creates a new query by compiling the input string. More...
 
static const CBLQueryCBLQuery_Retain (const CBLQuery *t)
 
_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery (const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *_cbl_nullable outErrorPos, CBLError *_cbl_nullable outError)
 Creates a new query by compiling the input string. More...
 
static const CBLQueryCBLQuery_Retain (const CBLQuery *t)
 
static void CBLQuery_Release (const CBLQuery *t)
 
void CBLQuery_SetParameters (CBLQuery *query, FLDict parameters)
 Assigns values to the query's parameters. More...
 
FLDict CBLQuery_Parameters (const CBLQuery *query)
 Returns the query's current parameter bindings, if any. More...
 
_cbl_warn_unused CBLResultSetCBLQuery_Execute (CBLQuery *, CBLError *)
 Runs the query, returning the results. More...
 
FLDict _cbl_nullable CBLQuery_Parameters (const CBLQuery *query)
 Returns the query's current parameter bindings, if any. More...
 
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute (CBLQuery *, CBLError *_cbl_nullable outError)
 Runs the query, returning the results. More...
 
_cbl_warn_unused FLSliceResult CBLQuery_Explain (const CBLQuery *)
 Returns information about the query, including the translated SQLite form, and the search strategy. More...
 
 Returns the name of a column in the result. More...
 
Result sets

A CBLResultSet is an iterator over the results returned by a query.

-

It exposes one result at a time – as a collection of values indexed either by position or by name – and can be stepped from one result to the next.

-

It's important to note that the initial position of the iterator is before the first result, so CBLResultSet_Next must be called first. Example:

-
CBLResultSet *rs = CBLQuery_Execute(query, &error);
assert(rs);
while (CBLResultSet_Next(rs) {
...
}

A CBLResultSet is an iterator over the results returned by a query.

+

It exposes one result at a time – as a collection of values indexed either by position or by name – and can be stepped from one result to the next.

+

It's important to note that the initial position of the iterator is before the first result, so CBLResultSet_Next must be called first. Example:

+
CBLResultSet *rs = CBLQuery_Execute(query, &error);
+
assert(rs);
+
while (CBLResultSet_Next(rs) {
+ +
...
+
}
+ +
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute(CBLQuery *, CBLError *_cbl_nullable outError)
Runs the query, returning the results.
+
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
+
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:206
+
static void CBLResultSet_Release(const CBLResultSet *t)
Definition: CBLQuery.h:179
+
FLValue CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
_cbl_warn_unused bool CBLResultSet_Next (CBLResultSet *)
 Moves the result-set iterator to the next result. More...
 
FLDict CBLResultSet_ResultDict (const CBLResultSet *)
 Returns the current result as a dictionary mapping column names to values. More...
 
CBLQueryCBLResultSet_GetQuery (const CBLResultSet *rs)
 Returns the Query that created this ResultSet. More...
 
static const CBLResultSetCBLResultSet_Retain (const CBLResultSet *t)
 
CBLQueryCBLResultSet_GetQuery (const CBLResultSet *rs)
 Returns the Query that created this ResultSet. More...
 
static const CBLResultSetCBLResultSet_Retain (const CBLResultSet *t)
 
static void CBLResultSet_Release (const CBLResultSet *t)
 
Database Indexes

Indexes are used to speed up queries by allowing fast – O(log n) – lookup of documents that have specific values or ranges of values.

+

The values may be properties, or expressions based on properties.

+

An index will speed up queries that use the expression it indexes, but it takes up space in the database file, and it slows down document saves slightly because it needs to be kept up to date when documents change.

+

Tuning a database with indexes can be a tricky task. Fortunately, a lot has been written about it in the relational-database (SQL) realm, and much of that advice holds for Couchbase Lite. You may find SQLite's documentation particularly helpful since Couchbase Lite's querying is based on SQLite.

+

Two types of indexes are currently 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.

+
bool CBLDatabase_CreateValueIndex (CBLDatabase *db, FLString name, CBLValueIndexConfiguration config, CBLError *_cbl_nullable outError)
 Creates a value index. More...
 
bool CBLDatabase_CreateFullTextIndex (CBLDatabase *db, FLString name, CBLFullTextIndexConfiguration config, CBLError *_cbl_nullable outError)
 Creates a full-text index. More...
 
bool CBLDatabase_DeleteIndex (CBLDatabase *db, FLString name, CBLError *_cbl_nullable outError)
 Deletes an index given its name. More...
 
_cbl_warn_unused FLArray CBLDatabase_GetIndexNames (CBLDatabase *db)
 Returns the names of the indexes on this database, as a Fleece array of strings. More...
 
- - + - - - - - - - - - -

-Change listener

Adding a change listener to a query turns it into a "live query".

-

When changes are made to documents, the query will periodically re-run and compare its results with the prior results; if the new results are different, the listener callback will be called.

+

Change listener

Adding a change listener to a query turns it into a "live query".

+

When changes are made to documents, the query will periodically re-run and compare its results with the prior results; if the new results are different, the listener callback will be called.

Note
The result set passed to the listener is the entire new result set, not just the rows that changed.
typedef void(* CBLQueryChangeListener) (void *context, CBLQuery *query)
 A callback to be invoked after the query's results have changed. More...
 
_cbl_warn_unused CBLListenerTokenCBLQuery_AddChangeListener (CBLQuery *query, CBLQueryChangeListener listener, void *context)
 Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove). More...
 
_cbl_warn_unused CBLResultSetCBLQuery_CopyCurrentResults (const CBLQuery *query, CBLListenerToken *listener, CBLError *error)
 Returns the query's entire current result set, after it's been announced via a call to the listener's callback. More...
 
- - - - - - - - - - - - - - + + + + + + + + +

-Database Indexes

Indexes are used to speed up queries by allowing fast – O(log n) – lookup of documents that have specific values or ranges of values.

-

The values may be properties, or expressions based on properties.

-

An index will speed up queries that use the expression it indexes, but it takes up space in the database file, and it slows down document saves slightly because it needs to be kept up to date when documents change.

-

Tuning a database with indexes can be a tricky task. Fortunately, a lot has been written about it in the relational-database (SQL) realm, and much of that advice holds for Couchbase Lite. You may find SQLite's documentation particularly helpful since Couchbase Lite's querying is based on SQLite.

-

Two types of indexes are currently 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.

-
enum  CBLIndexType : uint32_t { kCBLValueIndex, -kCBLFullTextIndex - }
 Types of database indexes. More...
 
bool CBLDatabase_CreateIndex (CBLDatabase *db, FLString name, CBLIndexSpec spec, CBLError *outError)
 Creates a database index. More...
 
bool CBLDatabase_DeleteIndex (CBLDatabase *db, FLString name, CBLError *outError)
 Deletes an index given its name. More...
 
_cbl_warn_unused FLMutableArray CBLDatabase_IndexNames (CBLDatabase *db)
 Returns the names of the indexes on this database, as a Fleece array of strings. More...
 
typedef void(* CBLQueryChangeListener) (void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)
 A callback to be invoked after the query's results have changed. More...
 
_cbl_warn_unused CBLListenerTokenCBLQuery_AddChangeListener (CBLQuery *query, CBLQueryChangeListener listener, void *_cbl_nullable context)
 Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove). More...
 
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults (const CBLQuery *query, CBLListenerToken *listener, CBLError *_cbl_nullable outError)
 Returns the query's entire current result set, after it's been announced via a call to the listener's callback. More...
 
diff --git a/docs/C/html/_c_b_l_query_8h_source.html b/docs/C/html/_c_b_l_query_8h_source.html index 78432513..999c0caa 100644 --- a/docs/C/html/_c_b_l_query_8h_source.html +++ b/docs/C/html/_c_b_l_query_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLQuery.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLQuery.h
+
CBLQuery.h
-Go to the documentation of this file.
1 //
2 // CBLQuery.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "fleece/Fleece.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
45 typedef CBL_ENUM(uint32_t, CBLQueryLanguage) {
48 };
49 
50 
71  CBLQueryLanguage language,
72  FLString queryString,
73  int *outErrorPos,
74  CBLError* error) CBLAPI;
75 
77 
90  FLDict parameters) CBLAPI;
91 
94 
101 
110 
113 
121  unsigned columnIndex) CBLAPI;
122 
152 
157  unsigned index) CBLAPI;
158 
165  FLString key) CBLAPI;
166 
171 
176 
179 
181 
204 typedef void (*CBLQueryChangeListener)(void *context,
205  CBLQuery* query _cbl_nonnull);
206 
221  void *context) CBLAPI;
222 
232  CBLListenerToken *listener _cbl_nonnull,
233  CBLError *error) CBLAPI;
234 
267 typedef CBL_ENUM(uint32_t, CBLIndexType) {
270 };
271 
272 
274 typedef struct {
277 
280 
284 
297 } CBLIndexSpec;
298 
299 
305  FLString name,
306  CBLIndexSpec spec,
307  CBLError *outError) CBLAPI;
308 
311  FLString name,
312  CBLError *outError) CBLAPI;
313 
318 
322 #ifdef __cplusplus
323 }
324 #endif
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:251
-
Parameters for creating a database index.
Definition: CBLQuery.h:274
-
FLString language
In a full-text index, the dominant language.
Definition: CBLQuery.h:296
-
_cbl_warn_unused FLMutableArray CBLDatabase_IndexNames(CBLDatabase *db)
Returns the names of the indexes on this database, as a Fleece array of strings.
-
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:63
-
CBLQueryLanguage
Query languages.
Definition: CBLQuery.h:45
-
An index that stores property or expression values.
Definition: CBLQuery.h:268
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
- -
FLDict CBLQuery_Parameters(const CBLQuery *query)
Returns the query's current parameter bindings, if any.
-
struct CBLQuery CBLQuery
A compiled database query.
Definition: CBLBase.h:205
-
FLArray CBLResultSet_ResultArray(const CBLResultSet *)
Returns the current result as an array of column values.
-
_cbl_warn_unused CBLListenerToken * CBLQuery_AddChangeListener(CBLQuery *query, CBLQueryChangeListener listener, void *context)
Registers a change listener callback with a query, turning it into a "live query" until the listener ...
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
N1QL syntax
Definition: CBLQuery.h:47
-
CBLQuery * CBLResultSet_GetQuery(const CBLResultSet *rs)
Returns the Query that created this ResultSet.
-
bool ignoreAccents
In a full-text index, should diacritical marks (accents) be ignored? Defaults to false.
Definition: CBLQuery.h:283
-
bool CBLDatabase_DeleteIndex(CBLDatabase *db, FLString name, CBLError *outError)
Deletes an index given its name.
-
void CBLQuery_SetParameters(CBLQuery *query, FLDict parameters)
Assigns values to the query's parameters.
- -
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:184
-
FLValue CBLResultSet_ValueForKey(const CBLResultSet *, FLString key)
Returns the value of a column of the current result, given its name.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
_cbl_warn_unused CBLQuery * CBLQuery_New(const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *outErrorPos, CBLError *error)
Creates a new query by compiling the input string.
-
#define _cbl_warn_unused
Definition: CBL_Compat.h:43
-
FLValue CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
-
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:43
-
FLSlice CBLQuery_ColumnName(const CBLQuery *, unsigned columnIndex)
Returns the name of a column in the result.
-
FLString keyExpressionsJSON
A JSON array describing each column of the index.
Definition: CBLQuery.h:279
-
An index of strings, that enables searching for words with MATCH
Definition: CBLQuery.h:269
-
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
-
CBLIndexType
Types of database indexes.
Definition: CBLQuery.h:267
-
bool CBLDatabase_CreateIndex(CBLDatabase *db, FLString name, CBLIndexSpec spec, CBLError *outError)
Creates a database index.
-
_cbl_warn_unused CBLResultSet * CBLQuery_Execute(CBLQuery *, CBLError *)
Runs the query, returning the results.
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:39
-
unsigned CBLQuery_ColumnCount(const CBLQuery *)
Returns the number of columns in each result.
-
_cbl_warn_unused CBLResultSet * CBLQuery_CopyCurrentResults(const CBLQuery *query, CBLListenerToken *listener, CBLError *error)
Returns the query's entire current result set, after it's been announced via a call to the listener's...
-
void(* CBLQueryChangeListener)(void *context, CBLQuery *query)
A callback to be invoked after the query's results have changed.
Definition: CBLQuery.h:204
-
JSON query schema
Definition: CBLQuery.h:46
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:40
-
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:208
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:172
-
FLDict CBLResultSet_ResultDict(const CBLResultSet *)
Returns the current result as a dictionary mapping column names to values.
-
_cbl_warn_unused FLSliceResult CBLQuery_Explain(const CBLQuery *)
Returns information about the query, including the translated SQLite form, and the search strategy.
-
CBLIndexType type
The type of index to create.
Definition: CBLQuery.h:276
+Go to the documentation of this file.
1//
+
2// CBLQuery.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/Fleece.h"
+
22
+ +
24
+
25
+
43typedef CBL_ENUM(uint32_t, CBLQueryLanguage) {
+ + +
46};
+
47
+
48
+ + +
69 CBLQueryLanguage language,
+
70 FLString queryString,
+
71 int* _cbl_nullable outErrorPos,
+
72 CBLError* _cbl_nullable outError) CBLAPI;
+
73
+ +
75
+ +
88 FLDict parameters) CBLAPI;
+
89
+ +
92
+ + +
99 CBLError* _cbl_nullable outError) CBLAPI;
+
100
+ + +
109
+ +
112
+ +
120 unsigned columnIndex) CBLAPI;
+
121
+ + +
151
+ +
156 unsigned index) CBLAPI;
+
157
+ +
164 FLString key) CBLAPI;
+
165
+ +
170
+ +
175
+ +
178
+ +
180
+
204typedef void (*CBLQueryChangeListener)(void* _cbl_nullable context,
+
205 CBLQuery* query,
+
206 CBLListenerToken* token);
+
207
+ + +
221 CBLQueryChangeListener listener,
+
222 void* _cbl_nullable context) CBLAPI;
+
223
+ + +
233 CBLListenerToken *listener,
+
234 CBLError* _cbl_nullable outError) CBLAPI;
+
235
+
267typedef struct {
+ +
270
+ + +
275
+ +
281 FLString name,
+ +
283 CBLError* _cbl_nullable outError) CBLAPI;
+
284
+
285
+
287typedef struct {
+ +
290
+ +
294
+ +
298
+ + +
312
+ +
318 FLString name,
+ +
320 CBLError* _cbl_nullable outError) CBLAPI;
+
321
+ +
324 FLString name,
+
325 CBLError* _cbl_nullable outError) CBLAPI;
+
326
+ + +
331
+ +
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
+
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
+ + +
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
+
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
+
FLDict _cbl_nullable CBLQuery_Parameters(const CBLQuery *query)
Returns the query's current parameter bindings, if any.
+
_cbl_warn_unused FLArray CBLDatabase_GetIndexNames(CBLDatabase *db)
Returns the names of the indexes on this database, as a Fleece array of strings.
+
CBLQuery * CBLResultSet_GetQuery(const CBLResultSet *rs)
Returns the Query that created this ResultSet.
+
FLValue CBLResultSet_ValueForKey(const CBLResultSet *, FLString key)
Returns the value of a column of the current result, given its name.
+
void(* CBLQueryChangeListener)(void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)
A callback to be invoked after the query's results have changed.
Definition: CBLQuery.h:204
+
void CBLQuery_SetParameters(CBLQuery *query, FLDict parameters)
Assigns values to the query's parameters.
+
_cbl_warn_unused FLSliceResult CBLQuery_Explain(const CBLQuery *)
Returns information about the query, including the translated SQLite form, and the search strategy.
+
FLSlice CBLQuery_ColumnName(const CBLQuery *, unsigned columnIndex)
Returns the name of a column in the result.
+
FLArray CBLResultSet_ResultArray(const CBLResultSet *)
Returns the current result as an array of column values.
+
CBLQueryLanguage
Query languages.
Definition: CBLQuery.h:43
+
FLDict CBLResultSet_ResultDict(const CBLResultSet *)
Returns the current result as a dictionary mapping column names to values.
+
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute(CBLQuery *, CBLError *_cbl_nullable outError)
Runs the query, returning the results.
+
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
+
bool CBLDatabase_CreateFullTextIndex(CBLDatabase *db, FLString name, CBLFullTextIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a full-text index.
+
struct CBLQuery CBLQuery
A compiled database query.
Definition: CBLBase.h:203
+
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:206
+
_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery(const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *_cbl_nullable outErrorPos, CBLError *_cbl_nullable outError)
Creates a new query by compiling the input string.
+
_cbl_warn_unused CBLListenerToken * CBLQuery_AddChangeListener(CBLQuery *query, CBLQueryChangeListener listener, void *_cbl_nullable context)
Registers a change listener callback with a query, turning it into a "live query" until the listener ...
+
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults(const CBLQuery *query, CBLListenerToken *listener, CBLError *_cbl_nullable outError)
Returns the query's entire current result set, after it's been announced via a call to the listener's...
+
bool CBLDatabase_DeleteIndex(CBLDatabase *db, FLString name, CBLError *_cbl_nullable outError)
Deletes an index given its name.
+
unsigned CBLQuery_ColumnCount(const CBLQuery *)
Returns the number of columns in each result.
+
bool CBLDatabase_CreateValueIndex(CBLDatabase *db, FLString name, CBLValueIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a value index.
+
FLValue CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
+
@ kCBLN1QLLanguage
N1QL syntax
Definition: CBLQuery.h:45
+
@ kCBLJSONLanguage
JSON query schema
Definition: CBLQuery.h:44
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:56
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
Full-Text Index Configuration.
Definition: CBLQuery.h:287
+
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:293
+
bool ignoreAccents
Should diacritical marks (accents) be ignored? Defaults to false.
Definition: CBLQuery.h:297
+
CBLQueryLanguage expressionLanguage
The language used in the expressions.
Definition: CBLQuery.h:289
+
FLString language
The dominant language.
Definition: CBLQuery.h:310
+
Value Index Configuration.
Definition: CBLQuery.h:267
+
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:273
+
CBLQueryLanguage expressionLanguage
The language used in the expressions.
Definition: CBLQuery.h:269
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/_c_b_l_replicator_8h.html b/docs/C/html/_c_b_l_replicator_8h.html index c81661a3..fef9835d 100644 --- a/docs/C/html/_c_b_l_replicator_8h.html +++ b/docs/C/html/_c_b_l_replicator_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLReplicator.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
CBLReplicator.h File Reference
+
CBLReplicator.h File Reference
#include "CBLBase.h"
@@ -77,7 +77,7 @@

Go to the source code of this file.

- @@ -95,19 +95,19 @@

+

Data Structures

struct  CBLProxySettings
 Proxy settings for the replicator. More...
 Information about a document that's been pushed or pulled. More...
 
- - - + + - - - - - - + + + + + + @@ -121,16 +121,20 @@

+

Functions

Lifecycle
static const CBLReplicatorCBLReplicator_Retain (const CBLReplicator *t)
 
static const CBLReplicatorCBLReplicator_Retain (const CBLReplicator *t)
 
static void CBLReplicator_Release (const CBLReplicator *t)
 
_cbl_warn_unused CBLReplicatorCBLReplicator_New (const CBLReplicatorConfiguration *, CBLError *)
 Creates a replicator with the given configuration. More...
 
const CBLReplicatorConfigurationCBLReplicator_Config (CBLReplicator *)
 Returns the configuration of an existing replicator. More...
 
_cbl_warn_unused CBLReplicator *_cbl_nullable CBLReplicator_Create (const CBLReplicatorConfiguration *, CBLError *_cbl_nullable outError)
 Creates a replicator with the given configuration. More...
 
const CBLReplicatorConfigurationCBLReplicator_Config (CBLReplicator *)
 Returns the configuration of an existing replicator. More...
 
void CBLReplicator_Start (CBLReplicator *replicator, bool resetCheckpoint)
 Starts a replicator, asynchronously. More...
 
 Puts the replicator in or out of "suspended" state. More...
 
- - + - + + + @@ -140,83 +144,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Configuration

enum  CBLReplicatorType : uint8_t { kCBLReplicatorTypePushAndPull = 0, -kCBLReplicatorTypePush, -kCBLReplicatorTypePull +

Configuration

enum  CBLReplicatorType : uint8_t { kCBLReplicatorTypePushAndPull = 0 +, kCBLReplicatorTypePush +, kCBLReplicatorTypePull }
 Direction of replication: push, pull, or both. More...
 
enum  CBLProxyType : uint8_t { kCBLProxyHTTP, -kCBLProxyHTTPS +
enum  CBLDocumentFlags : unsigned { kCBLDocumentFlagsDeleted = 1 << 0 +, kCBLDocumentFlagsAccessRemoved = 1 << 1 + }
 Flags describing a replicated document. More...
 
enum  CBLProxyType : uint8_t { kCBLProxyHTTP +, kCBLProxyHTTPS }
 Types of proxy servers, for CBLProxySettings. More...
 
typedef struct CBLAuthenticator CBLAuthenticator
 An opaque object representing authentication credentials for a remote server. More...
 
typedef bool(* CBLReplicationFilter) (void *context, CBLDocument *document, bool isDeleted)
 A callback that can decide whether a particular document should be pushed or pulled. More...
 
typedef const CBLDocument *(* CBLConflictResolver) (void *context, FLString documentID, const CBLDocument *localDocument, const CBLDocument *remoteDocument)
 Conflict-resolution callback for use in replications. More...
 
CBL_CORE_API const FLString kCBLAuthDefaultCookieName
 The name of the HTTP cookie used by Sync Gateway to store session keys. More...
 
const CBLConflictResolver CBLDefaultConflictResolver
 Default conflict resolver. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_NewWithURL (FLString url)
 Creates a new endpoint representing a server-based database at the given URL. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_NewWithLocalDB (CBLDatabase *)
 Creates a new endpoint representing another local database. More...
 
void CBLEndpoint_Free (CBLEndpoint *)
 Frees a CBLEndpoint object. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_NewPassword (FLString username, FLString password)
 Creates an authenticator for HTTP Basic (username/password) auth. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_NewSession (FLString sessionID, FLString cookieName)
 Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a cookie name (pass NULL for the default.) More...
 
void CBLAuth_Free (CBLAuthenticator *)
 Frees a CBLAuthenticator object. More...
 
typedef bool(* CBLReplicationFilter) (void *_cbl_nullable context, CBLDocument *document, CBLDocumentFlags flags)
 A callback that can decide whether a particular document should be pushed or pulled. More...
 
typedef const CBLDocument *_cbl_nullable(* CBLConflictResolver) (void *_cbl_nullable context, FLString documentID, const CBLDocument *_cbl_nullable localDocument, const CBLDocument *_cbl_nullable remoteDocument)
 Conflict-resolution callback for use in replications. More...
 
typedef FLSliceResult(* CBLPropertyEncryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLStringResult *algorithm, FLStringResult *kid, CBLError *error)
 Callback that encrypts CBLEncryptable properties in documents pushed by the replicator. More...
 
typedef FLSliceResult(* CBLPropertyDecryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLString algorithm, FLString kid, CBLError *error)
 Callback that decrypts encrypted CBLEncryptable properties in documents pulled by the replicator. More...
 
CBL_PUBLIC const FLString kCBLAuthDefaultCookieName
 The name of the HTTP cookie used by Sync Gateway to store session keys. More...
 
CBL_PUBLIC const CBLConflictResolver CBLDefaultConflictResolver
 Default conflict resolver. More...
 
_cbl_warn_unused CBLEndpoint *_cbl_nullable CBLEndpoint_CreateWithURL (FLString url, CBLError *_cbl_nullable outError)
 Creates a new endpoint representing a server-based database at the given URL. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_CreateWithLocalDB (CBLDatabase *)
 Creates a new endpoint representing another local database. More...
 
void CBLEndpoint_Free (CBLEndpoint *_cbl_nullable)
 Frees a CBLEndpoint object. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_CreatePassword (FLString username, FLString password)
 Creates an authenticator for HTTP Basic (username/password) auth. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_CreateSession (FLString sessionID, FLString cookieName)
 Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a cookie name (pass NULL for the default.) More...
 
void CBLAuth_Free (CBLAuthenticator *_cbl_nullable)
 Frees a CBLAuthenticator object. More...
 
- + - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + +

-Status and Progress

Status and Progress

enum  CBLReplicatorActivityLevel : uint8_t {
-  kCBLReplicatorStopped, -kCBLReplicatorOffline, -kCBLReplicatorConnecting, -kCBLReplicatorIdle, -
+  kCBLReplicatorStopped +, kCBLReplicatorOffline +, kCBLReplicatorConnecting +, kCBLReplicatorIdle +,
  kCBLReplicatorBusy
}
 The possible states a replicator can be in during its lifecycle. More...
 
enum  CBLDocumentFlags : unsigned { kCBLDocumentFlagsDeleted = 1 << 0, -kCBLDocumentFlagsAccessRemoved = 1 << 1 - }
 Flags describing a replicated document. More...
 
typedef void(* CBLReplicatorChangeListener) (void *context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
 A callback that notifies you when the replicator's status changes. More...
 
typedef void(* CBLReplicatorChangeListener) (void *_cbl_nullable context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
 A callback that notifies you when the replicator's status changes. More...
 
typedef void(* CBLDocumentReplicationListener) (void *context, CBLReplicator *replicator, bool isPush, unsigned numDocuments, const CBLReplicatedDocument *documents)
 A callback that notifies you when documents are replicated. More...
 
CBLReplicatorStatus CBLReplicator_Status (CBLReplicator *)
 Returns the replicator's current status. More...
 
_cbl_warn_unused FLDict CBLReplicator_PendingDocumentIDs (CBLReplicator *, CBLError *)
 Indicates which documents have local changes that have not yet been pushed to the server by this replicator. More...
 
bool CBLReplicator_IsDocumentPending (CBLReplicator *repl, FLString docID, CBLError *outError)
 Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddChangeListener (CBLReplicator *, CBLReplicatorChangeListener, void *context)
 Adds a listener that will be called when the replicator's status changes. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddDocumentReplicationListener (CBLReplicator *, CBLDocumentReplicationListener, void *context)
 Adds a listener that will be called when documents are replicated. More...
 
_cbl_warn_unused FLDict _cbl_nullable CBLReplicator_PendingDocumentIDs (CBLReplicator *, CBLError *_cbl_nullable outError)
 Indicates which documents have local changes that have not yet been pushed to the server by this replicator. More...
 
bool CBLReplicator_IsDocumentPending (CBLReplicator *repl, FLString docID, CBLError *_cbl_nullable outError)
 Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddChangeListener (CBLReplicator *, CBLReplicatorChangeListener, void *_cbl_nullable context)
 Adds a listener that will be called when the replicator's status changes. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddDocumentReplicationListener (CBLReplicator *, CBLDocumentReplicationListener, void *_cbl_nullable context)
 Adds a listener that will be called when documents are replicated. More...
 
diff --git a/docs/C/html/_c_b_l_replicator_8h_source.html b/docs/C/html/_c_b_l_replicator_8h_source.html index 74ce3665..79b4348f 100644 --- a/docs/C/html/_c_b_l_replicator_8h_source.html +++ b/docs/C/html/_c_b_l_replicator_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CBLReplicator.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLReplicator.h
+
CBLReplicator.h
-Go to the documentation of this file.
1 //
2 // CBLReplicator.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "fleece/Fleece.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
37 
39 typedef struct CBLEndpoint CBLEndpoint;
40 
48 
49 #ifdef COUCHBASE_ENTERPRISE
50 
53 #endif
54 
57 
58 
61 
65  FLString password) CBLAPI;
66 
71  FLString cookieName) CBLAPI;
72 
75 
76 
78 typedef CBL_ENUM(uint8_t, CBLReplicatorType) {
82 };
83 
92 typedef bool (*CBLReplicationFilter)(void *context, CBLDocument* document, bool isDeleted);
93 
112 typedef const CBLDocument* (*CBLConflictResolver)(void *context,
113  FLString documentID,
114  const CBLDocument *localDocument,
115  const CBLDocument *remoteDocument);
116 
119 
120 
122 typedef CBL_ENUM(uint8_t, CBLProxyType) {
125 };
126 
127 
129 typedef struct {
132  uint16_t port;
136 
137 
139 typedef struct {
143  bool continuous;
144  //-- HTTP settings:
148  //-- TLS settings:
151  //-- Filtering:
157  void* context;
159 
168 
172  CBLError*) CBLAPI;
173 
176 
185  bool resetCheckpoint) CBLAPI;
186 
191 
198 
204 void CBLReplicator_SetSuspended(CBLReplicator* repl, bool suspended) CBLAPI;
205 
221 };
222 
227 typedef struct {
229  uint64_t documentCount;
231 
233 typedef struct {
238 
241 
257  CBLError*) CBLAPI;
258 
268  FLString docID,
269  CBLError *outError) CBLAPI;
270 
271 
279 typedef void (*CBLReplicatorChangeListener)(void *context,
280  CBLReplicator *replicator _cbl_nonnull,
281  const CBLReplicatorStatus *status _cbl_nonnull);
282 
287  void *context) CBLAPI;
288 
289 
291 typedef CBL_OPTIONS(unsigned, CBLDocumentFlags) {
294 };
295 
296 
298 typedef struct {
303 
313 typedef void (*CBLDocumentReplicationListener)(void *context,
314  CBLReplicator *replicator _cbl_nonnull,
315  bool isPush,
316  unsigned numDocuments,
317  const CBLReplicatedDocument* documents);
318 
323  void *context) CBLAPI;
324 
328 #ifdef __cplusplus
329 }
330 #endif
uint64_t documentCount
Very-approximate completion, from 0.0 to 1.0.
Definition: CBLReplicator.h:229
-
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:251
-
Bidirectional; both push and pull.
Definition: CBLReplicator.h:79
-
void CBLReplicator_Start(CBLReplicator *replicator, bool resetCheckpoint)
Starts a replicator, asynchronously.
-
FLString hostname
Proxy server hostname or IP address.
Definition: CBLReplicator.h:131
-
The replicator is unstarted, finished, or hit a fatal error.
Definition: CBLReplicator.h:216
-
bool continuous
Continuous replication?
Definition: CBLReplicator.h:143
-
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:63
-
The replicator is inactive, waiting for changes to sync.
Definition: CBLReplicator.h:219
-
void * context
Arbitrary value that will be passed to callbacks.
Definition: CBLReplicator.h:157
-
float fractionComplete
Definition: CBLReplicator.h:228
-
_cbl_warn_unused CBLAuthenticator * CBLAuth_NewPassword(FLString username, FLString password)
Creates an authenticator for HTTP Basic (username/password) auth.
-
Pushing changes to the target.
Definition: CBLReplicator.h:80
-
The document has been deleted.
Definition: CBLReplicator.h:292
-
CBLReplicatorType
Direction of replication: push, pull, or both.
Definition: CBLReplicator.h:78
-
CBLDatabase * database
The database to replicate.
Definition: CBLReplicator.h:140
-
CBLReplicatorType replicatorType
Push, pull or both.
Definition: CBLReplicator.h:142
-
struct CBLAuthenticator CBLAuthenticator
An opaque object representing authentication credentials for a remote server.
Definition: CBLReplicator.h:60
-
A replicator's current status.
Definition: CBLReplicator.h:233
-
FLSlice trustedRootCertificates
Set of anchor certs (PEM format)
Definition: CBLReplicator.h:150
-
void(* CBLDocumentReplicationListener)(void *context, CBLReplicator *replicator, bool isPush, unsigned numDocuments, const CBLReplicatedDocument *documents)
A callback that notifies you when documents are replicated.
Definition: CBLReplicator.h:313
-
CBLProxyType type
Type of proxy.
Definition: CBLReplicator.h:130
-
struct CBLReplicator CBLReplicator
A background task that syncs a CBLDatabase with a remote server or peer.
Definition: CBLBase.h:214
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
- -
CBLEndpoint * endpoint
The address of the other database to replicate with.
Definition: CBLReplicator.h:141
-
HTTPS proxy; must support 'CONNECT' method.
Definition: CBLReplicator.h:124
-
_cbl_warn_unused CBLEndpoint * CBLEndpoint_NewWithURL(FLString url)
Creates a new endpoint representing a server-based database at the given URL.
-
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddChangeListener(CBLReplicator *, CBLReplicatorChangeListener, void *context)
Adds a listener that will be called when the replicator's status changes.
-
CBLReplicationFilter pullFilter
Optional callback to validate incoming docs.
Definition: CBLReplicator.h:155
-
_cbl_warn_unused FLDict CBLReplicator_PendingDocumentIDs(CBLReplicator *, CBLError *)
Indicates which documents have local changes that have not yet been pushed to the server by this repl...
-
struct CBLEndpoint CBLEndpoint
An opaque object representing the location of a database to replicate with.
Definition: CBLReplicator.h:39
-
Pulling changes from the target.
Definition: CBLReplicator.h:81
-
void CBLReplicator_SetHostReachable(CBLReplicator *, bool reachable)
Informs the replicator whether it's considered possible to reach the remote host with the current net...
-
bool(* CBLReplicationFilter)(void *context, CBLDocument *document, bool isDeleted)
A callback that can decide whether a particular document should be pushed or pulled.
Definition: CBLReplicator.h:92
-
FLArray documentIDs
Optional set of document IDs to replicate.
Definition: CBLReplicator.h:153
-
Proxy settings for the replicator.
Definition: CBLReplicator.h:129
-
const CBLReplicatorConfiguration * CBLReplicator_Config(CBLReplicator *)
Returns the configuration of an existing replicator.
-
CBLProxyType
Types of proxy servers, for CBLProxySettings.
Definition: CBLReplicator.h:122
-
void CBLReplicator_Stop(CBLReplicator *)
Stops a running replicator, asynchronously.
-
FLSlice pinnedServerCertificate
An X.509 cert to "pin" TLS connections to (PEM or DER)
Definition: CBLReplicator.h:149
-
_cbl_warn_unused CBLReplicator * CBLReplicator_New(const CBLReplicatorConfiguration *, CBLError *)
Creates a replicator with the given configuration.
-
CBLReplicationFilter pushFilter
Optional callback to filter which docs are pushed.
Definition: CBLReplicator.h:154
-
CBLReplicatorStatus CBLReplicator_Status(CBLReplicator *)
Returns the replicator's current status.
- -
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:184
-
_cbl_warn_unused CBLEndpoint * CBLEndpoint_NewWithLocalDB(CBLDatabase *)
Creates a new endpoint representing another local database.
-
uint16_t port
Proxy server port.
Definition: CBLReplicator.h:132
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
The configuration of a replicator.
Definition: CBLReplicator.h:139
-
#define CBLAPI
Definition: CBL_Compat.h:83
-
CBLError error
If the code is nonzero, the document failed to replicate.
Definition: CBLReplicator.h:301
-
FLDict headers
Extra HTTP headers to add to the WebSocket request.
Definition: CBLReplicator.h:147
-
#define _cbl_warn_unused
Definition: CBL_Compat.h:43
-
CBLConflictResolver conflictResolver
Optional conflict-resolver callback.
Definition: CBLReplicator.h:156
-
bool CBLReplicator_IsDocumentPending(CBLReplicator *repl, FLString docID, CBLError *outError)
Indicates whether the document with the given ID has local changes that have not yet been pushed to t...
-
CBLReplicatorActivityLevel
The possible states a replicator can be in during its lifecycle.
Definition: CBLReplicator.h:215
-
CBLReplicatorActivityLevel activity
Current state.
Definition: CBLReplicator.h:234
-
#define CBL_OPTIONS(_type, _name)
Definition: CBL_Compat.h:64
-
The replicator is actively transferring data.
Definition: CBLReplicator.h:220
-
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddDocumentReplicationListener(CBLReplicator *, CBLDocumentReplicationListener, void *context)
Adds a listener that will be called when documents are replicated.
-
CBLAuthenticator * authenticator
Authentication credentials, if needed.
Definition: CBLReplicator.h:145
-
void(* CBLReplicatorChangeListener)(void *context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
A callback that notifies you when the replicator's status changes.
Definition: CBLReplicator.h:279
-
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:193
-
Information about a document that's been pushed or pulled.
Definition: CBLReplicator.h:298
-
The replicator is connecting to the remote host.
Definition: CBLReplicator.h:218
-
A fractional progress value, ranging from 0.0 to 1.0 as replication progresses.
Definition: CBLReplicator.h:227
-
CBL_CORE_API const FLString kCBLAuthDefaultCookieName
The name of the HTTP cookie used by Sync Gateway to store session keys.
-
_cbl_warn_unused CBLAuthenticator * CBLAuth_NewSession(FLString sessionID, FLString cookieName)
Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a co...
-
HTTP proxy; must support 'CONNECT' method.
Definition: CBLReplicator.h:123
-
const CBLProxySettings * proxy
HTTP client proxy settings.
Definition: CBLReplicator.h:146
-
FLString password
Password for proxy auth.
Definition: CBLReplicator.h:134
-
void CBLReplicator_SetSuspended(CBLReplicator *repl, bool suspended)
Puts the replicator in or out of "suspended" state.
-
CBLDocumentFlags flags
Indicates whether the document was deleted or removed.
Definition: CBLReplicator.h:300
-
FLString ID
The document ID.
Definition: CBLReplicator.h:299
-
FLString username
Username for proxy auth (optional)
Definition: CBLReplicator.h:133
-
void CBLAuth_Free(CBLAuthenticator *)
Frees a CBLAuthenticator object.
-
The replicator is offline, as the remote host is unreachable.
Definition: CBLReplicator.h:217
-
A struct holding information about an error.
Definition: CBLBase.h:106
-
void CBLEndpoint_Free(CBLEndpoint *)
Frees a CBLEndpoint object.
-
CBLDocumentFlags
Flags describing a replicated document.
Definition: CBLReplicator.h:291
-
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:40
-
CBLReplicatorProgress progress
Approximate fraction complete.
Definition: CBLReplicator.h:235
-
#define CBL_CORE_API
Definition: CBL_Compat.h:95
-
Lost access to the document on the server.
Definition: CBLReplicator.h:293
-
CBLError error
Error, if any.
Definition: CBLReplicator.h:236
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
-
const CBLConflictResolver CBLDefaultConflictResolver
Default conflict resolver.
-
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:172
-
const CBLDocument *(* CBLConflictResolver)(void *context, FLString documentID, const CBLDocument *localDocument, const CBLDocument *remoteDocument)
Conflict-resolution callback for use in replications.
Definition: CBLReplicator.h:112
-
FLArray channels
Optional set of channels to pull from.
Definition: CBLReplicator.h:152
+Go to the documentation of this file.
1//
+
2// CBLReplicator.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "fleece/Fleece.h"
+
22
+ +
24
+ +
35
+
37typedef struct CBLEndpoint CBLEndpoint;
+
38
+ + +
50 CBLError* _cbl_nullable outError) CBLAPI;
+
51
+
52#ifdef COUCHBASE_ENTERPRISE
+ + +
56#endif
+
57
+ +
60
+
61
+ +
64
+ + +
68
+ + +
73
+ +
76
+
77
+
79typedef CBL_ENUM(uint8_t, CBLReplicatorType) {
+ + + +
83};
+
84
+
85
+
87typedef CBL_OPTIONS(unsigned, CBLDocumentFlags) {
+ + +
90};
+
91
+
92
+
101typedef bool (*CBLReplicationFilter)(void* _cbl_nullable context,
+
102 CBLDocument* document,
+
103 CBLDocumentFlags flags);
+
104
+ +
128 FLString documentID,
+
129 const CBLDocument* _cbl_nullable localDocument,
+
130 const CBLDocument* _cbl_nullable remoteDocument);
+
131
+ +
134
+
135
+
137typedef CBL_ENUM(uint8_t, CBLProxyType) {
+ + +
140};
+
141
+
142
+
144typedef struct {
+ + +
147 uint16_t port;
+ + + +
151
+
152#ifdef COUCHBASE_ENTERPRISE
+
153
+ +
159 void* context,
+
160 FLString documentID,
+
161 FLDict properties,
+
162 FLString keyPath,
+
163 FLSlice input,
+
164 FLStringResult* algorithm,
+
165 FLStringResult* kid,
+
166 CBLError* error
+
167);
+
168
+ +
174 void* context,
+
175 FLString documentID,
+
176 FLDict properties,
+
177 FLString keyPath,
+
178 FLSlice input,
+
179 FLString algorithm,
+
180 FLString kid,
+
181 CBLError* error
+
182);
+
183
+
184#endif
+
185
+
187typedef struct {
+ + + + +
192 //-- Auto Purge:
+ +
194 //-- Retry Logic:
+
195 unsigned maxAttempts;
+ +
198 //-- WebSocket:
+
199 unsigned heartbeat;
+
200 //-- HTTP settings:
+ + + +
204 //-- TLS settings:
+ + +
207 //-- Filtering:
+ + + + + + +
214
+
215#ifdef COUCHBASE_ENTERPRISE
+
216 //-- Property Encryption
+ + +
219#endif
+
220
+ +
222
+
223
+ +
231
+ + +
235 CBLError* _cbl_nullable outError) CBLAPI;
+
236
+ +
239
+ +
248 bool resetCheckpoint) CBLAPI;
+
249
+ +
254
+ +
261 bool reachable) CBLAPI;
+
262
+ +
269
+ + + + + + + +
286
+
291typedef struct {
+
292 float complete;
+
293 uint64_t documentCount;
+ +
295
+
297typedef struct {
+ + + + +
302
+ +
305
+ + +
321 CBLError* _cbl_nullable outError) CBLAPI;
+
322
+ +
332 FLString docID,
+
333 CBLError* _cbl_nullable outError) CBLAPI;
+
334
+
335
+
343typedef void (*CBLReplicatorChangeListener)(void* _cbl_nullable context,
+
344 CBLReplicator *replicator,
+
345 const CBLReplicatorStatus *status);
+
346
+ + + +
351 void* _cbl_nullable context) CBLAPI;
+
352
+
353
+
355typedef struct {
+ + + + +
360
+
370typedef void (*CBLDocumentReplicationListener)(void *context,
+
371 CBLReplicator *replicator,
+
372 bool isPush,
+
373 unsigned numDocuments,
+
374 const CBLReplicatedDocument* documents);
+
375
+ + + +
380 void* _cbl_nullable context) CBLAPI;
+
381
+ +
#define CBL_OPTIONS(_type, _name)
Definition: CBL_Compat.h:57
+
#define CBLAPI
Definition: CBL_Compat.h:98
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
+
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
+
#define CBL_PUBLIC
Definition: CBL_Compat.h:117
+
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
+
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
+ + +
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
+
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:191
+
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
+
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
+
CBLProxyType
Types of proxy servers, for CBLProxySettings.
Definition: CBLReplicator.h:137
+
struct CBLAuthenticator CBLAuthenticator
An opaque object representing authentication credentials for a remote server.
Definition: CBLReplicator.h:63
+
_cbl_warn_unused CBLAuthenticator * CBLAuth_CreateSession(FLString sessionID, FLString cookieName)
Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a co...
+
struct CBLEndpoint CBLEndpoint
An opaque object representing the location of a database to replicate with.
Definition: CBLReplicator.h:37
+
bool(* CBLReplicationFilter)(void *_cbl_nullable context, CBLDocument *document, CBLDocumentFlags flags)
A callback that can decide whether a particular document should be pushed or pulled.
Definition: CBLReplicator.h:101
+
void CBLReplicator_Start(CBLReplicator *replicator, bool resetCheckpoint)
Starts a replicator, asynchronously.
+
FLSliceResult(* CBLPropertyDecryptor)(void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLString algorithm, FLString kid, CBLError *error)
Callback that decrypts encrypted CBLEncryptable properties in documents pulled by the replicator.
Definition: CBLReplicator.h:173
+
_cbl_warn_unused CBLAuthenticator * CBLAuth_CreatePassword(FLString username, FLString password)
Creates an authenticator for HTTP Basic (username/password) auth.
+
bool CBLReplicator_IsDocumentPending(CBLReplicator *repl, FLString docID, CBLError *_cbl_nullable outError)
Indicates whether the document with the given ID has local changes that have not yet been pushed to t...
+
CBL_PUBLIC const FLString kCBLAuthDefaultCookieName
The name of the HTTP cookie used by Sync Gateway to store session keys.
+
void CBLReplicator_Stop(CBLReplicator *)
Stops a running replicator, asynchronously.
+
struct CBLReplicator CBLReplicator
A background task that syncs a CBLDatabase with a remote server or peer.
Definition: CBLBase.h:212
+
_cbl_warn_unused CBLReplicator *_cbl_nullable CBLReplicator_Create(const CBLReplicatorConfiguration *, CBLError *_cbl_nullable outError)
Creates a replicator with the given configuration.
+
_cbl_warn_unused FLDict _cbl_nullable CBLReplicator_PendingDocumentIDs(CBLReplicator *, CBLError *_cbl_nullable outError)
Indicates which documents have local changes that have not yet been pushed to the server by this repl...
+
void(* CBLReplicatorChangeListener)(void *_cbl_nullable context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
A callback that notifies you when the replicator's status changes.
Definition: CBLReplicator.h:343
+
CBLReplicatorStatus CBLReplicator_Status(CBLReplicator *)
Returns the replicator's current status.
+
void CBLEndpoint_Free(CBLEndpoint *_cbl_nullable)
Frees a CBLEndpoint object.
+
void(* CBLDocumentReplicationListener)(void *context, CBLReplicator *replicator, bool isPush, unsigned numDocuments, const CBLReplicatedDocument *documents)
A callback that notifies you when documents are replicated.
Definition: CBLReplicator.h:370
+
CBL_PUBLIC const CBLConflictResolver CBLDefaultConflictResolver
Default conflict resolver.
+
CBLReplicatorActivityLevel
The possible states a replicator can be in during its lifecycle.
Definition: CBLReplicator.h:279
+
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddChangeListener(CBLReplicator *, CBLReplicatorChangeListener, void *_cbl_nullable context)
Adds a listener that will be called when the replicator's status changes.
+
void CBLAuth_Free(CBLAuthenticator *_cbl_nullable)
Frees a CBLAuthenticator object.
+
FLSliceResult(* CBLPropertyEncryptor)(void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLStringResult *algorithm, FLStringResult *kid, CBLError *error)
Callback that encrypts CBLEncryptable properties in documents pushed by the replicator.
Definition: CBLReplicator.h:158
+
CBLDocumentFlags
Flags describing a replicated document.
Definition: CBLReplicator.h:87
+
CBLReplicatorType
Direction of replication: push, pull, or both.
Definition: CBLReplicator.h:79
+
void CBLReplicator_SetSuspended(CBLReplicator *repl, bool suspended)
Puts the replicator in or out of "suspended" state.
+
void CBLReplicator_SetHostReachable(CBLReplicator *, bool reachable)
Informs the replicator whether it's considered possible to reach the remote host with the current net...
+
_cbl_warn_unused CBLEndpoint * CBLEndpoint_CreateWithLocalDB(CBLDatabase *)
Creates a new endpoint representing another local database.
+
const CBLDocument *_cbl_nullable(* CBLConflictResolver)(void *_cbl_nullable context, FLString documentID, const CBLDocument *_cbl_nullable localDocument, const CBLDocument *_cbl_nullable remoteDocument)
Conflict-resolution callback for use in replications.
Definition: CBLReplicator.h:127
+
_cbl_warn_unused CBLListenerToken * CBLReplicator_AddDocumentReplicationListener(CBLReplicator *, CBLDocumentReplicationListener, void *_cbl_nullable context)
Adds a listener that will be called when documents are replicated.
+
_cbl_warn_unused CBLEndpoint *_cbl_nullable CBLEndpoint_CreateWithURL(FLString url, CBLError *_cbl_nullable outError)
Creates a new endpoint representing a server-based database at the given URL.
+
const CBLReplicatorConfiguration * CBLReplicator_Config(CBLReplicator *)
Returns the configuration of an existing replicator.
+
@ kCBLProxyHTTP
HTTP proxy; must support 'CONNECT' method.
Definition: CBLReplicator.h:138
+
@ kCBLProxyHTTPS
HTTPS proxy; must support 'CONNECT' method.
Definition: CBLReplicator.h:139
+
@ kCBLReplicatorConnecting
The replicator is connecting to the remote host.
Definition: CBLReplicator.h:282
+
@ kCBLReplicatorOffline
The replicator is offline, as the remote host is unreachable.
Definition: CBLReplicator.h:281
+
@ kCBLReplicatorStopped
The replicator is unstarted, finished, or hit a fatal error.
Definition: CBLReplicator.h:280
+
@ kCBLReplicatorIdle
The replicator is inactive, waiting for changes to sync.
Definition: CBLReplicator.h:283
+
@ kCBLReplicatorBusy
The replicator is actively transferring data.
Definition: CBLReplicator.h:284
+
@ kCBLDocumentFlagsAccessRemoved
Lost access to the document on the server.
Definition: CBLReplicator.h:89
+
@ kCBLDocumentFlagsDeleted
The document has been deleted.
Definition: CBLReplicator.h:88
+
@ kCBLReplicatorTypePushAndPull
Bidirectional; both push and pull.
Definition: CBLReplicator.h:80
+
@ kCBLReplicatorTypePush
Pushing changes to the target.
Definition: CBLReplicator.h:81
+
@ kCBLReplicatorTypePull
Pulling changes from the target.
Definition: CBLReplicator.h:82
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:56
+
A struct holding information about an error.
Definition: CBLBase.h:104
+
Proxy settings for the replicator.
Definition: CBLReplicator.h:144
+
uint16_t port
Proxy server port.
Definition: CBLReplicator.h:147
+
FLString hostname
Proxy server hostname or IP address.
Definition: CBLReplicator.h:146
+
FLString password
Password for proxy auth.
Definition: CBLReplicator.h:149
+
FLString username
Username for proxy auth (optional)
Definition: CBLReplicator.h:148
+
CBLProxyType type
Type of proxy.
Definition: CBLReplicator.h:145
+
Information about a document that's been pushed or pulled.
Definition: CBLReplicator.h:355
+
CBLError error
If the code is nonzero, the document failed to replicate.
Definition: CBLReplicator.h:358
+
CBLDocumentFlags flags
Indicates whether the document was deleted or removed.
Definition: CBLReplicator.h:357
+
FLString ID
The document ID.
Definition: CBLReplicator.h:356
+
The configuration of a replicator.
Definition: CBLReplicator.h:187
+
void *_cbl_nullable context
Arbitrary value that will be passed to callbacks.
Definition: CBLReplicator.h:213
+
unsigned maxAttemptWaitTime
Max wait time between retry attempts in seconds. Specify 0 to use the default value of 300 seconds.
Definition: CBLReplicator.h:197
+
const CBLProxySettings *_cbl_nullable proxy
HTTP client proxy settings.
Definition: CBLReplicator.h:202
+
FLArray _cbl_nullable channels
Optional set of channels to pull from.
Definition: CBLReplicator.h:208
+
bool disableAutoPurge
Disable/Enable auto-purging documents when the user's access to the documents has been revoked.
Definition: CBLReplicator.h:193
+
bool continuous
Continuous replication?
Definition: CBLReplicator.h:191
+
CBLReplicatorType replicatorType
Push, pull or both.
Definition: CBLReplicator.h:190
+
FLSlice pinnedServerCertificate
An X.509 cert to "pin" TLS connections to (PEM or DER)
Definition: CBLReplicator.h:205
+
unsigned heartbeat
The heartbeat interval in seconds. Specify 0 to use the default value of 300 seconds.
Definition: CBLReplicator.h:199
+
FLArray _cbl_nullable documentIDs
Optional set of document IDs to replicate.
Definition: CBLReplicator.h:209
+
unsigned maxAttempts
Max retry attempts where the initial connect to replicate counts toward the given value.
Definition: CBLReplicator.h:195
+
FLDict _cbl_nullable headers
Extra HTTP headers to add to the WebSocket request.
Definition: CBLReplicator.h:203
+
CBLDatabase * database
The database to replicate.
Definition: CBLReplicator.h:188
+
CBLAuthenticator *_cbl_nullable authenticator
Authentication credentials, if needed.
Definition: CBLReplicator.h:201
+
CBLEndpoint * endpoint
The address of the other database to replicate with.
Definition: CBLReplicator.h:189
+
CBLConflictResolver _cbl_nullable conflictResolver
Optional conflict-resolver callback.
Definition: CBLReplicator.h:212
+
CBLPropertyDecryptor propertyDecryptor
Optional callback to decrypt encrypted CBLEncryptable values.
Definition: CBLReplicator.h:218
+
CBLReplicationFilter _cbl_nullable pushFilter
Optional callback to filter which docs are pushed.
Definition: CBLReplicator.h:210
+
CBLPropertyEncryptor propertyEncryptor
Optional callback to encrypt CBLEncryptable values.
Definition: CBLReplicator.h:217
+
FLSlice trustedRootCertificates
Set of anchor certs (PEM format)
Definition: CBLReplicator.h:206
+
CBLReplicationFilter _cbl_nullable pullFilter
Optional callback to validate incoming docs.
Definition: CBLReplicator.h:211
+
A fractional progress value, ranging from 0.0 to 1.0 as replication progresses.
Definition: CBLReplicator.h:291
+
uint64_t documentCount
Very-approximate fractional completion, from 0.0 to 1.0.
Definition: CBLReplicator.h:293
+
float complete
Definition: CBLReplicator.h:292
+
A replicator's current status.
Definition: CBLReplicator.h:297
+
CBLError error
Error, if any.
Definition: CBLReplicator.h:300
+
CBLReplicatorActivityLevel activity
Current state.
Definition: CBLReplicator.h:298
+
CBLReplicatorProgress progress
Approximate fraction complete.
Definition: CBLReplicator.h:299
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/_couchbase_lite_8h.html b/docs/C/html/_couchbase_lite_8h.html index 106c37eb..f2dd9a77 100644 --- a/docs/C/html/_couchbase_lite_8h.html +++ b/docs/C/html/_couchbase_lite_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CouchbaseLite.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
CouchbaseLite.h File Reference
+
CouchbaseLite.h File Reference
#include "CBLBase.h"
#include "CBLBlob.h"
#include "CBLDatabase.h"
#include "CBLDocument.h"
+#include "CBLEncryptable.h"
#include "CBLLog.h"
+#include "CBLPlatform.h"
#include "CBLQuery.h"
#include "CBLReplicator.h"
-#include "CBLCertificate.h"
-#include "CBLURLEndpointListener.h"

Go to the source code of this file.

diff --git a/docs/C/html/_couchbase_lite_8h_source.html b/docs/C/html/_couchbase_lite_8h_source.html index 1c8b43c4..27748e6e 100644 --- a/docs/C/html/_couchbase_lite_8h_source.html +++ b/docs/C/html/_couchbase_lite_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl/CouchbaseLite.h Source File @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CouchbaseLite.h
+
CouchbaseLite.h
-Go to the documentation of this file.
1 //
2 // CouchbaseLite.h
3 //
4 // Copyright (c) 2018 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include "CBLBase.h"
21 #include "CBLBlob.h"
22 #include "CBLDatabase.h"
23 #include "CBLDocument.h"
24 #include "CBLLog.h"
25 #include "CBLQuery.h"
26 #include "CBLReplicator.h"
27 
28 #ifdef COUCHBASE_ENTERPRISE
29 #include "CBLCertificate.h"
30 #include "CBLURLEndpointListener.h"
31 #endif
- - - - - - - - +Go to the documentation of this file.
1//
+
2// CouchbaseLite.h
+
3//
+
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include "CBLBase.h"
+
21#include "CBLBlob.h"
+
22#include "CBLDatabase.h"
+
23#include "CBLDocument.h"
+
24#include "CBLEncryptable.h"
+
25#include "CBLLog.h"
+
26#include "CBLPlatform.h"
+
27#include "CBLQuery.h"
+
28#include "CBLReplicator.h"
+ + + + + + + + +
diff --git a/docs/C/html/_f_l_slice_8h.html b/docs/C/html/_f_l_slice_8h.html index 90489c64..c2f684a9 100644 --- a/docs/C/html/_f_l_slice_8h.html +++ b/docs/C/html/_f_l_slice_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Macros | Typedefs | Functions
-
-
FLSlice.h File Reference
+
FLSlice.h File Reference

#include "Base.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,7 +115,7 @@

+

Typedefs

typedef FLSlice FLHeapSlice
 A heap-allocated, reference-counted slice. More...
typedef FLSliceResult FLStringResult
 
- @@ -126,6 +126,9 @@ + + + @@ -135,6 +138,9 @@ + + + @@ -145,9 +151,15 @@ + + + + + +

+

Functions

static FLSlice FLStr (const char *str)
 Returns a slice pointing to the contents of a C string. More...
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
 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)
 Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string. More...
 
FLSliceResult FLSlice_Copy (FLSlice)
 Allocates an FLSliceResult, copying the given slice. More...
 
static FLSliceResult FLSliceResult_CreateWith (const void *bytes, size_t size)
 Allocates an FLSliceResult, copying size bytes starting at buf. More...
 
void _FLBuf_Retain (const void *)
 
void _FLBuf_Release (const void *)
static void FLSliceResult_Release (FLSliceResult s)
 Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero. More...
 
static FLSlice FLSliceResult_AsSlice (FLSliceResult sr)
 Type-casts a FLSliceResult to FLSlice, since C doesn't know it's a subclass. More...
 
void FL_WipeMemory (void *dst, size_t size)
 Writes zeroes to size bytes of memory starting at dst. More...
 

Macro Definition Documentation

- +

◆ _FLSLICE_H

@@ -161,7 +173,7 @@

+

◆ FLAPI

@@ -178,9 +190,7 @@

diff --git a/docs/C/html/_f_l_slice_8h_source.html b/docs/C/html/_f_l_slice_8h_source.html index 8d63123b..c6cc4a58 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 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/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 Couchbase. All rights reserved.
7 //
8 
9 #pragma once
10 #ifndef _FLSLICE_H
11 #define _FLSLICE_H
12 
13 #include "Base.h"
14 #include <stdbool.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <string.h>
18 
19 
20 #ifdef __cplusplus
21  #include <string>
22  #define FLAPI noexcept
23  namespace fleece { struct alloc_slice; }
24 #else
25  #define FLAPI
26 #endif
27 
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 
40 typedef struct FLSlice {
41  const void *buf;
42  size_t size;
43 
44 #ifdef __cplusplus
45  explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
46  explicit operator std::string() const {return std::string((char*)buf, size);}
47 #endif
48 } FLSlice;
49 
50 
58 typedef struct FLSliceResult {
59  const void *buf;
60  size_t size;
61 
62 #ifdef __cplusplus
63  explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
64  explicit operator FLSlice () const {return {buf, size};}
65  inline explicit operator std::string() const;
66 #endif
68 
69 
73 #ifdef __cplusplus
74  struct FLHeapSlice : public FLSlice {
75  constexpr FLHeapSlice() noexcept :FLSlice{nullptr, 0} { }
76  private:
77  constexpr FLHeapSlice(const void *b, size_t s) noexcept :FLSlice{b, s} { }
78  friend struct fleece::alloc_slice;
79  };
80 #else
82 #endif
83 
84 
85 // Aliases used to indicate that a slice is expected to contain UTF-8 data.
86 typedef FLSlice FLString;
88 
89 
91 #ifdef _MSC_VER
92  static const FLSlice kFLSliceNull = { NULL, 0 };
93 #else
94  #define kFLSliceNull ((FLSlice){NULL, 0})
95 #endif
96 
97 
102 static inline FLSlice FLStr(const char *str) FLAPI {
103  FLSlice foo = { str, str ? strlen(str) : 0 };
104  return foo;
105 }
106 
109 #ifdef __cplusplus
110  #define FLSTR(STR) (FLSlice {("" STR), sizeof(("" STR))-1})
111 #else
112  #define FLSTR(STR) ((FLSlice){("" STR), sizeof(("" STR))-1})
113 #endif
114 
115 
118 
122 
130 bool FLSlice_ToCString(FLSlice s, char* buffer NONNULL, size_t capacity) FLAPI;
131 
134 
137 
138 void _FLBuf_Retain(const void*) FLAPI; // internal; do not call
139 void _FLBuf_Release(const void*) FLAPI; // internal; do not call
140 
143  _FLBuf_Retain(s.buf);
144  return s;
145 }
146 
149  _FLBuf_Release(s.buf);
150 }
151 
152 
155 #ifdef __cplusplus
156 
157  FLSliceResult::operator std::string () const {
158  auto str = std::string((char*)buf, size);
159  FLSliceResult_Release(*this);
160  return str;
161  }
162 
163 }
164 #endif
165 
166 #endif // _FLSLICE_H
void _FLBuf_Retain(const void *)
-
FLSliceResult FLStringResult
Definition: FLSlice.h:87
-
bool FLSlice_ToCString(FLSlice s, char *buffer, size_t capacity)
Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string.
-
#define kFLSliceNull
A convenient constant denoting a null slice.
Definition: FLSlice.h:94
-
const void * buf
Definition: FLSlice.h:59
-
bool FLSlice_Equal(FLSlice a, FLSlice b) FLPURE
Equality test of two slices.
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
-
size_t size
Definition: FLSlice.h:60
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
const void * buf
Definition: FLSlice.h:41
- -
#define FLPURE
Definition: Base.h:82
-
static FLSlice FLStr(const char *str)
Returns a slice pointing to the contents of a C string.
Definition: FLSlice.h:102
-
void _FLBuf_Release(const void *)
-
#define FLAPI
Definition: FLSlice.h:25
-
static FLSliceResult FLSliceResult_Retain(FLSliceResult s)
Increments the ref-count of a FLSliceResult.
Definition: FLSlice.h:142
-
FLSlice FLHeapSlice
A heap-allocated, reference-counted slice.
Definition: FLSlice.h:81
-
FLSlice FLString
Definition: FLSlice.h:86
-
FLSliceResult FLSlice_Copy(FLSlice)
Allocates an FLSliceResult, copying the given slice.
-
FLSliceResult FLSliceResult_New(size_t)
Allocates an FLSliceResult of the given size, without initializing the buffer.
-
int FLSlice_Compare(FLSlice, FLSlice) FLPURE
Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences ...
-
#define NONNULL
Definition: Base.h:61
-
size_t size
Definition: FLSlice.h:42
-
static void FLSliceResult_Release(FLSliceResult s)
Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero.
Definition: FLSlice.h:148
+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 Couchbase. All rights reserved.
+
7//
+
8
+
9#pragma once
+
10#ifndef _FLSLICE_H
+
11#define _FLSLICE_H
+
12
+
13#include "Base.h"
+
14#include <stdbool.h>
+
15#include <stdint.h>
+
16#include <stdlib.h>
+
17#include <string.h>
+
18
+
19
+
20#ifdef __cplusplus
+
21 #include <string>
+
22 #define FLAPI noexcept
+
23 namespace fleece { struct alloc_slice; }
+
24#else
+
25 #define FLAPI
+
26#endif
+
27
+
28
+
29#ifdef __cplusplus
+
30extern "C" {
+
31#endif
+
32
+
33
+
40typedef struct FLSlice {
+
41 const void *buf;
+
42 size_t size;
+
43
+
44#ifdef __cplusplus
+
45 explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
+
46 explicit operator std::string() const {return std::string((char*)buf, size);}
+
47#endif
+
48} FLSlice;
+
49
+
50
+
58typedef struct FLSliceResult {
+
59 const void *buf;
+
60 size_t size;
+
61
+
62#ifdef __cplusplus
+
63 explicit operator bool() const noexcept FLPURE {return buf != nullptr;}
+
64 explicit operator FLSlice () const {return {buf, size};}
+
65 inline explicit operator std::string() const;
+
66#endif
+ +
68
+
69
+
73#ifdef __cplusplus
+
74 struct FLHeapSlice : public FLSlice {
+
75 constexpr FLHeapSlice() noexcept :FLSlice{nullptr, 0} { }
+
76 private:
+
77 constexpr FLHeapSlice(const void *b, size_t s) noexcept :FLSlice{b, s} { }
+
78 friend struct fleece::alloc_slice;
+
79 };
+
80#else
+ +
82#endif
+
83
+
84
+
85// Aliases used to indicate that a slice is expected to contain UTF-8 data.
+ + +
88
+
89
+
91#ifdef _MSC_VER
+
92 static const FLSlice kFLSliceNull = { NULL, 0 };
+
93#else
+
94 #define kFLSliceNull ((FLSlice){NULL, 0})
+
95#endif
+
96
+
97
+
102static inline FLSlice FLStr(const char *str) FLAPI {
+
103 FLSlice foo = { str, str ? strlen(str) : 0 };
+
104 return foo;
+
105}
+
106
+
109#ifdef __cplusplus
+
110 #define FLSTR(STR) (FLSlice {("" STR), sizeof(("" STR))-1})
+
111#else
+
112 #define FLSTR(STR) ((FLSlice){("" STR), sizeof(("" STR))-1})
+
113#endif
+
114
+
115
+ +
118
+ +
122
+ +
125
+
133bool FLSlice_ToCString(FLSlice s, char* buffer NONNULL, size_t capacity) FLAPI;
+
134
+ +
137
+ +
140
+
141
+
143static inline FLSliceResult FLSliceResult_CreateWith(const void *bytes, size_t size) FLAPI {
+
144 FLSlice s = {bytes, size};
+
145 return FLSlice_Copy(s);
+
146}
+
147
+
148
+
149void _FLBuf_Retain(const void*) FLAPI; // internal; do not call
+
150void _FLBuf_Release(const void*) FLAPI; // internal; do not call
+
151
+ +
154 _FLBuf_Retain(s.buf);
+
155 return s;
+
156}
+
157
+ +
160 _FLBuf_Release(s.buf);
+
161}
+
162
+ +
165 return *(FLSlice*)&sr;
+
166}
+
167
+
168
+
172void FL_WipeMemory(void *dst, size_t size) FLAPI;
+
173
+
174
+
177#ifdef __cplusplus
+
178}
+
179
+
180 FLPURE static inline bool operator== (FLSlice s1, FLSlice s2) {return FLSlice_Equal(s1, s2);}
+
181 FLPURE static inline bool operator!= (FLSlice s1, FLSlice s2) {return !(s1 == s2);}
+
182
+
183 FLPURE static inline bool operator== (FLSliceResult sr, FLSlice s) {return (FLSlice)sr == s;}
+
184 FLPURE static inline bool operator!= (FLSliceResult sr, FLSlice s) {return !(sr ==s);}
+
185
+
186
+
187 FLSliceResult::operator std::string () const {
+
188 auto str = std::string((char*)buf, size);
+ +
190 return str;
+
191 }
+
192#endif
+
193
+
194#endif // _FLSLICE_H
+ +
#define FLPURE
Definition: Base.h:83
+
#define NONNULL
Definition: Base.h:62
+
#define FLAPI
Definition: FLSlice.h:25
+
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:159
+
#define kFLSliceNull
A convenient constant denoting a null slice.
Definition: FLSlice.h:94
+
FLSliceResult FLSliceResult_New(size_t)
Allocates an FLSliceResult of the given size, without initializing the buffer.
+
void _FLBuf_Retain(const void *)
+
void _FLBuf_Release(const void *)
+
static FLSliceResult FLSliceResult_Retain(FLSliceResult s)
Increments the ref-count of a FLSliceResult.
Definition: FLSlice.h:153
+
int FLSlice_Compare(FLSlice, FLSlice) FLPURE
Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences ...
+
FLSliceResult FLStringResult
Definition: FLSlice.h:87
+
FLSlice FLString
Definition: FLSlice.h:86
+
FLSlice FLHeapSlice
A heap-allocated, reference-counted slice.
Definition: FLSlice.h:81
+
static FLSlice FLSliceResult_AsSlice(FLSliceResult sr)
Type-casts a FLSliceResult to FLSlice, since C doesn't know it's a subclass.
Definition: FLSlice.h:164
+
uint32_t FLSlice_Hash(FLSlice s) FLPURE
Computes a 32-bit hash of a slice's data, suitable for use in hash tables.
+
bool FLSlice_ToCString(FLSlice s, char *buffer, size_t capacity)
Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string.
+
FLSliceResult FLSlice_Copy(FLSlice)
Allocates an FLSliceResult, copying the given slice.
+
void FL_WipeMemory(void *dst, size_t size)
Writes zeroes to size bytes of memory starting at dst.
+
static FLSlice FLStr(const char *str)
Returns a slice pointing to the contents of a C string.
Definition: FLSlice.h:102
+
static FLSliceResult FLSliceResult_CreateWith(const void *bytes, size_t size)
Allocates an FLSliceResult, copying size bytes starting at buf.
Definition: FLSlice.h:143
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
const void * buf
Definition: FLSlice.h:41
+
size_t size
Definition: FLSlice.h:42
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
+
const void * buf
Definition: FLSlice.h:59
+
size_t size
Definition: FLSlice.h:60
diff --git a/docs/C/html/_fleece_09_core_foundation_8h.html b/docs/C/html/_fleece_09_core_foundation_8h.html index 3c92dc83..a713dd0a 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 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/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>
@@ -77,7 +77,7 @@

Go to the source code of this file.

- @@ -92,9 +92,7 @@ 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 65762854..05d38bff 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 @@ - - + +Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece+CoreFoundation.h Source File @@ -30,21 +30,22 @@

+

Functions

bool FLEncoder_WriteCFObject (FLEncoder, CFTypeRef)
 Writes a Core Foundation (or Objective-C) object to an Encoder. More...
- + +/* @license-end */ +
-
-
Fleece+CoreFoundation.h
+
Fleece+CoreFoundation.h
-Go to the documentation of this file.
1 //
2 // Fleece+CoreFoundation.h
3 //
4 // Copyright (c) 2016 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #include <CoreFoundation/CFBase.h>
21 #include "Fleece.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
32  bool FLEncoder_WriteCFObject(FLEncoder, CFTypeRef) FLAPI;
33 
34 
38 
39 
42 
43 
44 #ifdef __OBJC__
45 #import <Foundation/NSMapTable.h>
46 
47  // Equivalents of the above functions that take & return Objective-C object types:
48 
51  bool FLEncoder_WriteNSObject(FLEncoder, id) FLAPI;
52 
53 
55  NSMapTable* FLCreateSharedStringsTable(void) FLAPI;
56 
57 
59  id FLValue_GetNSObject(FLValue, NSMapTable *sharedStrings) FLAPI;
60 
61 
63  FLValue FLDict_GetWithNSString(FLDict, NSString*) FLAPI;
64 
65 
67  NSString* FLDictIterator_GetKeyAsNSString(const FLDictIterator *i,
68  NSMapTable *sharedStrings) FLAPI;
69 
71  NSData* FLEncoder_FinishWithNSData(FLEncoder, NSError**) FLAPI;
72 
73 
75  extern NSString* const FLErrorDomain;
76 
77 
78  @interface NSObject (Fleece)
83  - (void) fl_encodeToFLEncoder: (FLEncoder)enc;
84  @end
85 
86 
87 #endif
88 
91 #ifdef __cplusplus
92 }
93 #endif
Opaque dictionary iterator.
Definition: Fleece.h:571
-
FLValue FLDict_GetWithCFString(FLDict, CFStringRef)
Same as FLDictGet, but takes the key as a CFStringRef.
-
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:45
- -
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
bool FLEncoder_WriteCFObject(FLEncoder, CFTypeRef)
Writes a Core Foundation (or Objective-C) object to an Encoder.
-
#define FLAPI
Definition: FLSlice.h:25
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:39
-
CFTypeRef FLValue_CopyCFObject(FLValue)
Returns a Value as a corresponding CoreFoundation object.
+Go to the documentation of this file.
1//
+
2// Fleece+CoreFoundation.h
+
3//
+
4// Copyright (c) 2016 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#include <CoreFoundation/CFBase.h>
+
21#include "Fleece.h"
+
22
+
23#ifdef __cplusplus
+
24extern "C" {
+
25#endif
+
26
+ +
33
+
34
+ +
38
+
39
+ +
42
+
43
+
44#ifdef __OBJC__
+
45#import <Foundation/NSMapTable.h>
+
46
+
47 // Equivalents of the above functions that take & return Objective-C object types:
+
48
+
51 bool FLEncoder_WriteNSObject(FLEncoder, id) FLAPI;
+
52
+
53
+
55 NSMapTable* FLCreateSharedStringsTable(void) FLAPI;
+
56
+
57
+
59 id FLValue_GetNSObject(FLValue, NSMapTable *sharedStrings) FLAPI;
+
60
+
61
+
63 FLValue FLDict_GetWithNSString(FLDict, NSString*) FLAPI;
+
64
+
65
+
67 NSString* FLDictIterator_GetKeyAsNSString(const FLDictIterator *i,
+
68 NSMapTable *sharedStrings) FLAPI;
+
69
+
71 NSData* FLEncoder_FinishWithNSData(FLEncoder, NSError**) FLAPI;
+
72
+
73
+
75 extern NSString* const FLErrorDomain;
+
76
+
77
+
78 @interface NSObject (Fleece)
+
83 - (void) fl_encodeToFLEncoder: (FLEncoder)enc;
+
84 @end
+
85
+
86
+
87#endif
+
88
+
91#ifdef __cplusplus
+
92}
+
93#endif
+
#define FLAPI
Definition: FLSlice.h:25
+ +
FLValue FLDict_GetWithCFString(FLDict, CFStringRef)
Same as FLDictGet, but takes the key as a CFStringRef.
+
bool FLEncoder_WriteCFObject(FLEncoder, CFTypeRef)
Writes a Core Foundation (or Objective-C) object to an Encoder.
+
CFTypeRef FLValue_CopyCFObject(FLValue)
Returns a Value as a corresponding CoreFoundation object.
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:61
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
Opaque dictionary iterator.
Definition: Fleece.h:638
diff --git a/docs/C/html/_fleece_8h.html b/docs/C/html/_fleece_8h.html index 1321885c..67fe0ca4 100644 --- a/docs/C/html/_fleece_8h.html +++ b/docs/C/html/_fleece_8h.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h File Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
Enumerations | Functions | Variables
-
-
Fleece.h File Reference
+
Fleece.h File Reference

#include "FLSlice.h"
@@ -82,7 +82,7 @@

Go to the source code of this file.

- @@ -96,15 +96,17 @@

+

Data Structures

struct  FLArrayIterator
 Opaque array iterator. 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...
 
- @@ -141,43 +143,43 @@

+

Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
typedef struct _FLSharedKeyScope * FLSharedKeyScope
 
-

+

Enumerations

enum  FLError {
-  kFLNoError = 0, -kFLMemoryError, -kFLOutOfRange, -kFLInvalidData, -
-  kFLEncodeError, -kFLJSONError, -kFLUnknownValue, -kFLInternalError, -
-  kFLNotFound, -kFLSharedKeysStateError, -kFLPOSIXError, -kFLUnsupported +  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 +  kFLUndefined = -1 +, kFLNull = 0 +, kFLBoolean +, kFLNumber +,
+  kFLString +, kFLData +, kFLArray +, kFLDict
}
 Types of Fleece values. More...
 
- @@ -248,33 +250,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -307,11 +282,14 @@ + + + - + - + @@ -403,6 +381,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -414,12 +432,12 @@ - - - - - - + + + + + + @@ -436,8 +454,20 @@ - + @@ -454,8 +484,22 @@ - + @@ -509,9 +553,6 @@ - - - @@ -524,6 +565,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + +

+

Functions

FLStringResult FLValue_ToJSON (FLValue)
 Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings. More...
FLValue FLValue_NewData (FLSlice)
 Allocates a data/blob value on the heap. 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 integer 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 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...
 
uint32_t FLArray_Count (FLArray) FLPURE
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 
FLValue FLDeepIterator_GetValue (FLDeepIterator)
 Returns the current value being iterated over. More...
 
FLValue 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, or an empty slice if not in a dictionary. More...
 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, or 0 if not in an array. More...
 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...
bool FLEncodeApplyingJSONDelta (FLValue 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 FL_NONNULL, 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 FLValue_FromData (FLSlice data, FLTrust) FLPURE
 Returns a pointer to the root value in the encoded data, or NULL if validation failed. More...
 Produces a human-readable dump of the Value encoded in the data. More...
 
Debugging Functions
const char * FLDump (FLValue)
 Debugging function that returns a C string of JSON. More...
 
const char * FLDumpData (FLSlice data)
 Debugging function that returns a C string of JSON. More...
 
const char * FLDump (FLValue)
 Debugging function that returns a C string of JSON. More...
 
const char * FLDumpData (FLSlice data)
 Debugging function that returns a C string of JSON. More...
 
Ref-counting (mutable values only)
FLValue FLValue_Retain (FLValue)
 If this value is mutable (and thus heap-based) its ref-count is incremented. More...
static void FLDict_Release (FLDict v)
 
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, 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 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:55
+
Opaque array iterator.
Definition: Fleece.h:434
+
void FLArrayIterator_Begin (FLArray, FLArrayIterator *)
 Initializes a FLArrayIterator struct to iterate over an array. More...
 
 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))) {
+ +
// ...
+ +
}
+
void FLDictIterator_Begin(FLDict, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
+
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
+
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
+
FLValue FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
+
Opaque dictionary iterator.
Definition: Fleece.h:638
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
void FLDictIterator_Begin (FLDict, FLDictIterator *)
 Initializes a FLDictIterator struct to iterate over a dictionary. More...
 
void FLMutableDict_SetChanged (FLMutableDict, bool)
 Sets or clears the mutable Dict's "changed" flag. More...
 
FLSlot FLMutableDict_Set (FLMutableDict FL_NONNULL, FLString key)
 Returns the Slot storing the key's value, adding a new one if needed (with a null value.) To set the value itself, call one of the FLSlot functions, e.g. More...
 
void FLMutableDict_Remove (FLMutableDict, FLString key)
 Removes the value for a key. More...
 
FLMutableDict FLMutableDict_GetMutableDict (FLMutableDict, 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.

@@ -601,33 +675,32 @@
FLDoc FLEncoder_FinishDoc (FLEncoder, FLError *)
 Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc. More...
 
FLSliceResult FLEncoder_Finish (FLEncoder e, FLError *outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null. More...
 
MUST_USE_RESULT FLSliceResult FLEncoder_Finish (FLEncoder e, FLError *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 * FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
const char * FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
- - - - - - - - + + + + + + +

+

Variables

const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
const FLArray kFLEmptyArray
 
const FLDict kFLEmptyDict
 
FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
FLEECE_PUBLIC const FLArray kFLEmptyArray
 
FLEECE_PUBLIC const FLDict kFLEmptyDict
 
- - + - @@ -661,16 +734,21 @@ + + + + + +

-FLDoc

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

+

FLDoc

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

enum  FLTrust { kFLUntrusted, -kFLTrusted +
enum  FLTrust { kFLUntrusted +, kFLTrusted }
 Specifies whether not input data is trusted to be 100% valid Fleece. More...
 
FLSharedKeys FLDoc_GetSharedKeys (FLDoc) FLPURE
 Returns the FLSharedKeys used by this FLDoc, as specified when it was created. More...
 
bool FLDoc_SetAssociated (FLDoc doc, void *pointer, const char *type)
 Associates an arbitrary pointer value with a document, and thus its contained values. More...
 
void * FLDoc_GetAssociated (FLDoc doc, const char *type) FLPURE
 Returns the pointer associated with the document. More...
 
FLDoc FLValue_FindDoc (FLValue) FLPURE
 Looks up the Doc containing the Value, or NULL if the Value was created without a Doc. More...
 
- - + @@ -694,12 +772,6 @@ - - - - - - @@ -715,12 +787,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0, -kFLDeepCopy = 1, -kFLCopyImmutables = 2, -kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) +

Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0 +, kFLDeepCopy = 1 +, kFLCopyImmutables = 2 +, kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) }
 
FLMutableArray FLArray_MutableCopy (FLArray, FLCopyFlags)
void FLMutableArray_SetChanged (FLMutableArray, bool)
 Sets or clears the mutable Array's "changed" flag. More...
 
FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
 Lets you store a value into a MutableArray, by returning a FLSlot that you can call a function like FLSlot_SetInt on. More...
 
FLSlot FLMutableArray_Append (FLMutableArray)
 Appends a null value to a MutableArray and returns a FLSlot that you can call to store something else in the new value. More...
 
void FLMutableArray_Insert (FLMutableArray array, uint32_t firstIndex, uint32_t count)
 Inserts a contiguous range of JSON null values into the array. More...
 
FLMutableDict FLMutableArray_GetMutableDict (FLMutableArray, 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...
 
- - + @@ -742,9 +879,9 @@ - - - + + + @@ -765,7 +902,7 @@

-Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece, -kFLEncodeJSON, -kFLEncodeJSON5 +

Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece +, kFLEncodeJSON +, kFLEncodeJSON5 }
 Output formats a FLEncoder can generate. More...
 
void FLEncoder_SetExtraInfo (FLEncoder, void *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_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...
 
 

Macro Definition Documentation

- +

◆ _FLEECE_H

@@ -777,14 +914,26 @@

+

+
+ +

◆ FLEECE_PUBLIC

+ +
+
+ + + + +
#define FLEECE_PUBLIC
+
+
diff --git a/docs/C/html/_fleece_8h_source.html b/docs/C/html/_fleece_8h_source.html index b8cdcb8d..52a9a4aa 100644 --- a/docs/C/html/_fleece_8h_source.html +++ b/docs/C/html/_fleece_8h_source.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/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 (c) 2016 Couchbase, Inc All rights reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 
19 #pragma once
20 #ifndef _FLEECE_H
21 #define _FLEECE_H
22 
23 #include "FLSlice.h"
24 #include <stdio.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30  // This is the C API! For the C++ API, see Fleece.hh.
31 
32 
34 
38 #ifndef FL_IMPL
39  typedef const struct _FLValue* FLValue;
40  typedef const struct _FLArray* FLArray;
41  typedef const struct _FLDict* FLDict;
42  typedef struct _FLSlot* FLSlot;
43  typedef struct _FLArray* FLMutableArray;
44  typedef struct _FLDict* FLMutableDict;
45  typedef struct _FLEncoder* FLEncoder;
46 #endif
47 
48 
50  typedef enum {
52  kFLMemoryError, // Out of memory, or allocation failed
53  kFLOutOfRange, // Array index or iterator out of range
54  kFLInvalidData, // Bad input data (NaN, non-string key, etc.)
55  kFLEncodeError, // Structural error encoding (missing value, too many ends, etc.)
56  kFLJSONError, // Error parsing JSON
57  kFLUnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?)
58  kFLInternalError, // Something that shouldn't happen
59  kFLNotFound, // Key not found
60  kFLSharedKeysStateError, // Misuse of shared keys (not in transaction, etc.)
62  kFLUnsupported, // Operation is unsupported
63  } FLError;
64 
65 
67 
68 
78 #ifndef FL_IMPL
79  typedef struct _FLDoc* FLDoc;
80  typedef struct _FLSharedKeys* FLSharedKeys;
81 #endif
82 
84  typedef enum {
95  } FLTrust;
96 
97 
102 
106  FLDoc FLDoc_FromJSON(FLSlice json, FLError *outError) FLAPI;
107 
109  void FLDoc_Release(FLDoc) FLAPI;
110 
114 
117 
120 
123 
126 
130 
131 
140 
144 
148 
149 
160 
164 
167  bool json5,
168  bool canonicalForm) FLAPI;
169 
185  FLStringResult *outErrorMessage,
186  size_t *outErrorPos,
187  FLError *outError) FLAPI;
188 
192  const char* FLDump(FLValue) FLAPI;
194  const char* FLDumpData(FLSlice data) FLAPI;
195 
199 
201 
222  typedef enum {
224  kFLNull = 0,
231  } FLValueType;
232 
233 
235  typedef int64_t FLTimestamp;
236 
238  #define FLTimestampNone INT64_MIN
239 
240 
244 
247 
253 
256 
260 
266 
271 
278 
285 
288 
293 
296 
299 
302 
306 
309 
312 
319 
324 
325  static inline FLArray FLArray_Retain(FLArray v) {FLValue_Retain((FLValue)v); return v;}
326  static inline void FLArray_Release(FLArray v) {FLValue_Release((FLValue)v);}
327  static inline FLDict FLDict_Retain(FLDict v) {FLValue_Retain((FLValue)v); return v;}
328  static inline void FLDict_Release(FLDict v) {FLValue_Release((FLValue)v);}
329 
335 
339 
341  extern const FLValue kFLNullValue;
342 
343 
345 
346 
355  void FLSlot_SetBool(FLSlot NONNULL, bool) FLAPI;
356  void FLSlot_SetInt(FLSlot NONNULL, int64_t) FLAPI;
357  void FLSlot_SetUInt(FLSlot NONNULL, uint64_t) FLAPI;
358  void FLSlot_SetFloat(FLSlot NONNULL, float) FLAPI;
359  void FLSlot_SetDouble(FLSlot NONNULL, double) FLAPI;
363 
364 
366 
367 
380  uint32_t FLArray_Count(FLArray) FLAPI FLPURE;
381 
385 
388 
390  FLValue FLArray_Get(FLArray, uint32_t index) FLAPI FLPURE;
391 
392  extern const FLArray kFLEmptyArray;
393 
411  typedef struct {
412 #if !DOXYGEN_PARSING
413  void* _private1;
414  uint32_t _private2;
415  bool _private3;
416  void* _private4;
417 #endif
418  } FLArrayIterator;
419 
423 
426 
429 
432 
435 
439 
441 
445  typedef enum {
450  } FLCopyFlags;
451 
452 
465 
469 
473  }
475  static inline void FLMutableArray_Release(FLMutableArray d) {
477  }
478 
481 
484 
487 
491 
495 
500  void FLMutableArray_Insert(FLMutableArray array, uint32_t firstIndex, uint32_t count) FLAPI;
501 
506  void FLMutableArray_Remove(FLMutableArray array, uint32_t firstIndex, uint32_t count) FLAPI;
507 
511  void FLMutableArray_Resize(FLMutableArray array, uint32_t size) FLAPI;
512 
519 
526 
530 
532 
538  uint32_t FLDict_Count(FLDict) FLAPI FLPURE;
539 
543 
546 
550 
551  extern const FLDict kFLEmptyDict;
552 
571  typedef struct {
572 #if !DOXYGEN_PARSING
573  void* _private1;
574  uint32_t _private2;
575  bool _private3;
576  void* _private4[4];
577  int _private5;
578 #endif
579  } FLDictIterator;
580 
585 
588 
591 
594 
597 
600 
604 
613  typedef struct {
614 #if !DOXYGEN_PARSING
615  FLSlice _private1;
616  void* _private2;
617  uint32_t _private3, private4;
618  bool private5;
619 #endif
620  } FLDictKey;
621 
628 
631 
635 
636 
638 
639 
655 
659 
663  }
664 
666  static inline void FLMutableDict_Release(FLMutableDict d) {
668  }
669 
672 
675 
678 
682 
685 
688 
695 
702 
706 
708 
715 #ifndef FL_IMPL
716  typedef struct _FLDeepIterator* FLDeepIterator;
717 #endif
718 
723 
725 
728 
731 
734 
737 
740 
743 
744  typedef struct {
746  uint32_t index;
747  } FLPathComponent;
748 
751  FLPathComponent* * NONNULL outPath,
752  size_t* NONNULL outDepth) FLAPI;
753 
756 
759 
760 
762 
763 
781 #ifndef FL_IMPL
782  typedef struct _FLKeyPath* FLKeyPath;
783 #endif
784 
786  FLKeyPath FLKeyPath_New(FLSlice specifier, FLError *error) FLAPI;
787 
790 
793 
797  FLValue FLKeyPath_EvalOnce(FLSlice specifier, FLValue root NONNULL, FLError *error) FLAPI;
798 
801 
803  bool FLKeyPath_Equals(FLKeyPath path1, FLKeyPath path2) FLAPI;
804 
807  size_t i,
808  FLSlice *outDictKey NONNULL,
809  int32_t *outArrayIndex NONNULL) FLAPI;
810 
812 
813 
836 
837  typedef bool (*FLSharedKeysReadCallback)(void *context, FLSharedKeys);
838 
840  void *context) FLAPI;
841 
844 
847 
851 
855 
862 
865 
869 
871  void FLSharedKeys_RevertToCount(FLSharedKeys NONNULL, unsigned oldCount) FLAPI;
872 
875 
878 
879 
880  typedef struct _FLSharedKeyScope* FLSharedKeyScope;
883 
884 
886 
887 
903  typedef enum {
907  } FLEncoderFormat;
908 
909 
912 
921  size_t reserveSize,
922  bool uniqueStrings) FLAPI;
923 
925  FLEncoder FLEncoder_NewWritingToFile(FILE* NONNULL, bool uniqueStrings) FLAPI;
926 
929 
932 
934  void FLEncoder_SetExtraInfo(FLEncoder NONNULL, void *info) FLAPI;
935 
938 
939 
955  bool reuseStrings, bool externPointers) FLAPI;
956 
959 
963 
967 
970 
974 
987 
993 
996 
1000  bool FLEncoder_WriteInt(FLEncoder NONNULL, int64_t) FLAPI;
1001 
1005  bool FLEncoder_WriteUInt(FLEncoder NONNULL, uint64_t) FLAPI;
1006 
1013 
1019 
1024 
1032  bool FLEncoder_WriteDateString(FLEncoder NONNULL encoder, FLTimestamp ts, bool asUTC) FLAPI;
1033 
1038 
1044 
1045 
1051  bool FLEncoder_BeginArray(FLEncoder NONNULL, size_t reserveCount) FLAPI;
1052 
1055 
1056 
1065  bool FLEncoder_BeginDict(FLEncoder NONNULL, size_t reserveCount) FLAPI;
1066 
1069 
1073 
1076 
1077 
1080 
1081 
1086 
1090  void FLEncoder_WriteValueAgain(FLEncoder e, intptr_t preWrittenValue);
1091 
1092 
1098 
1099 
1104 
1111 
1116 
1120 
1127 
1130 
1135 
1137 
1155 
1163  bool FLEncodeJSONDelta(FLValue old, FLValue nuu, FLEncoder NONNULL jsonEncoder) FLAPI;
1164 
1165 
1175  FLSlice jsonDelta,
1176  FLError *error) FLAPI;
1177 
1188  FLSlice jsonDelta,
1189  FLEncoder encoder) FLAPI;
1190 
1191 
1194 #ifdef __cplusplus
1195 }
1196 #endif
1197 
1198 
1199 #ifdef __OBJC__
1200 // When compiling as Objective-C, include CoreFoundation / Objective-C utilities:
1201 #include "Fleece+CoreFoundation.h"
1202 #endif
1203 
1204 #endif // _FLEECE_H
bool FLValue_IsMutable(FLValue) FLPURE
Returns true if the value is mutable.
-
Type of a NULL pointer, i.e. no such value, like JSON undefined. Also the type of a value created by ...
Definition: Fleece.h:223
-
FLArray FLValue_AsArray(FLValue) FLPURE
If a FLValue represents an array, returns it cast to FLArray, else NULL.
-
FLString FLValue_AsString(FLValue) FLPURE
Returns the exact contents of a string value, or null for all other types.
-
void FLMutableArray_Resize(FLMutableArray array, uint32_t size)
Changes the size of an array.
-
void FLEncoder_Free(FLEncoder)
Frees the space used by an encoder.
-
FLMutableDict FLDict_AsMutable(FLDict) FLPURE
If the dictionary is mutable, returns it cast to FLMutableDict, else NULL.
-
bool FLEncoder_EndDict(FLEncoder)
Ends writing a dictionary value; pops back the previous encoding state.
-
bool FLEncoder_EndArray(FLEncoder)
Ends writing an array value; pops back the previous encoding state.
-
FLEncoder FLEncoder_NewWithOptions(FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
Creates a new encoder, allowing some options to be customized.
-
FLSlot FLMutableArray_Append(FLMutableArray)
Appends a null value to a MutableArray and returns a FLSlot that you can call to store something else...
-
Opaque dictionary iterator.
Definition: Fleece.h:571
-
bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC)
Writes a timestamp to an encoder, as an ISO-8601 date string.
-
uint32_t FLDictIterator_GetCount(const FLDictIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
-
JSON5, an extension of JSON with a more readable syntax
Definition: Fleece.h:906
-
void FLDeepIterator_Free(FLDeepIterator)
-
float FLValue_AsFloat(FLValue) FLPURE
Returns a value coerced to a 32-bit floating point number.
-
FLSliceResult FLData_ConvertJSON(FLSlice json, FLError *outError)
Directly converts JSON data to Fleece-encoded data.
-
bool FLValue_AsBool(FLValue) FLPURE
Returns a value coerced to boolean.
-
void FLDictIterator_Begin(FLDict, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
-
bool FLEncoder_WriteFloat(FLEncoder, float)
Writes a 32-bit floating point number to an encoder.
-
Definition: Fleece.h:61
-
Definition: Fleece.h:58
-
FLSharedKeys FLSharedKeys_New(void)
Creates a new empty FLSharedKeys object, which must eventually be released.
-
Equivalent to a JSON 'null'.
Definition: Fleece.h:224
-
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:45
-
FLValue FLDictIterator_GetKey(const FLDictIterator *) FLPURE
Returns the current key being iterated over.
-
FLSlice FLValue_AsData(FLValue) FLPURE
Returns the exact contents of a data value, or null for all other types.
-
FLValue FLKeyPath_EvalOnce(FLSlice specifier, FLValue root, FLError *error)
Evaluates a key-path from a specifier string, for a given Fleece root object.
-
uint32_t FLArrayIterator_GetCount(const FLArrayIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
-
bool FLEncoder_WriteKey(FLEncoder, FLString)
Specifies the key for the next value to be written to the current dictionary.
-
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.
-
bool FLMutableDict_IsChanged(FLMutableDict)
Returns true if the Dict has been changed from the source it was copied from.
-
FLError FLEncoder_GetError(FLEncoder)
Returns the error code of an encoder, or NoError (0) if there's no error.
-
int64_t FLValue_AsInt(FLValue) FLPURE
Returns a value coerced to an integer.
-
FLError
Error codes returned from some API calls.
Definition: Fleece.h:50
-
void FLSlot_SetUInt(FLSlot, uint64_t)
Stores an unsigned integer into a slot.
-
bool FLDict_IsEmpty(FLDict) FLPURE
Returns true if a dictionary is empty (or NULL).
-
bool FLSharedKeys_LoadStateData(FLSharedKeys, FLSlice)
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData.
-
unsigned FLSharedKeys_Count(FLSharedKeys)
Returns the number of keys in the mapping.
-
Definition: Fleece.h:56
-
FLDoc FLDoc_Retain(FLDoc)
Adds a reference to an FLDoc.
-
Definition: Fleece.h:54
-
size_t FLDeepIterator_GetDepth(FLDeepIterator)
Returns the current depth in the hierarchy, starting at 1 for the top-level children.
-
FLKeyPath FLKeyPath_New(FLSlice specifier, FLError *error)
Creates a new FLKeyPath object by compiling a path specifier string.
-
bool FLEncoder_WriteString(FLEncoder, FLString)
Writes a string to an encoder.
-
int64_t FLTimestamp
A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC....
Definition: Fleece.h:235
-
FLSlice key
Dict key, or kFLSliceNull if none.
Definition: Fleece.h:745
-
Definition: Fleece.h:744
-
FLSlot FLMutableDict_Set(FLMutableDict FL_NONNULL, FLString key)
Returns the Slot storing the key's value, adding a new one if needed (with a null value....
-
uint32_t FLDict_Count(FLDict) FLPURE
Returns the number of items in a dictionary, or 0 if the pointer is NULL.
-
bool(* FLSharedKeysReadCallback)(void *context, FLSharedKeys)
Definition: Fleece.h:837
-
A simple reference to a block of memory.
Definition: FLSlice.h:40
-
bool FLMutableArray_IsChanged(FLMutableArray)
Returns true if the Array has been changed from the source it was copied from.
-
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.
-
struct _FLDoc * FLDoc
A reference to a document.
Definition: Fleece.h:79
-
uint64_t FLValue_AsUnsigned(FLValue) FLPURE
Returns a value coerced to an unsigned integer.
-
const FLDict kFLEmptyDict
-
FLSliceResult FLApplyJSONDelta(FLValue old, FLSlice jsonDelta, FLError *error)
Applies the JSON data created by CreateJSONDelta to the value old, which must be equal to the old val...
-
bool FLArray_IsEmpty(FLArray) FLPURE
Returns true if an array is empty (or NULL).
-
bool FLEncoder_WriteRaw(FLEncoder, FLSlice)
Writes raw data directly to the encoded output.
-
FLMutableDict FLMutableArray_GetMutableDict(FLMutableArray, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
-
static void FLArray_Release(FLArray v)
Definition: Fleece.h:326
-
FLStringResult FLValue_ToJSONX(FLValue v, bool json5, bool canonicalForm)
Most general Fleece to JSON converter.
-
void FLKeyPath_Free(FLKeyPath)
Frees a compiled FLKeyPath object.
-
FLSlot FLMutableArray_Set(FLMutableArray, uint32_t index)
Lets you store a value into a MutableArray, by returning a FLSlot that you can call a function like F...
-
Binary data (no JSON equivalent)
Definition: Fleece.h:228
-
bool FLValue_IsDouble(FLValue)
Returns true if the value is non-NULL and represents a 64-bit floating-point number.
-
struct _FLKeyPath * FLKeyPath
A reference to a key path.
Definition: Fleece.h:782
-
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...
-
FLSharedKeys FLSharedKeys_NewWithRead(FLSharedKeysReadCallback, void *context)
-
FLMutableArray FLArray_MutableCopy(FLArray, FLCopyFlags)
Creates a new mutable Array that's a copy of the source Array.
-
FLDeepIterator FLDeepIterator_New(FLValue)
Creates a FLDeepIterator to iterate over a dictionary.
-
FLDoc FLValue_FindDoc(FLValue) FLPURE
Looks up the Doc containing the Value, or NULL if the Value was created without a Doc.
-
A true or false value.
Definition: Fleece.h:225
-
FLValue FLValue_NewData(FLSlice)
Allocates a data/blob value on the heap.
-
FLSlice FLDoc_GetData(FLDoc) FLPURE
Returns the encoded Fleece data backing the document.
-
FLDoc FLDoc_FromResultData(FLSliceResult data, FLTrust, FLSharedKeys, FLSlice externData)
Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other...
-
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
-
FLEncoderFormat
Output formats a FLEncoder can generate.
Definition: Fleece.h:903
-
struct _FLSharedKeyScope * FLSharedKeyScope
Definition: Fleece.h:880
-
Definition: Fleece.h:55
-
FLMutableArray FLMutableArray_New(void)
Creates a new empty mutable Array.
-
A string.
Definition: Fleece.h:227
-
Definition: Fleece.h:449
-
JSON encoding.
Definition: Fleece.h:905
-
A mapping of strings to values.
Definition: Fleece.h:230
-
const FLArray kFLEmptyArray
-
void FLSlot_SetNull(FLSlot)
Stores a JSON null into a slot.
-
FLSliceResult FLEncoder_Snip(FLEncoder e)
Returns the data written so far as a standalone Fleece document, whose root is the last value written...
-
FLValue FLArrayIterator_GetValueAt(const FLArrayIterator *, uint32_t offset) FLPURE
Returns a value in the array at the given offset from the current value.
-
void FLMutableArray_Remove(FLMutableArray array, uint32_t firstIndex, uint32_t count)
Removes contiguous items from the array.
-
void FLSharedKeys_RevertToCount(FLSharedKeys, unsigned oldCount)
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount.
-
FLValue FLArray_Get(FLArray, uint32_t index) FLPURE
Returns an value at an array index, or NULL if the index is out of range.
-
bool FLEncodeJSONDelta(FLValue old, FLValue nuu, FLEncoder jsonEncoder)
Writes JSON that describes the changes to turn the value old into nuu.
-
FLStringResult FLValue_ToString(FLValue)
Returns a string representation of any scalar value.
-
uint32_t FLDeepIterator_GetIndex(FLDeepIterator)
Returns the array index of the current value, or 0 if not in an array.
-
Fleece encoding.
Definition: Fleece.h:904
-
size_t FLEncoder_BytesWritten(FLEncoder)
Returns the number of bytes encoded so far.
- -
#define FLPURE
Definition: Base.h:82
-
uint32_t FLArray_Count(FLArray) FLPURE
Returns the number of items in an array, or 0 if the pointer is NULL.
-
Definition: Fleece.h:59
-
bool FLEncoder_WriteNull(FLEncoder)
Writes a null value to an encoder.
-
FLValueType FLValue_GetType(FLValue) FLPURE
Returns the data type of an arbitrary Value.
-
FLSliceResult FLEncoder_Finish(FLEncoder e, FLError *outError)
Ends encoding; if there has been no error, it returns the encoded data, else null.
-
void FLMutableDict_Remove(FLMutableDict, FLString key)
Removes the value for a key.
-
bool FLEncodeApplyingJSONDelta(FLValue old, FLSlice jsonDelta, FLEncoder encoder)
Applies the (parsed) JSON data created by CreateJSONDelta to the value old, which must be equal to th...
-
Input data is not trusted to be valid, and will be fully validated by the API call.
Definition: Fleece.h:86
-
void FLSlot_SetString(FLSlot, FLString)
Stores a string into a slot.
-
FLStringResult FLJSON5_ToJSON(FLString json5, FLStringResult *outErrorMessage, size_t *outErrorPos, FLError *outError)
Converts valid JSON5 https://json5.org to JSON.
-
FLValue FLValue_FromData(FLSlice data, FLTrust) FLPURE
Returns a pointer to the root value in the encoded data, or NULL if validation failed.
-
bool FLValue_IsUnsigned(FLValue) FLPURE
Returns true if the value is non-NULL and represents an integer >= 2^63.
-
Definition: Fleece.h:52
-
void FLSharedKeyScope_Free(FLSharedKeyScope)
-
void FLSlot_SetFloat(FLSlot, float)
Stores a float into a slot.
-
FLMutableDict FLMutableDict_New(void)
Creates a new empty mutable Dict.
-
FLString FLDictKey_GetString(const FLDictKey *)
Returns the string value of the key (which it was initialized with.)
-
bool FLKeyPath_Equals(FLKeyPath path1, FLKeyPath path2)
Equality test.
-
FLDoc FLEncoder_FinishDoc(FLEncoder, FLError *)
Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc.
-
FLStringResult FLValue_ToJSON(FLValue)
Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON ...
-
A numeric value, either integer or floating-point.
Definition: Fleece.h:226
-
FLStringResult FLKeyPath_ToString(FLKeyPath path)
Returns a path in string form.
-
struct _FLDict * FLMutableDict
A reference to a mutable dictionary.
Definition: Fleece.h:44
-
Definition: Fleece.h:60
-
FLDoc FLDoc_FromJSON(FLSlice json, FLError *outError)
Creates an FLDoc from JSON-encoded data.
-
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:41
-
FLSliceResult FLDeepIterator_GetJSONPointer(FLDeepIterator)
Returns the current path in JSONPointer format (RFC 6901).
-
FLValue FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
-
FLCopyFlags
Definition: Fleece.h:445
-
double FLValue_AsDouble(FLValue) FLPURE
Returns a value coerced to a 32-bit floating point number.
-
void FLSlot_SetInt(FLSlot, int64_t)
Stores an integer into a slot.
-
FLEncoder FLEncoder_NewWritingToFile(FILE *, bool uniqueStrings)
Creates a new Fleece encoder that writes to a file, not to memory.
-
FLEncoder FLEncoder_New(void)
Creates a new encoder, for generating Fleece data.
-
FLDict FLValue_AsDict(FLValue) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
-
bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount)
Begins writing an array value to an encoder.
-
Definition: Fleece.h:53
-
FLDict FLMutableDict_GetSource(FLMutableDict)
If the Dict was created by FLDict_MutableCopy, returns the original source Dict.
-
Definition: Fleece.h:447
-
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
-
bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount)
Begins writing a dictionary value to an encoder.
-
static FLArray FLArray_Retain(FLArray v)
Definition: Fleece.h:325
-
FLStringResult FLData_Dump(FLSlice data)
Produces a human-readable dump of the Value encoded in the data.
-
FLTimestamp FLValue_AsTimestamp(FLValue) FLPURE
Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure.
-
Definition: Fleece.h:51
-
void FLDeepIterator_GetPath(FLDeepIterator, FLPathComponent **outPath, size_t *outDepth)
Returns the path as an array of FLPathComponents.
-
FLString FLSharedKeys_Decode(FLSharedKeys, int key)
Returns the key string that maps to the given integer key, else NULL.
-
void FLSlot_SetValue(FLSlot, FLValue)
Stores an FLValue into a slot.
-
FLMutableDict FLMutableDict_GetMutableDict(FLMutableDict, FLString key)
Convenience function for getting a dict-valued property in mutable form.
-
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
-
void FLEncoder_WriteValueAgain(FLEncoder e, intptr_t preWrittenValue)
Writes another reference (a "pointer") to an already-written value, given a reference previously retu...
-
static void FLMutableDict_Release(FLMutableDict d)
Decrements the refcount of (and possibly frees) a mutable Dict.
Definition: Fleece.h:666
-
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:43
-
bool FLEncoder_WriteValue(FLEncoder, FLValue)
Writes a Fleece Value to an Encoder.
-
FLSlice FLDeepIterator_GetKey(FLDeepIterator)
Returns the key of the current value, or an empty slice if not in a dictionary.
-
size_t FLEncoder_FinishItem(FLEncoder)
Finishes encoding the current item, and returns its offset in the output data.
-
void FLEncoder_SetExtraInfo(FLEncoder, void *info)
Associates an arbitrary user-defined value with the encoder.
-
Opaque key for a dictionary.
Definition: Fleece.h:613
-
bool FLEncoder_WriteInt(FLEncoder, int64_t)
Writes an integer to an encoder.
-
FLSharedKeys FLDoc_GetSharedKeys(FLDoc) FLPURE
Returns the FLSharedKeys used by this FLDoc, as specified when it was created.
-
void FLMutableArray_SetChanged(FLMutableArray, bool)
Sets or clears the mutable Array's "changed" flag.
-
bool FLSharedKeys_LoadState(FLSharedKeys, FLValue)
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_Wr...
-
FLSharedKeys FLSharedKeys_Retain(FLSharedKeys)
Increments the reference count of an FLSharedKeys.
-
const char * FLDumpData(FLSlice data)
Debugging function that returns a C string of JSON.
-
void FLEncoder_Reset(FLEncoder)
Resets the state of an encoder without freeing it.
-
intptr_t FLEncoder_LastValueWritten(FLEncoder e)
Returns an opaque reference to the last complete value written to the encoder, if possible.
-
static void FLMutableArray_Release(FLMutableArray d)
Decrements the refcount of (and possibly frees) a mutable Array.
Definition: Fleece.h:475
-
FLValue FLValue_Retain(FLValue)
If this value is mutable (and thus heap-based) its ref-count is incremented.
-
void FLDeepIterator_SkipChildren(FLDeepIterator)
Tells the iterator to skip the children of the current value.
-
bool FLEncoder_WriteDouble(FLEncoder, double)
Writes a 64-bit floating point number to an encoder.
-
bool FLValue_IsEqual(FLValue v1, FLValue v2) FLPURE
Compares two values for equality.
-
void FLMutableDict_SetChanged(FLMutableDict, bool)
Sets or clears the mutable Dict's "changed" flag.
-
void FLSlot_SetData(FLSlot, FLSlice)
Stores a data blob into a slot.
-
void FLSharedKeys_Release(FLSharedKeys)
Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero.
-
Definition: Fleece.h:62
-
FLValue FLDict_GetWithKey(FLDict, FLDictKey *)
Looks up a key in a dictionary using an FLDictKey.
- -
static void FLDict_Release(FLDict v)
Definition: Fleece.h:328
-
void FLSharedKeys_WriteState(FLSharedKeys, FLEncoder)
Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed...
-
#define FLAPI
Definition: FLSlice.h:25
-
void FLArrayIterator_Begin(FLArray, 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.
-
FLValueType
Types of Fleece values.
Definition: Fleece.h:222
-
static FLDict FLDict_Retain(FLDict v)
Definition: Fleece.h:327
-
An array of values.
Definition: Fleece.h:229
-
FLSliceResult FLDeepIterator_GetPathString(FLDeepIterator)
Returns the current path in JavaScript format.
-
bool FLEncoder_WriteKeyValue(FLEncoder, FLValue)
Specifies the key for the next value to be written to the current dictionary.
-
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:39
-
Definition: Fleece.h:446
-
FLSliceResult FLSharedKeys_GetStateData(FLSharedKeys)
Returns a data blob containing the current state (all the keys and their integers....
-
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: Fleece.h:80
-
void FLSlot_SetDouble(FLSlot, double)
Stores a double into a slot.
-
FLArray FLMutableArray_GetSource(FLMutableArray)
If the Array was created by FLArray_MutableCopy, returns the original source Array.
-
FLSliceResult FLDoc_GetAllocedData(FLDoc) FLPURE
Returns the FLSliceResult data owned by the document, if any, else a null slice.
-
FLSlice FLEncoder_GetBase(FLEncoder)
Returns the base value passed to FLEncoder_Amend.
-
uint32_t index
Array index, only if there's no key.
Definition: Fleece.h:746
-
struct _FLDeepIterator * FLDeepIterator
A reference to a deep iterator.
Definition: Fleece.h:716
-
FLStringResult FLValue_ToJSON5(FLValue v)
Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unq...
-
FLValue FLKeyPath_Eval(FLKeyPath, FLValue root)
Evaluates a compiled key-path for a given Fleece root object.
-
size_t FLEncoder_GetNextWritePos(FLEncoder)
Returns the byte offset in the encoded data where the next value will be written.
-
bool FLEncoder_WriteBool(FLEncoder, bool)
Writes a boolean value (true or false) to an encoder.
-
void FLEncoder_SetSharedKeys(FLEncoder, FLSharedKeys)
Tells the encoder to use a shared-keys mapping when encoding dictionary keys.
-
void FLValue_Release(FLValue)
If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero t...
-
bool FLDeepIterator_Next(FLDeepIterator)
Advances the iterator to the next value, or returns false if at the end.
-
bool FLEncoder_WriteData(FLEncoder, FLSlice)
Writes a binary data value (a blob) to an encoder.
-
FLMutableArray FLArray_AsMutable(FLArray) FLPURE
If the array is mutable, returns it cast to FLMutableArray, else NULL.
-
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:40
-
void FLDoc_Release(FLDoc)
Releases a reference to an FLDoc.
-
FLMutableArray FLMutableDict_GetMutableArray(FLMutableDict, FLString key)
Convenience function for getting an array-valued property in mutable form.
-
void FLMutableDict_RemoveAll(FLMutableDict)
Removes all keys and values.
-
FLMutableDict FLDict_MutableCopy(FLDict source, FLCopyFlags)
Creates a new mutable Dict that's a copy of the source Dict.
-
void FLDictIterator_End(FLDictIterator *)
Cleans up after an iterator.
-
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:42
-
void * FLEncoder_GetExtraInfo(FLEncoder)
Returns the user-defined value associated with the encoder; NULL by default.
-
FLSharedKeyScope FLSharedKeyScope_WithRange(FLSlice range, FLSharedKeys)
-
Opaque array iterator.
Definition: Fleece.h:411
-
FLValue FLDoc_GetRoot(FLDoc) FLPURE
Returns the root value in the FLDoc, usually an FLDict.
-
void FLSlot_SetBool(FLSlot, bool)
Stores a boolean into a slot.
-
bool FLEncoder_WriteUndefined(FLEncoder)
Writes an undefined value to an encoder.
-
FLSliceResult FLCreateJSONDelta(FLValue old, FLValue nuu)
Returns JSON that encodes the changes to turn the value old into nuu.
-
Definition: Fleece.h:57
-
Input data is trusted to be valid.
Definition: Fleece.h:94
-
#define NONNULL
Definition: Base.h:61
-
bool FLEncoder_WriteUInt(FLEncoder, uint64_t)
Writes an unsigned integer to an encoder.
-
bool FLEncoder_ConvertJSON(FLEncoder, FLSlice json)
Parses JSON data and writes the object(s) to the encoder.
-
FLValue FLValue_NewString(FLString)
Allocates a string value on the heap.
-
FLDictKey FLDictKey_Init(FLSlice string)
Initializes an FLDictKey struct with a key string.
-
const FLValue kFLNullValue
A constant null value (not a NULL pointer!)
-
Definition: Fleece.h:448
-
FLMutableArray FLMutableArray_GetMutableArray(FLMutableArray, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
-
static FLMutableDict FLMutableDict_Retain(FLMutableDict d)
Increments the ref-count of a mutable Dict.
Definition: Fleece.h:661
-
void FLMutableArray_Insert(FLMutableArray array, uint32_t firstIndex, uint32_t count)
Inserts a contiguous range of JSON null values into the array.
-
const char * FLDump(FLValue)
Debugging function that returns a C string of JSON.
-
FLTrust
Specifies whether not input data is trusted to be 100% valid Fleece.
Definition: Fleece.h:84
-
FLValue FLDict_Get(FLDict, FLSlice keyString) FLPURE
Looks up a key in a dictionary, returning its value.
-
FLValue FLArrayIterator_GetValue(const FLArrayIterator *) FLPURE
Returns the current value being iterated over.
-
static FLMutableArray FLMutableArray_Retain(FLMutableArray d)
Increments the ref-count of a mutable Array.
Definition: Fleece.h:471
-
FLValue FLDeepIterator_GetValue(FLDeepIterator)
Returns the current value being iterated over.
-
const char * FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
-
void FLEncoder_SuppressTrailer(FLEncoder)
Tells the encoder not to write the two-byte Fleece trailer at the end of the data.
-
bool FLValue_IsInteger(FLValue) FLPURE
Returns true if the value is non-NULL and represents an integer.
+Go to the documentation of this file.
1//
+
2// Fleece.h
+
3//
+
4// Copyright (c) 2016 Couchbase, Inc All rights reserved.
+
5//
+
6// Licensed under the Apache License, Version 2.0 (the "License");
+
7// you may not use this file except in compliance with the License.
+
8// You may obtain a copy of the License at
+
9//
+
10// http://www.apache.org/licenses/LICENSE-2.0
+
11//
+
12// Unless required by applicable law or agreed to in writing, software
+
13// distributed under the License is distributed on an "AS IS" BASIS,
+
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
15// See the License for the specific language governing permissions and
+
16// limitations under the License.
+
17//
+
18
+
19#pragma once
+
20#ifndef _FLEECE_H
+
21#define _FLEECE_H
+
22
+
23#include "FLSlice.h"
+
24#include <stdio.h>
+
25
+
26// On Windows, FLEECE_PUBLIC marks symbols as being exported from the shared library.
+
27// However, this is not the whole list of things that are exported. The API methods
+
28// are exported using a definition list, but it is not possible to correctly include
+
29// initialized global variables, so those need to be marked (both in the header and
+
30// implementation) with FLEECE_PUBLIC. See kFLNullValue below and in Fleece.cc
+
31// for an example.
+
32#if defined(_MSC_VER)
+
33#ifdef FLEECE_EXPORTS
+
34#define FLEECE_PUBLIC __declspec(dllexport)
+
35#else
+
36#define FLEECE_PUBLIC __declspec(dllimport)
+
37#endif
+
38#else
+
39#define FLEECE_PUBLIC
+
40#endif
+
41
+
42#ifdef __cplusplus
+
43extern "C" {
+
44#endif
+
45
+
46 // This is the C API! For the C++ API, see Fleece.hh.
+
47
+
48
+
50
+
54#ifndef FL_IMPL
+
55 typedef const struct _FLValue* FLValue;
+
56 typedef const struct _FLArray* FLArray;
+
57 typedef const struct _FLDict* FLDict;
+
58 typedef struct _FLSlot* FLSlot;
+
59 typedef struct _FLArray* FLMutableArray;
+
60 typedef struct _FLDict* FLMutableDict;
+
61 typedef struct _FLEncoder* FLEncoder;
+
62#endif
+
63
+
64
+
66 typedef enum {
+ +
68 kFLMemoryError, // Out of memory, or allocation failed
+
69 kFLOutOfRange, // Array index or iterator out of range
+
70 kFLInvalidData, // Bad input data (NaN, non-string key, etc.)
+
71 kFLEncodeError, // Structural error encoding (missing value, too many ends, etc.)
+
72 kFLJSONError, // Error parsing JSON
+
73 kFLUnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?)
+
74 kFLInternalError, // Something that shouldn't happen
+
75 kFLNotFound, // Key not found
+
76 kFLSharedKeysStateError, // Misuse of shared keys (not in transaction, etc.)
+ +
78 kFLUnsupported, // Operation is unsupported
+
79 } FLError;
+
80
+
81
+
83
+
84
+
94#ifndef FL_IMPL
+
95 typedef struct _FLDoc* FLDoc;
+
96 typedef struct _FLSharedKeys* FLSharedKeys;
+
97#endif
+
98
+
100 typedef enum {
+ + + +
112
+
113
+ +
118
+ +
123
+ +
126
+ +
130
+ +
133
+ +
136
+ +
139
+ +
142
+
157 bool FLDoc_SetAssociated(FLDoc doc, void *pointer, const char *type) FLAPI;
+
158
+
167 void* FLDoc_GetAssociated(FLDoc doc, const char *type) FLAPI FLPURE;
+
168
+ +
172
+
173
+ +
182
+ +
186
+ +
190
+
191
+ +
202
+ +
206
+ +
209 bool json5,
+
210 bool canonicalForm) FLAPI;
+
211
+ +
227 FLStringResult *outErrorMessage,
+
228 size_t *outErrorPos,
+
229 FLError *outError) FLAPI;
+
230
+
234 const char* FLDump(FLValue) FLAPI;
+
236 const char* FLDumpData(FLSlice data) FLAPI;
+
237
+
242
+
243
+
264 typedef enum {
+ + + + + + + +
272 kFLDict
+ +
274
+
275
+
277 typedef int64_t FLTimestamp;
+
278
+
280 #define FLTimestampNone INT64_MIN
+
281
+
282
+ +
286
+ +
289
+ +
295
+ +
298
+ +
302
+ +
308
+ +
313
+ +
320
+ +
327
+ +
330
+ +
335
+ +
338
+ +
341
+ +
344
+ +
348
+ +
351
+ +
354
+ +
361
+ +
366
+
367 static inline FLArray FLArray_Retain(FLArray v) {FLValue_Retain((FLValue)v); return v;}
+
368 static inline void FLArray_Release(FLArray v) {FLValue_Release((FLValue)v);}
+
369 static inline FLDict FLDict_Retain(FLDict v) {FLValue_Retain((FLValue)v); return v;}
+
370 static inline void FLDict_Release(FLDict v) {FLValue_Release((FLValue)v);}
+
371
+ +
378
+ +
383
+ +
386
+
387
+
389
+
390
+ +
404
+ +
408
+ +
411
+ +
414
+ +
416
+
434 typedef struct {
+
435#if !DOXYGEN_PARSING
+
436 void* _private1;
+
437 uint32_t _private2;
+
438 bool _private3;
+
439 void* _private4;
+
440#endif
+ +
442
+ +
446
+ +
449
+ +
452
+ +
455
+ +
458
+
463
+
464
+
468 typedef enum {
+ + + + +
473 } FLCopyFlags;
+
474
+
475
+ +
488
+ +
492
+ + +
496 }
+ + +
500 }
+
501
+ +
504
+ +
507
+ +
510
+
515 void FLMutableArray_Insert(FLMutableArray array, uint32_t firstIndex, uint32_t count) FLAPI;
+
516
+
521 void FLMutableArray_Remove(FLMutableArray array, uint32_t firstIndex, uint32_t count) FLAPI;
+
522
+
526 void FLMutableArray_Resize(FLMutableArray array, uint32_t size) FLAPI;
+
527
+ +
534
+ +
541
+
542
+
544 static inline void FLMutableArray_SetNull(FLMutableArray NONNULL, uint32_t index);
+
546 static inline void FLMutableArray_SetBool(FLMutableArray NONNULL, uint32_t index, bool);
+
548 static inline void FLMutableArray_SetInt(FLMutableArray NONNULL, uint32_t index, int64_t);
+
552 static inline void FLMutableArray_SetUInt(FLMutableArray NONNULL, uint32_t index, uint64_t);
+
554 static inline void FLMutableArray_SetFloat(FLMutableArray NONNULL, uint32_t index, float);
+
556 static inline void FLMutableArray_SetDouble(FLMutableArray NONNULL, uint32_t index, double);
+
558 static inline void FLMutableArray_SetString(FLMutableArray NONNULL, uint32_t index, FLString);
+
560 static inline void FLMutableArray_SetData(FLMutableArray NONNULL, uint32_t index, FLSlice);
+
562 static inline void FLMutableArray_SetValue(FLMutableArray NONNULL, uint32_t index, FLValue);
+
564 static inline void FLMutableArray_SetArray(FLMutableArray NONNULL, uint32_t index, FLArray);
+
566 static inline void FLMutableArray_SetDict(FLMutableArray NONNULL, uint32_t index, FLDict);
+
567
+ +
571 static inline void FLMutableArray_AppendBool(FLMutableArray NONNULL, bool);
+
573 static inline void FLMutableArray_AppendInt(FLMutableArray NONNULL, int64_t);
+
577 static inline void FLMutableArray_AppendUInt(FLMutableArray NONNULL, uint64_t);
+
579 static inline void FLMutableArray_AppendFloat(FLMutableArray NONNULL, float);
+
581 static inline void FLMutableArray_AppendDouble(FLMutableArray NONNULL, double);
+ + + + + +
592
+
593
+
598
+
599
+ +
606
+ +
610
+ +
613
+ +
617
+
618 FLEECE_PUBLIC extern const FLDict kFLEmptyDict;
+
619
+
638 typedef struct {
+
639#if !DOXYGEN_PARSING
+
640 void* _private1;
+
641 uint32_t _private2;
+
642 bool _private3;
+
643 void* _private4[4];
+
644 int _private5;
+
645#endif
+ +
647
+ +
652
+ +
655
+ +
658
+ +
661
+ +
664
+ +
667
+ +
671
+
680 typedef struct {
+
681#if !DOXYGEN_PARSING
+
682 FLSlice _private1;
+
683 void* _private2;
+
684 uint32_t _private3, private4;
+
685 bool private5;
+
686#endif
+
687 } FLDictKey;
+
688
+ +
695
+ +
698
+ +
702
+
703
+
705
+
706
+ +
722
+ +
726
+ + +
730 }
+
731
+
733 static inline void FLMutableDict_Release(FLMutableDict d) {
+ +
735 }
+
736
+ +
739
+ +
742
+ +
745
+ +
748
+ +
751
+ +
758
+ +
765
+
766
+
768 static inline void FLMutableDict_SetNull(FLMutableDict NONNULL, FLString key);
+
770 static inline void FLMutableDict_SetBool(FLMutableDict NONNULL, FLString key, bool);
+
772 static inline void FLMutableDict_SetInt(FLMutableDict NONNULL, FLString key, int64_t);
+
776 static inline void FLMutableDict_SetUInt(FLMutableDict NONNULL, FLString key, uint64_t);
+
778 static inline void FLMutableDict_SetFloat(FLMutableDict NONNULL, FLString key, float);
+
780 static inline void FLMutableDict_SetDouble(FLMutableDict NONNULL, FLString key, double);
+ + + + + +
791
+
792
+
797
+
798
+
805#ifndef FL_IMPL
+
806 typedef struct _FLDeepIterator* FLDeepIterator;
+
807#endif
+
808
+ +
813
+ +
815
+ +
818
+ +
821
+ +
824
+ +
827
+ +
830
+ +
833
+ +
836
+
837 typedef struct {
+ +
839 uint32_t index;
+ +
841
+ +
844 FLPathComponent* * NONNULL outPath,
+
845 size_t* NONNULL outDepth) FLAPI;
+
846
+ +
849
+ +
852
+
853
+
855
+
856
+
874#ifndef FL_IMPL
+
875 typedef struct _FLKeyPath* FLKeyPath;
+
876#endif
+
877
+ +
880
+ +
883
+ +
886
+ +
891
+ +
894
+ +
897
+ +
900 size_t i,
+
901 FLSlice *outDictKey NONNULL,
+
902 int32_t *outArrayIndex NONNULL) FLAPI;
+
903
+
905
+
906
+ +
929
+
930 typedef bool (*FLSharedKeysReadCallback)(void *context, FLSharedKeys);
+
931
+ +
933 void *context) FLAPI;
+
934
+ +
937
+ +
940
+ +
944
+ +
948
+ +
955
+ +
958
+ +
962
+ +
965
+ +
968
+ +
971
+
972
+
973 typedef struct _FLSharedKeyScope* FLSharedKeyScope;
+ + +
976
+
977
+
979
+
980
+
996 typedef enum {
+ + + + +
1001
+
1002
+ +
1005
+ +
1014 size_t reserveSize,
+
1015 bool uniqueStrings) FLAPI;
+
1016
+ +
1019
+ +
1022
+ +
1025
+ +
1028
+ +
1031
+
1032
+ +
1048 bool reuseStrings, bool externPointers) FLAPI;
+
1049
+ +
1052
+ +
1056
+ +
1060
+ +
1063
+ +
1067
+ +
1080
+ +
1086
+ +
1089
+ +
1094
+ +
1099
+ +
1106
+ +
1112
+ +
1117
+ +
1126
+ +
1131
+ +
1137
+
1138
+
1144 bool FLEncoder_BeginArray(FLEncoder NONNULL, size_t reserveCount) FLAPI;
+
1145
+ +
1148
+
1149
+
1158 bool FLEncoder_BeginDict(FLEncoder NONNULL, size_t reserveCount) FLAPI;
+
1159
+ +
1162
+ +
1166
+ +
1169
+
1170
+ +
1173
+
1174
+ +
1179
+
1183 void FLEncoder_WriteValueAgain(FLEncoder e, intptr_t preWrittenValue);
+
1184
+
1185
+ +
1191
+
1192
+ +
1197
+ +
1204
+ +
1209
+ + +
1214
+ +
1221
+ +
1224
+
1230
+
1231
+ +
1249
+ +
1258
+
1259
+ +
1269 FLSlice jsonDelta,
+
1270 FLError *error) FLAPI;
+
1271
+ +
1282 FLSlice jsonDelta,
+
1283 FLEncoder encoder) FLAPI;
+
1284
+
1285
+
1287
+
1288
+ + +
1310
+ + +
1317
+ + +
1324
+
1325
+ + + + + + + + + +
1335
+
1336 static inline void FLSlot_SetArray(FLSlot NONNULL slot, FLArray array) {
+
1337 FLSlot_SetValue(slot, (FLValue)array);
+
1338 }
+
1339
+
1340 static inline void FLSlot_SetDict(FLSlot NONNULL slot, FLDict dict) {
+
1341 FLSlot_SetValue(slot, (FLValue)dict);
+
1342 }
+
1343
+
1344
+
1345 // implementations of the inline methods declared earlier:
+
1346
+
1347 static inline void FLMutableArray_SetNull(FLMutableArray a, uint32_t index) {
+ +
1349 }
+
1350 static inline void FLMutableArray_SetBool(FLMutableArray a, uint32_t index, bool val) {
+
1351 FLSlot_SetBool(FLMutableArray_Set(a, index), val);
+
1352 }
+
1353 static inline void FLMutableArray_SetInt(FLMutableArray a, uint32_t index, int64_t val) {
+
1354 FLSlot_SetInt(FLMutableArray_Set(a, index), val);
+
1355 }
+
1356 static inline void FLMutableArray_SetUInt(FLMutableArray a, uint32_t index, uint64_t val) {
+
1357 FLSlot_SetUInt(FLMutableArray_Set(a, index), val);
+
1358 }
+
1359 static inline void FLMutableArray_SetFloat(FLMutableArray a, uint32_t index, float val) {
+
1360 FLSlot_SetFloat(FLMutableArray_Set(a, index), val);
+
1361 }
+
1362 static inline void FLMutableArray_SetDouble(FLMutableArray a, uint32_t index, double val) {
+
1363 FLSlot_SetDouble(FLMutableArray_Set(a, index), val);
+
1364 }
+
1365 static inline void FLMutableArray_SetString(FLMutableArray a, uint32_t index, FLString val) {
+
1366 FLSlot_SetString(FLMutableArray_Set(a, index), val);
+
1367 }
+
1368 static inline void FLMutableArray_SetData(FLMutableArray a, uint32_t index, FLSlice val) {
+
1369 FLSlot_SetData(FLMutableArray_Set(a, index), val);
+
1370 }
+
1371 static inline void FLMutableArray_SetValue(FLMutableArray a, uint32_t index, FLValue val) {
+
1372 FLSlot_SetValue(FLMutableArray_Set(a, index), val);
+
1373 }
+
1374 static inline void FLMutableArray_SetArray(FLMutableArray a, uint32_t index, FLArray val) {
+ +
1376 }
+
1377 static inline void FLMutableArray_SetDict(FLMutableArray a, uint32_t index, FLDict val) {
+ +
1379 }
+
1380
+ + +
1383 }
+
1384 static inline void FLMutableArray_AppendBool(FLMutableArray a, bool val) {
+ +
1386 }
+
1387 static inline void FLMutableArray_AppendInt(FLMutableArray a, int64_t val) {
+ +
1389 }
+
1390 static inline void FLMutableArray_AppendUInt(FLMutableArray a, uint64_t val) {
+ +
1392 }
+
1393 static inline void FLMutableArray_AppendFloat(FLMutableArray a, float val) {
+ +
1395 }
+
1396 static inline void FLMutableArray_AppendDouble(FLMutableArray a, double val) {
+ +
1398 }
+ + +
1401 }
+ + +
1404 }
+ + +
1407 }
+ + +
1410 }
+ + +
1413 }
+
1414
+
1415 static inline void FLMutableDict_SetNull(FLMutableDict d, FLString key) {
+ +
1417 }
+
1418 static inline void FLMutableDict_SetBool(FLMutableDict d, FLString key, bool val) {
+
1419 FLSlot_SetBool(FLMutableDict_Set(d, key), val);
+
1420 }
+
1421 static inline void FLMutableDict_SetInt(FLMutableDict d, FLString key, int64_t val) {
+
1422 FLSlot_SetInt(FLMutableDict_Set(d, key), val);
+
1423 }
+
1424 static inline void FLMutableDict_SetUInt(FLMutableDict d, FLString key, uint64_t val) {
+
1425 FLSlot_SetUInt(FLMutableDict_Set(d, key), val);
+
1426 }
+
1427 static inline void FLMutableDict_SetFloat(FLMutableDict d, FLString key, float val) {
+
1428 FLSlot_SetFloat(FLMutableDict_Set(d, key), val);
+
1429 }
+
1430 static inline void FLMutableDict_SetDouble(FLMutableDict d, FLString key, double val) {
+
1431 FLSlot_SetDouble(FLMutableDict_Set(d, key), val);
+
1432 }
+
1433 static inline void FLMutableDict_SetString(FLMutableDict d, FLString key, FLString val) {
+
1434 FLSlot_SetString(FLMutableDict_Set(d, key), val);
+
1435 }
+
1436 static inline void FLMutableDict_SetData(FLMutableDict d, FLString key, FLSlice val) {
+
1437 FLSlot_SetData(FLMutableDict_Set(d, key), val);
+
1438 }
+
1439 static inline void FLMutableDict_SetValue(FLMutableDict d, FLString key, FLValue val) {
+
1440 FLSlot_SetValue(FLMutableDict_Set(d, key), val);
+
1441 }
+
1442 static inline void FLMutableDict_SetArray(FLMutableDict d, FLString key, FLArray val) {
+ +
1444 }
+
1445 static inline void FLMutableDict_SetDict(FLMutableDict d, FLString key, FLDict val) {
+ +
1447 }
+
1448
+
1449
+
1452#ifdef __cplusplus
+
1453}
+
1454#endif
+
1455
+
1456
+
1457#ifdef __OBJC__
+
1458// When compiling as Objective-C, include CoreFoundation / Objective-C utilities:
+
1459#include "Fleece+CoreFoundation.h"
+
1460#endif
+
1461
+
1462#endif // _FLEECE_H
+
#define FLPURE
Definition: Base.h:83
+
#define NONNULL
Definition: Base.h:62
+
#define MUST_USE_RESULT
Definition: Base.h:47
+ +
#define FLAPI
Definition: FLSlice.h:25
+ +
#define FLEECE_PUBLIC
Definition: Fleece.h:39
+
static void FLMutableArray_SetInt(FLMutableArray, uint32_t index, int64_t)
Stores an integer into an array.
Definition: Fleece.h:1353
+
bool FLMutableArray_IsChanged(FLMutableArray)
Returns true if the Array has been changed from the source it was copied from.
+
void FLMutableArray_Remove(FLMutableArray array, uint32_t firstIndex, uint32_t count)
Removes contiguous items from the array.
+
FLMutableDict FLMutableArray_GetMutableDict(FLMutableArray, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
+
FLCopyFlags
Definition: Fleece.h:468
+
FLMutableArray FLMutableArray_GetMutableArray(FLMutableArray, uint32_t index)
Convenience function for getting an array-valued property in mutable form.
+
static void FLMutableArray_AppendDict(FLMutableArray, FLDict)
Appends a Fleece dictionary to an array.
Definition: Fleece.h:1411
+
static void FLMutableArray_SetArray(FLMutableArray, uint32_t index, FLArray)
Stores a Fleece array into an array.
Definition: Fleece.h:1374
+
bool FLArray_IsEmpty(FLArray) FLPURE
Returns true if an array is empty (or NULL).
+
static void FLMutableArray_AppendDouble(FLMutableArray, double)
Appends a 64-bit floating point number to an array.
Definition: Fleece.h:1396
+
static void FLMutableArray_SetUInt(FLMutableArray, uint32_t index, uint64_t)
Stores an unsigned integer into an array.
Definition: Fleece.h:1356
+
uint32_t FLArrayIterator_GetCount(const FLArrayIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
+
static void FLMutableArray_AppendUInt(FLMutableArray, uint64_t)
Appends an unsigned integer to an array.
Definition: Fleece.h:1390
+
FLMutableArray FLMutableArray_New(void)
Creates a new empty mutable Array.
+
void FLArrayIterator_Begin(FLArray, FLArrayIterator *)
Initializes a FLArrayIterator struct to iterate over an array.
+
static void FLMutableArray_SetFloat(FLMutableArray, uint32_t index, float)
Stores a 32-bit floating-point number into an array.
Definition: Fleece.h:1359
+
FLValue FLArrayIterator_GetValueAt(const FLArrayIterator *, uint32_t offset) FLPURE
Returns a value in the array at the given offset from the current value.
+
static void FLMutableArray_SetDict(FLMutableArray, uint32_t index, FLDict)
Stores a Fleece dictionary into an array.
Definition: Fleece.h:1377
+
static void FLMutableArray_AppendInt(FLMutableArray, int64_t)
Appends an integer to an array.
Definition: Fleece.h:1387
+
void FLMutableArray_SetChanged(FLMutableArray, bool)
Sets or clears the mutable Array's "changed" flag.
+
static void FLMutableArray_SetString(FLMutableArray, uint32_t index, FLString)
Stores a UTF-8-encoded string into an array.
Definition: Fleece.h:1365
+
static void FLMutableArray_AppendBool(FLMutableArray, bool)
Appends a boolean value to an array.
Definition: Fleece.h:1384
+
static void FLMutableArray_AppendString(FLMutableArray, FLString)
Appends a UTF-8-encoded string to an array.
Definition: Fleece.h:1399
+
FLMutableArray FLArray_AsMutable(FLArray) FLPURE
If the array is mutable, returns it cast to FLMutableArray, else NULL.
+
static void FLMutableArray_SetDouble(FLMutableArray, uint32_t index, double)
Stores a 64-bit floating point number into an array.
Definition: Fleece.h:1362
+
FLValue FLArray_Get(FLArray, uint32_t index) FLPURE
Returns an value at an array index, or NULL if the index is out of range.
+
static void FLMutableArray_AppendValue(FLMutableArray, FLValue)
Appends a Fleece value to an array.
Definition: Fleece.h:1405
+
static FLMutableArray FLMutableArray_Retain(FLMutableArray d)
Increments the ref-count of a mutable Array.
Definition: Fleece.h:494
+
void FLMutableArray_Insert(FLMutableArray array, uint32_t firstIndex, uint32_t count)
Inserts a contiguous range of JSON null values into the array.
+
static void FLMutableArray_SetData(FLMutableArray, uint32_t index, FLSlice)
Stores a binary data blob into an array.
Definition: Fleece.h:1368
+
FLEECE_PUBLIC const FLArray kFLEmptyArray
+
static void FLMutableArray_SetBool(FLMutableArray, uint32_t index, bool)
Stores a boolean value into an array.
Definition: Fleece.h:1350
+
static void FLMutableArray_Release(FLMutableArray d)
Decrements the refcount of (and possibly frees) a mutable Array.
Definition: Fleece.h:498
+
static void FLMutableArray_AppendNull(FLMutableArray)
Appends a JSON null value to an array.
Definition: Fleece.h:1381
+
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:1347
+
static void FLMutableArray_AppendData(FLMutableArray, FLSlice)
Appends a binary data blob to an array.
Definition: Fleece.h:1402
+
FLMutableArray FLArray_MutableCopy(FLArray, FLCopyFlags)
Creates a new mutable Array that's a copy of the source Array.
+
FLValue FLArrayIterator_GetValue(const FLArrayIterator *) FLPURE
Returns the current value being iterated over.
+
uint32_t FLArray_Count(FLArray) FLPURE
Returns the number of items in an array, or 0 if the pointer is NULL.
+
static void FLMutableArray_AppendFloat(FLMutableArray, float)
Appends a 32-bit floating-point number to an array.
Definition: Fleece.h:1393
+
void FLMutableArray_Resize(FLMutableArray array, uint32_t size)
Changes the size of an array.
+
static void FLMutableArray_SetValue(FLMutableArray, uint32_t index, FLValue)
Stores a Fleece value into an array.
Definition: Fleece.h:1371
+
FLArray FLMutableArray_GetSource(FLMutableArray)
If the Array was created by FLArray_MutableCopy, returns the original source Array.
+
static void FLMutableArray_AppendArray(FLMutableArray, FLArray)
Appends a Fleece array to an array.
Definition: Fleece.h:1408
+
@ kFLDeepCopy
Definition: Fleece.h:470
+
@ kFLCopyImmutables
Definition: Fleece.h:471
+
@ kFLDefaultCopy
Definition: Fleece.h:469
+
@ kFLDeepCopyImmutables
Definition: Fleece.h:472
+
void FLDeepIterator_GetPath(FLDeepIterator, FLPathComponent **outPath, size_t *outDepth)
Returns the path as an array of FLPathComponents.
+
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:806
+
FLValue FLDeepIterator_GetParent(FLDeepIterator)
Returns the parent/container of the current value, or NULL at the end of iteration.
+
void FLDeepIterator_Free(FLDeepIterator)
+
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.
+
FLDeepIterator FLDeepIterator_New(FLValue)
Creates a FLDeepIterator to iterate over a dictionary.
+
FLValue FLDeepIterator_GetValue(FLDeepIterator)
Returns the current value being iterated over.
+
FLSliceResult FLDeepIterator_GetJSONPointer(FLDeepIterator)
Returns the current path in JSONPointer format (RFC 6901).
+
FLSliceResult FLDeepIterator_GetPathString(FLDeepIterator)
Returns the current path in JavaScript format.
+
void FLDictIterator_Begin(FLDict, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
+
bool FLMutableDict_IsChanged(FLMutableDict)
Returns true if the Dict has been changed from the source it was copied from.
+
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:1445
+
static void FLMutableDict_SetNull(FLMutableDict, FLString key)
Stores a JSON null value into a mutable dictionary.
Definition: Fleece.h:1415
+
FLMutableDict FLMutableDict_New(void)
Creates a new empty mutable Dict.
+
static FLMutableDict FLMutableDict_Retain(FLMutableDict d)
Increments the ref-count of a mutable Dict.
Definition: Fleece.h:728
+
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
+
uint32_t FLDict_Count(FLDict) FLPURE
Returns the number of items in a dictionary, or 0 if the pointer is NULL.
+
FLValue FLDict_GetWithKey(FLDict, FLDictKey *)
Looks up a key in a dictionary using an FLDictKey.
+
void FLMutableDict_SetChanged(FLMutableDict, bool)
Sets or clears the mutable Dict's "changed" flag.
+
static void FLMutableDict_SetData(FLMutableDict, FLString key, FLSlice)
Stores a binary data blob into a mutable dictionary.
Definition: Fleece.h:1436
+
FLMutableArray FLMutableDict_GetMutableArray(FLMutableDict, FLString key)
Convenience function for getting an array-valued property in mutable form.
+
FLValue FLDict_Get(FLDict, FLSlice keyString) FLPURE
Looks up a key in a dictionary, returning its value.
+
uint32_t FLDictIterator_GetCount(const FLDictIterator *) FLPURE
Returns the number of items remaining to be iterated, including the current one.
+
void FLMutableDict_RemoveAll(FLMutableDict)
Removes all keys and values.
+
FLEECE_PUBLIC const FLDict kFLEmptyDict
+
FLMutableDict FLDict_MutableCopy(FLDict source, FLCopyFlags)
Creates a new mutable Dict that's a copy of the source Dict.
+
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:1427
+
static void FLMutableDict_SetInt(FLMutableDict, FLString key, int64_t)
Stores an integer into a mutable dictionary.
Definition: Fleece.h:1421
+
static void FLMutableDict_SetValue(FLMutableDict, FLString key, FLValue)
Stores a Fleece value into a mutable dictionary.
Definition: Fleece.h:1439
+
static void FLMutableDict_SetDouble(FLMutableDict, FLString key, double)
Stores a 64-bit floating point number into a mutable dictionary.
Definition: Fleece.h:1430
+
FLDict FLMutableDict_GetSource(FLMutableDict)
If the Dict was created by FLDict_MutableCopy, returns the original source Dict.
+
FLMutableDict FLDict_AsMutable(FLDict) FLPURE
If the dictionary is mutable, returns it cast to FLMutableDict, else NULL.
+
bool FLDict_IsEmpty(FLDict) FLPURE
Returns true if a dictionary is empty (or NULL).
+
static void FLMutableDict_SetBool(FLMutableDict, FLString key, bool)
Stores a boolean value into a mutable dictionary.
Definition: Fleece.h:1418
+
FLMutableDict FLMutableDict_GetMutableDict(FLMutableDict, FLString key)
Convenience function for getting a dict-valued property in mutable form.
+
static void FLMutableDict_SetArray(FLMutableDict, FLString key, FLArray)
Stores a Fleece array into a mutable dictionary.
Definition: Fleece.h:1442
+
static void FLMutableDict_Release(FLMutableDict d)
Decrements the refcount of (and possibly frees) a mutable Dict.
Definition: Fleece.h:733
+
static void FLMutableDict_SetString(FLMutableDict, FLString key, FLString)
Stores a UTF-8-encoded string into a mutable dictionary.
Definition: Fleece.h:1433
+
void FLMutableDict_Remove(FLMutableDict, FLString key)
Removes the value for a key.
+
FLValue FLDictIterator_GetKey(const FLDictIterator *) FLPURE
Returns the current key being iterated over.
+
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
+
FLValue FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
+
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:1424
+
bool FLEncoder_ConvertJSON(FLEncoder, FLSlice json)
Parses JSON data and writes the object(s) to the encoder.
+
const char * FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
+
FLSliceResult FLEncoder_Snip(FLEncoder e)
Returns the data written so far as a standalone Fleece document, whose root is the last value written...
+
bool FLEncoder_WriteUInt(FLEncoder, uint64_t)
Writes an unsigned integer to an encoder.
+
void FLEncoder_SetSharedKeys(FLEncoder, FLSharedKeys)
Tells the encoder to use a shared-keys mapping when encoding dictionary keys.
+
void FLEncoder_Free(FLEncoder)
Frees the space used by an encoder.
+
intptr_t FLEncoder_LastValueWritten(FLEncoder e)
Returns an opaque reference to the last complete value written to the encoder, if possible.
+
FLEncoder FLEncoder_NewWritingToFile(FILE *, bool uniqueStrings)
Creates a new Fleece encoder that writes to a file, not to memory.
+
void FLEncoder_SetExtraInfo(FLEncoder, void *info)
Associates an arbitrary user-defined value with the encoder.
+
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.
+
bool FLEncoder_WriteInt(FLEncoder, int64_t)
Writes an integer to an encoder.
+
void FLEncoder_WriteValueAgain(FLEncoder e, intptr_t preWrittenValue)
Writes another reference (a "pointer") to an already-written value, given a reference previously retu...
+
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.
+
FLDoc FLEncoder_FinishDoc(FLEncoder, FLError *)
Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc.
+
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.
+
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...
+
bool FLEncoder_WriteNull(FLEncoder)
Writes a null value to an encoder.
+
MUST_USE_RESULT FLSliceResult FLEncoder_Finish(FLEncoder e, FLError *outError)
Ends encoding; if there has been no error, it returns the encoded data, else null.
+
bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount)
Begins writing a dictionary value to 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:996
+
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.
+
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.
+
@ kFLEncodeFleece
Fleece encoding.
Definition: Fleece.h:997
+
@ kFLEncodeJSON5
JSON5, an extension of JSON with a more readable syntax
Definition: Fleece.h:999
+
@ kFLEncodeJSON
JSON encoding.
Definition: Fleece.h:998
+
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:875
+
bool FLKeyPath_Equals(FLKeyPath path1, FLKeyPath path2)
Equality test.
+
FLStringResult FLKeyPath_ToString(FLKeyPath path)
Returns a path in string form.
+
void FLKeyPath_Free(FLKeyPath)
Frees a compiled FLKeyPath object.
+
FLValue FLKeyPath_EvalOnce(FLSlice specifier, FLValue root, FLError *error)
Evaluates a key-path from a specifier string, for a given Fleece root object.
+
FLKeyPath FLKeyPath_New(FLSlice specifier, FLError *error)
Creates a new FLKeyPath object by compiling a path specifier string.
+
FLValue FLKeyPath_Eval(FLKeyPath, FLValue root)
Evaluates a compiled key-path for a given Fleece root 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)
+
struct _FLSharedKeyScope * FLSharedKeyScope
Definition: Fleece.h:973
+
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.
+
void FLSharedKeys_Release(FLSharedKeys)
Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero.
+
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...
+
FLSharedKeys FLSharedKeys_Retain(FLSharedKeys)
Increments the reference count of an FLSharedKeys.
+
bool FLSharedKeys_LoadState(FLSharedKeys, FLValue)
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_Wr...
+
void FLSharedKeyScope_Free(FLSharedKeyScope)
+
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.
+
bool(* FLSharedKeysReadCallback)(void *context, FLSharedKeys)
Definition: Fleece.h:930
+
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.
+
FLSharedKeys FLSharedKeys_NewWithRead(FLSharedKeysReadCallback, void *context)
+
FLValueType
Types of Fleece values.
Definition: Fleece.h:264
+
static void FLArray_Release(FLArray v)
Definition: Fleece.h:368
+
FLValueType FLValue_GetType(FLValue) FLPURE
Returns the data type of an arbitrary Value.
+
int64_t FLTimestamp
A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC....
Definition: Fleece.h:277
+
FLTimestamp FLValue_AsTimestamp(FLValue) FLPURE
Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure.
+
FLArray FLValue_AsArray(FLValue) FLPURE
If a FLValue represents an array, returns it cast to FLArray, else NULL.
+
FLStringResult FLValue_ToString(FLValue)
Returns a string representation of any scalar value.
+
bool FLValue_IsMutable(FLValue) FLPURE
Returns true if the value is mutable.
+
FLEECE_PUBLIC const FLValue kFLNullValue
A constant null value (not a NULL pointer!)
+
FLValue FLValue_NewString(FLString)
Allocates a string value on the heap.
+
static FLDict FLDict_Retain(FLDict v)
Definition: Fleece.h:369
+
FLString FLValue_AsString(FLValue) FLPURE
Returns the exact contents of a string value, or null for all other types.
+
bool FLValue_IsEqual(FLValue v1, FLValue v2) FLPURE
Compares two values for equality.
+
bool FLValue_IsInteger(FLValue) FLPURE
Returns true if the value is non-NULL and represents an integer.
+
static FLArray FLArray_Retain(FLArray v)
Definition: Fleece.h:367
+
static void FLDict_Release(FLDict v)
Definition: Fleece.h:370
+
bool FLValue_AsBool(FLValue) FLPURE
Returns a value coerced to boolean.
+
FLSlice FLValue_AsData(FLValue) FLPURE
Returns the exact contents of a data value, or null for all other types.
+
bool FLValue_IsDouble(FLValue)
Returns true if the value is non-NULL and represents a 64-bit floating-point number.
+
float FLValue_AsFloat(FLValue) FLPURE
Returns a value coerced to a 32-bit floating point number.
+
bool FLValue_IsUnsigned(FLValue) FLPURE
Returns true if the value is non-NULL and represents an integer >= 2^63.
+
FLDict FLValue_AsDict(FLValue) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
+
FLValue FLValue_Retain(FLValue)
If this value is mutable (and thus heap-based) its ref-count is incremented.
+
double FLValue_AsDouble(FLValue) FLPURE
Returns a value coerced to a 32-bit floating point number.
+
void FLValue_Release(FLValue)
If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero t...
+
uint64_t FLValue_AsUnsigned(FLValue) FLPURE
Returns a value coerced to an unsigned integer.
+
int64_t FLValue_AsInt(FLValue) FLPURE
Returns a value coerced to an integer.
+
FLValue FLValue_NewData(FLSlice)
Allocates a data/blob value on the heap.
+
@ kFLArray
An array of values.
Definition: Fleece.h:271
+
@ kFLNumber
A numeric value, either integer or floating-point.
Definition: Fleece.h:268
+
@ kFLBoolean
A true or false value.
Definition: Fleece.h:267
+
@ kFLString
A string.
Definition: Fleece.h:269
+
@ kFLNull
Equivalent to a JSON 'null'.
Definition: Fleece.h:266
+
@ 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:265
+
@ kFLDict
A mapping of strings to values.
Definition: Fleece.h:272
+
@ kFLData
Binary data (no JSON equivalent)
Definition: Fleece.h:270
+
void FLSlot_SetValue(FLSlot, FLValue)
Stores an FLValue into a slot.
+
void FLSlot_SetNull(FLSlot)
Stores a JSON null into a slot.
+
static void FLSlot_SetArray(FLSlot slot, FLArray array)
Definition: Fleece.h:1336
+
static void FLSlot_SetDict(FLSlot slot, FLDict dict)
Definition: Fleece.h:1340
+
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.
+
MUST_USE_RESULT FLSlot FLMutableDict_Set(FLMutableDict FL_NONNULL, FLString key)
Returns an FLSlot that refers to the given key/value pair of the given dictionary.
+
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.
+
FLSliceResult FLApplyJSONDelta(FLValue old, FLSlice jsonDelta, FLError *error)
Applies the JSON data created by CreateJSONDelta to the value old, which must be equal to the old val...
+
bool FLEncodeJSONDelta(FLValue old, FLValue nuu, FLEncoder jsonEncoder)
Writes JSON that describes the changes to turn the value old into nuu.
+
bool FLEncodeApplyingJSONDelta(FLValue 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 old, FLValue nuu)
Returns JSON that encodes the changes to turn the value old into nuu.
+
FLStringResult FLJSON5_ToJSON(FLString json5, FLStringResult *outErrorMessage, size_t *outErrorPos, FLError *outError)
Converts valid JSON5 https://json5.org to JSON.
+
FLStringResult FLValue_ToJSON(FLValue)
Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON ...
+
FLStringResult FLValue_ToJSONX(FLValue v, bool json5, bool canonicalForm)
Most general Fleece to JSON converter.
+
FLStringResult FLValue_ToJSON5(FLValue v)
Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unq...
+
const char * FLDump(FLValue)
Debugging function that returns a C string of JSON.
+
const char * FLDumpData(FLSlice data)
Debugging function that returns a C string of JSON.
+
FLDoc FLDoc_FromJSON(FLSlice json, FLError *outError)
Creates an FLDoc from JSON-encoded data.
+
FLDoc FLDoc_FromResultData(FLSliceResult data, FLTrust, FLSharedKeys, FLSlice externData)
Creates an FLDoc from Fleece-encoded data that's been returned as a result from FLSlice_Copy or other...
+
void * FLDoc_GetAssociated(FLDoc doc, const char *type) FLPURE
Returns the pointer associated with the document.
+
FLDoc FLValue_FindDoc(FLValue) FLPURE
Looks up the Doc containing the Value, or NULL if the Value was created without a Doc.
+
bool FLDoc_SetAssociated(FLDoc doc, void *pointer, const char *type)
Associates an arbitrary pointer value with a document, and thus its contained values.
+
FLDoc FLDoc_Retain(FLDoc)
Adds a reference to an FLDoc.
+
FLSharedKeys FLDoc_GetSharedKeys(FLDoc) FLPURE
Returns the FLSharedKeys used by this FLDoc, as specified when it was created.
+
struct _FLDoc * FLDoc
A reference to a document.
Definition: Fleece.h:95
+
FLValue FLDoc_GetRoot(FLDoc) FLPURE
Returns the root value in the FLDoc, usually an FLDict.
+
FLValue FLValue_FromData(FLSlice data, FLTrust) FLPURE
Returns a pointer to the root value in the encoded data, or NULL if validation failed.
+
FLStringResult FLData_Dump(FLSlice data)
Produces a human-readable dump of the Value encoded in the data.
+
FLTrust
Specifies whether not input data is trusted to be 100% valid Fleece.
Definition: Fleece.h:100
+
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: Fleece.h:96
+
FLSliceResult FLDoc_GetAllocedData(FLDoc) FLPURE
Returns the FLSliceResult data owned by the document, if any, else a null slice.
+
FLSliceResult FLData_ConvertJSON(FLSlice json, FLError *outError)
Directly converts JSON data to Fleece-encoded data.
+
FLSlice FLDoc_GetData(FLDoc) FLPURE
Returns the encoded Fleece data backing the document.
+
void FLDoc_Release(FLDoc)
Releases a reference to an FLDoc.
+
@ kFLTrusted
Input data is trusted to be valid.
Definition: Fleece.h:110
+
@ kFLUntrusted
Input data is not trusted to be valid, and will be fully validated by the API call.
Definition: Fleece.h:102
+
struct _FLDict * FLMutableDict
A reference to a mutable dictionary.
Definition: Fleece.h:60
+
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:57
+
struct _FLSlot * FLSlot
A reference to a mutable array/dict item.
Definition: Fleece.h:58
+
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: Fleece.h:59
+
FLError
Error codes returned from some API calls.
Definition: Fleece.h:66
+
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:56
+
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: Fleece.h:61
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
@ kFLNotFound
Definition: Fleece.h:75
+
@ kFLInvalidData
Definition: Fleece.h:70
+
@ kFLInternalError
Definition: Fleece.h:74
+
@ kFLSharedKeysStateError
Definition: Fleece.h:76
+
@ kFLOutOfRange
Definition: Fleece.h:69
+
@ kFLEncodeError
Definition: Fleece.h:71
+
@ kFLMemoryError
Definition: Fleece.h:68
+
@ kFLUnsupported
Definition: Fleece.h:78
+
@ kFLUnknownValue
Definition: Fleece.h:73
+
@ kFLJSONError
Definition: Fleece.h:72
+
@ kFLPOSIXError
Definition: Fleece.h:77
+
@ kFLNoError
Definition: Fleece.h:67
+
Opaque array iterator.
Definition: Fleece.h:434
+
Opaque dictionary iterator.
Definition: Fleece.h:638
+
Opaque key for a dictionary.
Definition: Fleece.h:680
+
Definition: Fleece.h:837
+
uint32_t index
Array index, only if there's no key.
Definition: Fleece.h:839
+
FLSlice key
Dict key, or kFLSliceNull if none.
Definition: Fleece.h:838
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:58
diff --git a/docs/C/html/annotated.html b/docs/C/html/annotated.html index f5c4761f..a0b68fe4 100644 --- a/docs/C/html/annotated.html +++ b/docs/C/html/annotated.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Data Structures @@ -30,21 +30,22 @@
- + +/* @license-end */ +

@@ -62,39 +63,34 @@
-
-
Data Structures
+
Data Structures
Here are the data structures with brief descriptions:
- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +
 CCBLConnectionStatus
 CCBLDatabaseConfigurationDatabase configuration options
 CCBLEncryptionKeyEncryption key specified in a CBLDatabaseConfiguration
 CCBLErrorA struct holding information about an error
 CCBLIndexSpecParameters for creating a database index
 CCBLListenerAuthenticatorDescribes how clients should authenticate to a CBLURLEndpointListener
 CCBLLogFileConfigurationThe properties for configuring logging to files
 CCBLProxySettingsProxy settings for the replicator
 CCBLReplicatedDocumentInformation about a document that's been pushed or pulled
 CCBLReplicatorConfigurationThe configuration of a replicator
 CCBLReplicatorProgressA fractional progress value, ranging from 0.0 to 1.0 as replication progresses
 CCBLReplicatorStatusA replicator's current status
 CCBLURLEndpointListenerConfigurationConfiguration of a P2P connection listener
 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
 CCBLDatabaseConfigurationDatabase configuration options
 CCBLEncryptionKeyEncryption key specified in a CBLDatabaseConfiguration
 CCBLErrorA struct holding information about an error
 CCBLFullTextIndexConfigurationFull-Text Index Configuration
 CCBLLogFileConfigurationThe properties for configuring logging to files
 CCBLProxySettingsProxy settings for the replicator
 CCBLReplicatedDocumentInformation about a document that's been pushed or pulled
 CCBLReplicatorConfigurationThe configuration of a replicator
 CCBLReplicatorProgressA fractional progress value, ranging from 0.0 to 1.0 as replication progresses
 CCBLReplicatorStatusA replicator's current status
 CCBLValueIndexConfigurationValue Index Configuration
 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/classes.html b/docs/C/html/classes.html index df8c42dd..b9717c34 100644 --- a/docs/C/html/classes.html +++ b/docs/C/html/classes.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Data Structure Index @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -62,28 +63,22 @@
-
-
Data Structure Index
+
Data Structure Index
diff --git a/docs/C/html/dir_17ad6c03ac95e637f87755575f40449e.html b/docs/C/html/dir_17ad6c03ac95e637f87755575f40449e.html index 1fb1b603..681158fd 100644 --- a/docs/C/html/dir_17ad6c03ac95e637f87755575f40449e.html +++ b/docs/C/html/dir_17ad6c03ac95e637f87755575f40449e.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/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_2ecb5472ec723897fff4bd7d3317a27a.html b/docs/C/html/dir_2ecb5472ec723897fff4bd7d3317a27a.html index a37e9260..a1d2e24e 100644 --- a/docs/C/html/dir_2ecb5472ec723897fff4bd7d3317a27a.html +++ b/docs/C/html/dir_2ecb5472ec723897fff4bd7d3317a27a.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece Directory Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
fleece Directory Reference
+
fleece Directory Reference
- - + - + - + - +

+

Files

file  Base.h [code]
file  Base.h [code]
 
file  Fleece+CoreFoundation.h [code]
file  Fleece+CoreFoundation.h [code]
 
file  Fleece.h [code]
file  Fleece.h [code]
 
file  FLSlice.h [code]
file  FLSlice.h [code]
 
diff --git a/docs/C/html/dir_42eeca32d5bbc87802b2b9475842edbd.html b/docs/C/html/dir_42eeca32d5bbc87802b2b9475842edbd.html index 87649183..b18c8920 100644 --- a/docs/C/html/dir_42eeca32d5bbc87802b2b9475842edbd.html +++ b/docs/C/html/dir_42eeca32d5bbc87802b2b9475842edbd.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include/cbl Directory Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
cbl Directory Reference
+
cbl Directory Reference
diff --git a/docs/C/html/dir_644f78e2d6809b3b77fed6ee8030c9f9.html b/docs/C/html/dir_644f78e2d6809b3b77fed6ee8030c9f9.html index 7cedbc71..ba9972cf 100644 --- a/docs/C/html/dir_644f78e2d6809b3b77fed6ee8030c9f9.html +++ b/docs/C/html/dir_644f78e2d6809b3b77fed6ee8030c9f9.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/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_b346636a750f54d78818ae1d73f9fdd0.html b/docs/C/html/dir_b346636a750f54d78818ae1d73f9fdd0.html index 731233c1..384ef5de 100644 --- a/docs/C/html/dir_b346636a750f54d78818ae1d73f9fdd0.html +++ b/docs/C/html/dir_b346636a750f54d78818ae1d73f9fdd0.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core Directory Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
couchbase-lite-core Directory Reference
+
couchbase-lite-core Directory Reference
- - +

+

Directories

directory  vendor
directory  vendor
 
diff --git a/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html b/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html index f3a1c40b..5d20ffa6 100644 --- a/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html +++ b/docs/C/html/dir_c5da75fdc1d6c57999112ed830c87a3c.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor Directory Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
vendor Directory Reference
+
vendor Directory Reference
- - +

+

Directories

directory  couchbase-lite-core
directory  couchbase-lite-core
 
diff --git a/docs/C/html/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/C/html/dir_d44c64559bbebec7f509842c48db8b23.html index d99ac323..57d48f73 100644 --- a/docs/C/html/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/docs/C/html/dir_d44c64559bbebec7f509842c48db8b23.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: include Directory Reference @@ -30,21 +30,22 @@ - + +/* @license-end */ +
-
-
include Directory Reference
+
include Directory Reference
- - +

+

Directories

directory  cbl
directory  cbl
 
diff --git a/docs/C/html/dir_f77815f292c27e5d3b6029f59ba49998.html b/docs/C/html/dir_f77815f292c27e5d3b6029f59ba49998.html index 698f8763..c33cd0e5 100644 --- a/docs/C/html/dir_f77815f292c27e5d3b6029f59ba49998.html +++ b/docs/C/html/dir_f77815f292c27e5d3b6029f59ba49998.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: vendor/couchbase-lite-core/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 e2515926..8e9cca36 100644 --- a/docs/C/html/doxygen.css +++ b/docs/C/html/doxygen.css @@ -1,4 +1,4 @@ -/* The standard CSS for doxygen 1.8.15 */ +/* The standard CSS for doxygen 1.9.2 */ body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; @@ -53,17 +53,24 @@ dt { font-weight: bold; } -div.multicol { +ul.multicol { -moz-column-gap: 1em; -webkit-column-gap: 1em; + column-gap: 1em; -moz-column-count: 3; -webkit-column-count: 3; + column-count: 3; } p.startli, p.startdd { margin-top: 2px; } +th p.starttd, th p.intertd, th p.endtd { + font-size: 100%; + font-weight: 700; +} + p.starttd { margin-top: 0px; } @@ -96,30 +103,96 @@ caption { } span.legend { - font-size: 70%; - text-align: center; + font-size: 70%; + text-align: center; } h3.version { - font-size: 90%; - text-align: center; + font-size: 90%; + text-align: center; } -div.qindex, div.navtab{ - background-color: #EBEFF6; - border: 1px solid #A3B4D7; - text-align: center; +div.navtab { + border-right: 1px solid #A3B4D7; + padding-right: 15px; + text-align: right; + line-height: 110%; } -div.qindex, div.navpath { +div.navtab table { + border-spacing: 0; +} + +td.navtab { + padding-right: 6px; + padding-left: 6px; +} +td.navtabHL { + background-image: url('tab_a.png'); + background-repeat:repeat-x; + padding-right: 6px; + padding-left: 6px; +} + +td.navtabHL a, td.navtabHL a:visited { + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +} + +a.navtab { + font-weight: bold; +} + +div.qindex{ + text-align: center; width: 100%; line-height: 140%; + font-size: 130%; + color: #A0A0A0; } -div.navtab { - margin-right: 15px; +dt.alphachar{ + font-size: 180%; + font-weight: bold; +} + +.alphachar a{ + color: black; +} + +.alphachar a:hover, .alphachar a:visited{ + text-decoration: none; } +.classindex dl { + padding: 25px; + column-count:1 +} + +.classindex dd { + display:inline-block; + margin-left: 50px; + width: 90%; + line-height: 1.15em; +} + +.classindex dl.odd { + background-color: #F8F9FC; +} + +@media(min-width: 1120px) { + .classindex dl { + column-count:2 + } +} + +@media(min-width: 1320px) { + .classindex dl { + column-count:3 + } +} + + /* @group Link Styling */ a { @@ -136,17 +209,6 @@ a:hover { text-decoration: underline; } -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #9CAFD4; - color: #FFFFFF; - border: 1px double #869DCA; -} - .contents a.qindexHL:visited { color: #FFFFFF; } @@ -166,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 { @@ -251,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; @@ -377,6 +467,12 @@ img.footer { vertical-align: middle; } +.compoundTemplParams { + color: #4665A2; + font-size: 80%; + line-height: 120%; +} + /* @group Code Colorization */ span.keyword { @@ -533,7 +629,7 @@ table.memberdecls { white-space: nowrap; } -.memItemRight { +.memItemRight, .memTemplItemRight { width: 100%; } @@ -701,7 +797,7 @@ dl.reflist dd { padding-left: 0px; } -.params .paramname, .retval .paramname, .tparams .paramname { +.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname { font-weight: bold; vertical-align: top; } @@ -1279,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; } @@ -1351,10 +1447,12 @@ dl.citelist dt { font-weight:bold; margin-right:10px; padding:5px; + text-align:right; + width:52px; } dl.citelist dd { - margin:2px 0; + margin:2px 0 2px 72px; padding:5px 0; } @@ -1417,6 +1515,12 @@ div.toc li.level4 { margin-left: 45px; } +span.emoji { + /* font family used at the site: https://unicode.org/emoji/charts/full-emoji-list.html + * font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", Times, Symbola, Aegyptus, Code2000, Code2001, Code2002, Musica, serif, LastResort; + */ +} + .PageDocRTL-title div.toc li.level1 { margin-left: 0 !important; margin-right: 0; @@ -1654,47 +1758,6 @@ tr.heading h2 { /* @group Markdown */ -/* -table.markdownTable { - border-collapse:collapse; - margin-top: 4px; - margin-bottom: 4px; -} - -table.markdownTable td, table.markdownTable th { - border: 1px solid #2D4068; - padding: 3px 7px 2px; -} - -table.markdownTableHead tr { -} - -table.markdownTableBodyLeft td, table.markdownTable th { - border: 1px solid #2D4068; - padding: 3px 7px 2px; -} - -th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone { - background-color: #374F7F; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; -} - -th.markdownTableHeadLeft { - text-align: left -} - -th.markdownTableHeadRight { - text-align: right -} - -th.markdownTableHeadCenter { - text-align: center -} -*/ - table.markdownTable { border-collapse:collapse; margin-top: 4px; diff --git a/docs/C/html/doxygen.svg b/docs/C/html/doxygen.svg new file mode 100644 index 00000000..d42dad52 --- /dev/null +++ b/docs/C/html/doxygen.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/C/html/dynsections.js b/docs/C/html/dynsections.js index ea0a7b39..3174bd7b 100644 --- a/docs/C/html/dynsections.js +++ b/docs/C/html/dynsections.js @@ -1,25 +1,26 @@ /* - @licstart The following is the entire license notice for the - JavaScript code in this file. + @licstart The following is the entire license notice for the JavaScript code in this file. - Copyright (C) 1997-2017 by Dimitri van Heesch + The MIT License (MIT) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + Copyright (C) 1997-2020 by Dimitri van Heesch - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. - @licend The above is the entire license notice - for the JavaScript code in this file + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file */ function toggleVisibility(linkObj) { diff --git a/docs/C/html/files.html b/docs/C/html/files.html index 1595b172..f01a76e4 100644 --- a/docs/C/html/files.html +++ b/docs/C/html/files.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: File List @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -62,8 +63,7 @@
-
-
File List
+
File List
Here is a list of all files with brief descriptions:
diff --git a/docs/C/html/functions.html b/docs/C/html/functions.html index 91526776..3a186555 100644 --- a/docs/C/html/functions.html +++ b/docs/C/html/functions.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Data Fields @@ -30,21 +30,22 @@
- + +/* @license-end */ + @@ -64,243 +65,124 @@
Here is a list of all struct and union fields with links to the structures/unions they belong to:
-

- a -

- - -

- b -

diff --git a/docs/C/html/functions_vars.html b/docs/C/html/functions_vars.html index f2344b1c..e1824634 100644 --- a/docs/C/html/functions_vars.html +++ b/docs/C/html/functions_vars.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Data Fields - Variables @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,243 +65,124 @@
  -

- a -

- - -

- b -

diff --git a/docs/C/html/globals.html b/docs/C/html/globals.html index e8caf2fa..a83aadfe 100644 --- a/docs/C/html/globals.html +++ b/docs/C/html/globals.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,62 +65,29 @@
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 008e3c54..e9d207ed 100644 --- a/docs/C/html/globals_c.html +++ b/docs/C/html/globals_c.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,734 +65,202 @@
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 4514d36c..ddf06877 100644 --- a/docs/C/html/globals_defs.html +++ b/docs/C/html/globals_defs.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,128 +65,88 @@
  -

- _ -

diff --git a/docs/C/html/globals_enum.html b/docs/C/html/globals_enum.html index 4083fc2b..4ce0c85f 100644 --- a/docs/C/html/globals_enum.html +++ b/docs/C/html/globals_enum.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -63,76 +64,30 @@
 
diff --git a/docs/C/html/globals_eval.html b/docs/C/html/globals_eval.html index 677cd538..0dfae35b 100644 --- a/docs/C/html/globals_eval.html +++ b/docs/C/html/globals_eval.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,375 +65,126 @@
  -

- c -

- - -

- k -

diff --git a/docs/C/html/globals_f.html b/docs/C/html/globals_f.html index d80c4f55..29dc1fa8 100644 --- a/docs/C/html/globals_f.html +++ b/docs/C/html/globals_f.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,677 +65,281 @@
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 ea995982..1ed8a0b2 100644 --- a/docs/C/html/globals_func.html +++ b/docs/C/html/globals_func.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,20 +65,14 @@
  -

- _ -

diff --git a/docs/C/html/globals_func_c.html b/docs/C/html/globals_func_c.html index bb134219..cd9d657f 100644 --- a/docs/C/html/globals_func_c.html +++ b/docs/C/html/globals_func_c.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,413 +65,150 @@
  -

- c -

diff --git a/docs/C/html/globals_func_f.html b/docs/C/html/globals_func_f.html index caa14d43..dc8944e9 100644 --- a/docs/C/html/globals_func_f.html +++ b/docs/C/html/globals_func_f.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,593 +65,252 @@
  -

- f -

diff --git a/docs/C/html/globals_h.html b/docs/C/html/globals_h.html new file mode 100644 index 00000000..a77aabca --- /dev/null +++ b/docs/C/html/globals_h.html @@ -0,0 +1,77 @@ + + + + + + + +Couchbase Lite C: Globals + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+
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 d75babdc..b555bf0e 100644 --- a/docs/C/html/globals_k.html +++ b/docs/C/html/globals_k.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,230 +65,138 @@
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_m.html b/docs/C/html/globals_m.html index e8f42b3f..b877defc 100644 --- a/docs/C/html/globals_m.html +++ b/docs/C/html/globals_m.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,17 +65,13 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- m -

    -
  • MUST_USE_RESULT -: Base.h -
  • +

    - m -

diff --git a/docs/C/html/globals_n.html b/docs/C/html/globals_n.html index 851f8ada..7dd8d57d 100644 --- a/docs/C/html/globals_n.html +++ b/docs/C/html/globals_n.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,17 +65,13 @@
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_r.html b/docs/C/html/globals_r.html index 3f6d3b86..3fa02db1 100644 --- a/docs/C/html/globals_r.html +++ b/docs/C/html/globals_r.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,17 +65,13 @@
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
-

- r -

    -
  • RETURNS_NONNULL -: Base.h -
  • +

    - r -

diff --git a/docs/C/html/globals_s.html b/docs/C/html/globals_s.html new file mode 100644 index 00000000..ff565256 --- /dev/null +++ b/docs/C/html/globals_s.html @@ -0,0 +1,77 @@ + + + + + + + +Couchbase Lite C: Globals + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+
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 8f79aac9..7fd9a582 100644 --- a/docs/C/html/globals_type.html +++ b/docs/C/html/globals_type.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -64,150 +65,59 @@
  -

- c -

diff --git a/docs/C/html/globals_vars.html b/docs/C/html/globals_vars.html index e3aaba90..7cfe6ac2 100644 --- a/docs/C/html/globals_vars.html +++ b/docs/C/html/globals_vars.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Globals @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -63,43 +64,23 @@
 
diff --git a/docs/C/html/globals_w.html b/docs/C/html/globals_w.html new file mode 100644 index 00000000..1b27c754 --- /dev/null +++ b/docs/C/html/globals_w.html @@ -0,0 +1,77 @@ + + + + + + + +Couchbase Lite C: Globals + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
+ +

- w -

    +
  • WINAPI_FAMILY_PARTITION : Base.h
  • +
+
+ + + + diff --git a/docs/C/html/group___c_f.html b/docs/C/html/group___c_f.html index aac90aa3..7772c2f6 100644 --- a/docs/C/html/group___c_f.html +++ b/docs/C/html/group___c_f.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Fleece CoreFoundation and Objective-C Helpers @@ -30,21 +30,22 @@ - + +/* @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...
 Writes a Core Foundation (or Objective-C) object to an Encoder. More...
 
CFTypeRef FLValue_CopyCFObject (FLValue)
 Returns a Value as a corresponding CoreFoundation object. More...
 Returns a Value as a corresponding CoreFoundation object. More...
 
FLValue FLDict_GetWithCFString (FLDict, CFStringRef)
 Same as FLDictGet, but takes the key as a CFStringRef. More...
 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___f_l_array.html b/docs/C/html/group___f_l_array.html index 565965ba..e2ea2d13 100644 --- a/docs/C/html/group___f_l_array.html +++ b/docs/C/html/group___f_l_array.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Fleece Arrays @@ -30,21 +30,22 @@ - + +/* @license-end */ + @@ -66,116 +67,185 @@ 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) FLPURE
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 Returns the number of items in an array, or 0 if the pointer is NULL. More...
 
bool FLArray_IsEmpty (FLArray) FLPURE
 Returns true if an array is empty (or NULL). More...
 Returns true if an array is empty (or NULL). More...
 
FLMutableArray FLArray_AsMutable (FLArray) FLPURE
 If the array is mutable, returns it cast to FLMutableArray, else NULL. More...
 If the array is mutable, returns it cast to FLMutableArray, else NULL. More...
 
FLValue FLArray_Get (FLArray, uint32_t index) FLPURE
 Returns an value at an array index, or NULL if the index is out of range. More...
 Returns an value at an array index, or NULL if the index is out of range. More...
 
- - - -

+

Variables

const FLArray kFLEmptyArray
 
- - - - - - - - - - - - - - - - - + +

-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, FLArrayIterator *)
 Initializes a FLArrayIterator struct to iterate over an array. More...
 
FLValue FLArrayIterator_GetValue (const FLArrayIterator *) FLPURE
 Returns the current value being iterated over. More...
 
FLValue 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...
 
FLEECE_PUBLIC const FLArray kFLEmptyArray
 
- - + - + - + - + - + - + - + - + - - - - - - - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0, -kFLDeepCopy = 1, -kFLCopyImmutables = 2, -kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) +

Mutable Arrays

enum  FLCopyFlags { kFLDefaultCopy = 0 +, kFLDeepCopy = 1 +, kFLCopyImmutables = 2 +, kFLDeepCopyImmutables = (kFLDeepCopy | kFLCopyImmutables) }
 
FLMutableArray FLArray_MutableCopy (FLArray, FLCopyFlags)
 Creates a new mutable Array that's a copy of the source Array. More...
 Creates a new mutable Array that's a copy of the source Array. More...
 
FLMutableArray FLMutableArray_New (void)
 Creates a new empty mutable Array. More...
 Creates a new empty mutable Array. More...
 
static FLMutableArray FLMutableArray_Retain (FLMutableArray d)
 Increments the ref-count of a mutable Array. More...
 Increments the ref-count of a mutable Array. More...
 
static void FLMutableArray_Release (FLMutableArray d)
 Decrements the refcount of (and possibly frees) a mutable Array. More...
 Decrements the refcount of (and possibly frees) a mutable Array. More...
 
FLArray FLMutableArray_GetSource (FLMutableArray)
 If the Array was created by FLArray_MutableCopy, returns the original source Array. More...
 If the Array was created by FLArray_MutableCopy, returns the original source Array. More...
 
bool FLMutableArray_IsChanged (FLMutableArray)
 Returns true if the Array has been changed from the source it was copied from. More...
 Returns true if the Array has been changed from the source it was copied from. More...
 
void FLMutableArray_SetChanged (FLMutableArray, bool)
 Sets or clears the mutable Array's "changed" flag. More...
 Sets or clears the mutable Array's "changed" flag. More...
 
FLSlot FLMutableArray_Set (FLMutableArray, uint32_t index)
 Lets you store a value into a MutableArray, by returning a FLSlot that you can call a function like FLSlot_SetInt on. More...
 
FLSlot FLMutableArray_Append (FLMutableArray)
 Appends a null value to a MutableArray and returns a FLSlot that you can call to store something else in the new value. More...
 
void FLMutableArray_Insert (FLMutableArray array, uint32_t firstIndex, uint32_t count)
 Inserts a contiguous range of JSON null values into the array. More...
 Inserts a contiguous range of JSON null values into the array. More...
 
void FLMutableArray_Remove (FLMutableArray array, uint32_t firstIndex, uint32_t count)
 Removes contiguous items from the array. More...
 Removes contiguous items from the array. More...
 
void FLMutableArray_Resize (FLMutableArray array, uint32_t size)
 Changes the size of an array. More...
 Changes the size of an array. More...
 
FLMutableArray FLMutableArray_GetMutableArray (FLMutableArray, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FLMutableArray_GetMutableDict (FLMutableArray, uint32_t index)
 Convenience function for getting an array-valued property in mutable form. More...
 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...
 
+ + + + + + + + + + + + + + + + +

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, 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 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:55
+
Opaque array iterator.
Definition: Fleece.h:434
+
void FLArrayIterator_Begin (FLArray, FLArrayIterator *)
 Initializes a FLArrayIterator struct to iterate over an array. More...
 
FLValue FLArrayIterator_GetValue (const FLArrayIterator *) FLPURE
 Returns the current value being iterated over. More...
 
FLValue 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...
 

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.

+

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

Function Documentation

-
+

◆ FLArray_AsMutable()

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

+

◆ FLArray_Count()

- +

◆ FLArrayIterator_Begin()

@@ -348,11 +418,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()

@@ -372,7 +442,7 @@

+

◆ FLArrayIterator_GetValue()

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

+

◆ FLArrayIterator_GetValueAt()

@@ -422,7 +492,7 @@

+

◆ FLArrayIterator_Next()

@@ -442,43 +512,64 @@

-

◆ FLMutableArray_Append()

+ +

◆ FLMutableArray_AppendArray()

+ + + + + +
- + - + + + + + + + + + + +
FLSlot FLMutableArray_Append static void FLMutableArray_AppendArray ( FLMutableArray )a,
FLArray val 
)
+
+inlinestatic
-

Appends a null value to a MutableArray and returns a FLSlot that you can call to store something else in the new value.

+

Appends a Fleece array to an array.

- -

◆ FLMutableArray_GetMutableArray()

+ +

◆ FLMutableArray_AppendBool()

+ + + - -
- + - + - - + + @@ -486,34 +577,37 @@

+inlinestatic +

+
FLMutableArray FLMutableArray_GetMutableArray static void FLMutableArray_AppendBool ( FLMutableArray , a,
uint32_t index bool val 
-

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.
  • -
+

Appends a boolean value to an array.

-
-

◆ FLMutableArray_GetMutableDict()

+ +

◆ FLMutableArray_AppendData()

+ + +
- + - + - - + + @@ -521,60 +615,75 @@

+inlinestatic +

+
FLMutableDict FLMutableArray_GetMutableDict static void FLMutableArray_AppendData ( FLMutableArray , a,
uint32_t index FLSlice val 
-

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.
  • -
+

Appends a binary data blob to an array.

-
-

◆ FLMutableArray_GetSource()

+ +

◆ FLMutableArray_AppendDict()

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

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

+

Appends a Fleece dictionary to an array.

- -

◆ FLMutableArray_Insert()

+ +

◆ FLMutableArray_AppendDouble()

+ + +
- + - - - - - - - + - - + + @@ -582,63 +691,95 @@

+inlinestatic +

+
void FLMutableArray_Insert static void FLMutableArray_AppendDouble ( FLMutableArray array,
uint32_t firstIndex, a,
uint32_t count double val 
-

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.
-
-
+

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

-
-

◆ FLMutableArray_IsChanged()

+ +

◆ FLMutableArray_AppendFloat()

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

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

+

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

- -

◆ FLMutableArray_New()

+ +

◆ FLMutableArray_AppendInt()

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

Creates a new empty mutable Array.

-

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

+

Appends an integer to an array.

- -

◆ FLMutableArray_Release()

+ +

◆ FLMutableArray_AppendNull()

- -

◆ FLMutableArray_Remove()

+ +

◆ FLMutableArray_AppendString()

+ + + + + + + + +
- + - - - - - - - + - - + + @@ -695,37 +833,37 @@

+inlinestatic +

+
void FLMutableArray_Remove static void FLMutableArray_AppendString ( FLMutableArray array,
uint32_t firstIndex, a,
uint32_t count FLString val 
-

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.
-
-
+

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

-
-

◆ FLMutableArray_Resize()

+ +

◆ FLMutableArray_AppendUInt()

+ + + @@ -764,18 +917,18 @@

-

Increments the ref-count of a mutable Array.

+

Appends a Fleece value to an array.

-
-

◆ FLMutableArray_Set()

+ +

◆ FLMutableArray_GetMutableArray()

- + - + - - + + @@ -733,15 +871,20 @@

+inlinestatic +

+
void FLMutableArray_Resize static void FLMutableArray_AppendUInt ( FLMutableArray array, a,
uint32_t size uint64_t val 
- -

◆ FLMutableArray_Retain()

+ +

◆ FLMutableArray_AppendValue()

- + @@ -794,18 +947,23 @@

-

Lets you store a value into a MutableArray, by returning a FLSlot that you can call a function like FLSlot_SetInt on.

+

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_SetChanged()

+ +

◆ FLMutableArray_GetMutableDict()

FLSlot FLMutableArray_Set FLMutableArray FLMutableArray_GetMutableArray ( FLMutableArray  ,
- + @@ -813,8 +971,8 @@

- - + + @@ -824,21 +982,780 @@

-

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

+

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.
  • +
-

Variable Documentation

-
-

◆ kFLEmptyArray

+ +

◆ FLMutableArray_GetSource()

void FLMutableArray_SetChanged FLMutableDict FLMutableArray_GetMutableDict ( FLMutableArray  , bool  uint32_t index 
- - -
const FLArray kFLEmptyArray
+
FLArray FLMutableArray_GetSource (FLMutableArray )
+
+ +

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

+ +
+
+ +

◆ FLMutableArray_Insert()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void FLMutableArray_Insert (FLMutableArray 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 )
+
+ +

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

+ +
+
+ +

◆ FLMutableArray_New()

+ +
+
+ + + + + + + + +
FLMutableArray FLMutableArray_New (void )
+
+ +

Creates a new empty mutable Array.

+

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

+ +
+
+ +

◆ FLMutableArray_Release()

+ +
+
+ + + + + +
+ + + + + + + + +
static void FLMutableArray_Release (FLMutableArray d)
+
+inlinestatic
+
+ +

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

+ +
+
+ +

◆ FLMutableArray_Remove()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void FLMutableArray_Remove (FLMutableArray 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 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 FLMutableArray_Retain (FLMutableArray 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 ,
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
@@ -846,9 +1763,7 @@

diff --git a/docs/C/html/group___f_l_deep_iterator.html b/docs/C/html/group___f_l_deep_iterator.html index 61498e51..ac2dffe1 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 @@ - - + + Couchbase Lite C: Fleece Deep Iterator @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -66,65 +67,67 @@ 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...
 A reference to a deep iterator. More...
 
- - + - + + + + - + - + - + - + - + - + - + - +

+

Functions

FLDeepIterator FLDeepIterator_New (FLValue)
 Creates a FLDeepIterator to iterate over a dictionary. More...
 Creates a FLDeepIterator to iterate over a dictionary. More...
 
void FLDeepIterator_Free (FLDeepIterator)
 
FLValue FLDeepIterator_GetValue (FLDeepIterator)
 Returns the current value being iterated over. More...
 Returns the current value being iterated over. More...
 
FLValue 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, or an empty slice if not in a dictionary. More...
 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, or 0 if not in an array. More...
 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...
 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...
 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...
 Advances the iterator to the next value, or returns false if at the end. More...
 
void FLDeepIterator_GetPath (FLDeepIterator, FLPathComponent **outPath, size_t *outDepth)
 Returns the path as an array of FLPathComponents. More...
 Returns the path as an array of FLPathComponents. More...
 
FLSliceResult FLDeepIterator_GetPathString (FLDeepIterator)
 Returns the current path in JavaScript format. More...
 Returns the current path in JavaScript format. More...
 
FLSliceResult FLDeepIterator_GetJSONPointer (FLDeepIterator)
 Returns the current path in JSONPointer format (RFC 6901). More...
 Returns the current path in JSONPointer format (RFC 6901). More...
 

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

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

Function Documentation

- +

◆ FLDeepIterator_Free()

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

+

◆ FLDeepIterator_GetDepth()

- +

◆ FLDeepIterator_GetJSONPointer()

+ +

◆ FLDeepIterator_GetParent()

+ +
+
+ + + + + + + + +
FLValue FLDeepIterator_GetParent (FLDeepIterator )
+
+ +

Returns the parent/container of the current value, or NULL at the end of iteration.

- +

◆ FLDeepIterator_GetPath()

- +

◆ FLDeepIterator_Next()

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

+

◆ FLDeepIterator_SkipChildren()

@@ -380,9 +403,7 @@

diff --git a/docs/C/html/group___f_l_dict.html b/docs/C/html/group___f_l_dict.html index d5d48d92..dbddb107 100644 --- a/docs/C/html/group___f_l_dict.html +++ b/docs/C/html/group___f_l_dict.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Fleece Dictionaries @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -66,12 +67,11 @@ Data Structures | Functions | Variables -
-
Fleece Dictionaries
+
Fleece Dictionaries
- @@ -80,106 +80,148 @@

+

Data Structures

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

+

Functions

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

+

Variables

const FLDict kFLEmptyDict
 
FLEECE_PUBLIC const FLDict kFLEmptyDict
 
- - + + - + - + - + - + - + - + - +

-Dict iteration

Iterating a dictionary typically looks like this:

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

Dict iteration

Iterating a dictionary typically looks like this:

+
+
FLDictIterator_Begin(theDict, &iter);
+
FLValue value;
+
while (NULL != (value = FLDictIterator_GetValue(&iter))) {
+ +
// ...
+ +
}
+
void FLDictIterator_Begin(FLDict, FLDictIterator *)
Initializes a FLDictIterator struct to iterate over a dictionary.
+
FLString FLDictIterator_GetKeyString(const FLDictIterator *)
Returns the current key's string value.
+
bool FLDictIterator_Next(FLDictIterator *)
Advances the iterator to the next value, or returns false if at the end.
+
FLValue FLDictIterator_GetValue(const FLDictIterator *) FLPURE
Returns the current value being iterated over.
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
Opaque dictionary iterator.
Definition: Fleece.h:638
+
A simple reference to a block of memory.
Definition: FLSlice.h:40
+
void FLDictIterator_Begin (FLDict, FLDictIterator *)
 Initializes a FLDictIterator struct to iterate over a dictionary. More...
 Initializes a FLDictIterator struct to iterate over a dictionary. More...
 
FLValue FLDictIterator_GetKey (const FLDictIterator *) FLPURE
 Returns the current key being iterated over. More...
 Returns the current key being iterated over. More...
 
FLString FLDictIterator_GetKeyString (const FLDictIterator *)
 Returns the current key's string value. More...
 Returns the current key's string value. More...
 
FLValue FLDictIterator_GetValue (const FLDictIterator *) FLPURE
 Returns the current value being iterated over. More...
 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...
 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...
 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...
 Cleans up after an iterator. More...
 
- + - + - + - +

-Optimized Keys

Optimized Keys

FLDictKey FLDictKey_Init (FLSlice string)
 Initializes an FLDictKey struct with a key string. More...
 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...
 Returns the string value of the key (which it was initialized with.) More...
 
FLValue FLDict_GetWithKey (FLDict, FLDictKey *)
 Looks up a key in a dictionary using an FLDictKey. More...
 Looks up a key in a dictionary using an FLDictKey. More...
 
- + - + - + - + - + - + - + - + - - - - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Mutable dictionaries

Mutable dictionaries

FLMutableDict FLDict_MutableCopy (FLDict source, FLCopyFlags)
 Creates a new mutable Dict that's a copy of the source Dict. More...
 Creates a new mutable Dict that's a copy of the source Dict. More...
 
FLMutableDict FLMutableDict_New (void)
 Creates a new empty mutable Dict. More...
 Creates a new empty mutable Dict. More...
 
static FLMutableDict FLMutableDict_Retain (FLMutableDict d)
 Increments the ref-count of a mutable Dict. More...
 Increments the ref-count of a mutable Dict. More...
 
static void FLMutableDict_Release (FLMutableDict d)
 Decrements the refcount of (and possibly frees) a mutable Dict. More...
 Decrements the refcount of (and possibly frees) a mutable Dict. More...
 
FLDict FLMutableDict_GetSource (FLMutableDict)
 If the Dict was created by FLDict_MutableCopy, returns the original source Dict. More...
 If the Dict was created by FLDict_MutableCopy, returns the original source Dict. More...
 
bool FLMutableDict_IsChanged (FLMutableDict)
 Returns true if the Dict has been changed from the source it was copied from. More...
 Returns true if the Dict has been changed from the source it was copied from. More...
 
void FLMutableDict_SetChanged (FLMutableDict, bool)
 Sets or clears the mutable Dict's "changed" flag. More...
 Sets or clears the mutable Dict's "changed" flag. More...
 
FLSlot FLMutableDict_Set (FLMutableDict FL_NONNULL, FLString key)
 Returns the Slot storing the key's value, adding a new one if needed (with a null value.) To set the value itself, call one of the FLSlot functions, e.g. More...
 
void FLMutableDict_Remove (FLMutableDict, FLString key)
 Removes the value for a key. More...
 Removes the value for a key. More...
 
void FLMutableDict_RemoveAll (FLMutableDict)
 Removes all keys and values. More...
 Removes all keys and values. More...
 
FLMutableArray FLMutableDict_GetMutableArray (FLMutableDict, FLString key)
 Convenience function for getting an array-valued property in mutable form. More...
 Convenience function for getting an array-valued property in mutable form. More...
 
FLMutableDict FLMutableDict_GetMutableDict (FLMutableDict, FLString key)
 Convenience function for getting a dict-valued property in mutable form. More...
 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()

@@ -199,7 +241,7 @@

+

◆ FLDict_Count()

- +

◆ FLDict_GetWithKey()

@@ -277,11 +319,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()

- +

◆ FLDictIterator_Begin()

@@ -363,11 +405,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()

- +

◆ FLDictIterator_GetKeyString()

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

+

◆ FLDictIterator_GetValue()

@@ -469,7 +511,7 @@

+

◆ FLDictIterator_Next()

@@ -489,7 +531,7 @@

+

◆ FLDictKey_GetString()

@@ -509,7 +551,7 @@

+

◆ FLDictKey_Init()

@@ -537,7 +579,7 @@

+

◆ FLMutableDict_GetMutableArray()

@@ -572,7 +614,7 @@

+

◆ FLMutableDict_GetMutableDict()

@@ -607,7 +649,7 @@

+

◆ FLMutableDict_GetSource()

@@ -627,7 +669,7 @@

+

◆ FLMutableDict_IsChanged()

- +

◆ FLMutableDict_Release()

@@ -696,7 +739,7 @@

+

◆ FLMutableDict_Remove()

@@ -726,7 +769,7 @@

+

◆ FLMutableDict_RemoveAll()

@@ -746,7 +789,7 @@

+

◆ FLMutableDict_Retain()

@@ -774,23 +817,76 @@

-

◆ FLMutableDict_Set()

+ +

◆ FLMutableDict_SetArray()

+ + + + + +
- + - + - + + + + + + + + + + + + + +
FLSlot FLMutableDict_Set static void FLMutableDict_SetArray ( FLMutableDict FL_NONNULL, d,
FLString key key,
FLArray val 
)
+
+inlinestatic
+
+ +

Stores a Fleece array into a mutable dictionary.

+ +
+
+ +

◆ FLMutableDict_SetBool()

+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + @@ -798,14 +894,18 @@

+inlinestatic +

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

◆ FLMutableDict_SetChanged()

@@ -833,19 +933,418 @@

+

+ + +

◆ 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

+ +

◆ kFLEmptyDict

+ + + + + +
- +
const FLDict kFLEmptyDictFLEECE_PUBLIC const FLDict kFLEmptyDict
+
+extern
@@ -853,9 +1352,7 @@

diff --git a/docs/C/html/group___f_l_encoder.html b/docs/C/html/group___f_l_encoder.html index 154d689a..1ac5f254 100644 --- a/docs/C/html/group___f_l_encoder.html +++ b/docs/C/html/group___f_l_encoder.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Fleece Encoders @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -62,160 +63,155 @@

-
-
Fleece Encoders
+
Fleece Encoders

An FLEncoder generates encoded Fleece or JSON data. More...

- - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - +

-Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece, -kFLEncodeJSON, -kFLEncodeJSON5 +

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...
 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...
 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...
 Creates a new Fleece encoder that writes to a file, not to memory. More...
 
void FLEncoder_Free (FLEncoder)
 Frees the space used by an encoder. More...
 Frees the space used by an encoder. More...
 
void FLEncoder_SetSharedKeys (FLEncoder, FLSharedKeys)
 Tells the encoder to use a shared-keys mapping when encoding dictionary keys. More...
 Tells the encoder to use a shared-keys mapping when encoding dictionary keys. More...
 
void FLEncoder_SetExtraInfo (FLEncoder, void *info)
 Associates an arbitrary user-defined value with the encoder. More...
 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_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...
 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...
 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...
 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...
 Resets the state of an encoder without freeing it. More...
 
size_t FLEncoder_BytesWritten (FLEncoder)
 Returns the number of bytes encoded so far. More...
 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...
 Returns the byte offset in the encoded data where the next value will be written. 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.
+

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...
 Writes a null value to an encoder. More...
 
bool FLEncoder_WriteUndefined (FLEncoder)
 Writes an undefined value to an encoder. More...
 Writes an undefined value to an encoder. More...
 
bool FLEncoder_WriteBool (FLEncoder, bool)
 Writes a boolean value (true or false) to an encoder. More...
 Writes a boolean value (true or false) to an encoder. More...
 
bool FLEncoder_WriteInt (FLEncoder, int64_t)
 Writes an integer to an encoder. More...
 Writes an integer to an encoder. More...
 
bool FLEncoder_WriteUInt (FLEncoder, uint64_t)
 Writes an unsigned integer to an encoder. More...
 Writes an unsigned integer to an encoder. More...
 
bool FLEncoder_WriteFloat (FLEncoder, float)
 Writes a 32-bit floating point number to an encoder. More...
 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...
 Writes a 64-bit floating point number to an encoder. More...
 
bool FLEncoder_WriteString (FLEncoder, FLString)
 Writes a string to an encoder. More...
 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...
 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...
 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...
 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...
 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...
 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...
 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...
 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...
 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...
 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...
 Writes a Fleece Value to an Encoder. More...
 
intptr_t FLEncoder_LastValueWritten (FLEncoder e)
 Returns an opaque reference to the last complete value written to the encoder, if possible. More...
 Returns an opaque reference to the last complete value written to the encoder, if possible. More...
 
void FLEncoder_WriteValueAgain (FLEncoder e, intptr_t preWrittenValue)
 Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten. More...
 Writes another reference (a "pointer") to an already-written value, given a reference previously returned from FLEncoder_LastValueWritten. More...
 
FLSliceResult FLEncoder_Snip (FLEncoder e)
 Returns the data written so far as a standalone Fleece document, whose root is the last value written. More...
 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...
 Parses JSON data and writes the object(s) to the encoder. More...
 
- + - + - + - - - + + +

-Finishing up

Finishing up

size_t FLEncoder_FinishItem (FLEncoder)
 Finishes encoding the current item, and returns its offset in the output data. More...
 Finishes encoding the current item, and returns its offset in the output data. More...
 
FLDoc FLEncoder_FinishDoc (FLEncoder, FLError *)
 Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc. More...
 Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc. More...
 
FLSliceResult FLEncoder_Finish (FLEncoder e, FLError *outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null. More...
 
MUST_USE_RESULT FLSliceResult FLEncoder_Finish (FLEncoder e, FLError *outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null. More...
 
- + - + - - - + + +

-Error handling

Error handling

FLError FLEncoder_GetError (FLEncoder)
 Returns the error code of an encoder, or NoError (0) if there's no error. More...
 Returns the error code of an encoder, or NoError (0) if there's no error. More...
 
const char * FLEncoder_GetErrorMessage (FLEncoder)
 Returns the error message of an encoder, or NULL if there's no error. More...
 
const char * 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

@@ -229,18 +225,18 @@

-

Enumerator
kFLEncodeFleece 

Fleece encoding.

+
Enumerator
kFLEncodeFleece 

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()

@@ -279,7 +275,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
@@ -291,7 +287,7 @@

+

◆ FLEncoder_BeginArray()

eThe FLEncoder affected.
baseThe base document to create an amendment of.
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.
@@ -327,7 +323,7 @@

+

◆ FLEncoder_BeginDict()

@@ -354,7 +350,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.
@@ -363,7 +359,7 @@

+

◆ FLEncoder_BytesWritten()

- +

◆ FLEncoder_EndArray()

@@ -434,7 +430,7 @@

+

◆ FLEncoder_EndDict()

@@ -454,14 +450,14 @@

-

◆ FLEncoder_Finish()

+ +

◆ FLEncoder_Finish()

- + @@ -481,11 +477,11 @@

Ends encoding; if there has been no error, it returns the encoded data, else null.

-

This does not free the FLEncoder; call FLEncoder_Free (or FLEncoder_Reset) next.

+

This does not free the FLEncoder; call FLEncoder_Free (or FLEncoder_Reset) next.

-
+

◆ FLEncoder_FinishDoc()

- +

◆ FLEncoder_FinishItem()

@@ -536,7 +532,7 @@

+

◆ FLEncoder_Free()

@@ -556,7 +552,7 @@

+

◆ FLEncoder_GetBase()

@@ -576,7 +572,7 @@

+

◆ FLEncoder_GetError()

@@ -596,14 +592,14 @@

-

◆ FLEncoder_GetErrorMessage()

+ +

◆ FLEncoder_GetErrorMessage()

FLSliceResult FLEncoder_Finish MUST_USE_RESULT FLSliceResult FLEncoder_Finish ( FLEncoder  e,
- + @@ -616,14 +612,14 @@

-

◆ FLEncoder_GetExtraInfo()

+ +

◆ FLEncoder_GetExtraInfo()

const char* FLEncoder_GetErrorMessage const char * FLEncoder_GetErrorMessage ( FLEncoder  )
- + @@ -636,7 +632,7 @@

+

◆ FLEncoder_GetNextWritePos()

- +

◆ FLEncoder_LastValueWritten()

- +

◆ FLEncoder_New()

- +

◆ FLEncoder_NewWithOptions()

@@ -743,7 +739,7 @@

+

◆ FLEncoder_NewWritingToFile()

- +

◆ FLEncoder_SetExtraInfo()

@@ -824,7 +820,7 @@

+

◆ FLEncoder_SetSharedKeys()

@@ -854,7 +850,7 @@

+

◆ FLEncoder_Snip()

@@ -871,11 +867,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_WriteBool()

- +

◆ FLEncoder_WriteDateString()

@@ -1003,7 +999,7 @@

+

◆ FLEncoder_WriteDouble()

- +

◆ FLEncoder_WriteRaw()

- +

◆ FLEncoder_WriteString()

- +

◆ FLEncoder_WriteUInt()

- +

◆ FLEncoder_WriteValue()

@@ -1322,7 +1318,7 @@

+

◆ FLEncoder_WriteValueAgain()

@@ -1349,16 +1345,14 @@

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.

diff --git a/docs/C/html/group___f_l_key_path.html b/docs/C/html/group___f_l_key_path.html index e2ab6e27..b32eb17d 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 @@ - - + + Couchbase Lite C: Fleece Paths @@ -30,21 +30,22 @@

void* FLEncoder_GetExtraInfo void * FLEncoder_GetExtraInfo ( FLEncoder  )
- + +/* @license-end */ +
@@ -65,52 +66,51 @@ -
-
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...
 A reference to a key path. More...
 
- - + - + - + - + - + - + - +

+

Functions

FLKeyPath FLKeyPath_New (FLSlice specifier, FLError *error)
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 
void FLKeyPath_Free (FLKeyPath)
 Frees a compiled FLKeyPath object. More...
 Frees a compiled FLKeyPath object. More...
 
FLValue FLKeyPath_Eval (FLKeyPath, FLValue root)
 Evaluates a compiled key-path for a given Fleece root object. More...
 Evaluates a compiled key-path for a given Fleece root object. More...
 
FLValue FLKeyPath_EvalOnce (FLSlice specifier, FLValue root, FLError *error)
 Evaluates a key-path from a specifier string, for a given Fleece root object. More...
 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...
 Returns a path in string form. More...
 
bool FLKeyPath_Equals (FLKeyPath path1, FLKeyPath path2)
 Equality test. More...
 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...
 Returns an element of a path, either a key or an array index. More...
 

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()

- +

◆ FLKeyPath_GetElement()

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

+

◆ FLKeyPath_New()

@@ -317,7 +317,7 @@

+

◆ FLKeyPath_ToString()

@@ -340,9 +340,7 @@

diff --git a/docs/C/html/group___f_l_shared_keys.html b/docs/C/html/group___f_l_shared_keys.html index 21528da5..b315d02c 100644 --- a/docs/C/html/group___f_l_shared_keys.html +++ b/docs/C/html/group___f_l_shared_keys.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Shared Keys @@ -30,21 +30,22 @@

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

@@ -65,57 +66,56 @@ -
-
Shared Keys
+
Shared Keys

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

-

+

Typedefs

typedef bool(* FLSharedKeysReadCallback) (void *context, FLSharedKeys)
 
typedef struct _FLSharedKeyScope * FLSharedKeyScope
 
- - + - + - + - + - + - + - + - + - + - + - + @@ -123,11 +123,11 @@

+

Functions

FLSharedKeys FLSharedKeys_New (void)
 Creates a new empty FLSharedKeys object, which must eventually be released. More...
 Creates a new empty FLSharedKeys object, which must eventually be released. More...
 
FLSharedKeys FLSharedKeys_NewWithRead (FLSharedKeysReadCallback, void *context)
 
FLSliceResult FLSharedKeys_GetStateData (FLSharedKeys)
 Returns a data blob containing the current state (all the keys and their integers.) More...
 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...
 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...
 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...
 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...
 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...
 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...
 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...
 Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount. More...
 
FLSharedKeys FLSharedKeys_Retain (FLSharedKeys)
 Increments the reference count of an FLSharedKeys. More...
 Increments the reference count of an FLSharedKeys. More...
 
void FLSharedKeys_Release (FLSharedKeys)
 Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero. More...
 Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero. More...
 
FLSharedKeyScope FLSharedKeyScope_WithRange (FLSlice range, FLSharedKeys)
 
 

Detailed Description

-

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 Documentation

- +

◆ FLSharedKeyScope

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

+

◆ FLSharedKeysReadCallback

- +

◆ FLSharedKeys_Decode()

- +

◆ FLSharedKeys_GetStateData()

@@ -264,7 +264,7 @@

+

◆ FLSharedKeys_LoadState()

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

+

◆ FLSharedKeys_LoadStateData()

@@ -324,7 +324,7 @@

+

◆ FLSharedKeys_New()

@@ -344,7 +344,7 @@

+

◆ FLSharedKeys_NewWithRead()

@@ -372,7 +372,7 @@

+

◆ FLSharedKeys_Release()

@@ -392,7 +392,7 @@

+

◆ FLSharedKeys_Retain()

@@ -412,7 +412,7 @@

+

◆ FLSharedKeys_RevertToCount()

@@ -442,7 +442,7 @@

+

◆ FLSharedKeys_WriteState()

@@ -472,7 +472,7 @@

+

◆ FLSharedKeyScope_Free()

@@ -490,7 +490,7 @@

+

◆ FLSharedKeyScope_WithRange()

@@ -521,9 +521,7 @@

diff --git a/docs/C/html/group___f_l_slice.html b/docs/C/html/group___f_l_slice.html index 5075a092..559e643d 100644 --- a/docs/C/html/group___f_l_slice.html +++ b/docs/C/html/group___f_l_slice.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Slices @@ -30,21 +30,22 @@

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

@@ -67,12 +68,11 @@ Macros | Typedefs | Functions

-
-
Slices
+
Slices

- @@ -81,59 +81,71 @@

+

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...
 
- - + - +

+

Macros

#define kFLSliceNull   ((FLSlice){NULL, 0})
 A convenient constant denoting a null slice. More...
 A convenient constant denoting a null slice. More...
 
#define FLSTR(STR)   ((FLSlice){("" STR), sizeof(("" STR))-1})
 Macro version of FLStr, for use in initializing compile-time constants. More...
 Macro version of FLStr, for use in initializing compile-time constants. More...
 
- - +

+

Typedefs

typedef FLSlice FLHeapSlice
 A heap-allocated, reference-counted slice. More...
 A heap-allocated, reference-counted slice. More...
 
typedef FLSlice FLString
 
typedef FLSliceResult FLStringResult
 
- - + - + - + + + + - + - + - + + + + - + - + + + + + + +

+

Functions

static FLSlice FLStr (const char *str)
 Returns a slice pointing to the contents of a C string. More...
 Returns a slice pointing to the contents of a C string. More...
 
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
 Equality test of two slices. More...
 Equality test of two slices. More...
 
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
 Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences in length. More...
 Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences in length. More...
 
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)
 Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string. More...
 Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string. More...
 
FLSliceResult FLSliceResult_New (size_t)
 Allocates an FLSliceResult of the given size, without initializing the buffer. More...
 Allocates an FLSliceResult of the given size, without initializing the buffer. More...
 
FLSliceResult FLSlice_Copy (FLSlice)
 Allocates an FLSliceResult, copying the given slice. More...
 Allocates an FLSliceResult, copying the given slice. More...
 
static FLSliceResult FLSliceResult_CreateWith (const void *bytes, size_t size)
 Allocates an FLSliceResult, copying size bytes starting at buf. More...
 
void _FLBuf_Retain (const void *)
 
void _FLBuf_Release (const void *)
 
static FLSliceResult FLSliceResult_Retain (FLSliceResult s)
 Increments the ref-count of a FLSliceResult. More...
 Increments the ref-count of a FLSliceResult. More...
 
static void FLSliceResult_Release (FLSliceResult s)
 Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero. More...
 Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero. More...
 
static FLSlice FLSliceResult_AsSlice (FLSliceResult sr)
 Type-casts a FLSliceResult to FLSlice, since C doesn't know it's a subclass. More...
 
void FL_WipeMemory (void *dst, size_t size)
 Writes zeroes to size bytes of memory starting at dst. More...
 

Detailed Description

Macro Definition Documentation

- +

◆ FLSTR

@@ -150,11 +162,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

@@ -171,7 +183,7 @@

Typedef Documentation

- +

◆ FLHeapSlice

@@ -184,11 +196,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

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

+

◆ FLStringResult

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

Function Documentation

- +

◆ _FLBuf_Release()

@@ -235,7 +247,7 @@

+

◆ _FLBuf_Retain()

@@ -253,7 +265,38 @@

+ +

◆ FL_WipeMemory()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void FL_WipeMemory (void * dst,
size_t size 
)
+
+ +

Writes zeroes to size bytes of memory starting at dst.

+

Unlike a call to memset, these writes cannot be optimized away by the compiler. This is useful for securely removing traces of passwords or encryption keys.

+ +
+
+

◆ FLSlice_Compare()

@@ -283,7 +326,7 @@

+

◆ FLSlice_Copy()

@@ -303,7 +346,7 @@

+

◆ FLSlice_Equal()

+ +

◆ FLSliceResult_CreateWith()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static FLSliceResult FLSliceResult_CreateWith (const void * bytes,
size_t size 
)
+
+inlinestatic
+
+ +

Allocates an FLSliceResult, copying size bytes starting at buf.

+ +
+
+

◆ FLSliceResult_New()

@@ -398,7 +527,7 @@

+

◆ FLSliceResult_Release()

@@ -426,7 +555,7 @@

+

◆ FLSliceResult_Retain()

@@ -454,7 +583,7 @@

+

◆ FLStr()

@@ -479,7 +608,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.
@@ -488,9 +617,7 @@

diff --git a/docs/C/html/group___f_l_value.html b/docs/C/html/group___f_l_value.html index d236c2a0..bb6d0fbc 100644 --- a/docs/C/html/group___f_l_value.html +++ b/docs/C/html/group___f_l_value.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Fleece Value Accessors @@ -30,21 +30,22 @@

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

@@ -68,116 +69,114 @@ Enumerations | Functions | Variables

-
-
Fleece Value Accessors
+
Fleece Value Accessors

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...
 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...
 A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) More...
 
-

+

Enumerations

enum  FLValueType {
-  kFLUndefined = -1, -kFLNull = 0, -kFLBoolean, -kFLNumber, -
-  kFLString, -kFLData, -kFLArray, -kFLDict +  kFLUndefined = -1 +, kFLNull = 0 +, kFLBoolean +, kFLNumber +,
+  kFLString +, kFLData +, kFLArray +, kFLDict
}
 Types of Fleece values. More...
 
- - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +

+

Functions

FLValueType FLValue_GetType (FLValue) FLPURE
 Returns the data type of an arbitrary Value. More...
 Returns the data type of an arbitrary Value. More...
 
bool FLValue_IsInteger (FLValue) FLPURE
 Returns true if the value is non-NULL and represents an integer. More...
 Returns true if the value is non-NULL and represents an integer. More...
 
bool FLValue_IsUnsigned (FLValue) FLPURE
 Returns true if the value is non-NULL and represents an integer >= 2^63. More...
 Returns true if the value is non-NULL and represents an integer >= 2^63. More...
 
bool FLValue_IsDouble (FLValue)
 Returns true if the value is non-NULL and represents a 64-bit floating-point number. More...
 Returns true if the value is non-NULL and represents a 64-bit floating-point number. More...
 
bool FLValue_AsBool (FLValue) FLPURE
 Returns a value coerced to boolean. More...
 Returns a value coerced to boolean. More...
 
int64_t FLValue_AsInt (FLValue) FLPURE
 Returns a value coerced to an integer. More...
 Returns a value coerced to an integer. More...
 
uint64_t FLValue_AsUnsigned (FLValue) FLPURE
 Returns a value coerced to an unsigned integer. More...
 Returns a value coerced to an unsigned integer. More...
 
float FLValue_AsFloat (FLValue) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 Returns a value coerced to a 32-bit floating point number. More...
 
double FLValue_AsDouble (FLValue) FLPURE
 Returns a value coerced to a 32-bit floating point number. More...
 Returns a value coerced to a 32-bit floating point number. More...
 
FLString FLValue_AsString (FLValue) FLPURE
 Returns the exact contents of a string value, or null for all other types. More...
 Returns the exact contents of a string value, or null for all other types. More...
 
FLTimestamp FLValue_AsTimestamp (FLValue) FLPURE
 Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure. More...
 Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure. More...
 
FLSlice FLValue_AsData (FLValue) FLPURE
 Returns the exact contents of a data value, or null for all other types. More...
 Returns the exact contents of a data value, or null for all other types. More...
 
FLArray FLValue_AsArray (FLValue) FLPURE
 If a FLValue represents an array, returns it cast to FLArray, else NULL. More...
 If a FLValue represents an array, returns it cast to FLArray, else NULL. More...
 
FLDict FLValue_AsDict (FLValue) FLPURE
 If a FLValue represents a dictionary, returns it as an FLDict, else NULL. More...
 If a FLValue represents a dictionary, returns it as an FLDict, else NULL. More...
 
FLStringResult FLValue_ToString (FLValue)
 Returns a string representation of any scalar value. More...
 Returns a string representation of any scalar value. More...
 
bool FLValue_IsEqual (FLValue v1, FLValue v2) FLPURE
 Compares two values for equality. More...
 Compares two values for equality. More...
 
bool FLValue_IsMutable (FLValue) FLPURE
 Returns true if the value is mutable. More...
 Returns true if the value is mutable. More...
 
FLValue FLValue_NewString (FLString)
 Allocates a string value on the heap. More...
 Allocates a string value on the heap. More...
 
FLValue FLValue_NewData (FLSlice)
 Allocates a data/blob value on the heap. More...
 Allocates a data/blob value on the heap. More...
 
- - - - + + +

+

Variables

const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
FLEECE_PUBLIC const FLValue kFLNullValue
 A constant null value (not a NULL pointer!) More...
 
- + - + - + @@ -189,15 +188,15 @@

-Ref-counting (mutable values only)

Ref-counting (mutable values only)

FLValue FLValue_Retain (FLValue)
 If this value is mutable (and thus heap-based) its ref-count is incremented. More...
 If this value is mutable (and thus heap-based) its ref-count is incremented. More...
 
void FLValue_Release (FLValue)
 If this value is mutable (and thus heap-based) its ref-count is decremented, and if it reaches zero the value is freed. More...
 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 FLArray_Retain (FLArray 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.

+

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

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

Typedef Documentation

- +

◆ FLTimestamp

Function Documentation

-
+

◆ FLArray_Release()

@@ -293,7 +292,7 @@

+

◆ FLArray_Retain()

@@ -319,7 +318,7 @@

+

◆ FLDict_Release()

@@ -345,7 +344,7 @@

+

◆ FLDict_Retain()

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

+

◆ FLValue_AsArray()

- +

◆ FLValue_AsData()

- +

◆ FLValue_AsInt()

- +

◆ FLValue_AsString()

- +

◆ FLValue_IsDouble()

- +

◆ FLValue_IsInteger()

- +

◆ FLValue_NewString()

@@ -751,11 +750,11 @@

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 FLSlot_SetString.

+

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.

- +

◆ FLValue_Release()

- +

◆ FLValue_Retain()

- +

◆ FLValue_ToString()

Variable Documentation

-
-

◆ kFLNullValue

+ +

◆ kFLNullValue

+ + + + + +
- +
const FLValue kFLNullValueFLEECE_PUBLIC const FLValue kFLNullValue
+
+extern

A constant null value (not a NULL pointer!)

@@ -838,9 +845,7 @@

diff --git a/docs/C/html/group___slots.html b/docs/C/html/group___slots.html index fc0dad1c..90df3fd2 100644 --- a/docs/C/html/group___slots.html +++ b/docs/C/html/group___slots.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Value Slots @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -64,49 +65,181 @@
-
-
Value Slots
+
Value Slots
-

An FLSlot is a temporary reference to an element of a mutable Array/Dict. +

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...

- + + + + + + + + + - + - + - + - + - + - + - + - + - + + + + +

+

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...
 
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 FL_NONNULL, 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...
 Stores a JSON null into a slot. More...
 
void FLSlot_SetBool (FLSlot, bool)
 Stores a boolean into a slot. More...
 Stores a boolean into a slot. More...
 
void FLSlot_SetInt (FLSlot, int64_t)
 Stores an integer into a slot. More...
 Stores an integer into a slot. More...
 
void FLSlot_SetUInt (FLSlot, uint64_t)
 Stores an unsigned integer into a slot. More...
 Stores an unsigned int into a slot. More...
 
void FLSlot_SetFloat (FLSlot, float)
 Stores a float into a slot. More...
 Stores a float into a slot. More...
 
void FLSlot_SetDouble (FLSlot, double)
 Stores a double into a slot. More...
 Stores a double into a slot. More...
 
void FLSlot_SetString (FLSlot, FLString)
 Stores a string into a slot. More...
 Stores a UTF-8 string into a slot. More...
 
void FLSlot_SetData (FLSlot, FLSlice)
 Stores a data blob into a slot. More...
 Stores a data blob into a slot. More...
 
void FLSlot_SetValue (FLSlot, FLValue)
 Stores an FLValue into a slot. More...
 Stores an FLValue into a slot. More...
 
static void FLSlot_SetArray (FLSlot slot, FLArray array)
 
static void FLSlot_SetDict (FLSlot slot, FLDict dict)
 

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 functions below.

+

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()

+ +
+
+ + + + + + + + +
MUST_USE_RESULT FLSlot FLMutableArray_Append (FLMutableArray )
+
+ +

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.
+ +
+
+ +

◆ FLMutableArray_Set()

+ +
+
+ + + + + + + + + + + + + + + + + + +
MUST_USE_RESULT FLSlot FLMutableArray_Set (FLMutableArray ,
uint32_t index 
)
+
+ +

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.
+ +
+
+ +

◆ FLMutableDict_Set()

+ +
+
+ + + + + + + + + + + + + + + + + + +
MUST_USE_RESULT FLSlot FLMutableDict_Set (FLMutableDict FL_NONNULL,
FLString key 
)
+
+ +

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.
+ +
+
+ +

◆ FLSlot_SetArray()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static void FLSlot_SetArray (FLSlot slot,
FLArray array 
)
+
+inlinestatic
+
+ +
+
+

◆ FLSlot_SetBool()

@@ -136,7 +269,7 @@

+

◆ FLSlot_SetData()

@@ -166,7 +299,43 @@

+ +

◆ FLSlot_SetDict()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static void FLSlot_SetDict (FLSlot slot,
FLDict dict 
)
+
+inlinestatic
+
+ +
+
+

◆ FLSlot_SetDouble()

- +

◆ FLSlot_SetFloat()

- +

◆ FLSlot_SetInt()

@@ -256,7 +425,7 @@

+

◆ FLSlot_SetNull()

@@ -276,7 +445,7 @@

+

◆ FLSlot_SetString()

- +

◆ FLSlot_SetUInt()

- +

◆ FLSlot_SetValue()

@@ -369,9 +538,7 @@

diff --git a/docs/C/html/group__blobs.html b/docs/C/html/group__blobs.html index d565f193..ad1ee141 100644 --- a/docs/C/html/group__blobs.html +++ b/docs/C/html/group__blobs.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Blobs @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -66,117 +67,122 @@ Typedefs | Functions | Variables
-
-
Blobs
+
Blobs

A CBLBlob is a binary data blob associated with a document. More...

- - + - + - +

+

Typedefs

typedef struct CBLBlob CBLBlob
 A binary data value associated with a CBLDocument. More...
 A binary data value associated with a CBLDocument. More...
 
typedef struct CBLBlobReadStream CBLBlobReadStream
 A stream for reading a blob's content. More...
 A stream for reading a blob's content. More...
 
typedef struct CBLBlobWriteStream CBLBlobWriteStream
 A stream for writing a new blob to the database. More...
 A stream for writing a new blob to the database. More...
 
- - - + + - - - - - - + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + +

+

Functions

static const CBLBlobCBLBlob_Retain (const CBLBlob *t)
 
static const CBLBlobCBLBlob_Retain (const CBLBlob *t)
 
static void CBLBlob_Release (const CBLBlob *t)
 
bool FLDict_IsBlob (FLDict)
 Returns true if a dictionary in a document is a blob reference. More...
 
const CBLBlobFLDict_GetBlob (FLDict blobDict)
 Returns a CBLBlob object corresponding to a blob dictionary in a document. More...
 
bool FLDict_IsBlob (FLDict _cbl_nullable)
 Returns true if a dictionary in a document is a blob reference. More...
 
const CBLBlob *_cbl_nullable FLDict_GetBlob (FLDict _cbl_nullable blobDict)
 Returns a CBLBlob object corresponding to a blob dictionary in a document. More...
 
uint64_t CBLBlob_Length (const CBLBlob *)
 Returns the length in bytes of a blob's content (from its length property). More...
 Returns the length in bytes of a blob's content (from its length property). More...
 
FLString CBLBlob_Digest (const CBLBlob *)
 Returns the cryptographic digest of a blob's content (from its digest property). More...
 Returns the cryptographic digest of a blob's content (from its digest property). More...
 
FLString CBLBlob_ContentType (const CBLBlob *)
 Returns a blob's MIME type, if its metadata has a content_type property. More...
 Returns a blob's MIME type, if its metadata has a content_type property. More...
 
FLDict CBLBlob_Properties (const CBLBlob *)
 Returns a blob's metadata. More...
 Returns a blob's metadata. More...
 
_cbl_warn_unused FLStringResult CBLBlob_ToJSON (const CBLBlob *blob)
 Returns a blob's metadata as JSON. More...
 
_cbl_warn_unused FLSliceResult CBLBlob_Content (const CBLBlob *, CBLError *outError)
 Reads the blob's contents into memory and returns them. More...
 
_cbl_warn_unused CBLBlobReadStreamCBLBlob_OpenContentStream (const CBLBlob *, CBLError *outError)
 Opens a stream for reading a blob's content. More...
 
int CBLBlobReader_Read (CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *outError)
 Reads data from a blob. More...
 
void CBLBlobReader_Close (CBLBlobReadStream *)
 Closes a CBLBlobReadStream. More...
 
_cbl_warn_unused CBLBlobCBLBlob_NewWithData (FLString contentType, FLSlice contents)
 Creates a new blob given its contents as a single block of data. More...
 
_cbl_warn_unused CBLBlobWriteStreamCBLBlobWriter_New (CBLDatabase *db, CBLError *outError)
 Opens a stream for writing a new blob. More...
 
void CBLBlobWriter_Close (CBLBlobWriteStream *)
 Closes a blob-writing stream, if you need to give up without creating a CBLBlob. More...
 
bool CBLBlobWriter_Write (CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *outError)
 Writes data to a new blob. More...
 
_cbl_warn_unused CBLBlobCBLBlob_NewWithStream (FLString contentType, CBLBlobWriteStream *writer)
 Creates a new blob after its data has been written to a CBLBlobWriteStream. More...
 
static bool FLValue_IsBlob (FLValue v)
 Returns true if a value in a document is a blob reference. More...
 
static const CBLBlobFLValue_GetBlob (FLValue value)
 Instantiates a CBLBlob object corresponding to a blob dictionary in a document. More...
 
_cbl_warn_unused FLStringResult CBLBlob_CreateJSON (const CBLBlob *blob)
 Returns a blob's metadata as JSON. More...
 
_cbl_warn_unused FLSliceResult CBLBlob_Content (const CBLBlob *blob, CBLError *_cbl_nullable outError)
 Reads the blob's contents into memory and returns them. More...
 
_cbl_warn_unused CBLBlobReadStream *_cbl_nullable CBLBlob_OpenContentStream (const CBLBlob *blob, CBLError *_cbl_nullable)
 Opens a stream for reading a blob's content. More...
 
int CBLBlobReader_Read (CBLBlobReadStream *stream, void *dst, size_t maxLength, CBLError *_cbl_nullable outError)
 Reads data from a blob. More...
 
void CBLBlobReader_Close (CBLBlobReadStream *_cbl_nullable)
 Closes a CBLBlobReadStream. More...
 
bool CBLBlob_Equals (CBLBlob *blob, CBLBlob *anotherBlob)
 Compares whether the two given blobs are equal based on their content. More...
 
_cbl_warn_unused CBLBlobCBLBlob_CreateWithData (FLString contentType, FLSlice contents)
 Creates a new blob given its contents as a single block of data. More...
 
_cbl_warn_unused CBLBlobWriteStream *_cbl_nullable CBLBlobWriter_Create (CBLDatabase *db, CBLError *_cbl_nullable)
 Opens a stream for writing a new blob. More...
 
void CBLBlobWriter_Close (CBLBlobWriteStream *_cbl_nullable)
 Closes a blob-writing stream, if you need to give up without creating a CBLBlob. More...
 
bool CBLBlobWriter_Write (CBLBlobWriteStream *writer, const void *data, size_t length, CBLError *_cbl_nullable outError)
 Writes data to a new blob. More...
 
_cbl_warn_unused CBLBlobCBLBlob_CreateWithStream (FLString contentType, CBLBlobWriteStream *writer)
 Creates a new blob after its data has been written to a CBLBlobWriteStream. More...
 
static bool FLValue_IsBlob (FLValue _cbl_nullable v)
 Returns true if a value in a document is a blob reference. More...
 
static const CBLBlob *_cbl_nullable FLValue_GetBlob (FLValue _cbl_nullable value)
 Instantiates a CBLBlob object corresponding to a blob dictionary in a document. More...
 
void FLSlot_SetBlob (FLSlot slot, CBLBlob *blob)
 Stores a blob reference in a Fleece mutable Array or Dict. More...
 Stores a blob reference in a Fleece mutable Array or Dict. More...
 
const CBLBlob *_cbl_nullable CBLDatabase_GetBlob (CBLDatabase *db, FLDict properties, CBLError *_cbl_nullable outError)
 Get a CBLBlob object from the database using the CBLBlob properties. More...
 
bool CBLDatabase_SaveBlob (CBLDatabase *db, CBLBlob *blob, CBLError *_cbl_nullable outError)
 Save a new CBLBlob object into the database without associating it with any documents. More...
 
- - - - - - - - - - - - - - - - + + + + + + + + + + + +

+

Variables

CBL_CORE_API const FLSlice kCBLTypeProperty
 "@type" More...
 
CBL_CORE_API const FLSlice kCBLBlobType
 "blob" More...
 
CBL_CORE_API const FLSlice kCBLBlobDigestProperty
 "digest" More...
 
CBL_CORE_API const FLSlice kCBLBlobLengthProperty
 "length" More...
 
CBL_CORE_API const FLSlice kCBLBlobContentTypeProperty
 "content_type" More...
 
CBL_PUBLIC const FLSlice kCBLBlobType
 "blob" More...
 
CBL_PUBLIC const FLSlice kCBLBlobDigestProperty
 "digest" More...
 
CBL_PUBLIC const FLSlice kCBLBlobLengthProperty
 "length" More...
 
CBL_PUBLIC const FLSlice kCBLBlobContentTypeProperty
 "content_type" More...
 

Detailed Description

-

A CBLBlob is a binary data blob associated with a document.

-

The content of the blob is not stored in the document, but externally in the database. It is loaded only on demand, and can be streamed. Blobs can be arbitrarily large, although Sync Gateway will only accept blobs under 20MB.

-

The document contains only a blob reference: a dictionary with the special marker property "@type":"blob", and another property digest whose value is a hex SHA-1 digest of the blob's data. This digest is used as the key to retrieve the blob data. The dictionary usually also has the property length, containing the blob's length in bytes, and it may have the property content_type, containing a MIME type.

-

A CBLBlob object acts as a proxy for such a dictionary in a CBLDocument. Once you've loaded a document and located the Fleece Dictionaries holding the blob reference, call FLDict_GetBlob on it to create a CBLBlob object you can call. The object has accessors for the blob's metadata and for loading the data itself.

-

To create a new blob from in-memory data, call CBLBlob_NewWithData, then call FLSlot_SetBlob to add the CBLBlob to a mutable array or dictionary in the document. For example:

FLSlot_SetBlob(FLMutableDict_Set(properties, key), blob);
-

To create a new blob from a stream, call CBLBlobWriter_New to create a CBLBlobWriteStream, then make one or more calls to CBLBlobWriter_Write to write data to the blob, then finally call CBLBlob_NewWithStream to create the blob. To store the blob into a document, do as in the previous paragraph.

+

A CBLBlob is a binary data blob associated with a document.

+

The content of the blob is not stored in the document, but externally in the database. It is loaded only on demand, and can be streamed. Blobs can be arbitrarily large, although Sync Gateway will only accept blobs under 20MB.

+

The document contains only a blob reference: a dictionary with the special marker property "@type":"blob", and another property digest whose value is a hex SHA-1 digest of the blob's data. This digest is used as the key to retrieve the blob data. The dictionary usually also has the property length, containing the blob's length in bytes, and it may have the property content_type, containing a MIME type.

+

A CBLBlob object acts as a proxy for such a dictionary in a CBLDocument. Once you've loaded a document and located the Fleece Dictionaries holding the blob reference, call FLDict_GetBlob on it to create a CBLBlob object you can call. The object has accessors for the blob's metadata and for loading the data itself.

+

To create a new blob from in-memory data, call CBLBlob_CreateWithData, then call FLSlot_SetBlob to add the CBLBlob to a mutable array or dictionary in the document. For example:

FLSlot_SetBlob(FLMutableDict_Set(properties, key), blob);
+

To create a new blob from a stream, call CBLBlobWriter_Create to create a CBLBlobWriteStream, then make one or more calls to CBLBlobWriter_Write to write data to the blob, then finally call CBLBlob_CreateWithStream to create the blob. To store the blob into a document, do as in the previous paragraph.

Typedef Documentation

- +

◆ CBLBlob

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

+

◆ CBLBlobReadStream

@@ -208,7 +214,7 @@

+

◆ CBLBlobWriteStream

@@ -225,8 +231,8 @@

Function Documentation

- -

◆ CBLBlob_Content()

+ +

◆ CBLBlob_Content()

@@ -235,12 +241,12 @@

_cbl_warn_unused FLSliceResult CBLBlob_Content ( const CBLBlob *  - , + blob, - CBLError *  + CBLError *_cbl_nullable  outError  @@ -256,7 +262,7 @@

+

◆ CBLBlob_ContentType()

@@ -276,54 +282,34 @@

-

◆ CBLBlob_Digest()

- -
-
- - - - - - - - -
FLString CBLBlob_Digest (const CBLBlob)
-
- -

Returns the cryptographic digest of a blob's content (from its digest property).

- -
-
- -

◆ CBLBlob_Length()

+ +

◆ CBLBlob_CreateJSON()

- + - +
uint64_t CBLBlob_Length _cbl_warn_unused FLStringResult CBLBlob_CreateJSON ( const CBLBlob)blob)
-

Returns the length in bytes of a blob's content (from its length property).

+

Returns a blob's metadata as JSON.

- -

◆ CBLBlob_NewWithData()

+ +

◆ CBLBlob_CreateWithData()

- + @@ -355,14 +341,14 @@

-

◆ CBLBlob_NewWithStream()

+ +

◆ CBLBlob_CreateWithStream()

_cbl_warn_unused CBLBlob* CBLBlob_NewWithData _cbl_warn_unused CBLBlob * CBLBlob_CreateWithData ( FLString  contentType,
- + @@ -382,7 +368,7 @@

Creates a new blob after its data has been written to a CBLBlobWriteStream.

-

You should then add the blob to a mutable document as a property – see FLSlot_SetBlob.

Note
You are responsible for releasing the CBLBlob reference.
+

You should then add the blob to a mutable document as a property – see FLSlot_SetBlob.

Note
You are responsible for releasing the CBLBlob reference.
Do not free the stream; the blob will do that.
Parameters
@@ -396,23 +382,93 @@

-

◆ CBLBlob_OpenContentStream()

+ +

◆ CBLBlob_Digest()

+ +
+
+

_cbl_warn_unused CBLBlob* CBLBlob_NewWithStream _cbl_warn_unused CBLBlob * CBLBlob_CreateWithStream ( FLString  contentType,
+ + + + + + + +
FLString CBLBlob_Digest (const CBLBlob)
+
+ +

Returns the cryptographic digest of a blob's content (from its digest property).

+ +
+
+ +

◆ CBLBlob_Equals()

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool CBLBlob_Equals (CBLBlobblob,
CBLBlobanotherBlob 
)
+
+ +

Compares whether the two given blobs are equal based on their content.

+ +
+
+ +

◆ CBLBlob_Length()

+ +
+
+ + + + + + + + +
uint64_t CBLBlob_Length (const CBLBlob)
+
+ +

Returns the length in bytes of a blob's content (from its length property).

+ +
+
+ +

◆ CBLBlob_OpenContentStream()

- + - + - + @@ -426,7 +482,7 @@

+

◆ CBLBlob_Properties()

- +

◆ CBLBlob_Release()

@@ -473,8 +529,8 @@

-

◆ CBLBlob_Retain()

+ +

◆ CBLBlob_Retain()

@@ -483,7 +539,7 @@

_cbl_warn_unused CBLBlobReadStream* CBLBlob_OpenContentStream _cbl_warn_unused CBLBlobReadStream *_cbl_nullable CBLBlob_OpenContentStream ( const CBLBlob, blob,
CBLErroroutError _cbl_nullable 
- + @@ -499,28 +555,8 @@

-

◆ CBLBlob_ToJSON()

- -
-
-
static const CBLBlob* CBLBlob_Retain static const CBLBlob * CBLBlob_Retain ( const CBLBlob t)
- - - - - - - -
_cbl_warn_unused FLStringResult CBLBlob_ToJSON (const CBLBlobblob)
-
- -

Returns a blob's metadata as JSON.

- -
-
- -

◆ CBLBlobReader_Close()

+ +

◆ CBLBlobReader_Close()

@@ -529,7 +565,7 @@

void CBLBlobReader_Close ( CBLBlobReadStream *  - ) + _cbl_nullable) @@ -539,8 +575,8 @@

-

◆ CBLBlobReader_Read()

+ +

◆ CBLBlobReader_Read()

@@ -566,7 +602,7 @@

- CBLError *  + CBLError *_cbl_nullable  outError  @@ -591,8 +627,8 @@

-

◆ CBLBlobWriter_Close()

+ +

◆ CBLBlobWriter_Close()

@@ -601,7 +637,7 @@

void CBLBlobWriter_Close ( CBLBlobWriteStream *  - ) + _cbl_nullable) @@ -611,14 +647,14 @@

-

◆ CBLBlobWriter_New()

+ +

◆ CBLBlobWriter_Create()

- + @@ -627,7 +663,7 @@

- + @@ -638,13 +674,13 @@

Opens a stream for writing a new blob.

-

You should next call CBLBlobWriter_Write one or more times to write the data, then CBLBlob_NewWithStream to create the blob.

-

If for some reason you need to abort, just call CBLBlobWriter_Close.

+

You should next call CBLBlobWriter_Write one or more times to write the data, then CBLBlob_CreateWithStream to create the blob.

+

If for some reason you need to abort, just call CBLBlobWriter_Close.

- -

◆ CBLBlobWriter_Write()

+ +

◆ CBLBlobWriter_Write()

@@ -670,7 +706,7 @@

- + @@ -695,16 +731,109 @@

-

◆ FLDict_GetBlob()

+ +

◆ CBLDatabase_GetBlob()

_cbl_warn_unused CBLBlobWriteStream* CBLBlobWriter_New _cbl_warn_unused CBLBlobWriteStream *_cbl_nullable CBLBlobWriter_Create ( CBLDatabase db, CBLErroroutError _cbl_nullable 
CBLErrorCBLError *_cbl_nullable  outError 
- + + + + + + + + + + + + + + + + + + + + +
const CBLBlob* FLDict_GetBlob const CBLBlob *_cbl_nullable CBLDatabase_GetBlob (CBLDatabasedb,
FLDict properties,
CBLError *_cbl_nullable outError 
)
+
+ +

Get a CBLBlob object from the database using the CBLBlob properties.

+

The CBLBlob properties is a blob's metadata containing two required fields which are a special marker property "@type":"blob", and property digest whose value is a hex SHA-1 digest of the blob's data. The other optional properties are length and content_type. To obtain the CBLBlob properties from a CBLBlob, call CBLBlob_Properties function.

+
Note
You must release the CBLBlob when you're finished with it.
+
Parameters
+ + + + +
dbThe database.
propertiesThe properties for getting the CBLBlob object.
outErrorOn failure, error info will be written here if specified. A nonexistent blob is not considered a failure; in that event the error code will be zero.
+
+
+
Returns
A CBLBlob instance, or NULL if the doc doesn't exist or an error occurred.
+ +
+
+ +

◆ CBLDatabase_SaveBlob()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool CBLDatabase_SaveBlob (CBLDatabasedb,
CBLBlobblob,
CBLError *_cbl_nullable outError 
)
+
+ +

Save a new CBLBlob object into the database without associating it with any documents.

+

The properties of the saved CBLBlob object will include information necessary for referencing the CBLBlob object in the properties of the document to be saved into the database.

+

Normally you do not need to use this function unless you are in the situation (e.g. developing javascript binding) that you cannot retain the CBLBlob object until the document containing the CBLBlob object is successfully saved into the database.

Note
The saved CBLBlob objects that are not associated with any documents will be removed from the database when compacting the database.
+
Parameters
+ + + + +
dbThe database.
blobThe The CBLBlob to save.
outErrorOn failure, error info will be written here.
+
+
+ +
+
+ +

◆ FLDict_GetBlob()

+ +
+
+ + + + + @@ -722,8 +851,8 @@

-

◆ FLDict_IsBlob()

+ +

◆ FLDict_IsBlob()

@@ -732,18 +861,18 @@

bool FLDict_IsBlob

- +
const CBLBlob *_cbl_nullable FLDict_GetBlob (FLDict _cbl_nullable  blobDict)
( FLDict )_cbl_nullable)

Returns true if a dictionary in a document is a blob reference.

-

If so, you can call FLDict_GetBlob to access it.

Note
This function tests whether the dictionary has a @type property, whose value is "blob".
+

If so, you can call FLDict_GetBlob to access it.

Note
This function tests whether the dictionary has a @type property, whose value is "blob".
- +

◆ FLSlot_SetBlob()

@@ -772,7 +901,7 @@

Parameters
- +
slotThe position in the collection, as returned by functions like FLMutableArray_Set or FLMutableDict_Set.
slotThe position in the collection, as returned by functions like FLMutableArray_Set or FLMutableDict_Set.
blobThe CBLBlob to store (as a Dict) in the collection.
@@ -780,8 +909,8 @@

-

◆ FLValue_GetBlob()

+ +

◆ FLValue_GetBlob()

- -

◆ kCBLBlobDigestProperty

+ +

◆ kCBLBlobDigestProperty

+ + + + + +
- +
CBL_CORE_API const FLSlice kCBLBlobDigestPropertyCBL_PUBLIC const FLSlice kCBLBlobDigestProperty
+
+extern

"digest"

- -

◆ kCBLBlobLengthProperty

+ +

◆ kCBLBlobLengthProperty

+ + + + + +
- +
CBL_CORE_API const FLSlice kCBLBlobLengthPropertyCBL_PUBLIC const FLSlice kCBLBlobLengthProperty
+
+extern

"length"

- -

◆ kCBLBlobType

+ +

◆ kCBLBlobType

+ + + + + +
- +
CBL_CORE_API const FLSlice kCBLBlobTypeCBL_PUBLIC const FLSlice kCBLBlobType
+
+extern

"blob"

-
-
- -

◆ kCBLTypeProperty

- -
-
- - - - -
CBL_CORE_API const FLSlice kCBLTypeProperty
-
- -

"@type"

-

diff --git a/docs/C/html/group__database.html b/docs/C/html/group__database.html index 5d026c54..a6b73215 100644 --- a/docs/C/html/group__database.html +++ b/docs/C/html/group__database.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Database @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -65,15 +66,14 @@ -
-
Database
+
Database

A CBLDatabase is both a filesystem object and a container for documents. More...

- @@ -82,23 +82,15 @@

+

Data Structures

struct  CBLEncryptionKey
 Encryption key specified in a CBLDatabaseConfiguration. More...
 Database configuration options. More...
 
- - +

+

Typedefs

typedef struct CBLDatabase CBLDatabase
 A connection to an open database. More...
 A connection to an open database. More...
 
- - - - - + @@ -107,96 +99,97 @@ - + - +

-Database configuration

enum  CBLDatabaseFlags : uint32_t { kCBLDatabase_Create = 1, -kCBLDatabase_ReadOnly = 2, -kCBLDatabase_NoUpgrade = 4, -kCBLDatabase_VersionVectors = 0x8000 - }
 Flags for how to open a database. More...
 
enum  CBLEncryptionAlgorithm : uint32_t { kCBLEncryptionNone = 0, -kCBLEncryptionAES256 +

Database configuration

enum  CBLEncryptionAlgorithm : uint32_t { kCBLEncryptionNone = 0 +, kCBLEncryptionAES256 }
 Database encryption algorithms (available only in the Enterprise Edition). More...
 
 Encryption key sizes (in bytes). More...
 
CBLDatabaseConfiguration CBLDatabaseConfiguration_Default (void)
 Returns the default database configuration. More...
 Returns the default database configuration. More...
 
bool CBLEncryptionKey_FromPassword (CBLEncryptionKey *key, FLString password)
 Derives an encryption key from a password. More...
 Derives an encryption key from a password. More...
 
- - - - - - - - - - - -

-Database file operations

These functions operate on database files without opening them.

-
bool CBL_DatabaseExists (FLString name, FLString inDirectory)
 Returns true if a database with the given name exists in the given directory. More...
 
bool CBL_CopyDatabase (FLString fromPath, FLString toName, const CBLDatabaseConfiguration *config, CBLError *)
 Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from the original database when replicating. More...
 
bool CBL_DeleteDatabase (FLString name, FLString inDirectory, CBLError *outError)
 Deletes a database file. More...
 
- - + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +

-Database lifecycle

Opening, closing, and managing open databases.

+

Database lifecycle

Opening, closing, and managing open databases.

enum  CBLMaintenanceType : uint32_t { kCBLMaintenanceTypeCompact = 0, -kCBLMaintenanceTypeReindex, -kCBLMaintenanceTypeIntegrityCheck +
enum  CBLMaintenanceType : uint32_t {
+  kCBLMaintenanceTypeCompact = 0 +, kCBLMaintenanceTypeReindex +, kCBLMaintenanceTypeIntegrityCheck +, kCBLMaintenanceTypeOptimize +,
+  kCBLMaintenanceTypeFullOptimize +
}
 Maintenance Type used when performing database maintenance. More...
 
_cbl_warn_unused CBLDatabaseCBLDatabase_Open (FLSlice name, const CBLDatabaseConfiguration *config, CBLError *error)
 Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance. More...
 
bool CBLDatabase_Close (CBLDatabase *, CBLError *)
 Closes an open database. More...
 
static const CBLDatabaseCBLDatabase_Retain (const CBLDatabase *t)
 
_cbl_warn_unused CBLDatabase *_cbl_nullable CBLDatabase_Open (FLSlice name, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
 Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance. More...
 
bool CBLDatabase_Close (CBLDatabase *, CBLError *_cbl_nullable outError)
 Closes an open database. More...
 
static const CBLDatabaseCBLDatabase_Retain (const CBLDatabase *t)
 
static void CBLDatabase_Release (const CBLDatabase *t)
 
bool CBLDatabase_Delete (CBLDatabase *, CBLError *)
 Closes and deletes a database. More...
 
bool CBLDatabase_BeginBatch (CBLDatabase *, CBLError *)
 Begins a batch operation, similar to a transaction. More...
 
bool CBLDatabase_EndBatch (CBLDatabase *, CBLError *)
 Ends a batch operation. More...
 
bool CBLDatabase_ChangeEncryptionKey (CBLDatabase *, const CBLEncryptionKey *newKey, CBLError *outError)
 Encrypts or decrypts a database, or changes its encryption key. More...
 
bool CBLDatabase_PerformMaintenance (CBLDatabase *db, CBLMaintenanceType type, CBLError *outError)
 Performs database maintenance. More...
 
bool CBLDatabase_Delete (CBLDatabase *, CBLError *_cbl_nullable outError)
 Closes and deletes a database. More...
 
bool CBLDatabase_BeginTransaction (CBLDatabase *, CBLError *_cbl_nullable outError)
 Begins a transaction. More...
 
bool CBLDatabase_EndTransaction (CBLDatabase *, bool commit, CBLError *_cbl_nullable outError)
 Ends a transaction, either committing or aborting. More...
 
bool CBLDatabase_ChangeEncryptionKey (CBLDatabase *, const CBLEncryptionKey *_cbl_nullable newKey, CBLError *outError)
 Encrypts or decrypts a database, or changes its encryption key. More...
 
bool CBLDatabase_PerformMaintenance (CBLDatabase *db, CBLMaintenanceType type, CBLError *_cbl_nullable outError)
 Performs database maintenance. More...
 
+ + + + + + + + +

Database listeners

A database change listener lets you detect changes made to all documents in a database.

+

(If you only want to observe specific documents, use a CBLDocumentChangeListener instead.)

Note
If there are multiple CBLDatabase instances on the same database file, each one's listeners will be notified of changes made by other database instances.
+
Warning
Changes made to the database file by other processes will not be notified.
+
typedef void(* CBLDatabaseChangeListener) (void *_cbl_nullable context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
 A database change listener callback, invoked after one or more documents are changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddChangeListener (const CBLDatabase *db, CBLDatabaseChangeListener listener, void *_cbl_nullable context)
 Registers a database change listener callback. More...
 
+ + + + + + + + + + +

Database file operations

These functions operate on database files without opening them.

+
bool CBL_DatabaseExists (FLString name, FLString inDirectory)
 Returns true if a database with the given name exists in the given directory. More...
 
bool CBL_CopyDatabase (FLString fromPath, FLString toName, const CBLDatabaseConfiguration *_cbl_nullable config, CBLError *_cbl_nullable outError)
 Copies a database file to a new location, and assigns it a new internal UUID to distinguish it from the original database when replicating. More...
 
bool CBL_DeleteDatabase (FLString name, FLString inDirectory, CBLError *_cbl_nullable outError)
 Deletes a database file. More...
 
- - + - + - + - + - + -

-Database accessors

Getting information about a database.

+

Database accessors

Getting information about a database.

FLString CBLDatabase_Name (const CBLDatabase *)
 Returns the database's name. More...
 Returns the database's name. More...
 
_cbl_warn_unused FLStringResult CBLDatabase_Path (const CBLDatabase *)
 Returns the database's full filesystem path. More...
 Returns the database's full filesystem path. More...
 
uint64_t CBLDatabase_Count (const CBLDatabase *)
 Returns the number of documents in the database. More...
 Returns the number of documents in the database. More...
 
const CBLDatabaseConfiguration CBLDatabase_Config (const CBLDatabase *)
 Returns the database's configuration, as given when it was opened. More...
 Returns the database's configuration, as given when it was opened. More...
 
- - - - - - - -

-Database listeners

A database change listener lets you detect changes made to all documents in a database.

-

(If you only want to observe specific documents, use a CBLDocumentChangeListener instead.)

Note
If there are multiple CBLDatabase instances on the same database file, each one's listeners will be notified of changes made by other database instances.
-
Warning
Changes made to the database file by other processes will not be notified.
-
typedef void(* CBLDatabaseChangeListener) (void *context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])
 A database change listener callback, invoked after one or more documents are changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddChangeListener (const CBLDatabase *db, CBLDatabaseChangeListener listener, void *context)
 Registers a database change listener callback. More...
 

Detailed Description

-

A CBLDatabase is both a filesystem object and a container for documents.

+

A CBLDatabase is both a filesystem object and a container for documents.

Typedef Documentation

- +

◆ CBLDatabase

@@ -212,20 +205,20 @@

-

◆ CBLDatabaseChangeListener

+ +

◆ CBLDatabaseChangeListener

- +
typedef void(* CBLDatabaseChangeListener) (void *context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])typedef void(* CBLDatabaseChangeListener) (void *_cbl_nullable context, const CBLDatabase *db, unsigned numDocs, FLString docIDs[])

A database change listener callback, invoked after one or more documents are changed on disk.

-
Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
+
Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
Parameters
@@ -239,33 +232,7 @@

Enumeration Type Documentation

- -

◆ CBLDatabaseFlags

- -
-
-
contextAn arbitrary value given when the callback was registered.
- - - -
enum CBLDatabaseFlags : uint32_t
-
- -

Flags for how to open a database.

- - - - - -
Enumerator
kCBLDatabase_Create 

Create the file if it doesn't exist.

-
kCBLDatabase_ReadOnly 

Open file read-only.

-
kCBLDatabase_NoUpgrade 

Disable upgrading an older-version database.

-
kCBLDatabase_VersionVectors 

EXPERIMENTAL: Upgrade DB to use version vectors.

-
- -
-
- +

◆ CBLEncryptionAlgorithm

@@ -279,15 +246,15 @@

-EnumeratorkCBLEncryptionNone 

No encryption (default)

+EnumeratorkCBLEncryptionNone 

No encryption (default)

-kCBLEncryptionAES256 

AES with 256-bit key.

+kCBLEncryptionAES256 

AES with 256-bit key.

- +

◆ CBLEncryptionKeySize

@@ -301,13 +268,13 @@

-EnumeratorkCBLEncryptionKeySizeAES256 

Key size for kCBLEncryptionAES256.

+EnumeratorkCBLEncryptionKeySizeAES256 

Key size for kCBLEncryptionAES256.

- +

◆ CBLMaintenanceType

@@ -321,19 +288,25 @@

-EnumeratorkCBLMaintenanceTypeCompact 

Compact the database file and delete unused attachments.

+EnumeratorkCBLMaintenanceTypeCompact 

Compact the database file and delete unused attachments.

-kCBLMaintenanceTypeReindex 

Rebuild the entire database's indexes.

+kCBLMaintenanceTypeReindex 

Rebuild the entire database's indexes.

-kCBLMaintenanceTypeIntegrityCheck 

Check for the database’s corruption. If found, an error will be returned.

+kCBLMaintenanceTypeIntegrityCheck 

Check for the database’s corruption. If found, an error will be returned.

+ +kCBLMaintenanceTypeOptimize 

Partially scan indexes to gather database statistics that help optimize queries.

+

This operation is also performed automatically when closing the database.

+ +kCBLMaintenanceTypeFullOptimize 

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.

Function Documentation

- -

◆ CBL_CopyDatabase()

+ +

◆ CBL_CopyDatabase()

- +

◆ CBL_DatabaseExists()

@@ -419,8 +393,8 @@

-

◆ CBL_DeleteDatabase()

+ +

◆ CBL_DeleteDatabase()

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

- CBLError *  + CBLError *_cbl_nullable  outError  @@ -452,7 +426,7 @@

Deletes a database file.

-

If the database file is open, an error is returned.

Parameters
+

If the database file is open, an error is returned.

Parameters
@@ -464,14 +438,14 @@

-

◆ CBLDatabase_AddChangeListener()

+ +

◆ CBLDatabase_AddChangeListener()

nameThe database name (without the ".cblite2" extension.)
inDirectoryThe directory containing the database. If NULL, name must be an absolute or relative path to the database.
- + @@ -479,13 +453,13 @@

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

Registers a database change listener callback.

-

It will be called after one or more documents are changed on disk.

Parameters
+

It will be called after one or more documents are changed on disk.

Parameters

_cbl_warn_unused CBLListenerToken* CBLDatabase_AddChangeListener _cbl_warn_unused CBLListenerToken * CBLDatabase_AddChangeListener ( const CBLDatabase db, CBLDatabaseChangeListener CBLDatabaseChangeListener  listener,
void * void *_cbl_nullable  context 
@@ -505,18 +479,18 @@

Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
+
Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
- -

◆ CBLDatabase_BeginBatch()

+ +

◆ CBLDatabase_BeginTransaction()

dbThe database to observe.
listenerThe callback to be invoked.
- + @@ -524,8 +498,8 @@

- - + + @@ -535,17 +509,17 @@

-

Begins a batch operation, similar to a transaction.

-

You must later call CBLDatabase_EndBatch to end (commit) the batch.

Note
Multiple writes are much faster when grouped inside a single batch.
+

Begins a transaction.

+

You must later call CBLDatabase_EndTransaction to commit or abort the transaction.

Note
Multiple writes are much faster when grouped in a transaction.
-Changes will not be visible to other CBLDatabase instances on the same database until the batch operation ends.
+Changes will not be visible to other CBLDatabase instances on the same database until the transaction ends.
-Batch operations can nest. Changes are not committed until the outer batch ends.
+Transactions can nest. Changes are not committed until the outer transaction ends.
- -

◆ CBLDatabase_ChangeEncryptionKey()

+ +

◆ CBLDatabase_ChangeEncryptionKey()

@@ -559,7 +533,7 @@

- + @@ -577,12 +551,12 @@

Encrypts or decrypts a database, or changes its encryption key.

-

If newKey is NULL, or its algorithm is kCBLEncryptionNone, the database will be decrypted. Otherwise the database will be encrypted with that key; if it was already encrypted, it will be re-encrypted with the new key.

+

If newKey is NULL, or its algorithm is kCBLEncryptionNone, the database will be decrypted. Otherwise the database will be encrypted with that key; if it was already encrypted, it will be re-encrypted with the new key.

- -

◆ CBLDatabase_Close()

+ +

◆ CBLDatabase_Close()

@@ -596,8 +570,8 @@

- - + + @@ -611,7 +585,7 @@

+

◆ CBLDatabase_Config()

@@ -632,7 +606,7 @@

+

◆ CBLDatabase_Count()

@@ -652,8 +626,8 @@

-

◆ CBLDatabase_Delete()

+ +

◆ CBLDatabase_Delete()

@@ -667,8 +641,8 @@

- - + + @@ -679,18 +653,18 @@

Closes and deletes a database.

-

If there are any other connections to the database, an error is returned.

+

If there are any other connections to the database, an error is returned.

-
-

◆ CBLDatabase_EndBatch()

+ +

◆ CBLDatabase_EndTransaction()

bool CBLDatabase_BeginBatch bool CBLDatabase_BeginTransaction ( CBLDatabase , CBLError CBLError *_cbl_nullable outError 
const CBLEncryptionKeyconst CBLEncryptionKey *_cbl_nullable  newKey,
CBLError CBLError *_cbl_nullable outError 
CBLError CBLError *_cbl_nullable outError 
- + @@ -698,8 +672,14 @@

- - + + + + + + + + @@ -709,12 +689,11 @@

-

Ends a batch operation.

-

This must be called after CBLDatabase_BeginBatch.

+

Ends a transaction, either committing or aborting.

- +

◆ CBLDatabase_Name()

@@ -734,14 +713,14 @@

-

◆ CBLDatabase_Open()

+ +

◆ CBLDatabase_Open()

bool CBLDatabase_EndBatch bool CBLDatabase_EndTransaction ( CBLDatabase , CBLError bool commit,
CBLError *_cbl_nullable outError 
- + @@ -749,14 +728,14 @@

- + - - + + @@ -767,11 +746,11 @@

Opens a database, or creates it if it doesn't exist yet, returning a new CBLDatabase instance.

-

It's OK to open the same database file multiple times. Each CBLDatabase instance is independent of the others (and must be separately closed and released.)

Parameters
+

It's OK to open the same database file multiple times. Each CBLDatabase instance is independent of the others (and must be separately closed and released.)

Parameters

_cbl_warn_unused CBLDatabase* CBLDatabase_Open _cbl_warn_unused CBLDatabase *_cbl_nullable CBLDatabase_Open ( FLSlice  name, const CBLDatabaseConfigurationconst CBLDatabaseConfiguration *_cbl_nullable  config,
CBLErrorerror CBLError *_cbl_nullable outError 
- +
nameThe database name (without the ".cblite2" extension.)
configThe database configuration (directory and encryption option.)
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.
@@ -779,7 +758,7 @@

+

◆ CBLDatabase_Path()

@@ -799,8 +778,8 @@

-

◆ CBLDatabase_PerformMaintenance()

+ +

◆ CBLDatabase_PerformMaintenance()

@@ -820,7 +799,7 @@

- CBLError *  + CBLError *_cbl_nullable  outError  @@ -835,7 +814,7 @@

+

◆ CBLDatabase_Release()

@@ -861,8 +840,8 @@

-

◆ CBLDatabase_Retain()

+ +

◆ CBLDatabase_Retain()

- + +/* @license-end */ +
@@ -64,35 +65,34 @@
-
-
Fleece Delta Compression
+
Fleece Delta Compression

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

- - + - + - + - +

+

Functions

FLSliceResult FLCreateJSONDelta (FLValue old, FLValue nuu)
 Returns JSON that encodes the changes to turn the value old into nuu. More...
 Returns JSON that encodes the changes to turn the value old into nuu. More...
 
bool FLEncodeJSONDelta (FLValue old, FLValue nuu, FLEncoder jsonEncoder)
 Writes JSON that describes the changes to turn the value old into nuu. More...
 Writes JSON that describes the changes to turn the value old into nuu. More...
 
FLSliceResult FLApplyJSONDelta (FLValue old, FLSlice jsonDelta, FLError *error)
 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...
 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 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...
 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...
 

Detailed Description

-

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.

Function Documentation

- +

◆ FLApplyJSONDelta()

@@ -137,7 +137,7 @@

+

◆ FLCreateJSONDelta()

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

@@ -63,148 +64,148 @@
-
-
Documents
+Typedefs | +Variables
+
Documents

A CBLDocument is essentially a JSON object with an ID string that's unique in its database. More...

- - +

+

Typedefs

typedef struct CBLDocument CBLDocument
 An in-memory copy of a document. More...
 An in-memory copy of a document. More...
 
- - + + + +

-Document lifecycle

enum  CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins, -kCBLConcurrencyControlFailOnConflict +

+Variables

CBL_PUBLIC const FLSlice kCBLTypeProperty
 "@type" More...
 
+ + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +

Document lifecycle

enum  CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins +, kCBLConcurrencyControlFailOnConflict }
 Conflict-handling options when saving or deleting a document. More...
 
typedef bool(* CBLConflictHandler) (void *context, CBLDocument *documentBeingSaved, const CBLDocument *conflictingDocument)
 Custom conflict handler for use when saving or deleting a document. More...
 
_cbl_warn_unused const CBLDocumentCBLDatabase_GetDocument (const CBLDatabase *database, FLString docID)
 Reads a document from the database, creating a new (immutable) CBLDocument object. More...
 
static const CBLDocumentCBLDocument_Retain (const CBLDocument *t)
 
typedef bool(* CBLConflictHandler) (void *_cbl_nullable context, CBLDocument *_cbl_nullable documentBeingSaved, const CBLDocument *_cbl_nullable conflictingDocument)
 Custom conflict handler for use when saving or deleting a document. More...
 
_cbl_warn_unused const CBLDocument *_cbl_nullable CBLDatabase_GetDocument (const CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Reads a document from the database, creating a new (immutable) CBLDocument object. More...
 
static const CBLDocumentCBLDocument_Retain (const CBLDocument *t)
 
static void CBLDocument_Release (const CBLDocument *t)
 
bool CBLDatabase_SaveDocument (CBLDatabase *db, CBLDocument *doc, CBLError *error)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConcurrencyControl (CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *error)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConflictHandler (CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *context, CBLError *error)
 Saves a (mutable) document to the database, allowing for custom conflict handling in the event that the document has been updated since doc was loaded. More...
 
bool CBLDatabase_DeleteDocument (CBLDatabase *db, const CBLDocument *document, CBLError *error)
 Deletes a document from the database. More...
 
bool CBLDatabase_DeleteDocumentWithConcurrencyControl (CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *error)
 Deletes a document from the database. More...
 
bool CBLDatabase_PurgeDocument (CBLDatabase *db, const CBLDocument *document, CBLError *error)
 Purges a document. More...
 
bool CBLDatabase_PurgeDocumentByID (CBLDatabase *database, FLString docID, CBLError *error)
 Purges a document, given only its ID. More...
 
bool CBLDatabase_SaveDocument (CBLDatabase *db, CBLDocument *doc, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConcurrencyControl (CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database. More...
 
bool CBLDatabase_SaveDocumentWithConflictHandler (CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *_cbl_nullable context, CBLError *_cbl_nullable outError)
 Saves a (mutable) document to the database, allowing for custom conflict handling in the event that the document has been updated since doc was loaded. More...
 
bool CBLDatabase_DeleteDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
 Deletes a document from the database. More...
 
bool CBLDatabase_DeleteDocumentWithConcurrencyControl (CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
 Deletes a document from the database. More...
 
bool CBLDatabase_PurgeDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError)
 Purges a document. More...
 
bool CBLDatabase_PurgeDocumentByID (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Purges a document, given only its ID. More...
 
+ + + + + + + +

Document listeners

A document change listener lets you detect changes made to a specific document after they are persisted to the database.

+
Note
If there are multiple CBLDatabase instances on the same database file, each one's document listeners will be notified of changes made by other database instances.
+
typedef void(* CBLDocumentChangeListener) (void *context, const CBLDatabase *db, FLString docID)
 A document change listener callback, invoked after a specific document is changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddDocumentChangeListener (const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
 Registers a document change listener callback. More...
 
- - + - - - - - - - - - - - - + + + + + + + + + + + +

-Mutable documents

The type CBLDocument* without a const qualifier refers to a mutable document instance.

-

A mutable document exposes its properties as a mutable dictionary, so you can change them in place and then call CBLDatabase_SaveDocument to persist the changes.

+

Mutable documents

The type CBLDocument* without a const qualifier refers to a mutable document instance.

+

A mutable document exposes its properties as a mutable dictionary, so you can change them in place and then call CBLDatabase_SaveDocument to persist the changes.

_cbl_warn_unused CBLDocumentCBLDatabase_GetMutableDocument (CBLDatabase *database, FLString docID)
 Reads a document from the database, in mutable form that can be updated and saved. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_New (void) _cbl_returns_nonnull
 Creates a new, empty document in memory, with a randomly-generated unique ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_NewWithID (FLString docID) _cbl_returns_nonnull
 Creates a new, empty document in memory, with the given ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_ToMutable (const CBLDocument *original) _cbl_returns_nonnull
 Creates a new mutable CBLDocument instance that refers to the same document as the original. More...
 
_cbl_warn_unused CBLDocument *_cbl_nullable CBLDatabase_GetMutableDocument (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError)
 Reads a document from the database, in mutable form that can be updated and saved. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_Create (void)
 Creates a new, empty document in memory, with a randomly-generated unique ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_CreateWithID (FLString docID)
 Creates a new, empty document in memory, with the given ID. More...
 
_cbl_warn_unused CBLDocumentCBLDocument_MutableCopy (const CBLDocument *original)
 Creates a new mutable CBLDocument instance that refers to the same document as the original. More...
 
- - + - + - + - + - + - - - + + + - + - - - - - - - - - - - - - - -

-Document properties and metadata

A document's body is essentially a JSON object.

-

The properties are accessed in memory using the Fleece API, with the body itself being a dictionary).

+

Document properties and metadata

A document's body is essentially a JSON object.

+

The properties are accessed in memory using the Fleece API, with the body itself being a dictionary).

FLString CBLDocument_ID (const CBLDocument *)
 Returns a document's ID. More...
 Returns a document's ID. More...
 
FLString CBLDocument_RevisionID (const CBLDocument *)
 Returns a document's revision ID, which is a short opaque string that's guaranteed to be unique to every change made to the document. More...
 Returns a document's revision ID, which is a short opaque string that's guaranteed to be unique to every change made to the document. More...
 
uint64_t CBLDocument_Sequence (const CBLDocument *)
 Returns a document's current sequence in the local database. More...
 Returns a document's current sequence in the local database. More...
 
FLDict CBLDocument_Properties (const CBLDocument *)
 Returns a document's properties as a dictionary. More...
 Returns a document's properties as a dictionary. More...
 
FLMutableDict CBLDocument_MutableProperties (CBLDocument *) _cbl_returns_nonnull
 Returns a mutable document's properties as a mutable dictionary. More...
 
FLMutableDict CBLDocument_MutableProperties (CBLDocument *)
 Returns a mutable document's properties as a mutable dictionary. More...
 
void CBLDocument_SetProperties (CBLDocument *, FLMutableDict properties)
 Sets a mutable document's properties. More...
 Sets a mutable document's properties. More...
 
FLDoc CBLDocument_ToFleeceDoc (const CBLDocument *)
 
_cbl_warn_unused FLSliceResult CBLDocument_ToJSON (const CBLDocument *)
 Returns a document's properties as JSON. More...
 
bool CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *)
 Sets a mutable document's properties from a JSON string. More...
 
CBLTimestamp CBLDatabase_GetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLError *error)
 Returns the time, if any, at which a given document will expire and be purged. More...
 
bool CBLDatabase_SetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *error)
 Sets or clears the expiration time of a document. More...
 
- - - - - - - - + + + + + + + + + + + +

-Document listeners

A document change listener lets you detect changes made to a specific document after they are persisted to the database.

-
Note
If there are multiple CBLDatabase instances on the same database file, each one's document listeners will be notified of changes made by other database instances.
-
typedef void(* CBLDocumentChangeListener) (void *context, const CBLDatabase *db, FLString docID)
 A document change listener callback, invoked after a specific document is changed on disk. More...
 
_cbl_warn_unused CBLListenerTokenCBLDatabase_AddDocumentChangeListener (const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *context)
 Registers a document change listener callback. More...
 
_cbl_warn_unused FLSliceResult CBLDocument_CreateJSON (const CBLDocument *)
 Returns a document's properties as JSON. More...
 
bool CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *_cbl_nullable outError)
 Sets a mutable document's properties from a JSON string. More...
 
CBLTimestamp CBLDatabase_GetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLError *_cbl_nullable outError)
 Returns the time, if any, at which a given document will expire and be purged. More...
 
bool CBLDatabase_SetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *_cbl_nullable outError)
 Sets or clears the expiration time of a document. More...
 

Detailed Description

-

A CBLDocument is essentially a JSON object with an ID string that's unique in its database.

+

A CBLDocument is essentially a JSON object with an ID string that's unique in its database.

Typedef Documentation

- -

◆ CBLConflictHandler

+ +

◆ CBLConflictHandler

- +
typedef bool(* CBLConflictHandler) (void *context, CBLDocument *documentBeingSaved, const CBLDocument *conflictingDocument)typedef bool(* CBLConflictHandler) (void *_cbl_nullable context, CBLDocument *_cbl_nullable documentBeingSaved, const CBLDocument *_cbl_nullable conflictingDocument)

Custom conflict handler for use when saving or deleting a document.

-

This handler is called if the save would cause a conflict, i.e. if the document in the database has been updated (probably by a pull replicator, or by application code on another thread) since it was loaded into the CBLDocument being saved.

Parameters
+

This handler is called if the save would cause a conflict, i.e. if the document in the database has been updated (probably by a pull replicator, or by application code on another thread) since it was loaded into the CBLDocument being saved.

Parameters
- - + +
contextThe value of the context parameter you passed to CBLDatabase_SaveDocumentWithConflictHandler.
documentBeingSavedThe document being saved (same as the parameter you passed to CBLDatabase_SaveDocumentWithConflictHandler.) The callback may modify this document's properties as necessary to resolve the conflict.
contextThe value of the context parameter you passed to CBLDatabase_SaveDocumentWithConflictHandler.
documentBeingSavedThe document being saved (same as the parameter you passed to CBLDatabase_SaveDocumentWithConflictHandler.) The callback may modify this document's properties as necessary to resolve the conflict.
conflictingDocumentThe revision of the document currently in the database, which has been changed since documentBeingSaved was loaded. May be NULL, meaning that the document has been deleted.
@@ -213,7 +214,7 @@

+

◆ CBLDocument

- +

◆ CBLDocumentChangeListener

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

A document change listener callback, invoked after a specific document is changed on disk.

-
Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
+
Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
Parameters
@@ -256,7 +257,7 @@

Enumeration Type Documentation

- +

◆ CBLConcurrencyControl

@@ -270,23 +271,23 @@

-

-
contextAn arbitrary value given when the callback was registered.
Enumerator
kCBLConcurrencyControlLastWriteWins 

The current save/delete will overwrite a conflicting revision if there is a conflict.

+
Enumerator
kCBLConcurrencyControlLastWriteWins 

The current save/delete will overwrite a conflicting revision if there is a conflict.

kCBLConcurrencyControlFailOnConflict 

The current save/delete will fail if there is a conflict.

+
kCBLConcurrencyControlFailOnConflict 

The current save/delete will fail if there is a conflict.

Function Documentation

-
-

◆ CBLDatabase_AddDocumentChangeListener()

+ +

◆ CBLDatabase_AddDocumentChangeListener()

- + @@ -318,7 +319,7 @@

Registers a document change listener callback.

-

It will be called after a specific document is changed on disk.

Parameters
+

It will be called after a specific document is changed on disk.

Parameters

_cbl_warn_unused CBLListenerToken* CBLDatabase_AddDocumentChangeListener _cbl_warn_unused CBLListenerToken * CBLDatabase_AddDocumentChangeListener ( const CBLDatabase db,
@@ -327,12 +328,12 @@

Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
+
Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
- -

◆ CBLDatabase_DeleteDocument()

+ +

◆ CBLDatabase_DeleteDocument()

@@ -352,8 +353,8 @@

- - + + @@ -364,12 +365,12 @@

Deletes a document from the database.

-

Deletions are replicated.

Warning
You are still responsible for releasing the CBLDocument.
+

Deletions are replicated.

Warning
You are still responsible for releasing the CBLDocument.
Parameters

dbThe database to observe.
docIDThe ID of the document to observe.
CBLErrorerror CBLError *_cbl_nullable outError 
- +
dbThe database containing the document.
documentThe document to delete.
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.

@@ -377,8 +378,8 @@

-

◆ CBLDatabase_DeleteDocumentWithConcurrencyControl()

+ +

◆ CBLDatabase_DeleteDocumentWithConcurrencyControl()

@@ -404,8 +405,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -416,13 +417,13 @@

Deletes a document from the database.

-

Deletions are replicated.

Warning
You are still responsible for releasing the CBLDocument.
+

Deletions are replicated.

Warning
You are still responsible for releasing the CBLDocument.
Parameters
- +
dbThe database containing the document.
documentThe document to delete.
concurrencyConflict-handling strategy.
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.
@@ -430,14 +431,14 @@

-

◆ CBLDatabase_GetDocument()

+ +

◆ CBLDatabase_GetDocument()

- + @@ -446,7 +447,13 @@

- + + + + + + + @@ -457,20 +464,21 @@

Reads a document from the database, creating a new (immutable) CBLDocument object.

-

Each call to this function creates a new object (which must later be released.)

Note
If you are reading the document in order to make changes to it, call CBLDatabase_GetMutableDocument instead.
+

Each call to this function creates a new object (which must later be released.)

Note
If you are reading the document in order to make changes to it, call CBLDatabase_GetMutableDocument instead.
Parameters

_cbl_warn_unused const CBLDocument* CBLDatabase_GetDocument _cbl_warn_unused const CBLDocument *_cbl_nullable CBLDatabase_GetDocument ( const CBLDatabase database, FLString docID docID,
CBLError *_cbl_nullable outError 
+
databaseThe database.
docIDThe ID of the document.
outErrorOn failure, the error will be written here. (A nonexistent document is not considered a failure; in that event the error code will be zero.)
-
Returns
A new CBLDocument instance, or NULL if no document with that ID exists.
+
Returns
A new CBLDocument instance, or NULL if the doc doesn't exist or an error occurred.
- -

◆ CBLDatabase_GetDocumentExpiration()

+ +

◆ CBLDatabase_GetDocumentExpiration()

@@ -490,8 +498,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -502,11 +510,11 @@

Returns the time, if any, at which a given document will expire and be purged.

-

Documents don't normally expire; you have to call CBLDatabase_SetDocumentExpiration to set a document's expiration time.

Parameters
+

Documents don't normally expire; you have to call CBLDatabase_SetDocumentExpiration to set a document's expiration time.

Parameters
- +
dbThe database.
docIDThe ID of the document.
errorOn failure, an error is written here.
outErrorOn failure, an error is written here.
@@ -514,14 +522,14 @@

-

◆ CBLDatabase_GetMutableDocument()

+ +

◆ CBLDatabase_GetMutableDocument()

- + @@ -530,7 +538,13 @@

- + + + + + + + @@ -541,20 +555,21 @@

Reads a document from the database, in mutable form that can be updated and saved.

-

(This function is otherwise identical to CBLDatabase_GetDocument.)

Note
You must release the document when you're done with it.
+

(This function is otherwise identical to CBLDatabase_GetDocument.)

Note
You must release the document when you're done with it.
Parameters

_cbl_warn_unused CBLDocument* CBLDatabase_GetMutableDocument _cbl_warn_unused CBLDocument *_cbl_nullable CBLDatabase_GetMutableDocument ( CBLDatabase database, FLString docID docID,
CBLError *_cbl_nullable outError 
+
databaseThe database.
docIDThe ID of the document.
outErrorOn failure, the error will be written here. (A nonexistent document is not considered a failure; in that event the error code will be zero.)

-
Returns
A new mutable CBLDocument instance, or NULL if no document with that ID exists.
+
Returns
A new CBLDocument instance, or NULL if the doc doesn't exist or an error occurred.

- -

◆ CBLDatabase_PurgeDocument()

+ +

◆ CBLDatabase_PurgeDocument()

@@ -574,8 +589,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -586,13 +601,13 @@

Purges a document.

-

This removes all traces of the document from the database. Purges are not replicated. If the document is changed on a server, it will be re-created when pulled.

Warning
You are still responsible for releasing the CBLDocument reference.
-
Note
If you don't have the document in memory already, CBLDatabase_PurgeDocumentByID is a simpler shortcut.
+

This removes all traces of the document from the database. Purges are not replicated. If the document is changed on a server, it will be re-created when pulled.

Warning
You are still responsible for releasing the CBLDocument reference.
+
Note
If you don't have the document in memory already, CBLDatabase_PurgeDocumentByID is a simpler shortcut.
Parameters
- +
dbThe database containing the document.
documentThe document to delete.
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.
@@ -600,8 +615,8 @@

-

◆ CBLDatabase_PurgeDocumentByID()

+ +

◆ CBLDatabase_PurgeDocumentByID()

@@ -621,8 +636,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -638,7 +653,7 @@

databaseThe database. docIDThe document ID to purge. - errorOn failure, the error will be written here. + outErrorOn failure, the error will be written here. @@ -646,8 +661,8 @@

-

◆ CBLDatabase_SaveDocument()

+ +

◆ CBLDatabase_SaveDocument()

@@ -667,8 +682,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -679,12 +694,12 @@

Saves a (mutable) document to the database.

-
Warning
If a newer revision has been saved since doc was loaded, it will be overwritten by this one. This can lead to data loss! To avoid this, call CBLDatabase_SaveDocumentWithConcurrencyControl or CBLDatabase_SaveDocumentWithConflictHandler instead.
+
Warning
If a newer revision has been saved since doc was loaded, it will be overwritten by this one. This can lead to data loss! To avoid this, call CBLDatabase_SaveDocumentWithConcurrencyControl or CBLDatabase_SaveDocumentWithConflictHandler instead.
Parameters
- +
dbThe database to save to.
docThe mutable document to save.
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.
@@ -692,8 +707,8 @@

-

◆ CBLDatabase_SaveDocumentWithConcurrencyControl()

+ +

◆ CBLDatabase_SaveDocumentWithConcurrencyControl()

@@ -719,8 +734,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -731,12 +746,12 @@

Saves a (mutable) document to the database.

-

If a conflicting revision has been saved since doc was loaded, the concurrency parameter specifies whether the save should fail, or the conflicting revision should be overwritten with the revision being saved. If you need finer-grained control, call CBLDatabase_SaveDocumentWithConflictHandler instead.

Parameters
+

If a conflicting revision has been saved since doc was loaded, the concurrency parameter specifies whether the save should fail, or the conflicting revision should be overwritten with the revision being saved. If you need finer-grained control, call CBLDatabase_SaveDocumentWithConflictHandler instead.

Parameters
- +
dbThe database to save to.
docThe mutable document to save.
concurrencyConflict-handling strategy (fail or overwrite).
errorOn failure, the error will be written here.
outErrorOn failure, the error will be written here.
@@ -744,8 +759,8 @@

-

◆ CBLDatabase_SaveDocumentWithConflictHandler()

+ +

◆ CBLDatabase_SaveDocumentWithConflictHandler()

@@ -803,8 +818,8 @@

-

◆ CBLDatabase_SetDocumentExpiration()

+ +

◆ CBLDatabase_SetDocumentExpiration()

@@ -830,8 +845,8 @@

- CBLError *  - error  + CBLError *_cbl_nullable  + outError  @@ -847,7 +862,7 @@

dbThe database. docIDThe ID of the document. expirationThe expiration time as a CBLTimestamp (milliseconds since Unix epoch), or 0 if the document should never expire. - errorOn failure, an error is written here. + outErrorOn failure, an error is written here. @@ -855,100 +870,142 @@

-

◆ CBLDocument_ID()

+ +

◆ CBLDocument_Create()

- + - +
FLString CBLDocument_ID _cbl_warn_unused CBLDocument * CBLDocument_Create (const CBLDocumentvoid  )
-

Returns a document's ID.

+

Creates a new, empty document in memory, with a randomly-generated unique ID.

+

It will not be added to a database until saved.

Returns
The new mutable document instance.
- -

◆ CBLDocument_MutableProperties()

+ +

◆ CBLDocument_CreateJSON()

- + - +
FLMutableDict CBLDocument_MutableProperties _cbl_warn_unused FLSliceResult CBLDocument_CreateJSON (CBLDocumentconst CBLDocument )
-

Returns a mutable document's properties as a mutable dictionary.

-

You may modify this dictionary and then call CBLDatabase_SaveDocument to persist the changes.

Note
The dictionary object is owned by the document; you do not need to release it.
-
-Every call to this function returns the same mutable collection. This is the same collection returned by CBLDocument_Properties.
-
Warning
When the document is released, this reference to the properties becomes invalid. If you need to use any properties after releasing the document, you must retain them by calling FLValue_Retain (and of course later release them.)
+

Returns a document's properties as JSON.

+
Note
You are responsible for releasing the result by calling FLSliceResult_Release.
- -

◆ CBLDocument_New()

+ +

◆ CBLDocument_CreateWithID()

- + - + + + + +
_cbl_warn_unused CBLDocument* CBLDocument_New _cbl_warn_unused CBLDocument * CBLDocument_CreateWithID (void FLString docID)
+
+ +

Creates a new, empty document in memory, with the given ID.

+

It will not be added to a database until saved.

Note
If the given ID conflicts with a document already in the database, that will not be apparent until this document is saved. At that time, the result depends on the conflict handling mode used when saving; see the save functions for details.
+
Parameters
+ + +
docIDThe ID of the new document, or NULL to assign a new unique ID.
+
+
+
Returns
The new mutable document instance.
+ +
+
+ +

◆ CBLDocument_ID()

+ +
+
+ + + + +
FLString CBLDocument_ID (const CBLDocument )
-

Creates a new, empty document in memory, with a randomly-generated unique ID.

-

It will not be added to a database until saved.

Returns
The new mutable document instance.
+

Returns a document's ID.

- -

◆ CBLDocument_NewWithID()

+ +

◆ CBLDocument_MutableCopy()

- + - - + +
_cbl_warn_unused CBLDocument* CBLDocument_NewWithID _cbl_warn_unused CBLDocument * CBLDocument_MutableCopy (FLString docID)const CBLDocumentoriginal)
-

Creates a new, empty document in memory, with the given ID.

-

It will not be added to a database until saved.

Note
If the given ID conflicts with a document already in the database, that will not be apparent until this document is saved. At that time, the result depends on the conflict handling mode used when saving; see the save functions for details.
-
Parameters
- - -
docIDThe ID of the new document, or NULL to assign a new unique ID.
-
-
-
Returns
The new mutable document instance.
+

Creates a new mutable CBLDocument instance that refers to the same document as the original.

+

If the original document has unsaved changes, the new one will also start out with the same changes; but mutating one document thereafter will not affect the other.

Note
You must release the new reference when you're done with it. Similarly, the original document still exists and must also be released when you're done with it.
- + +

◆ CBLDocument_MutableProperties()

+ +
+
+ + + + + + + + +
FLMutableDict CBLDocument_MutableProperties (CBLDocument)
+
+ +

Returns a mutable document's properties as a mutable dictionary.

+

You may modify this dictionary and then call CBLDatabase_SaveDocument to persist the changes.

Note
The dictionary object is owned by the document; you do not need to release it.
+
+Every call to this function returns the same mutable collection. This is the same collection returned by CBLDocument_Properties.
+
Warning
When the document is released, this reference to the properties becomes invalid. If you need to use any properties after releasing the document, you must retain them by calling FLValue_Retain (and of course later release them.)
+ +
+
+

◆ CBLDocument_Properties()

@@ -968,11 +1025,11 @@

Note
The dictionary object is owned by the document; you do not need to release it.
Warning
When the document is released, this reference to the properties becomes invalid. If you need to use any properties after releasing the document, you must retain them by calling FLValue_Retain (and of course later release them.)
-This dictionary reference is immutable, but if the document is mutable the underlying dictionary itself is mutable and could be modified through a mutable reference obtained via CBLDocument_MutableProperties. If you need to preserve the properties, call FLDict_MutableCopy to make a deep copy.
+This dictionary reference is immutable, but if the document is mutable the underlying dictionary itself is mutable and could be modified through a mutable reference obtained via CBLDocument_MutableProperties. If you need to preserve the properties, call FLDict_MutableCopy to make a deep copy.

- +

◆ CBLDocument_Release()

@@ -998,8 +1055,8 @@

-

◆ CBLDocument_Retain()

+ +

◆ CBLDocument_Retain()

@@ -1008,7 +1065,7 @@

- + @@ -1024,7 +1081,7 @@

+

◆ CBLDocument_RevisionID()

- +

◆ CBLDocument_Sequence()

- -

◆ CBLDocument_SetJSON()

+ +

◆ CBLDocument_SetJSON()

@@ -1087,8 +1144,8 @@

- - + + @@ -1102,7 +1159,7 @@

+

◆ CBLDocument_SetProperties()

@@ -1129,76 +1186,39 @@

Sets a mutable document's properties.

-

Call CBLDatabase_SaveDocument to persist the changes.

Note
The dictionary object will be retained by the document. You are responsible for releasing any retained reference(s) you have to it.
- -

- - -

◆ CBLDocument_ToFleeceDoc()

- -
-
-
static const CBLDocument* CBLDocument_Retain static const CBLDocument * CBLDocument_Retain ( const CBLDocument t)CBLError CBLError *_cbl_nullable outError 
- - - - - - - -
FLDoc CBLDocument_ToFleeceDoc (const CBLDocument)
-

+

Call CBLDatabase_SaveDocument to persist the changes.

Note
The dictionary object will be retained by the document. You are responsible for releasing any retained reference(s) you have to it.
- -

◆ CBLDocument_ToJSON()

- -
-
- - - - - - - - -
_cbl_warn_unused FLSliceResult CBLDocument_ToJSON (const CBLDocument)
-
- -

Returns a document's properties as JSON.

-
Note
You are responsible for releasing the result by calling FLSliceResult_Release.
- -
-
- -

◆ CBLDocument_ToMutable()

+

Variable Documentation

+ +

◆ kCBLTypeProperty

+ + + + + +
- - - - - +
_cbl_warn_unused CBLDocument* CBLDocument_ToMutable (const CBLDocumentoriginal)CBL_PUBLIC const FLSlice kCBLTypeProperty
+
+extern
-

Creates a new mutable CBLDocument instance that refers to the same document as the original.

-

If the original document has unsaved changes, the new one will also start out with the same changes; but mutating one document thereafter will not affect the other.

Note
You must release the new reference when you're done with it. Similarly, the original document still exists and must also be released when you're done with it.
+

"@type"

diff --git a/docs/C/html/group__encryptables.html b/docs/C/html/group__encryptables.html new file mode 100644 index 00000000..c562f028 --- /dev/null +++ b/docs/C/html/group__encryptables.html @@ -0,0 +1,659 @@ + + + + + + + +Couchbase Lite C: Encryptables + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+ +
Encryptables
+
+
+ +

A CBLEncryptable is a value to be encrypted by the replicator when a document is pushed to the remote server. +More...

+ + + + + +

+Typedefs

typedef struct CBLEncryptable CBLEncryptable
 An encryptable value. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

static const CBLEncryptableCBLEncryptable_Retain (const CBLEncryptable *t)
 
static void CBLEncryptable_Release (const CBLEncryptable *t)
 
CBLEncryptableCBLEncryptable_CreateWithNull (void)
 Creates CBLEncryptable object with null value. More...
 
CBLEncryptableCBLEncryptable_CreateWithBool (bool value)
 Creates CBLEncryptable object with a boolean value. More...
 
CBLEncryptableCBLEncryptable_CreateWithInt (int64_t value)
 Creates CBLEncryptable object with an int value. More...
 
CBLEncryptableCBLEncryptable_CreateWithUInt (uint64_t value)
 Creates CBLEncryptable object with an unsigned int value. More...
 
CBLEncryptableCBLEncryptable_CreateWithFloat (float value)
 Creates CBLEncryptable object with a float value. More...
 
CBLEncryptableCBLEncryptable_CreateWithDouble (double value)
 Creates CBLEncryptable object with a double value. More...
 
CBLEncryptableCBLEncryptable_CreateWithString (FLString value)
 Creates CBLEncryptable object with a string value. More...
 
CBLEncryptableCBLEncryptable_CreateWithValue (FLValue value)
 Creates CBLEncryptable object with an FLValue value. More...
 
CBLEncryptableCBLEncryptable_CreateWithArray (FLArray value)
 Creates CBLEncryptable object with an FLArray value. More...
 
CBLEncryptableCBLEncryptable_CreateWithDict (FLDict value)
 Creates CBLEncryptable object with an FLDict value. More...
 
FLValue CBLEncryptable_Value (const CBLEncryptable *encryptable)
 Returns the value to be encrypted by the push replicator. More...
 
FLDict CBLEncryptable_Properties (const CBLEncryptable *encryptable)
 Returns the dictionary format of the CBLEncryptable object. More...
 
bool FLDict_IsEncryptableValue (FLDict _cbl_nullable)
 Checks whether the given dictionary is a CBLEncryptable or not. More...
 
static bool FLValue_IsEncryptableValue (FLValue _cbl_nullable value)
 Checks whether the given FLValue is a CBLEncryptable or not. More...
 
const CBLEncryptable *_cbl_nullable FLDict_GetEncryptableValue (FLDict _cbl_nullable encryptableDict)
 Returns a CBLEncryptable object corresponding to the given encryptable dictionary in a document or NULL if the dictionary is not a CBLEncryptable. More...
 
static const CBLEncryptable *_cbl_nullable FLValue_GetEncryptableValue (FLValue _cbl_nullable value)
 Returns a CBLEncryptable object corresponding to the given Fleece Value Accessors in a document or NULL if the value is not a CBLEncryptable. More...
 
void FLSlot_SetEncryptableValue (FLSlot slot, const CBLEncryptable *encryptable)
 Set a CBLEncryptable's dictionary in a Fleece mutable Dict. More...
 
+ + + + + + + +

+Variables

CBL_PUBLIC const FLSlice kCBLEncryptableType
 "encryptable" More...
 
CBL_PUBLIC const FLSlice kCBLEncryptableValueProperty
 "value" More...
 
+

Detailed Description

+

A CBLEncryptable is a value to be encrypted by the replicator when a document is pushed to the remote server.

+

When a document is pulled from the remote server, the encrypted value will be decrypted by the replicator.

+

Similar to CBLBlob, a CBLEncryptable acts as a proxy for a dictionary structure with the special marker property "@type":"encryptable", and another property value whose value is the actual value to be encrypted by the push replicator.

+

The push replicator will automatically detect CBLEncryptable dictionaries inside the document and calls the specified CBLPropertyEncryptor callback to encrypt the actual value. When the value is successfully encrypted, the replicator will transform the property key and the encrypted CBLPropertyEncryptor dictionary value into Couchbase Server SDK's encrypted field format :

+

The original key will be prefixed with 'encrypted$'.

+

The transformed CBLEncryptable dictionary will contain alg property indicating the encryption algorithm, ciphertext property whose value is a base-64 string of the encrypted value, and optionally kid property indicating the encryption key identifier if specified when returning the result of CBLPropertyEncryptor callback call.

+

For security reason, a document that contains CBLEncryptable dictionaries will fail to push with the kCBLErrorCrypto error if their value cannot be encrypted including when a CBLPropertyEncryptor callback is not specified or when there is an error or a null result returned from the callback call.

+

The pull replicator will automatically detect the encrypted properties that are in the Couchbase Server SDK's encrypted field format and call the specified CBLPropertyDecryptor callback to decrypt the encrypted value. When the value is successfully decrypted, the replicator will transform the property format back to the CBLEncryptable format including removing the 'encrypted$' prefix.

+

The CBLPropertyDecryptor callback can intentionally skip the decryption by returnning a null result. When a decryption is skipped, the encrypted property in the form of Couchbase Server SDK's encrypted field format will be kept as it was received from the remote server. If an error is returned from the callback call, the document will be failed to pull with the kCBLErrorCrypto error.

+

If a CBLPropertyDecryptor callback is not specified, the replicator will not attempt to detect any encrypted properties. As a result, all encrypted properties in the form of Couchbase Server SDK's encrypted field format will be kept as they was received from the remote server.

+

To create a new CBLEncryptable, call CBLEncryptable_CreateWith<Value Type> function such as CBLEncryptable_CreateWithString. Then call FLSlot_SetEncryptableValue to add the CBLEncryptable to a dictionary in the document. Noted that adding CBLEncryptable to an array is not supported. For example:

+

FLSlot_SetEncryptableValue(FLMutableDict_Set(properties, key), encryptableValue);

+

Note: When creating a CBLEncryptable, you are responsible for releasing the CBLEncryptable object but not until its document is saved into the database.

+

When a document is loaded from the database, call FLDict_GetEncryptableValue on an Encryptable dictionary value to obtain a CBLEncryptable object.

+

Typedef Documentation

+ +

◆ CBLEncryptable

+ +
+
+ + + + +
typedef struct CBLEncryptable CBLEncryptable
+
+ +

An encryptable value.

+

The encryptable values will be encrypted by a push replicator via the specified property encryptor callback when the document is push to the remote server. Likewise, the encryptable values will be decrypted by a pull replicator via the specified property decryptor callback when the document is pulled from the remote server.

+ +
+
+

Function Documentation

+ +

◆ CBLEncryptable_CreateWithArray()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithArray (FLArray value)
+
+ +

Creates CBLEncryptable object with an FLArray value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithBool()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithBool (bool value)
+
+ +

Creates CBLEncryptable object with a boolean value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithDict()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithDict (FLDict value)
+
+ +

Creates CBLEncryptable object with an FLDict value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithDouble()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithDouble (double value)
+
+ +

Creates CBLEncryptable object with a double value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithFloat()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithFloat (float value)
+
+ +

Creates CBLEncryptable object with a float value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithInt()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithInt (int64_t value)
+
+ +

Creates CBLEncryptable object with an int value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithNull()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithNull (void )
+
+ +

Creates CBLEncryptable object with null value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithString()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithString (FLString value)
+
+ +

Creates CBLEncryptable object with a string value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithUInt()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithUInt (uint64_t value)
+
+ +

Creates CBLEncryptable object with an unsigned int value.

+ +
+
+ +

◆ CBLEncryptable_CreateWithValue()

+ +
+
+ + + + + + + + +
CBLEncryptable * CBLEncryptable_CreateWithValue (FLValue value)
+
+ +

Creates CBLEncryptable object with an FLValue value.

+ +
+
+ +

◆ CBLEncryptable_Properties()

+ +
+
+ + + + + + + + +
FLDict CBLEncryptable_Properties (const CBLEncryptableencryptable)
+
+ +

Returns the dictionary format of the CBLEncryptable object.

+ +
+
+ +

◆ CBLEncryptable_Release()

+ +
+
+ + + + + +
+ + + + + + + + +
static void CBLEncryptable_Release (const CBLEncryptablet)
+
+inlinestatic
+
+ +
+
+ +

◆ CBLEncryptable_Retain()

+ +
+
+ + + + + +
+ + + + + + + + +
static const CBLEncryptable * CBLEncryptable_Retain (const CBLEncryptablet)
+
+inlinestatic
+
+ +
+
+ +

◆ CBLEncryptable_Value()

+ +
+
+ + + + + + + + +
FLValue CBLEncryptable_Value (const CBLEncryptableencryptable)
+
+ +

Returns the value to be encrypted by the push replicator.

+ +
+
+ +

◆ FLDict_GetEncryptableValue()

+ +
+
+ + + + + + + + +
const CBLEncryptable *_cbl_nullable FLDict_GetEncryptableValue (FLDict _cbl_nullable encryptableDict)
+
+ +

Returns a CBLEncryptable object corresponding to the given encryptable dictionary in a document or NULL if the dictionary is not a CBLEncryptable.

+
Note
The returned CBLEncryptable object will be released when its document is released.
+ +
+
+ +

◆ FLDict_IsEncryptableValue()

+ +
+
+ + + + + + + + +
bool FLDict_IsEncryptableValue (FLDict _cbl_nullable)
+
+ +

Checks whether the given dictionary is a CBLEncryptable or not.

+ +
+
+ +

◆ FLSlot_SetEncryptableValue()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void FLSlot_SetEncryptableValue (FLSlot slot,
const CBLEncryptableencryptable 
)
+
+ +

Set a CBLEncryptable's dictionary in a Fleece mutable Dict.

+ +
+
+ +

◆ FLValue_GetEncryptableValue()

+ +
+
+ + + + + +
+ + + + + + + + +
static const CBLEncryptable *_cbl_nullable FLValue_GetEncryptableValue (FLValue _cbl_nullable value)
+
+inlinestatic
+
+ +

Returns a CBLEncryptable object corresponding to the given Fleece Value Accessors in a document or NULL if the value is not a CBLEncryptable.

+
Note
The returned CBLEncryptable object will be released when its document is released.
+ +
+
+ +

◆ FLValue_IsEncryptableValue()

+ +
+
+ + + + + +
+ + + + + + + + +
static bool FLValue_IsEncryptableValue (FLValue _cbl_nullable value)
+
+inlinestatic
+
+ +

Checks whether the given FLValue is a CBLEncryptable or not.

+ +
+
+

Variable Documentation

+ +

◆ kCBLEncryptableType

+ +
+
+ + + + + +
+ + + + +
CBL_PUBLIC const FLSlice kCBLEncryptableType
+
+extern
+
+ +

"encryptable"

+ +
+
+ +

◆ kCBLEncryptableValueProperty

+ +
+
+ + + + + +
+ + + + +
CBL_PUBLIC const FLSlice kCBLEncryptableValueProperty
+
+extern
+
+ +

"value"

+ +
+
+
+ + + + diff --git a/docs/C/html/group__errors.html b/docs/C/html/group__errors.html index 8e4f781f..fa3bc07a 100644 --- a/docs/C/html/group__errors.html +++ b/docs/C/html/group__errors.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Errors @@ -30,21 +30,22 @@
- + +/* @license-end */ +

@@ -66,110 +67,109 @@ Data Structures | Enumerations | Functions
-
-
Errors
+
Errors

Types and constants for communicating errors from API calls. More...

-

+

Data Structures

struct  CBLError
 A struct holding information about an error. More...
 
-

+

Enumerations

enum  CBLErrorDomain : uint8_t {
-  CBLDomain = 1, -CBLPOSIXDomain, -CBLSQLiteDomain, -CBLFleeceDomain, -
-  CBLNetworkDomain, -CBLWebSocketDomain +  kCBLDomain = 1 +, kCBLPOSIXDomain +, kCBLSQLiteDomain +, kCBLFleeceDomain +,
+  kCBLNetworkDomain +, kCBLWebSocketDomain
}
 Error domains, serving as namespaces for numeric error codes. More...
 
enum  CBLErrorCode : int32_t {
-  CBLErrorAssertionFailed = 1, -CBLErrorUnimplemented, -CBLErrorUnsupportedEncryption, -CBLErrorBadRevisionID, -
-  CBLErrorCorruptRevisionData, -CBLErrorNotOpen, -CBLErrorNotFound, -CBLErrorConflict, -
-  CBLErrorInvalidParameter, -CBLErrorUnexpectedError, -CBLErrorCantOpenFile, -CBLErrorIOError, -
-  CBLErrorMemoryError, -CBLErrorNotWriteable, -CBLErrorCorruptData, -CBLErrorBusy, -
-  CBLErrorNotInTransaction, -CBLErrorTransactionNotClosed, -CBLErrorUnsupported, -CBLErrorNotADatabaseFile, -
-  CBLErrorWrongFormat, -CBLErrorCrypto, -CBLErrorInvalidQuery, -CBLErrorMissingIndex, -
-  CBLErrorInvalidQueryParam, -CBLErrorRemoteError, -CBLErrorDatabaseTooOld, -CBLErrorDatabaseTooNew, -
-  CBLErrorBadDocID, -CBLErrorCantUpgradeDatabase +  kCBLErrorAssertionFailed = 1 +, kCBLErrorUnimplemented +, kCBLErrorUnsupportedEncryption +, kCBLErrorBadRevisionID +,
+  kCBLErrorCorruptRevisionData +, kCBLErrorNotOpen +, kCBLErrorNotFound +, kCBLErrorConflict +,
+  kCBLErrorInvalidParameter +, kCBLErrorUnexpectedError +, kCBLErrorCantOpenFile +, kCBLErrorIOError +,
+  kCBLErrorMemoryError +, kCBLErrorNotWriteable +, kCBLErrorCorruptData +, kCBLErrorBusy +,
+  kCBLErrorNotInTransaction +, kCBLErrorTransactionNotClosed +, kCBLErrorUnsupported +, kCBLErrorNotADatabaseFile +,
+  kCBLErrorWrongFormat +, kCBLErrorCrypto +, kCBLErrorInvalidQuery +, kCBLErrorMissingIndex +,
+  kCBLErrorInvalidQueryParam +, kCBLErrorRemoteError +, kCBLErrorDatabaseTooOld +, kCBLErrorDatabaseTooNew +,
+  kCBLErrorBadDocID +, kCBLErrorCantUpgradeDatabase
}
 Couchbase Lite error codes, in the CBLDomain. More...
 
enum  CBLNetworkErrorCode : int32_t {
-  CBLNetErrDNSFailure = 1, -CBLNetErrUnknownHost, -CBLNetErrTimeout, -CBLNetErrInvalidURL, -
-  CBLNetErrTooManyRedirects, -CBLNetErrTLSHandshakeFailed, -CBLNetErrTLSCertExpired, -CBLNetErrTLSCertUntrusted, -
-  CBLNetErrTLSClientCertRequired, -CBLNetErrTLSClientCertRejected, -CBLNetErrTLSCertUnknownRoot, -CBLNetErrInvalidRedirect, -
-  CBLNetErrUnknown, -CBLNetErrTLSCertRevoked, -CBLNetErrTLSCertNameMismatch +  kCBLNetErrDNSFailure = 1 +, kCBLNetErrUnknownHost +, kCBLNetErrTimeout +, kCBLNetErrInvalidURL +,
+  kCBLNetErrTooManyRedirects +, kCBLNetErrTLSHandshakeFailed +, kCBLNetErrTLSCertExpired +, kCBLNetErrTLSCertUntrusted +,
+  kCBLNetErrTLSClientCertRequired +, kCBLNetErrTLSClientCertRejected +, kCBLNetErrTLSCertUnknownRoot +, kCBLNetErrInvalidRedirect +,
+  kCBLNetErrUnknown +, kCBLNetErrTLSCertRevoked +, kCBLNetErrTLSCertNameMismatch
}
 Network error codes, in the CBLNetworkDomain. More...
 
- - - - + + +

+

Functions

FLSliceResult CBLError_Message (const CBLError *)
 Returns a message describing an error. More...
 
FLSliceResult CBLError_Message (const CBLError *_cbl_nullable outError)
 Returns a message describing an error. More...
 

Detailed Description

-

Types and constants for communicating errors from API calls.

+

Types and constants for communicating errors from API calls.

Enumeration Type Documentation

- +

◆ CBLErrorCode

@@ -183,70 +183,70 @@

-EnumeratorCBLErrorAssertionFailed 

Internal assertion failure.

+EnumeratorkCBLErrorAssertionFailed 

Internal assertion failure.

-CBLErrorUnimplemented 

Oops, an unimplemented API call.

+kCBLErrorUnimplemented 

Oops, an unimplemented API call.

-CBLErrorUnsupportedEncryption 

Unsupported encryption algorithm.

+kCBLErrorUnsupportedEncryption 

Unsupported encryption algorithm.

-CBLErrorBadRevisionID 

Invalid revision ID syntax.

+kCBLErrorBadRevisionID 

Invalid revision ID syntax.

-CBLErrorCorruptRevisionData 

Revision contains corrupted/unreadable data.

+kCBLErrorCorruptRevisionData 

Revision contains corrupted/unreadable data.

-CBLErrorNotOpen 

Database/KeyStore/index is not open.

+kCBLErrorNotOpen 

Database/KeyStore/index is not open.

-CBLErrorNotFound 

Document not found.

+kCBLErrorNotFound 

Document not found.

-CBLErrorConflict 

Document update conflict.

+kCBLErrorConflict 

Document update conflict.

-CBLErrorInvalidParameter 

Invalid function parameter or struct value.

+kCBLErrorInvalidParameter 

Invalid function parameter or struct value.

-CBLErrorUnexpectedError  -CBLErrorCantOpenFile 

Internal unexpected C++ exception.

-

Database file can't be opened; may not exist

+kCBLErrorUnexpectedError  +kCBLErrorCantOpenFile 

Internal unexpected C++ exception.

+

Database file can't be opened; may not exist

-CBLErrorIOError 

File I/O error.

+kCBLErrorIOError 

File I/O error.

-CBLErrorMemoryError 

Memory allocation failed (out of memory?)

+kCBLErrorMemoryError 

Memory allocation failed (out of memory?)

-CBLErrorNotWriteable 

File is not writeable.

+kCBLErrorNotWriteable 

File is not writeable.

-CBLErrorCorruptData 

Data is corrupted.

+kCBLErrorCorruptData 

Data is corrupted.

-CBLErrorBusy 

Database is busy/locked.

+kCBLErrorBusy 

Database is busy/locked.

-CBLErrorNotInTransaction 

Function must be called while in a transaction.

+kCBLErrorNotInTransaction 

Function must be called while in a transaction.

-CBLErrorTransactionNotClosed 

Database can't be closed while a transaction is open.

+kCBLErrorTransactionNotClosed 

Database can't be closed while a transaction is open.

-CBLErrorUnsupported 

Operation not supported in this database.

+kCBLErrorUnsupported 

Operation not supported in this database.

-CBLErrorNotADatabaseFile  -CBLErrorWrongFormat 

File is not a database, or encryption key is wrong.

-

Database exists but not in the format/storage requested

+kCBLErrorNotADatabaseFile  +kCBLErrorWrongFormat 

File is not a database, or encryption key is wrong.

+

Database exists but not in the format/storage requested

-CBLErrorCrypto 

Encryption/decryption error.

+kCBLErrorCrypto 

Encryption/decryption error.

-CBLErrorInvalidQuery 

Invalid query.

+kCBLErrorInvalidQuery 

Invalid query.

-CBLErrorMissingIndex 

No such index, or query requires a nonexistent index.

+kCBLErrorMissingIndex 

No such index, or query requires a nonexistent index.

-CBLErrorInvalidQueryParam 

Unknown query param name, or param number out of range.

+kCBLErrorInvalidQueryParam 

Unknown query param name, or param number out of range.

-CBLErrorRemoteError 

Unknown error from remote server.

+kCBLErrorRemoteError 

Unknown error from remote server.

-CBLErrorDatabaseTooOld 

Database file format is older than what I can open.

+kCBLErrorDatabaseTooOld 

Database file format is older than what I can open.

-CBLErrorDatabaseTooNew 

Database file format is newer than what I can open.

+kCBLErrorDatabaseTooNew 

Database file format is newer than what I can open.

-CBLErrorBadDocID 

Invalid document ID.

+kCBLErrorBadDocID 

Invalid document ID.

-CBLErrorCantUpgradeDatabase  +kCBLErrorCantUpgradeDatabase 

- +

◆ CBLErrorDomain

@@ -260,23 +260,23 @@

-EnumeratorCBLDomain 

code is a Couchbase Lite error code; see CBLErrorCode

+EnumeratorkCBLDomain 

code is a Couchbase Lite error code; see CBLErrorCode

-CBLPOSIXDomain 

code is a POSIX errno; see "errno.h"

+kCBLPOSIXDomain 

code is a POSIX errno; see "errno.h"

-CBLSQLiteDomain 

code is a SQLite error; see "sqlite3.h"

+kCBLSQLiteDomain 

code is a SQLite error; see "sqlite3.h"

-CBLFleeceDomain 

code is a Fleece error; see "FleeceException.h"

+kCBLFleeceDomain 

code is a Fleece error; see "FleeceException.h"

-CBLNetworkDomain 

code is a network error; see CBLNetworkErrorCode

+kCBLNetworkDomain 

code is a network error; see CBLNetworkErrorCode

-CBLWebSocketDomain 

code is a WebSocket close code (1000...1015) or HTTP error (300..599)

+kCBLWebSocketDomain 

code is a WebSocket close code (1000...1015) or HTTP error (300..599)

- +

◆ CBLNetworkErrorCode

@@ -290,43 +290,43 @@

-EnumeratorCBLNetErrDNSFailure 

DNS lookup failed.

+EnumeratorkCBLNetErrDNSFailure 

DNS lookup failed.

-CBLNetErrUnknownHost 

DNS server doesn't know the hostname.

+kCBLNetErrUnknownHost 

DNS server doesn't know the hostname.

-CBLNetErrTimeout 

No response received before timeout.

+kCBLNetErrTimeout 

No response received before timeout.

-CBLNetErrInvalidURL 

Invalid URL.

+kCBLNetErrInvalidURL 

Invalid URL.

-CBLNetErrTooManyRedirects 

HTTP redirect loop.

+kCBLNetErrTooManyRedirects 

HTTP redirect loop.

-CBLNetErrTLSHandshakeFailed 

Low-level error establishing TLS.

+kCBLNetErrTLSHandshakeFailed 

Low-level error establishing TLS.

-CBLNetErrTLSCertExpired 

Server's TLS certificate has expired.

+kCBLNetErrTLSCertExpired 

Server's TLS certificate has expired.

-CBLNetErrTLSCertUntrusted 

Cert isn't trusted for other reason.

+kCBLNetErrTLSCertUntrusted 

Cert isn't trusted for other reason.

-CBLNetErrTLSClientCertRequired 

Server requires client to have a TLS certificate.

+kCBLNetErrTLSClientCertRequired 

Server requires client to have a TLS certificate.

-CBLNetErrTLSClientCertRejected 

Server rejected my TLS client certificate.

+kCBLNetErrTLSClientCertRejected 

Server rejected my TLS client certificate.

-CBLNetErrTLSCertUnknownRoot 

Self-signed cert, or unknown anchor cert.

+kCBLNetErrTLSCertUnknownRoot 

Self-signed cert, or unknown anchor cert.

-CBLNetErrInvalidRedirect 

Attempted redirect to invalid URL.

+kCBLNetErrInvalidRedirect 

Attempted redirect to invalid URL.

-CBLNetErrUnknown 

Unknown networking error.

+kCBLNetErrUnknown 

Unknown networking error.

-CBLNetErrTLSCertRevoked 

Server's cert has been revoked.

+kCBLNetErrTLSCertRevoked 

Server's cert has been revoked.

-CBLNetErrTLSCertNameMismatch 

Server cert's name does not match DNS name.

+kCBLNetErrTLSCertNameMismatch 

Server cert's name does not match DNS name.

Function Documentation

- -

◆ CBLError_Message()

+ +

◆ CBLError_Message()

@@ -334,8 +334,8 @@

FLSliceResult CBLError_Message ( - const CBLError *  - ) + const CBLError *_cbl_nullable  + outError) @@ -349,9 +349,7 @@

diff --git a/docs/C/html/group__json.html b/docs/C/html/group__json.html index 59736cca..905377f2 100644 --- a/docs/C/html/group__json.html +++ b/docs/C/html/group__json.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Converting Fleece To JSON @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -64,50 +65,48 @@
-
-
Converting Fleece To JSON
+
Converting Fleece To JSON

These are convenience functions that directly return JSON-encoded output. More...

- - + - + - + - +

+

Functions

FLStringResult FLValue_ToJSON (FLValue)
 Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings. More...
 Encodes a Fleece value as JSON (or a JSON fragment.) Any Data values will become base64-encoded JSON strings. More...
 
FLStringResult FLValue_ToJSON5 (FLValue v)
 Encodes a Fleece value as JSON5, a more lenient variant of JSON that allows dictionary keys to be unquoted if they're alphanumeric. More...
 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 v, bool json5, bool canonicalForm)
 Most general Fleece to JSON converter. More...
 Most general Fleece to JSON converter. More...
 
FLStringResult FLJSON5_ToJSON (FLString json5, FLStringResult *outErrorMessage, size_t *outErrorPos, FLError *outError)
 Converts valid JSON5 https://json5.org to JSON. More...
 Converts valid JSON5 https://json5.org to JSON. More...
 
- - - - - - - + + + + + + +

-Debugging Functions

const char * FLDump (FLValue)
 Debugging function that returns a C string of JSON. More...
 
const char * FLDumpData (FLSlice data)
 Debugging function that returns a C string of JSON. More...
 

Debugging Functions

const char * FLDump (FLValue)
 Debugging function that returns a C string of JSON. More...
 
const char * 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.

+

These are convenience functions that directly return JSON-encoded output.

+

For more control over the encoding, use an FLEncoder.

Function Documentation

- -

◆ FLDump()

+ +

◆ FLDump()

- + @@ -117,18 +116,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* FLDump const char * FLDump ( FLValue  )
- + @@ -138,11 +137,11 @@

Debugging function that returns a C string of JSON.

-

Does not free the string's memory!

+

Does not free the string's memory!

-
+

◆ FLJSON5_ToJSON()

@@ -181,7 +180,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

const char* FLDumpData const char * FLDumpData ( FLSlice  data)
@@ -195,7 +194,7 @@

+

◆ FLValue_ToJSON()

- +

◆ FLValue_ToJSONX()

@@ -275,9 +274,7 @@

diff --git a/docs/C/html/group__listeners.html b/docs/C/html/group__listeners.html index a28f1671..2f628584 100644 --- a/docs/C/html/group__listeners.html +++ b/docs/C/html/group__listeners.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Listeners @@ -30,21 +30,22 @@

json5The JSON5 to parse
- + +/* @license-end */ +
@@ -65,51 +66,49 @@ -
-
Listeners
+
Listeners

Every API function that registers a listener callback returns an opaque token representing the registered callback. More...

- - +

+

Typedefs

typedef struct CBLListenerToken CBLListenerToken
 An opaque 'cookie' representing a registered listener callback. More...
 An opaque 'cookie' representing a registered listener callback. More...
 
- - - - + + +

+

Functions

void CBLListener_Remove (CBLListenerToken *)
 Removes a listener callback, given the token that was returned when it was added. More...
 
void CBLListener_Remove (CBLListenerToken *_cbl_nullable)
 Removes a listener callback, given the token that was returned when it was added. More...
 
- - + - - - - - - + + + + + + - +

-Scheduling notifications

Applications may want control over when Couchbase Lite notifications (listener callbacks) happen.

-

They may want them called on a specific thread, or at certain times during an event loop. This behavior may vary by database, if for instance each database is associated with a separate thread.

-

The API calls here enable this. When notifications are "buffered" for a database, calls to listeners will be deferred until the application explicitly allows them. Instead, a single callback will be issued when the first notification becomes available; this gives the app a chance to schedule a time when the notifications should be sent and callbacks called.

+

Scheduling notifications

Applications may want control over when Couchbase Lite notifications (listener callbacks) happen.

+

They may want them called on a specific thread, or at certain times during an event loop. This behavior may vary by database, if for instance each database is associated with a separate thread.

+

The API calls here enable this. When notifications are "buffered" for a database, calls to listeners will be deferred until the application explicitly allows them. Instead, a single callback will be issued when the first notification becomes available; this gives the app a chance to schedule a time when the notifications should be sent and callbacks called.

typedef void(* CBLNotificationsReadyCallback) (void *context, CBLDatabase *db)
 Callback indicating that the database (or an object belonging to it) is ready to call one or more listeners. More...
 
void CBLDatabase_BufferNotifications (CBLDatabase *db, CBLNotificationsReadyCallback callback, void *context)
 Switches the database to buffered-notification mode. More...
 
typedef void(* CBLNotificationsReadyCallback) (void *_cbl_nullable context, CBLDatabase *db)
 Callback indicating that the database (or an object belonging to it) is ready to call one or more listeners. More...
 
void CBLDatabase_BufferNotifications (CBLDatabase *db, CBLNotificationsReadyCallback callback, void *_cbl_nullable context)
 Switches the database to buffered-notification mode. More...
 
void CBLDatabase_SendNotifications (CBLDatabase *db)
 Immediately issues all pending notifications for this database, by calling their listener callbacks. More...
 Immediately issues all pending notifications for this database, by calling their listener callbacks. More...
 

Detailed Description

-

Every API function that registers a listener callback returns an opaque token representing the registered callback.

-

To unregister any type of listener, call CBLListener_Remove.

-

The steps to creating a listener are:

    +

    Every API function that registers a listener callback returns an opaque token representing the registered callback.

    +

    To unregister any type of listener, call CBLListener_Remove.

    +

    The steps to creating a listener are:

    1. Define the type of contextual information the callback needs. This is usually one of your objects, or a custom struct.
    2. Implement the listener function:
      • The parameters and return value must match the callback defined in the API.
      • The first parameter is always a void* that points to your contextual information, so cast that to the actual pointer type.
      • -
      • The function may be called on a background thread! And since the CBL API is not itself thread-safe, you'll need to take special precautions if you want to call the API from your listener, such as protecting all of your calls (inside and outside the listener) with a mutex. It's safer to use CBLDatabase_BufferNotifications to schedule listener callbacks to a time of your own choosing, such as your thread's event loop; see that function's docs for details.
      • +
      • The function may be called on a background thread! And since the CBL API is not itself thread-safe, you'll need to take special precautions if you want to call the API from your listener, such as protecting all of your calls (inside and outside the listener) with a mutex. It's safer to use CBLDatabase_BufferNotifications to schedule listener callbacks to a time of your own choosing, such as your thread's event loop; see that function's docs for details.
    3. To register the listener, call the relevant AddListener function.
        @@ -117,13 +116,13 @@
      • The return value is a CBLListenerToken pointer; save that.
    4. -
    5. To unregister the listener, pass the CBLListenerToken to CBLListener_Remove.
        +
      • To unregister the listener, pass the CBLListenerToken to CBLListener_Remove.
        • You must unregister the listener before the contextual information pointer is invalidated, e.g. before freeing the object it points to.

    Typedef Documentation

    - +

    ◆ CBLListenerToken

- -

◆ CBLNotificationsReadyCallback

+ +

◆ CBLNotificationsReadyCallback

- +
typedef void(* CBLNotificationsReadyCallback) (void *context, CBLDatabase *db)typedef void(* CBLNotificationsReadyCallback) (void *_cbl_nullable context, CBLDatabase *db)

Callback indicating that the database (or an object belonging to it) is ready to call one or more listeners.

-

You should call CBLDatabase_SendNotifications at your earliest convenience, in the context (thread, dispatch queue, etc.) you want them to run.

Note
This callback is called only once until the next time CBLDatabase_SendNotifications is called. If you don't respond by (sooner or later) calling that function, you will not be informed that any listeners are ready.
+

You should call CBLDatabase_SendNotifications at your earliest convenience, in the context (thread, dispatch queue, etc.) you want them to run.

Note
This callback is called only once until the next time CBLDatabase_SendNotifications is called. If you don't respond by (sooner or later) calling that function, you will not be informed that any listeners are ready.
Warning
This can be called from arbitrary threads. It should do as little work as possible, just scheduling a future call to CBLDatabase_SendNotifications.

Function Documentation

- -

◆ CBLDatabase_BufferNotifications()

+ +

◆ CBLDatabase_BufferNotifications()

@@ -174,13 +173,13 @@

- CBLNotificationsReadyCallback  + CBLNotificationsReadyCallback  callback, - void *  + void *_cbl_nullable  context  @@ -192,7 +191,7 @@

Switches the database to buffered-notification mode.

-

Notifications for objects belonging to this database (documents, queries, replicators, and of course the database) will not be called immediately; your CBLNotificationsReadyCallback will be called instead.

Parameters
+

Notifications for objects belonging to this database (documents, queries, replicators, and of course the database) will not be called immediately; your CBLNotificationsReadyCallback will be called instead.

Parameters
@@ -203,7 +202,7 @@

+

◆ CBLDatabase_SendNotifications()

@@ -223,8 +222,8 @@

-

◆ CBLListener_Remove()

+ +

◆ CBLListener_Remove()

@@ -233,7 +232,7 @@

void CBLListener_Remove

- +
dbThe database whose notifications are to be buffered.
callbackThe function to be called when a notification is available.
( CBLListenerToken)_cbl_nullable)
@@ -246,9 +245,7 @@

diff --git a/docs/C/html/group__logging.html b/docs/C/html/group__logging.html index d8473837..ed9b2515 100644 --- a/docs/C/html/group__logging.html +++ b/docs/C/html/group__logging.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Logging @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -66,92 +67,85 @@ Data Structures | Enumerations | Functions
-
-
Logging
+
Logging

Managing messages that Couchbase Lite logs at runtime. More...

-

+

Data Structures

struct  CBLLogFileConfiguration
 The properties for configuring logging to files. More...
 
- -

+

Enumerations

enum  CBLLogDomain : uint8_t {
-  kCBLLogDomainAll, -kCBLLogDomainDatabase, -kCBLLogDomainQuery, -kCBLLogDomainReplicator, -
-  kCBLLogDomainNetwork -
+
enum  CBLLogDomain : uint8_t { kCBLLogDomainDatabase +, kCBLLogDomainQuery +, kCBLLogDomainReplicator +, kCBLLogDomainNetwork }
 Subsystems that log information. More...
 
enum  CBLLogLevel : uint8_t {
-  CBLLogDebug, -CBLLogVerbose, -CBLLogInfo, -CBLLogWarning, -
-  CBLLogError, -CBLLogNone +  kCBLLogDebug +, kCBLLogVerbose +, kCBLLogInfo +, kCBLLogWarning +,
+  kCBLLogError +, kCBLLogNone
}
 Levels of log messages. More...
 
- - + - +

+

Functions

void CBL_Log (CBLLogDomain domain, CBLLogLevel level, const char *format,...) __printflike(3
 Formats and writes a message to the log, in the given domain at the given level. More...
 Formats and writes a message to the log, in the given domain at the given level. More...
 
void void CBL_LogMessage (CBLLogDomain domain, CBLLogLevel level, FLSlice message)
 Writes a pre-formatted message to the log, exactly as given. More...
 Writes a pre-formatted message to the log, exactly as given. More...
 
- + - + - + - + - + - + - + - - - + + +

-Console Logging and Custom Logging

Console Logging and Custom Logging

typedef void(* CBLLogCallback) (CBLLogDomain domain, CBLLogLevel level, FLString message)
 A logging callback that the application can register. More...
 A logging callback that the application can register. More...
 
CBLLogLevel CBLLog_ConsoleLevel (void)
 Gets the current log level for debug console logging. More...
 Gets the current log level for debug console logging. More...
 
void CBLLog_SetConsoleLevel (CBLLogLevel)
 Sets the detail level of logging. More...
 Sets the detail level of logging. More...
 
CBLLogLevel CBLLog_CallbackLevel (void)
 Gets the current log level for debug console logging. More...
 Gets the current log level for debug console logging. More...
 
void CBLLog_SetCallbackLevel (CBLLogLevel)
 Sets the detail level of logging. More...
 Sets the detail level of logging. More...
 
CBLLogCallback CBLLog_Callback (void)
 Gets the current log callback. More...
 Gets the current log callback. More...
 
void CBLLog_SetCallback (CBLLogCallback)
 Sets the callback for receiving log messages. More...
 
void CBLLog_SetCallback (CBLLogCallback _cbl_nullable callback)
 Sets the callback for receiving log messages. More...
 
- - - - - - - + + + + + + +

-Log File Configuration

const CBLLogFileConfigurationCBLLog_FileConfig (void)
 Gets the current file logging configuration, or NULL if none is configured. More...
 
bool CBLLog_SetFileConfig (CBLLogFileConfiguration, CBLError *outError)
 Sets the file logging configuration, and begins logging to files. More...
 

Log File Configuration

const CBLLogFileConfiguration *_cbl_nullable CBLLog_FileConfig (void)
 Gets the current file logging configuration, or NULL if none is configured. More...
 
bool CBLLog_SetFileConfig (CBLLogFileConfiguration, CBLError *_cbl_nullable outError)
 Sets the file logging configuration, and begins logging to files. More...
 

Detailed Description

-

Managing messages that Couchbase Lite logs at runtime.

+

Managing messages that Couchbase Lite logs at runtime.

Typedef Documentation

- +

◆ CBLLogCallback

@@ -166,7 +160,7 @@

Parameters
- +
domainThe domain of the message; kCBLLogDomainAll if it doesn't fall into a specific domain.
domainThe domain of the message
levelThe severity level of the message.
messageThe actual formatted message.
@@ -176,7 +170,7 @@

Enumeration Type Documentation

- +

◆ CBLLogDomain

@@ -190,16 +184,15 @@

-EnumeratorkCBLLogDomainAll  -kCBLLogDomainDatabase  -kCBLLogDomainQuery  -kCBLLogDomainReplicator  -kCBLLogDomainNetwork  +EnumeratorkCBLLogDomainDatabase  +kCBLLogDomainQuery  +kCBLLogDomainReplicator  +kCBLLogDomainNetwork 

- +

◆ CBLLogLevel

Function Documentation

-
+

◆ CBL_Log()

- +

◆ CBLLog_SetConsoleLevel()

- -

◆ CBLLog_SetFileConfig()

+ +

◆ CBLLog_SetFileConfig()

@@ -486,7 +479,7 @@

- CBLError *  + CBLError *_cbl_nullable  outError  @@ -504,9 +497,7 @@

diff --git a/docs/C/html/group__other__types.html b/docs/C/html/group__other__types.html index a0197e43..1b9e3862 100644 --- a/docs/C/html/group__other__types.html +++ b/docs/C/html/group__other__types.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Other Types @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -65,26 +66,25 @@ -
-
Other Types
+
Other Types

- - +

+

Typedefs

typedef int64_t CBLTimestamp
 A date/time representation used for document expiration (and in date/time queries.) Measured in milliseconds since the Unix epoch (1/1/1970, midnight UTC.) More...
 A date/time representation used for document expiration (and in date/time queries.) Measured in milliseconds since the Unix epoch (1/1/1970, midnight UTC.) More...
 
- - +

+

Functions

CBLTimestamp CBL_Now (void)
 Returns the current time, in milliseconds since 1/1/1970. More...
 Returns the current time, in milliseconds since 1/1/1970. More...
 

Detailed Description

Typedef Documentation

- +

◆ CBLTimestamp

@@ -101,7 +101,7 @@

Function Documentation

- +

◆ CBL_Now()

@@ -124,9 +124,7 @@

diff --git a/docs/C/html/group__queries.html b/docs/C/html/group__queries.html index bfb06b0d..75d9745b 100644 --- a/docs/C/html/group__queries.html +++ b/docs/C/html/group__queries.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Queries @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -66,139 +67,148 @@ Data Structures | Typedefs | Enumerations
-
-
Queries
+
Queries

A CBLQuery represents a compiled database query. More...

- - - + + + + +

+

Data Structures

struct  CBLIndexSpec
 Parameters for creating a database index. More...
struct  CBLValueIndexConfiguration
 Value Index Configuration. More...
 
struct  CBLFullTextIndexConfiguration
 Full-Text Index Configuration. More...
 
- - + - +

+

Typedefs

typedef struct CBLQuery CBLQuery
 A compiled database query. More...
 A compiled database query. More...
 
typedef struct CBLResultSet CBLResultSet
 An iterator over the rows resulting from running a query. More...
 An iterator over the rows resulting from running a query. More...
 
- -

+

Enumerations

enum  CBLQueryLanguage : uint32_t { kCBLJSONLanguage, -kCBLN1QLLanguage +
enum  CBLQueryLanguage : uint32_t { kCBLJSONLanguage +, kCBLN1QLLanguage }
 Query languages. More...
 
- - - - - - + + + + + + + + + + + +

-Query objects

_cbl_warn_unused CBLQueryCBLQuery_New (const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *outErrorPos, CBLError *error)
 Creates a new query by compiling the input string. More...
 
static const CBLQueryCBLQuery_Retain (const CBLQuery *t)
 

Change listener

Adding a change listener to a query turns it into a "live query".

+

When changes are made to documents, the query will periodically re-run and compare its results with the prior results; if the new results are different, the listener callback will be called.

+
Note
The result set passed to the listener is the entire new result set, not just the rows that changed.
+
typedef void(* CBLQueryChangeListener) (void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)
 A callback to be invoked after the query's results have changed. More...
 
_cbl_warn_unused CBLListenerTokenCBLQuery_AddChangeListener (CBLQuery *query, CBLQueryChangeListener listener, void *_cbl_nullable context)
 Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove). More...
 
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults (const CBLQuery *query, CBLListenerToken *listener, CBLError *_cbl_nullable outError)
 Returns the query's entire current result set, after it's been announced via a call to the listener's callback. More...
 
+ + + + + + - + - - - - - - + + + + + + - + - + - +

Query objects

_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery (const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *_cbl_nullable outErrorPos, CBLError *_cbl_nullable outError)
 Creates a new query by compiling the input string. More...
 
static const CBLQueryCBLQuery_Retain (const CBLQuery *t)
 
static void CBLQuery_Release (const CBLQuery *t)
 
void CBLQuery_SetParameters (CBLQuery *query, FLDict parameters)
 Assigns values to the query's parameters. More...
 Assigns values to the query's parameters. More...
 
FLDict CBLQuery_Parameters (const CBLQuery *query)
 Returns the query's current parameter bindings, if any. More...
 
_cbl_warn_unused CBLResultSetCBLQuery_Execute (CBLQuery *, CBLError *)
 Runs the query, returning the results. More...
 
FLDict _cbl_nullable CBLQuery_Parameters (const CBLQuery *query)
 Returns the query's current parameter bindings, if any. More...
 
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute (CBLQuery *, CBLError *_cbl_nullable outError)
 Runs the query, returning the results. More...
 
_cbl_warn_unused FLSliceResult CBLQuery_Explain (const CBLQuery *)
 Returns information about the query, including the translated SQLite form, and the search strategy. More...
 Returns information about the query, including the translated SQLite form, and the search strategy. More...
 
unsigned CBLQuery_ColumnCount (const CBLQuery *)
 Returns the number of columns in each result. More...
 Returns the number of columns in each result. More...
 
FLSlice CBLQuery_ColumnName (const CBLQuery *, unsigned columnIndex)
 Returns the name of a column in the result. More...
 Returns the name of a column in the result. More...
 
- - + + - + - + - + - + - + - - - - - + + + + +

-Result sets

A CBLResultSet is an iterator over the results returned by a query.

-

It exposes one result at a time – as a collection of values indexed either by position or by name – and can be stepped from one result to the next.

-

It's important to note that the initial position of the iterator is before the first result, so CBLResultSet_Next must be called first. Example:

-
CBLResultSet *rs = CBLQuery_Execute(query, &error);
assert(rs);
while (CBLResultSet_Next(rs) {
...
}

Result sets

A CBLResultSet is an iterator over the results returned by a query.

+

It exposes one result at a time – as a collection of values indexed either by position or by name – and can be stepped from one result to the next.

+

It's important to note that the initial position of the iterator is before the first result, so CBLResultSet_Next must be called first. Example:

+
CBLResultSet *rs = CBLQuery_Execute(query, &error);
+
assert(rs);
+
while (CBLResultSet_Next(rs) {
+ +
...
+
}
+ +
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute(CBLQuery *, CBLError *_cbl_nullable outError)
Runs the query, returning the results.
+
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
+
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:206
+
static void CBLResultSet_Release(const CBLResultSet *t)
Definition: CBLQuery.h:179
+
FLValue CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
+
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:55
+
_cbl_warn_unused bool CBLResultSet_Next (CBLResultSet *)
 Moves the result-set iterator to the next result. More...
 Moves the result-set iterator to the next result. More...
 
FLValue CBLResultSet_ValueAtIndex (const CBLResultSet *, unsigned index)
 Returns the value of a column of the current result, given its (zero-based) numeric index. More...
 Returns the value of a column of the current result, given its (zero-based) numeric index. More...
 
FLValue CBLResultSet_ValueForKey (const CBLResultSet *, FLString key)
 Returns the value of a column of the current result, given its name. More...
 Returns the value of a column of the current result, given its name. More...
 
FLArray CBLResultSet_ResultArray (const CBLResultSet *)
 Returns the current result as an array of column values. More...
 Returns the current result as an array of column values. More...
 
FLDict CBLResultSet_ResultDict (const CBLResultSet *)
 Returns the current result as a dictionary mapping column names to values. More...
 Returns the current result as a dictionary mapping column names to values. More...
 
CBLQueryCBLResultSet_GetQuery (const CBLResultSet *rs)
 Returns the Query that created this ResultSet. More...
 
static const CBLResultSetCBLResultSet_Retain (const CBLResultSet *t)
 
CBLQueryCBLResultSet_GetQuery (const CBLResultSet *rs)
 Returns the Query that created this ResultSet. More...
 
static const CBLResultSetCBLResultSet_Retain (const CBLResultSet *t)
 
static void CBLResultSet_Release (const CBLResultSet *t)
 
- - + - - - - - - - - - -

-Change listener

Adding a change listener to a query turns it into a "live query".

-

When changes are made to documents, the query will periodically re-run and compare its results with the prior results; if the new results are different, the listener callback will be called.

-
Note
The result set passed to the listener is the entire new result set, not just the rows that changed.
+

Database Indexes

Indexes are used to speed up queries by allowing fast – O(log n) – lookup of documents that have specific values or ranges of values.

+

The values may be properties, or expressions based on properties.

+

An index will speed up queries that use the expression it indexes, but it takes up space in the database file, and it slows down document saves slightly because it needs to be kept up to date when documents change.

+

Tuning a database with indexes can be a tricky task. Fortunately, a lot has been written about it in the relational-database (SQL) realm, and much of that advice holds for Couchbase Lite. You may find SQLite's documentation particularly helpful since Couchbase Lite's querying is based on SQLite.

+

Two types of indexes are currently 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.

typedef void(* CBLQueryChangeListener) (void *context, CBLQuery *query)
 A callback to be invoked after the query's results have changed. More...
 
_cbl_warn_unused CBLListenerTokenCBLQuery_AddChangeListener (CBLQuery *query, CBLQueryChangeListener listener, void *context)
 Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove). More...
 
_cbl_warn_unused CBLResultSetCBLQuery_CopyCurrentResults (const CBLQuery *query, CBLListenerToken *listener, CBLError *error)
 Returns the query's entire current result set, after it's been announced via a call to the listener's callback. More...
 
- - - - - - - - - - - - - - + + + + + + + + + + + +

-Database Indexes

Indexes are used to speed up queries by allowing fast – O(log n) – lookup of documents that have specific values or ranges of values.

-

The values may be properties, or expressions based on properties.

-

An index will speed up queries that use the expression it indexes, but it takes up space in the database file, and it slows down document saves slightly because it needs to be kept up to date when documents change.

-

Tuning a database with indexes can be a tricky task. Fortunately, a lot has been written about it in the relational-database (SQL) realm, and much of that advice holds for Couchbase Lite. You may find SQLite's documentation particularly helpful since Couchbase Lite's querying is based on SQLite.

-

Two types of indexes are currently 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.

-
enum  CBLIndexType : uint32_t { kCBLValueIndex, -kCBLFullTextIndex - }
 Types of database indexes. More...
 
bool CBLDatabase_CreateIndex (CBLDatabase *db, FLString name, CBLIndexSpec spec, CBLError *outError)
 Creates a database index. More...
 
bool CBLDatabase_DeleteIndex (CBLDatabase *db, FLString name, CBLError *outError)
 Deletes an index given its name. More...
 
_cbl_warn_unused FLMutableArray CBLDatabase_IndexNames (CBLDatabase *db)
 Returns the names of the indexes on this database, as a Fleece array of strings. More...
 
bool CBLDatabase_CreateValueIndex (CBLDatabase *db, FLString name, CBLValueIndexConfiguration config, CBLError *_cbl_nullable outError)
 Creates a value index. More...
 
bool CBLDatabase_CreateFullTextIndex (CBLDatabase *db, FLString name, CBLFullTextIndexConfiguration config, CBLError *_cbl_nullable outError)
 Creates a full-text index. More...
 
bool CBLDatabase_DeleteIndex (CBLDatabase *db, FLString name, CBLError *_cbl_nullable outError)
 Deletes an index given its name. More...
 
_cbl_warn_unused FLArray CBLDatabase_GetIndexNames (CBLDatabase *db)
 Returns the names of the indexes on this database, as a Fleece array of strings. More...
 

Detailed Description

-

A CBLQuery represents a compiled database query.

-

The query language is a large subset of the N1QL language from Couchbase Server, which you can think of as "SQL for JSON" or "SQL++".

-

Queries may be given either in N1QL syntax, or in JSON using a schema that resembles a parse tree of N1QL. The JSON syntax is harder for humans, but much more amenable to machine generation, if you need to create queries programmatically or translate them from some other form.

+

A CBLQuery represents a compiled database query.

+

The query language is a large subset of the N1QL language from Couchbase Server, which you can think of as "SQL for JSON" or "SQL++".

+

Queries may be given either in N1QL syntax, or in JSON using a schema that resembles a parse tree of N1QL. The JSON syntax is harder for humans, but much more amenable to machine generation, if you need to create queries programmatically or translate them from some other form.

Typedef Documentation

- +

◆ CBLQuery

@@ -214,31 +224,32 @@

-

◆ CBLQueryChangeListener

+ +

◆ CBLQueryChangeListener

- +
typedef void(* CBLQueryChangeListener) (void *context, CBLQuery *query)typedef void(* CBLQueryChangeListener) (void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)

A callback to be invoked after the query's results have changed.

-

The actual result set can be obtained by calling CBLQuery_CopyCurrentResults, either during the callback or at any time thereafter.

Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
+

The actual result set can be obtained by calling CBLQuery_CopyCurrentResults, either during the callback or at any time thereafter.

Warning
By default, this listener may be called on arbitrary threads. If your code isn't prepared for that, you may want to use CBLDatabase_BufferNotifications so that listeners will be called in a safe context.
Parameters
+
contextThe same context value that you passed when adding the listener.
queryThe query that triggered the listener.
tokenThe token for obtaining the query results by calling CBLQuery_CopyCurrentResults.
- +

◆ CBLResultSet

@@ -255,59 +266,140 @@

Enumeration Type Documentation

- -

◆ CBLIndexType

+ +

◆ CBLQueryLanguage

- +
enum CBLIndexType : uint32_tenum CBLQueryLanguage : uint32_t
-

Types of database indexes.

+

Query languages.

- -
Enumerator
kCBLValueIndex 

An index that stores property or expression values.

+
Enumerator
kCBLJSONLanguage 

JSON query schema

kCBLFullTextIndex 

An index of strings, that enables searching for words with MATCH

+
kCBLN1QLLanguage 

N1QL syntax

- -

◆ CBLQueryLanguage

+

Function Documentation

+ +

◆ CBLDatabase_CreateFullTextIndex()

- + + + + + + + + + + + + + + + + + + + + + + + + + + +
enum CBLQueryLanguage : uint32_tbool CBLDatabase_CreateFullTextIndex (CBLDatabasedb,
FLString name,
CBLFullTextIndexConfiguration config,
CBLError *_cbl_nullable outError 
)
-

Query languages.

- - - -
Enumerator
kCBLJSONLanguage 

JSON query schema

-
kCBLN1QLLanguage 

N1QL syntax

-
+

Creates a full-text index.

+

Indexes are persistent. If an identical index with that name already exists, nothing happens (and no error is returned.) If a non-identical index with that name already exists, it is deleted and re-created.

-

Function Documentation

- -

◆ CBLDatabase_CreateIndex()

+ +

◆ CBLDatabase_CreateQuery()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery (const CBLDatabasedb,
CBLQueryLanguage language,
FLString queryString,
int *_cbl_nullable outErrorPos,
CBLError *_cbl_nullable outError 
)
+
+ +

Creates a new query by compiling the input string.

+

This is fast, but not instantaneous. If you need to run the same query many times, keep the CBLQuery around instead of compiling it each time. If you need to run related queries with only some values different, create one query with placeholder parameter(s), and substitute the desired value(s) with CBLQuery_SetParameters each time you run the query.

Note
You must release the CBLQuery when you're finished with it.
+
Parameters
+ + + + + + +
dbThe database to query.
languageThe query language, JSON or N1QL.
queryStringThe query string.
outErrorPosIf non-NULL, then on a parse error the approximate byte offset in the input expression will be stored here (or -1 if not known/applicable.)
outErrorOn failure, the error will be written here.
+
+
+
Returns
The new query object.
+ +
+
+ +

◆ CBLDatabase_CreateValueIndex()

- + @@ -321,13 +413,13 @@

- - + + - + @@ -338,13 +430,13 @@

-

Creates a database index.

-

Indexes are persistent. If an identical index with that name already exists, nothing happens (and no error is returned.) If a non-identical index with that name already exists, it is deleted and re-created.

+

Creates a value index.

+

Indexes are persistent. If an identical index with that name already exists, nothing happens (and no error is returned.) If a non-identical index with that name already exists, it is deleted and re-created.

-
-

◆ CBLDatabase_DeleteIndex()

+ +

◆ CBLDatabase_DeleteIndex()

@@ -364,7 +456,7 @@

- + @@ -379,14 +471,14 @@

-

◆ CBLDatabase_IndexNames()

+ +

◆ CBLDatabase_GetIndexNames()

bool CBLDatabase_CreateIndex bool CBLDatabase_CreateValueIndex ( CBLDatabase db, CBLIndexSpec spec, CBLValueIndexConfiguration config,
CBLErrorCBLError *_cbl_nullable  outError 
CBLErrorCBLError *_cbl_nullable  outError 
- + @@ -400,14 +492,14 @@

-

◆ CBLQuery_AddChangeListener()

+ +

◆ CBLQuery_AddChangeListener()

_cbl_warn_unused FLMutableArray CBLDatabase_IndexNames _cbl_warn_unused FLArray CBLDatabase_GetIndexNames ( CBLDatabase db)
- + @@ -415,13 +507,13 @@

- + - + @@ -432,8 +524,8 @@

-

Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove).

-

When the first change listener is added, the query will run (in the background) and notify the listener(s) of the results when ready. After that, it will run in the background after the database changes, and only notify the listeners when the result set changes.

Parameters
+

Registers a change listener callback with a query, turning it into a "live query" until the listener is removed (via CBLListener_Remove).

+

When the first change listener is added, the query will run (in the background) and notify the listener(s) of the results when ready. After that, it will run in the background after the database changes, and only notify the listeners when the result set changes.

Parameters

_cbl_warn_unused CBLListenerToken* CBLQuery_AddChangeListener _cbl_warn_unused CBLListenerToken * CBLQuery_AddChangeListener ( CBLQuery query, CBLQueryChangeListener CBLQueryChangeListener  listener,
void * void *_cbl_nullable  context 
@@ -441,11 +533,11 @@

Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
+
Returns
A token to be passed to CBLListener_Remove when it's time to remove the listener.
- +

◆ CBLQuery_ColumnCount()

- -

◆ CBLQuery_CopyCurrentResults()

+ +

◆ CBLQuery_CopyCurrentResults()

queryThe query to observe.
listenerThe callback to be invoked.
- + @@ -517,8 +609,8 @@

- - + + @@ -534,7 +626,7 @@

- +
_cbl_warn_unused CBLResultSet* CBLQuery_CopyCurrentResults _cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults ( const CBLQuery query, CBLErrorerror CBLError *_cbl_nullable outError 
queryThe query being listened to.
listenerThe query listener that was notified.
errorIf the query failed to run, the error will be stored here.
outErrorIf the query failed to run, the error will be stored here.
@@ -542,14 +634,14 @@

-

◆ CBLQuery_Execute()

+ +

◆ CBLQuery_Execute()

- + @@ -557,8 +649,8 @@

- - + + @@ -569,11 +661,11 @@

Runs the query, returning the results.

-

To obtain the results you'll typically call CBLResultSet_Next in a while loop, examining the values in the CBLResultSet each time around.

Note
You must release the result set when you're finished with it.
+

To obtain the results you'll typically call CBLResultSet_Next in a while loop, examining the values in the CBLResultSet each time around.

Note
You must release the result set when you're finished with it.
- +

◆ CBLQuery_Explain()

- - -

◆ CBLQuery_New()

- -
-
-
_cbl_warn_unused CBLResultSet* CBLQuery_Execute _cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute ( CBLQuery , CBLError CBLError *_cbl_nullable outError 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_cbl_warn_unused CBLQuery* CBLQuery_New (const CBLDatabasedb,
CBLQueryLanguage language,
FLString queryString,
int * outErrorPos,
CBLErrorerror 
)
-
- -

Creates a new query by compiling the input string.

-

This is fast, but not instantaneous. If you need to run the same query many times, keep the CBLQuery around instead of compiling it each time. If you need to run related queries with only some values different, create one query with placeholder parameter(s), and substitute the desired value(s) with CBLQuery_SetParameters each time you run the query.

Note
You must release the CBLQuery when you're finished with it.
-
Parameters
- - - - - - -
dbThe database to query.
languageThe query language, JSON or N1QL.
queryStringThe query string.
outErrorPosIf non-NULL, then on a parse error the approximate byte offset in the input expression will be stored here (or -1 if not known/applicable.)
errorOn failure, the error will be written here.
-
-
-
Returns
The new query object.
+

You can use this to help optimize the query: the word SCAN in the strategy indicates a linear scan of the entire database, which should be avoided by adding an index. The strategy will also show which index(es), if any, are used.

Note
You are responsible for releasing the result by calling FLSliceResult_Release.
- -

◆ CBLQuery_Parameters()

+ +

◆ CBLQuery_Parameters()

- + @@ -674,7 +706,7 @@

+

◆ CBLQuery_Release()

@@ -700,8 +732,8 @@

-

◆ CBLQuery_Retain()

+ +

◆ CBLQuery_Retain()

@@ -710,7 +742,7 @@

FLDict CBLQuery_Parameters FLDict _cbl_nullable CBLQuery_Parameters ( const CBLQuery query)
- + @@ -726,7 +758,7 @@

+

◆ CBLQuery_SetParameters()

static const CBLQuery* CBLQuery_Retain static const CBLQuery * CBLQuery_Retain ( const CBLQuery t)
@@ -764,14 +796,14 @@

-

◆ CBLResultSet_GetQuery()

+ +

◆ CBLResultSet_GetQuery()

queryThe query.
parametersThe parameters in the form of a Fleece dictionary whose keys are the parameter names. (It's easiest to construct this by using the mutable API, i.e. calling FLMutableDict_New and adding keys/values.)
- + @@ -784,7 +816,7 @@

+

◆ CBLResultSet_Next()

- +

◆ CBLResultSet_Release()

@@ -831,7 +863,7 @@

+

◆ CBLResultSet_ResultArray()

@@ -852,7 +884,7 @@

+

◆ CBLResultSet_ResultDict()

@@ -873,8 +905,8 @@

-

◆ CBLResultSet_Retain()

+ +

◆ CBLResultSet_Retain()

@@ -883,7 +915,7 @@

CBLQuery* CBLResultSet_GetQuery CBLQuery * CBLResultSet_GetQuery ( const CBLResultSet rs)
- + @@ -899,7 +931,7 @@

+

◆ CBLResultSet_ValueAtIndex()

- +

◆ CBLResultSet_ValueForKey()

@@ -957,16 +989,14 @@

Returns the value of a column of the current result, given its name.

-

This may return a NULL pointer, indicating MISSING, if the value doesn't exist, e.g. if the column is a property that doesn't exist in the document. (Or, of course, if the key is not a column name in this query.)

Note
See CBLQuery_ColumnName for a discussion of column names.
+

This may return a NULL pointer, indicating MISSING, if the value doesn't exist, e.g. if the column is a property that doesn't exist in the document. (Or, of course, if the key is not a column name in this query.)

Note
See CBLQuery_ColumnName for a discussion of column names.

diff --git a/docs/C/html/group__reading.html b/docs/C/html/group__reading.html index d5e30c66..1d774708 100644 --- a/docs/C/html/group__reading.html +++ b/docs/C/html/group__reading.html @@ -2,8 +2,8 @@ - - + +Couchbase Lite C: Reading Fleece Data @@ -30,21 +30,22 @@
static const CBLResultSet* CBLResultSet_Retain static const CBLResultSet * CBLResultSet_Retain ( const CBLResultSet t)
- + +/* @license-end */ +
@@ -62,69 +63,72 @@
-
-
Reading Fleece Data
+
Reading Fleece Data
- - + - - + - + - + - + - + - + - + - + - + - + + + + + + + - +

-FLDoc

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

+

FLDoc

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

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

-Parsing And Converting Values Directly

Parsing And Converting Values Directly

FLValue FLValue_FromData (FLSlice data, FLTrust) FLPURE
 Returns a pointer to the root value in the encoded data, or NULL if validation failed. More...
 Returns a pointer to the root value in the encoded data, or NULL if validation failed. More...
 
FLSliceResult FLData_ConvertJSON (FLSlice json, FLError *outError)
 Directly converts JSON data to Fleece-encoded data. More...
 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...
 Produces a human-readable dump of the Value encoded in the data. More...
 

Detailed Description

Typedef Documentation

- +

◆ FLDoc

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

+

◆ FLSharedKeys

@@ -157,7 +161,7 @@

Enumeration Type Documentation

- +

◆ FLTrust

@@ -171,17 +175,17 @@

-EnumeratorkFLUntrusted 

Input data is not trusted to be valid, and will be fully validated by the API call.

+EnumeratorkFLUntrusted 

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.)

+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()

- +

◆ FLData_Dump()

- +

◆ FLDoc_FromJSON()

- +

◆ FLDoc_FromResultData()

- +

◆ FLDoc_GetAllocedData()

@@ -327,7 +331,45 @@

+ +

◆ FLDoc_GetAssociated()

+ +
+
+ + + + + + + + + + + + + + + + + + +
void * FLDoc_GetAssociated (FLDoc doc,
const char * type 
)
+
+ +

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
+ + + +
docThe FLDoc to get a pointer from.
typeThe type of object expected, i.e. the same string literal passed to FLDoc_SetAssociated.
+
+
+
Returns
The associated pointer of that type, if any.
+ +
+
+

◆ FLDoc_GetData()

@@ -347,7 +389,7 @@

+

◆ FLDoc_GetRoot()

+ +

◆ FLDoc_SetAssociated()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool FLDoc_SetAssociated (FLDoc doc,
void * pointer,
const char * type 
)
+
+ +

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
+ + + + +
docThe FLDoc to store a pointer in.
pointerThe pointer to store in the FLDoc.
typeA C string literal identifying the type. This is used to avoid collisions with unrelated code that might try to store a different type of value.
+
+
+
Returns
True if the pointer was stored, false if a pointer of a different type is already stored.
+
Warning
Be sure to clear this before the associated object is freed/invalidated!
+
+This function is not thread-safe. Do not concurrently get & set objects.
- +

◆ FLValue_FindDoc()

- +

◆ FLValue_FromData()

diff --git a/docs/C/html/group__refcounting.html b/docs/C/html/group__refcounting.html index 20cf2b81..050e7222 100644 --- a/docs/C/html/group__refcounting.html +++ b/docs/C/html/group__refcounting.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Reference Counting @@ -30,21 +30,22 @@
- + +/* @license-end */ +

@@ -66,46 +67,45 @@ Macros | Typedefs | Functions
-
-
Reference Counting
+
Reference Counting

Couchbase Lite "objects" are reference-counted; the functions below are the shared retain and release operations. More...

-

+

Macros

#define CBL_REFCOUNTED(TYPE, NAME)
 
-

+

Typedefs

typedef struct CBLRefCounted CBLRefCounted
 
- - - - - - - + + + + + + - + - +

+

Functions

CBLRefCountedCBL_Retain (CBLRefCounted *)
 Increments an object's reference-count. More...
 
void CBL_Release (CBLRefCounted *)
 Decrements an object's reference-count, freeing the object if the count hits zero. More...
 
CBLRefCountedCBL_Retain (CBLRefCounted *_cbl_nullable)
 Increments an object's reference-count. More...
 
void CBL_Release (CBLRefCounted *_cbl_nullable)
 Decrements an object's reference-count, freeing the object if the count hits zero. More...
 
unsigned CBL_InstanceCount (void)
 Returns the total number of Couchbase Lite objects. More...
 Returns the total number of Couchbase Lite objects. More...
 
void CBL_DumpInstances (void)
 Logs the class and address of each Couchbase Lite object. More...
 Logs the class and address of each Couchbase Lite object. More...
 

Detailed Description

-

Couchbase Lite "objects" are reference-counted; the functions below are the shared retain and release operations.

-

(But there are type-safe equivalents defined for each class, so you can call CBLDatabase_Release() on a database, for instance, without having to type-cast.)

-

API functions that create a ref-counted object (typically named ..._New() or ..._Create()) return the object with a ref-count of 1; you are responsible for releasing the reference when you're done with it, or the object will be leaked.

-

Other functions that return an existing ref-counted object do not modify its ref-count. You do not need to release such a reference. But if you're keeping a reference to the object for a while, you should retain the reference to ensure it stays alive, and then release it when finished (to balance the retain.)

+

Couchbase Lite "objects" are reference-counted; the functions below are the shared retain and release operations.

+

(But there are type-safe equivalents defined for each class, so you can call CBLDatabase_Release() on a database, for instance, without having to type-cast.)

+

API functions that create a ref-counted object (typically named ..._New() or ..._Create()) return the object with a ref-count of 1; you are responsible for releasing the reference when you're done with it, or the object will be leaked.

+

Other functions that return an existing ref-counted object do not modify its ref-count. You do not need to release such a reference. But if you're keeping a reference to the object for a while, you should retain the reference to ensure it stays alive, and then release it when finished (to balance the retain.)

Macro Definition Documentation

- +

◆ CBL_REFCOUNTED

@@ -130,15 +130,18 @@

-Value:
{return (const TYPE)CBL_Retain((CBLRefCounted*)t);} \
static inline void CBL##NAME##_Release(const TYPE t) {CBL_Release((CBLRefCounted*)t);}
struct CBLRefCounted CBLRefCounted
Definition: CBLBase.h:152
-
void CBL_Release(CBLRefCounted *)
Decrements an object's reference-count, freeing the object if the count hits zero.
-
CBLRefCounted * CBL_Retain(CBLRefCounted *)
Increments an object's reference-count.
-
#define _cbl_nonnull
Definition: CBL_Compat.h:47
+Value:
static inline const TYPE CBL##NAME##_Retain(const TYPE _cbl_nullable t) \
+
{return (const TYPE)CBL_Retain((CBLRefCounted*)t);} \
+
static inline void CBL##NAME##_Release(const TYPE _cbl_nullable t) {CBL_Release((CBLRefCounted*)t);}
+
#define _cbl_nullable
Definition: CBL_Compat.h:86
+
struct CBLRefCounted CBLRefCounted
Definition: CBLBase.h:150
+
void CBL_Release(CBLRefCounted *_cbl_nullable)
Decrements an object's reference-count, freeing the object if the count hits zero.
+
CBLRefCounted * CBL_Retain(CBLRefCounted *_cbl_nullable)
Increments an object's reference-count.

Typedef Documentation

- +

◆ CBLRefCounted

- +

◆ CBL_InstanceCount()

- -

◆ CBL_Release()

+ +

◆ CBL_Release()

@@ -205,44 +208,42 @@

void CBL_Release ( CBLRefCounted *  - ) + _cbl_nullable)

Decrements an object's reference-count, freeing the object if the count hits zero.

-

Usually you'll call one of the type-safe synonyms specific to the object type, like CBLDatabase_Release.

+

Usually you'll call one of the type-safe synonyms specific to the object type, like CBLDatabase_Release.

- -

◆ CBL_Retain()

+ +

◆ CBL_Retain()

- + - +
CBLRefCounted* CBL_Retain CBLRefCounted * CBL_Retain ( CBLRefCounted)_cbl_nullable)

Increments an object's reference-count.

-

Usually you'll call one of the type-safe synonyms specific to the object type, like CBLDatabase_Retain`

+

Usually you'll call one of the type-safe synonyms specific to the object type, like CBLDatabase_Retain`

diff --git a/docs/C/html/group__replication.html b/docs/C/html/group__replication.html index 51426679..6cafd6b4 100644 --- a/docs/C/html/group__replication.html +++ b/docs/C/html/group__replication.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Replication @@ -30,21 +30,22 @@

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

@@ -65,15 +66,14 @@ -
-
Replication
+
Replication

A replicator is a background task that synchronizes changes between a local database and another database on a remote server (or on a peer device, or even another local database.) More...

- @@ -90,170 +90,135 @@ - - - - - - - -

+

Data Structures

struct  CBLProxySettings
 Proxy settings for the replicator. More...
struct  CBLReplicatedDocument
 Information about a document that's been pushed or pulled. More...
 
struct  CBLListenerAuthenticator
 Describes how clients should authenticate to a CBLURLEndpointListener. More...
 
struct  CBLURLEndpointListenerConfiguration
 Configuration of a P2P connection listener. More...
 
struct  CBLConnectionStatus
 
- - +

+

Typedefs

typedef struct CBLReplicator CBLReplicator
 A background task that syncs a CBLDatabase with a remote server or peer. More...
 A background task that syncs a CBLDatabase with a remote server or peer. More...
 
- - + - + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-Configuration

enum  CBLReplicatorType : uint8_t { kCBLReplicatorTypePushAndPull = 0, -kCBLReplicatorTypePush, -kCBLReplicatorTypePull +

Configuration

enum  CBLReplicatorType : uint8_t { kCBLReplicatorTypePushAndPull = 0 +, kCBLReplicatorTypePush +, kCBLReplicatorTypePull }
 Direction of replication: push, pull, or both. More...
 
enum  CBLProxyType : uint8_t { kCBLProxyHTTP, -kCBLProxyHTTPS +
enum  CBLDocumentFlags : unsigned { kCBLDocumentFlagsDeleted = 1 << 0 +, kCBLDocumentFlagsAccessRemoved = 1 << 1 + }
 Flags describing a replicated document. More...
 
enum  CBLProxyType : uint8_t { kCBLProxyHTTP +, kCBLProxyHTTPS }
 Types of proxy servers, for CBLProxySettings. More...
 
typedef struct CBLEndpoint CBLEndpoint
 An opaque object representing the location of a database to replicate with. More...
 An opaque object representing the location of a database to replicate with. More...
 
typedef struct CBLAuthenticator CBLAuthenticator
 An opaque object representing authentication credentials for a remote server. More...
 An opaque object representing authentication credentials for a remote server. More...
 
typedef bool(* CBLReplicationFilter) (void *context, CBLDocument *document, bool isDeleted)
 A callback that can decide whether a particular document should be pushed or pulled. More...
 
typedef const CBLDocument *(* CBLConflictResolver) (void *context, FLString documentID, const CBLDocument *localDocument, const CBLDocument *remoteDocument)
 Conflict-resolution callback for use in replications. More...
 
CBL_CORE_API const FLString kCBLAuthDefaultCookieName
 The name of the HTTP cookie used by Sync Gateway to store session keys. More...
 
const CBLConflictResolver CBLDefaultConflictResolver
 Default conflict resolver. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_NewWithURL (FLString url)
 Creates a new endpoint representing a server-based database at the given URL. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_NewWithLocalDB (CBLDatabase *)
 Creates a new endpoint representing another local database. More...
 
void CBLEndpoint_Free (CBLEndpoint *)
 Frees a CBLEndpoint object. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_NewPassword (FLString username, FLString password)
 Creates an authenticator for HTTP Basic (username/password) auth. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_NewSession (FLString sessionID, FLString cookieName)
 Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a cookie name (pass NULL for the default.) More...
 
void CBLAuth_Free (CBLAuthenticator *)
 Frees a CBLAuthenticator object. More...
 
- - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

-Lifecycle

static const CBLReplicatorCBLReplicator_Retain (const CBLReplicator *t)
 
static void CBLReplicator_Release (const CBLReplicator *t)
 
_cbl_warn_unused CBLReplicatorCBLReplicator_New (const CBLReplicatorConfiguration *, CBLError *)
 Creates a replicator with the given configuration. More...
 
const CBLReplicatorConfigurationCBLReplicator_Config (CBLReplicator *)
 Returns the configuration of an existing replicator. More...
 
void CBLReplicator_Start (CBLReplicator *replicator, bool resetCheckpoint)
 Starts a replicator, asynchronously. More...
 
void CBLReplicator_Stop (CBLReplicator *)
 Stops a running replicator, asynchronously. More...
 
void CBLReplicator_SetHostReachable (CBLReplicator *, bool reachable)
 Informs the replicator whether it's considered possible to reach the remote host with the current network configuration. More...
 
void CBLReplicator_SetSuspended (CBLReplicator *repl, bool suspended)
 Puts the replicator in or out of "suspended" state. More...
 
typedef bool(* CBLReplicationFilter) (void *_cbl_nullable context, CBLDocument *document, CBLDocumentFlags flags)
 A callback that can decide whether a particular document should be pushed or pulled. More...
 
typedef const CBLDocument *_cbl_nullable(* CBLConflictResolver) (void *_cbl_nullable context, FLString documentID, const CBLDocument *_cbl_nullable localDocument, const CBLDocument *_cbl_nullable remoteDocument)
 Conflict-resolution callback for use in replications. More...
 
typedef FLSliceResult(* CBLPropertyEncryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLStringResult *algorithm, FLStringResult *kid, CBLError *error)
 Callback that encrypts CBLEncryptable properties in documents pushed by the replicator. More...
 
typedef FLSliceResult(* CBLPropertyDecryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLString algorithm, FLString kid, CBLError *error)
 Callback that decrypts encrypted CBLEncryptable properties in documents pulled by the replicator. More...
 
CBL_PUBLIC const FLString kCBLAuthDefaultCookieName
 The name of the HTTP cookie used by Sync Gateway to store session keys. More...
 
CBL_PUBLIC const CBLConflictResolver CBLDefaultConflictResolver
 Default conflict resolver. More...
 
_cbl_warn_unused CBLEndpoint *_cbl_nullable CBLEndpoint_CreateWithURL (FLString url, CBLError *_cbl_nullable outError)
 Creates a new endpoint representing a server-based database at the given URL. More...
 
_cbl_warn_unused CBLEndpointCBLEndpoint_CreateWithLocalDB (CBLDatabase *)
 Creates a new endpoint representing another local database. More...
 
void CBLEndpoint_Free (CBLEndpoint *_cbl_nullable)
 Frees a CBLEndpoint object. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_CreatePassword (FLString username, FLString password)
 Creates an authenticator for HTTP Basic (username/password) auth. More...
 
_cbl_warn_unused CBLAuthenticatorCBLAuth_CreateSession (FLString sessionID, FLString cookieName)
 Creates an authenticator using a Couchbase Sync Gateway login session identifier, and optionally a cookie name (pass NULL for the default.) More...
 
void CBLAuth_Free (CBLAuthenticator *_cbl_nullable)
 Frees a CBLAuthenticator object. More...
 
- + - - - - - - + + + - + - + - - - - - - - - - - - - + + + + + + + + + + + +

-Status and Progress

Status and Progress

enum  CBLReplicatorActivityLevel : uint8_t {
-  kCBLReplicatorStopped, -kCBLReplicatorOffline, -kCBLReplicatorConnecting, -kCBLReplicatorIdle, -
+  kCBLReplicatorStopped +, kCBLReplicatorOffline +, kCBLReplicatorConnecting +, kCBLReplicatorIdle +,
  kCBLReplicatorBusy
}
 The possible states a replicator can be in during its lifecycle. More...
 
enum  CBLDocumentFlags : unsigned { kCBLDocumentFlagsDeleted = 1 << 0, -kCBLDocumentFlagsAccessRemoved = 1 << 1 - }
 Flags describing a replicated document. More...
 
typedef void(* CBLReplicatorChangeListener) (void *context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
 A callback that notifies you when the replicator's status changes. More...
 
typedef void(* CBLReplicatorChangeListener) (void *_cbl_nullable context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
 A callback that notifies you when the replicator's status changes. More...
 
typedef void(* CBLDocumentReplicationListener) (void *context, CBLReplicator *replicator, bool isPush, unsigned numDocuments, const CBLReplicatedDocument *documents)
 A callback that notifies you when documents are replicated. More...
 A callback that notifies you when documents are replicated. More...
 
CBLReplicatorStatus CBLReplicator_Status (CBLReplicator *)
 Returns the replicator's current status. More...
 Returns the replicator's current status. More...
 
_cbl_warn_unused FLDict CBLReplicator_PendingDocumentIDs (CBLReplicator *, CBLError *)
 Indicates which documents have local changes that have not yet been pushed to the server by this replicator. More...
 
bool CBLReplicator_IsDocumentPending (CBLReplicator *repl, FLString docID, CBLError *outError)
 Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddChangeListener (CBLReplicator *, CBLReplicatorChangeListener, void *context)
 Adds a listener that will be called when the replicator's status changes. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddDocumentReplicationListener (CBLReplicator *, CBLDocumentReplicationListener, void *context)
 Adds a listener that will be called when documents are replicated. More...
 
_cbl_warn_unused FLDict _cbl_nullable CBLReplicator_PendingDocumentIDs (CBLReplicator *, CBLError *_cbl_nullable outError)
 Indicates which documents have local changes that have not yet been pushed to the server by this replicator. More...
 
bool CBLReplicator_IsDocumentPending (CBLReplicator *repl, FLString docID, CBLError *_cbl_nullable outError)
 Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddChangeListener (CBLReplicator *, CBLReplicatorChangeListener, void *_cbl_nullable context)
 Adds a listener that will be called when the replicator's status changes. More...
 
_cbl_warn_unused CBLListenerTokenCBLReplicator_AddDocumentReplicationListener (CBLReplicator *, CBLDocumentReplicationListener, void *_cbl_nullable context)
 Adds a listener that will be called when documents are replicated. More...
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +

-Replication Listener/Server

typedef bool(* CBLPasswordAuthenticator) (FLString username, FLString password)
 Authentication callback. More...
 
typedef struct CBLURLEndpointListener CBLURLEndpointListener
 
_cbl_warn_unused CBLURLEndpointListenerCBLURLEndpointListener_New (CBLURLEndpointListenerConfiguration *)
 Creates a P2P connection listener. More...
 
bool CBLURLEndpointListener_Start (CBLURLEndpointListener *, CBLError *)
 Starts a P2P connection listener. More...
 
uint16_t CBLURLEndpointListener_GetPort (CBLURLEndpointListener *)
 Returns the actual port number being listened on. More...
 
_cbl_warn_unused FLMutableArray CBLURLEndpointListener_GetURLs (CBLURLEndpointListener *listener)
 Returns the URL(s) at which the listener can be reached. More...
 
CBLConnectionStatus CBLURLEndpointListener_GetStatus (CBLURLEndpointListener *)
 Returns information about how many current connections a P2P connection listener has. More...
 
void CBLURLEndpointListener_Stop (CBLURLEndpointListener *)
 Stops a P2P connection listener. More...
 
static const CBLURLEndpointListenerCBLURLEndpointListener_Retain (const CBLURLEndpointListener *t)
 
static void CBLURLEndpointListener_Release (const CBLURLEndpointListener *t)
 

Lifecycle

static const CBLReplicatorCBLReplicator_Retain (const CBLReplicator *t)
 
static void CBLReplicator_Release (const CBLReplicator *t)
 
_cbl_warn_unused CBLReplicator *_cbl_nullable CBLReplicator_Create (const CBLReplicatorConfiguration *, CBLError *_cbl_nullable outError)
 Creates a replicator with the given configuration. More...
 
const CBLReplicatorConfigurationCBLReplicator_Config (CBLReplicator *)
 Returns the configuration of an existing replicator. More...
 
void CBLReplicator_Start (CBLReplicator *replicator, bool resetCheckpoint)
 Starts a replicator, asynchronously. More...
 
void CBLReplicator_Stop (CBLReplicator *)
 Stops a running replicator, asynchronously. More...
 
void CBLReplicator_SetHostReachable (CBLReplicator *, bool reachable)
 Informs the replicator whether it's considered possible to reach the remote host with the current network configuration. More...
 
void CBLReplicator_SetSuspended (CBLReplicator *repl, bool suspended)
 Puts the replicator in or out of "suspended" state. More...
 

Detailed Description

-

A replicator is a background task that synchronizes changes between a local database and another database on a remote server (or on a peer device, or even another local database.)

+

A replicator is a background task that synchronizes changes between a local database and another database on a remote server (or on a peer device, or even another local database.)

Typedef Documentation

- +

◆ CBLAuthenticator

@@ -269,20 +234,21 @@

-

◆ CBLConflictResolver

+ +

◆ CBLConflictResolver

- +
typedef const CBLDocument*(* CBLConflictResolver) (void *context, FLString documentID, const CBLDocument *localDocument, const CBLDocument *remoteDocument)typedef const CBLDocument *_cbl_nullable(* CBLConflictResolver) (void *_cbl_nullable context, FLString documentID, const CBLDocument *_cbl_nullable localDocument, const CBLDocument *_cbl_nullable remoteDocument)

Conflict-resolution callback for use in replications.

-

This callback will be invoked when the replicator finds a newer server-side revision of a document that also has local changes. The local and remote changes must be resolved before the document can be pushed to the server.

Warning
This callback will be called on a background thread managed by the replicator. It must pay attention to thread-safety. However, unlike a filter callback, it does not need to return quickly. If it needs to prompt for user input, that's OK.
+

This callback will be invoked when the replicator finds a newer server-side revision of a document that also has local changes. The local and remote changes must be resolved before the document can be pushed to the server.

Note
Any new CBLBlob objects set to the resolved document returned by the callback must not be released. They need to be retained for installation while the resolved document is being saved into the database, and the replicator will be responsible for releasing them after they are installed.
+
Warning
This callback will be called on a background thread managed by the replicator. It must pay attention to thread-safety. However, unlike a filter callback, it does not need to return quickly. If it needs to prompt for user input, that's OK.
Parameters
@@ -296,7 +262,7 @@

+

◆ CBLDocumentReplicationListener

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

+

◆ CBLEndpoint

@@ -339,31 +305,74 @@

-

◆ CBLPasswordAuthenticator

+ +

◆ CBLPropertyDecryptor

+ +
+
+

contextThe context field of the CBLReplicatorConfiguration.
+ + + +
typedef FLSliceResult(* CBLPropertyDecryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLString algorithm, FLString kid, CBLError *error)
+
+ +

Callback that decrypts encrypted CBLEncryptable properties in documents pulled by the replicator.

+
Note
The decryption will be skipped (the encrypted data will be kept) when a null FLSliceResult without an error is returned. If an error is returned, the document will be failed to replicate with the kCBLErrorCrypto error.
+
Parameters
+ + + + + + + + + +
contextReplicator’s context
documentIDDocument ID
propertiesDocument properties
keyPathKey path of the property to be decrypted
inputProperty data to be decrypted
algorithmAlgorithm name
kidEncryption key identifier specified when encryting the value
errorOn return: error (Optional)
+
+
+ +
+
+ +

◆ CBLPropertyEncryptor

- +
typedef bool(* CBLPasswordAuthenticator) (FLString username, FLString password)typedef FLSliceResult(* CBLPropertyEncryptor) (void *context, FLString documentID, FLDict properties, FLString keyPath, FLSlice input, FLStringResult *algorithm, FLStringResult *kid, CBLError *error)
-

Authentication callback.

-

Given a username and password, it should return true to allow the connection, false to reject it.

+

Callback that encrypts CBLEncryptable properties in documents pushed by the replicator.

+
Note
If a null FLSliceResult or an error is returned, the document will be failed to replicate with the kCBLErrorCrypto error when. For security reason, the encryption cannot be skipped.
+
Parameters
+ + + + + + + + + +
contextReplicator’s context
documentIDDocument ID
propertiesDocument properties
keyPathKey path of the property to be encrypted
inputProperty data to be encrypted
algorithmOn return: algorithm name (Optional: Default Value is 'CB_MOBILE_CUSTOM')
kidOn return: encryption key identifier (Optional)
errorOn return: error (Optional)
+
+
- -

◆ CBLReplicationFilter

+ +

◆ CBLReplicationFilter

- +
typedef bool(* CBLReplicationFilter) (void *context, CBLDocument *document, bool isDeleted)typedef bool(* CBLReplicationFilter) (void *_cbl_nullable context, CBLDocument *document, CBLDocumentFlags flags)
@@ -374,7 +383,7 @@

contextThe context field of the CBLReplicatorConfiguration. documentThe document in question. - isDeletedTrue if the document has been deleted. + flagsIndicates whether the document was deleted or removed. @@ -382,7 +391,7 @@

+

◆ CBLReplicator

@@ -398,14 +407,14 @@

-

◆ CBLReplicatorChangeListener

+ +

◆ CBLReplicatorChangeListener

- +
typedef void(* CBLReplicatorChangeListener) (void *context, CBLReplicator *replicator, const CBLReplicatorStatus *status)typedef void(* CBLReplicatorChangeListener) (void *_cbl_nullable context, CBLReplicator *replicator, const CBLReplicatorStatus *status)
@@ -421,24 +430,10 @@

-

◆ CBLURLEndpointListener

- -
-
-

Enumeration Type Documentation

- +

◆ CBLDocumentFlags

@@ -452,15 +447,15 @@

-EnumeratorkCBLDocumentFlagsDeleted 

The document has been deleted.

+EnumeratorkCBLDocumentFlagsDeleted 

The document has been deleted.

-kCBLDocumentFlagsAccessRemoved 

Lost access to the document on the server.

+kCBLDocumentFlagsAccessRemoved 

Lost access to the document on the server.

- +

◆ CBLProxyType

@@ -474,15 +469,15 @@

CBLProxySettings.

- -
Enumerator
kCBLProxyHTTP 

HTTP proxy; must support 'CONNECT' method.

+
Enumerator
kCBLProxyHTTP 

HTTP proxy; must support 'CONNECT' method.

kCBLProxyHTTPS 

HTTPS proxy; must support 'CONNECT' method.

+
kCBLProxyHTTPS 

HTTPS proxy; must support 'CONNECT' method.

- +

◆ CBLReplicatorActivityLevel

@@ -496,21 +491,21 @@

-EnumeratorkCBLReplicatorStopped 

The replicator is unstarted, finished, or hit a fatal error.

+EnumeratorkCBLReplicatorStopped 

The replicator is unstarted, finished, or hit a fatal error.

-kCBLReplicatorOffline 

The replicator is offline, as the remote host is unreachable.

+kCBLReplicatorOffline 

The replicator is offline, as the remote host is unreachable.

-kCBLReplicatorConnecting 

The replicator is connecting to the remote host.

+kCBLReplicatorConnecting 

The replicator is connecting to the remote host.

-kCBLReplicatorIdle 

The replicator is inactive, waiting for changes to sync.

+kCBLReplicatorIdle 

The replicator is inactive, waiting for changes to sync.

-kCBLReplicatorBusy 

The replicator is actively transferring data.

+kCBLReplicatorBusy 

The replicator is actively transferring data.

- +

◆ CBLReplicatorType

@@ -524,45 +519,25 @@

-EnumeratorkCBLReplicatorTypePushAndPull 

Bidirectional; both push and pull.

+EnumeratorkCBLReplicatorTypePushAndPull 

Bidirectional; both push and pull.

-kCBLReplicatorTypePush 

Pushing changes to the target.

+kCBLReplicatorTypePush 

Pushing changes to the target.

-kCBLReplicatorTypePull 

Pulling changes from the target.

+kCBLReplicatorTypePull 

Pulling changes from the target.

Function Documentation

- -

◆ CBLAuth_Free()

+ +

◆ CBLAuth_CreatePassword()

- - - - - - -
void CBLAuth_Free (CBLAuthenticator)
-
- -

Frees a CBLAuthenticator object.

- -
-
- -

◆ CBLAuth_NewPassword()

- -
-
- - - + @@ -585,14 +560,14 @@

-

◆ CBLAuth_NewSession()

+ +

◆ CBLAuth_CreateSession()

_cbl_warn_unused CBLAuthenticator* CBLAuth_NewPassword _cbl_warn_unused CBLAuthenticator * CBLAuth_CreatePassword ( FLString  username,
- + @@ -615,34 +590,34 @@

-

◆ CBLEndpoint_Free()

+ +

◆ CBLAuth_Free()

_cbl_warn_unused CBLAuthenticator* CBLAuth_NewSession _cbl_warn_unused CBLAuthenticator * CBLAuth_CreateSession ( FLString  sessionID,
- + - - + +
void CBLEndpoint_Free void CBLAuth_Free (CBLEndpoint)CBLAuthenticator_cbl_nullable)
-

Frees a CBLEndpoint object.

+

Frees a CBLAuthenticator object.

- -

◆ CBLEndpoint_NewWithLocalDB()

+ +

◆ CBLEndpoint_CreateWithLocalDB()

- + @@ -652,39 +627,71 @@

Creates a new endpoint representing another local database.

-

(Enterprise Edition only.)

+

(Enterprise Edition only.)

-
-

◆ CBLEndpoint_NewWithURL()

+ +

◆ CBLEndpoint_CreateWithURL()

_cbl_warn_unused CBLEndpoint* CBLEndpoint_NewWithLocalDB _cbl_warn_unused CBLEndpoint * CBLEndpoint_CreateWithLocalDB ( CBLDatabase )
- + - + + + + + + + + + + +
_cbl_warn_unused CBLEndpoint* CBLEndpoint_NewWithURL _cbl_warn_unused CBLEndpoint *_cbl_nullable CBLEndpoint_CreateWithURL ( FLString url)url,
CBLError *_cbl_nullable outError 
)

Creates a new endpoint representing a server-based database at the given URL.

-

The URL's scheme must be ws or wss, it must of course have a valid hostname, and its path must be the name of the database on that server. The port can be omitted; it defaults to 80 for ws and 443 for wss. For example: wss://example.org/dbname

+

The URL's scheme must be ws or wss, it must of course have a valid hostname, and its path must be the name of the database on that server.

+

The port can be omitted; it defaults to 80 for ws and 443 for wss. For example: wss://example.org/dbname.

+

If an invalid endpoint URL is specified, an error will be returned.

- -

◆ CBLReplicator_AddChangeListener()

+ +

◆ CBLEndpoint_Free()

- + + + + + + +
_cbl_warn_unused CBLListenerToken* CBLReplicator_AddChangeListener void CBLEndpoint_Free (CBLEndpoint_cbl_nullable)
+
+ +

Frees a CBLEndpoint object.

+ +
+
+ +

◆ CBLReplicator_AddChangeListener()

+ +
+
+ + + @@ -692,13 +699,13 @@

- + - + @@ -713,14 +720,14 @@

-

◆ CBLReplicator_AddDocumentReplicationListener()

+ +

◆ CBLReplicator_AddDocumentReplicationListener()

_cbl_warn_unused CBLListenerToken * CBLReplicator_AddChangeListener ( CBLReplicator , CBLReplicatorChangeListener CBLReplicatorChangeListener  ,
void * void *_cbl_nullable  context 
- + @@ -734,7 +741,7 @@

- + @@ -749,14 +756,14 @@

-

◆ CBLReplicator_Config()

+ +

◆ CBLReplicator_Config()

_cbl_warn_unused CBLListenerToken* CBLReplicator_AddDocumentReplicationListener _cbl_warn_unused CBLListenerToken * CBLReplicator_AddDocumentReplicationListener ( CBLReplicator , void * void *_cbl_nullable  context 
- + @@ -769,28 +776,22 @@

-

◆ CBLReplicator_IsDocumentPending()

+ +

◆ CBLReplicator_Create()

const CBLReplicatorConfiguration* CBLReplicator_Config const CBLReplicatorConfiguration * CBLReplicator_Config ( CBLReplicator )
- + - - - - - - - - + + - + @@ -801,29 +802,33 @@

-

Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator.

-

This is equivalent to, but faster than, calling CBLReplicator_PendingDocumentIDs and checking whether the result contains docID. See that function's documentation for details.

-
Note
A false result means the document is not pending, or there was an error. To tell the difference, compare the error code to zero.
+

Creates a replicator with the given configuration.

- -

◆ CBLReplicator_New()

+ +

◆ CBLReplicator_IsDocumentPending()

bool CBLReplicator_IsDocumentPending _cbl_warn_unused CBLReplicator *_cbl_nullable CBLReplicator_Create (CBLReplicatorrepl,
FLString docID, const CBLReplicatorConfiguration,
CBLErrorCBLError *_cbl_nullable  outError 
- + - - + + + + + + + + - - + + @@ -833,18 +838,20 @@

-

Creates a replicator with the given configuration.

+

Indicates whether the document with the given ID has local changes that have not yet been pushed to the server by this replicator.

+

This is equivalent to, but faster than, calling CBLReplicator_PendingDocumentIDs and checking whether the result contains docID. See that function's documentation for details.

+
Note
A false result means the document is not pending, or there was an error. To tell the difference, compare the error code to zero.
- -

◆ CBLReplicator_PendingDocumentIDs()

+ +

◆ CBLReplicator_PendingDocumentIDs()

_cbl_warn_unused CBLReplicator* CBLReplicator_New bool CBLReplicator_IsDocumentPending (const CBLReplicatorConfiguration, CBLReplicatorrepl,
FLString docID,
CBLError CBLError *_cbl_nullable outError 
- + @@ -852,8 +859,8 @@

- - + + @@ -864,8 +871,8 @@

Indicates which documents have local changes that have not yet been pushed to the server by this replicator.

-

This is of course a snapshot, that will go out of date as the replicator makes progress and/or documents are saved locally.

-

The result is, effectively, a set of document IDs: a dictionary whose keys are the IDs and values are true. If there are no pending documents, the dictionary is empty. On error, NULL is returned.

+

This is of course a snapshot, that will go out of date as the replicator makes progress and/or documents are saved locally.

+

The result is, effectively, a set of document IDs: a dictionary whose keys are the IDs and values are true. If there are no pending documents, the dictionary is empty. On error, NULL is returned.

Note
This function can be called on a stopped or un-started replicator.
Documents that would never be pushed by this replicator, due to its configuration's pushFilter or docIDs, are ignored.
@@ -873,7 +880,7 @@

+

◆ CBLReplicator_Release()

@@ -899,8 +906,8 @@

-

◆ CBLReplicator_Retain()

+ +

◆ CBLReplicator_Retain()

@@ -909,7 +916,7 @@

_cbl_warn_unused FLDict CBLReplicator_PendingDocumentIDs _cbl_warn_unused FLDict _cbl_nullable CBLReplicator_PendingDocumentIDs ( CBLReplicator , CBLError CBLError *_cbl_nullable outError 
- + @@ -925,7 +932,7 @@

+

◆ CBLReplicator_SetHostReachable()

- +

◆ CBLReplicator_SetSuspended()

- +

◆ CBLReplicator_Start()

static const CBLReplicator* CBLReplicator_Retain static const CBLReplicator * CBLReplicator_Retain ( const CBLReplicator t)
@@ -1024,7 +1031,7 @@

+

◆ CBLReplicator_Status()

@@ -1044,7 +1051,7 @@

+

◆ CBLReplicator_Stop()

-

- -

◆ CBLURLEndpointListener_GetPort()

- -
-
-
replicatorThe replicator instance.
resetCheckpointIf true, the persistent saved state ("checkpoint") for this replication will be discarded, causing it to re-scan all documents. This significantly increases time and bandwidth (redundant docs are not transferred, but their IDs are) but can resolve unexpected problems with missing documents if one side or the other has gotten out of sync.
- - - - - - - -
uint16_t CBLURLEndpointListener_GetPort (CBLURLEndpointListener)
-
- -

Returns the actual port number being listened on.

- -
-
- -

◆ CBLURLEndpointListener_GetStatus()

- -
-
- - - - - - - - -
CBLConnectionStatus CBLURLEndpointListener_GetStatus (CBLURLEndpointListener)
-
- -

Returns information about how many current connections a P2P connection listener has.

+

Does nothing if it's not already started. The replicator will call your CBLReplicatorChangeListener with an activity level of kCBLReplicatorStopped after it stops. Until then, consider it still active.

- -

◆ CBLURLEndpointListener_GetURLs()

- -
-
- - - - - - - - -
_cbl_warn_unused FLMutableArray CBLURLEndpointListener_GetURLs (CBLURLEndpointListenerlistener)
-
- -

Returns the URL(s) at which the listener can be reached.

-

There is one URL for each network address, generally in declining order of usefulness.

Note
Caller is responsible for releasing the returned object.
-
Parameters
- - -
listenerThe listener.
-
-
-
Returns
The URLs as a Fleece array of strings (which must be released).
- -
-
- -

◆ CBLURLEndpointListener_New()

- -
-
- - - - - - - - -
_cbl_warn_unused CBLURLEndpointListener* CBLURLEndpointListener_New (CBLURLEndpointListenerConfiguration)
-
- -

Creates a P2P connection listener.

- -
-
- -

◆ CBLURLEndpointListener_Release()

+

Variable Documentation

+ +

◆ CBLDefaultConflictResolver

- -

◆ CBLURLEndpointListener_Retain()

+ +

◆ kCBLAuthDefaultCookieName

- -

◆ CBLURLEndpointListener_Start()

- -
-
- - - - - - - - - - - - - - - - - - -
bool CBLURLEndpointListener_Start (CBLURLEndpointListener,
CBLError 
)
-
- -

Starts a P2P connection listener.

- -
-
- -

◆ CBLURLEndpointListener_Stop()

- -
-
- - - - - - - - -
void CBLURLEndpointListener_Stop (CBLURLEndpointListener)
-
- -

Stops a P2P connection listener.

- -
-
-

Variable Documentation

- -

◆ CBLDefaultConflictResolver

- -
-
- - - - -
const CBLConflictResolver CBLDefaultConflictResolver
-
- -

Default conflict resolver.

-

This always returns localDocument.

- -
-
- -

◆ kCBLAuthDefaultCookieName

- -
-
- - - - -
CBL_CORE_API const FLString kCBLAuthDefaultCookieName
-
-

The name of the HTTP cookie used by Sync Gateway to store session keys.

@@ -1292,9 +1125,7 @@

diff --git a/docs/C/html/group__types.html b/docs/C/html/group__types.html index 079a2930..c8349c20 100644 --- a/docs/C/html/group__types.html +++ b/docs/C/html/group__types.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Basic Fleece Data Types @@ -30,21 +30,22 @@

- + +/* @license-end */ +
@@ -65,52 +66,51 @@ -
-
Basic Fleece Data Types
+
Basic Fleece Data Types

- - + - + - + - + - + - + - +

+

Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
 A reference to a value of any type. More...
 
typedef const struct _FLArray * FLArray
 A reference to an array value. More...
 A reference to an array value. More...
 
typedef const struct _FLDict * FLDict
 A reference to a dictionary (map) value. More...
 A reference to a dictionary (map) value. More...
 
typedef struct _FLSlot * FLSlot
 A reference to a mutable array/dict item. More...
 A reference to a mutable array/dict item. More...
 
typedef struct _FLArray * FLMutableArray
 A reference to a mutable array. More...
 A reference to a mutable array. More...
 
typedef struct _FLDict * FLMutableDict
 A reference to a mutable dictionary. More...
 A reference to a mutable dictionary. More...
 
typedef struct _FLEncoder * FLEncoder
 A reference to an encoder. More...
 A reference to an encoder. More...
 
- @@ -118,7 +118,7 @@

+

Enumerations

enum  FLError {
-  kFLNoError = 0, -kFLMemoryError, -kFLOutOfRange, -kFLInvalidData, -
-  kFLEncodeError, -kFLJSONError, -kFLUnknownValue, -kFLInternalError, -
-  kFLNotFound, -kFLSharedKeysStateError, -kFLPOSIXError, -kFLUnsupported +  kFLNoError = 0 +, kFLMemoryError +, kFLOutOfRange +, kFLInvalidData +,
+  kFLEncodeError +, kFLJSONError +, kFLUnknownValue +, kFLInternalError +,
+  kFLNotFound +, kFLSharedKeysStateError +, kFLPOSIXError +, kFLUnsupported
}
 Error codes returned from some API calls. More...

Detailed Description

Typedef Documentation

- +

◆ FLArray

@@ -134,7 +134,7 @@

+

◆ FLDict

@@ -150,7 +150,7 @@

+

◆ FLEncoder

@@ -166,7 +166,7 @@

+

◆ FLMutableArray

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

+

◆ FLMutableDict

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

+

◆ FLSlot

@@ -214,7 +214,7 @@

+

◆ FLValue

@@ -231,7 +231,7 @@

Enumeration Type Documentation

- +

◆ FLError

@@ -245,18 +245,18 @@

-EnumeratorkFLNoError  -kFLMemoryError  -kFLOutOfRange  -kFLInvalidData  -kFLEncodeError  -kFLJSONError  -kFLUnknownValue  -kFLInternalError  -kFLNotFound  -kFLSharedKeysStateError  -kFLPOSIXError  -kFLUnsupported  +EnumeratorkFLNoError  +kFLMemoryError  +kFLOutOfRange  +kFLInvalidData  +kFLEncodeError  +kFLJSONError  +kFLUnknownValue  +kFLInternalError  +kFLNotFound  +kFLSharedKeysStateError  +kFLPOSIXError  +kFLUnsupported 

@@ -264,9 +264,7 @@

diff --git a/docs/C/html/index.html b/docs/C/html/index.html index 25f587e7..8c655f30 100644 --- a/docs/C/html/index.html +++ b/docs/C/html/index.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: Main Page @@ -30,21 +30,22 @@

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

@@ -62,16 +63,13 @@

-
-
Couchbase Lite C Documentation
+
Couchbase Lite C Documentation
diff --git a/docs/C/html/jquery.js b/docs/C/html/jquery.js index 1ee895ca..c9ed3d99 100644 --- a/docs/C/html/jquery.js +++ b/docs/C/html/jquery.js @@ -1,71 +1,26 @@ +/*! jQuery v3.6.0 | (c) OpenJS 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=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},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&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,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.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(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(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 0a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),h=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(h=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):h=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),h}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+o.eventNamespace,c=h[2];c?n.on(l,c,r):i.on(l,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,h=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};l>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),h.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-r-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-r-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,(i>0||u>a(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,h,l=i.nodeName.toLowerCase();return"area"===l?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(l)?(r=!i.disabled,r&&(h=t(i).closest("fieldset")[0],h&&(r=!h.disabled))):r="a"===l?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
"),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,h=this._change[o];return this._updatePrevProperties(),h?(i=h.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,h=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,h=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=r-e.minWidth),s&&l&&(t.left=r-e.maxWidth),a&&c&&(t.top=h-e.minHeight),n&&c&&(t.top=h-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element +},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,h=t(this).resizable("instance"),l=h.options,c=h.element,u=l.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(h.containerElement=t(d),/document/.test(u)||u===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=h._num(e.css("padding"+s))}),h.containerOffset=e.offset(),h.containerPosition=e.position(),h.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,o=h.containerSize.width,a=h._hasScroll(d,"left")?d.scrollWidth:o,r=h._hasScroll(d)?d.scrollHeight:n,h.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?h.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-h.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-h.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,c=h[1]||1,u=Math.round((n.width-o.width)/l)*l,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=h,_&&(p+=l),v&&(f+=c),m&&(p-=l),g&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-l)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-l>0?(i.size.width=p,i.position.left=a.left-u):(p=l-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable});/** + * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler + * Licensed under MIT + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1)[^>]*$|#([\w\-]*)$)/,bM=/\S/,bI=/^\s+/,bE=/\s+$/,bA=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,bN=/^[\],:{}\s]*$/,bW=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,bP=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,bJ=/(?:^|:|,)(?:\s*\[)+/g,by=/(webkit)[ \/]([\w.]+)/,bR=/(opera)(?:.*version)?[ \/]([\w.]+)/,bQ=/(msie) ([\w.]+)/,bS=/(mozilla)(?:.*? rv:([\w.]+))?/,bB=/-([a-z]|[0-9])/ig,bZ=/^-ms-/,bT=function(b0,b1){return(b1+"").toUpperCase()},bX=bu.userAgent,bV,bC,e,bL=Object.prototype.toString,bG=Object.prototype.hasOwnProperty,bz=Array.prototype.push,bK=Array.prototype.slice,bO=String.prototype.trim,bv=Array.prototype.indexOf,bx={};bF.fn=bF.prototype={constructor:bF,init:function(b0,b4,b3){var b2,b5,b1,b6;if(!b0){return this}if(b0.nodeType){this.context=this[0]=b0;this.length=1;return this}if(b0==="body"&&!b4&&av.body){this.context=av;this[0]=av.body;this.selector=b0;this.length=1;return this}if(typeof b0==="string"){if(b0.charAt(0)==="<"&&b0.charAt(b0.length-1)===">"&&b0.length>=3){b2=[null,b0,null]}else{b2=bY.exec(b0)}if(b2&&(b2[1]||!b4)){if(b2[1]){b4=b4 instanceof bF?b4[0]:b4;b6=(b4?b4.ownerDocument||b4:av);b1=bA.exec(b0);if(b1){if(bF.isPlainObject(b4)){b0=[av.createElement(b1[1])];bF.fn.attr.call(b0,b4,true)}else{b0=[b6.createElement(b1[1])]}}else{b1=bF.buildFragment([b2[1]],[b6]);b0=(b1.cacheable?bF.clone(b1.fragment):b1.fragment).childNodes}return bF.merge(this,b0)}else{b5=av.getElementById(b2[2]);if(b5&&b5.parentNode){if(b5.id!==b2[2]){return b3.find(b0)}this.length=1;this[0]=b5}this.context=av;this.selector=b0;return this}}else{if(!b4||b4.jquery){return(b4||b3).find(b0)}else{return this.constructor(b4).find(b0)}}}else{if(bF.isFunction(b0)){return b3.ready(b0)}}if(b0.selector!==L){this.selector=b0.selector;this.context=b0.context}return bF.makeArray(b0,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return bK.call(this,0)},get:function(b0){return b0==null?this.toArray():(b0<0?this[this.length+b0]:this[b0])},pushStack:function(b1,b3,b0){var b2=this.constructor();if(bF.isArray(b1)){bz.apply(b2,b1)}else{bF.merge(b2,b1)}b2.prevObject=this;b2.context=this.context;if(b3==="find"){b2.selector=this.selector+(this.selector?" ":"")+b0}else{if(b3){b2.selector=this.selector+"."+b3+"("+b0+")"}}return b2},each:function(b1,b0){return bF.each(this,b1,b0)},ready:function(b0){bF.bindReady();bC.add(b0);return this},eq:function(b0){b0=+b0;return b0===-1?this.slice(b0):this.slice(b0,b0+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(bK.apply(this,arguments),"slice",bK.call(arguments).join(","))},map:function(b0){return this.pushStack(bF.map(this,function(b2,b1){return b0.call(b2,b1,b2)}))},end:function(){return this.prevObject||this.constructor(null)},push:bz,sort:[].sort,splice:[].splice};bF.fn.init.prototype=bF.fn;bF.extend=bF.fn.extend=function(){var b9,b2,b0,b1,b6,b7,b5=arguments[0]||{},b4=1,b3=arguments.length,b8=false;if(typeof b5==="boolean"){b8=b5;b5=arguments[1]||{};b4=2}if(typeof b5!=="object"&&!bF.isFunction(b5)){b5={}}if(b3===b4){b5=this;--b4}for(;b40){return}bC.fireWith(av,[bF]);if(bF.fn.trigger){bF(av).trigger("ready").off("ready")}}},bindReady:function(){if(bC){return}bC=bF.Callbacks("once memory");if(av.readyState==="complete"){return setTimeout(bF.ready,1)}if(av.addEventListener){av.addEventListener("DOMContentLoaded",e,false);bd.addEventListener("load",bF.ready,false)}else{if(av.attachEvent){av.attachEvent("onreadystatechange",e);bd.attachEvent("onload",bF.ready);var b0=false;try{b0=bd.frameElement==null}catch(b1){}if(av.documentElement.doScroll&&b0){bw()}}}},isFunction:function(b0){return bF.type(b0)==="function"},isArray:Array.isArray||function(b0){return bF.type(b0)==="array"},isWindow:function(b0){return b0!=null&&b0==b0.window},isNumeric:function(b0){return !isNaN(parseFloat(b0))&&isFinite(b0)},type:function(b0){return b0==null?String(b0):bx[bL.call(b0)]||"object"},isPlainObject:function(b2){if(!b2||bF.type(b2)!=="object"||b2.nodeType||bF.isWindow(b2)){return false}try{if(b2.constructor&&!bG.call(b2,"constructor")&&!bG.call(b2.constructor.prototype,"isPrototypeOf")){return false}}catch(b1){return false}var b0;for(b0 in b2){}return b0===L||bG.call(b2,b0)},isEmptyObject:function(b1){for(var b0 in b1){return false}return true},error:function(b0){throw new Error(b0)},parseJSON:function(b0){if(typeof b0!=="string"||!b0){return null}b0=bF.trim(b0);if(bd.JSON&&bd.JSON.parse){return bd.JSON.parse(b0)}if(bN.test(b0.replace(bW,"@").replace(bP,"]").replace(bJ,""))){return(new Function("return "+b0))()}bF.error("Invalid JSON: "+b0)},parseXML:function(b2){if(typeof b2!=="string"||!b2){return null}var b0,b1;try{if(bd.DOMParser){b1=new DOMParser();b0=b1.parseFromString(b2,"text/xml")}else{b0=new ActiveXObject("Microsoft.XMLDOM");b0.async="false";b0.loadXML(b2)}}catch(b3){b0=L}if(!b0||!b0.documentElement||b0.getElementsByTagName("parsererror").length){bF.error("Invalid XML: "+b2)}return b0},noop:function(){},globalEval:function(b0){if(b0&&bM.test(b0)){(bd.execScript||function(b1){bd["eval"].call(bd,b1)})(b0)}},camelCase:function(b0){return b0.replace(bZ,"ms-").replace(bB,bT)},nodeName:function(b1,b0){return b1.nodeName&&b1.nodeName.toUpperCase()===b0.toUpperCase()},each:function(b3,b6,b2){var b1,b4=0,b5=b3.length,b0=b5===L||bF.isFunction(b3);if(b2){if(b0){for(b1 in b3){if(b6.apply(b3[b1],b2)===false){break}}}else{for(;b40&&b0[0]&&b0[b1-1])||b1===0||bF.isArray(b0));if(b3){for(;b21?aK.call(arguments,0):bG;if(!(--bw)){bC.resolveWith(bC,bx)}}}function bz(bF){return function(bG){bB[bF]=arguments.length>1?aK.call(arguments,0):bG;bC.notifyWith(bE,bB)}}if(e>1){for(;bv
a";bH=bv.getElementsByTagName("*");bE=bv.getElementsByTagName("a")[0];if(!bH||!bH.length||!bE){return{}}bF=av.createElement("select");bx=bF.appendChild(av.createElement("option"));bD=bv.getElementsByTagName("input")[0];bI={leadingWhitespace:(bv.firstChild.nodeType===3),tbody:!bv.getElementsByTagName("tbody").length,htmlSerialize:!!bv.getElementsByTagName("link").length,style:/top/.test(bE.getAttribute("style")),hrefNormalized:(bE.getAttribute("href")==="/a"),opacity:/^0.55/.test(bE.style.opacity),cssFloat:!!bE.style.cssFloat,checkOn:(bD.value==="on"),optSelected:bx.selected,getSetAttribute:bv.className!=="t",enctype:!!av.createElement("form").enctype,html5Clone:av.createElement("nav").cloneNode(true).outerHTML!=="<:nav>",submitBubbles:true,changeBubbles:true,focusinBubbles:false,deleteExpando:true,noCloneEvent:true,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableMarginRight:true,pixelMargin:true};b.boxModel=bI.boxModel=(av.compatMode==="CSS1Compat");bD.checked=true;bI.noCloneChecked=bD.cloneNode(true).checked;bF.disabled=true;bI.optDisabled=!bx.disabled;try{delete bv.test}catch(bB){bI.deleteExpando=false}if(!bv.addEventListener&&bv.attachEvent&&bv.fireEvent){bv.attachEvent("onclick",function(){bI.noCloneEvent=false});bv.cloneNode(true).fireEvent("onclick")}bD=av.createElement("input");bD.value="t";bD.setAttribute("type","radio");bI.radioValue=bD.value==="t";bD.setAttribute("checked","checked");bD.setAttribute("name","t");bv.appendChild(bD);bC=av.createDocumentFragment();bC.appendChild(bv.lastChild);bI.checkClone=bC.cloneNode(true).cloneNode(true).lastChild.checked;bI.appendChecked=bD.checked;bC.removeChild(bD);bC.appendChild(bv);if(bv.attachEvent){for(by in {submit:1,change:1,focusin:1}){bA="on"+by;bw=(bA in bv);if(!bw){bv.setAttribute(bA,"return;");bw=(typeof bv[bA]==="function")}bI[by+"Bubbles"]=bw}}bC.removeChild(bv);bC=bF=bx=bv=bD=null;b(function(){var bM,bV,bW,bU,bO,bP,bR,bL,bK,bQ,bN,e,bT,bS=av.getElementsByTagName("body")[0];if(!bS){return}bL=1;bT="padding:0;margin:0;border:";bN="position:absolute;top:0;left:0;width:1px;height:1px;";e=bT+"0;visibility:hidden;";bK="style='"+bN+bT+"5px solid #000;";bQ="
";bM=av.createElement("div");bM.style.cssText=e+"width:0;height:0;position:static;top:0;margin-top:"+bL+"px";bS.insertBefore(bM,bS.firstChild);bv=av.createElement("div");bM.appendChild(bv);bv.innerHTML="
t
";bz=bv.getElementsByTagName("td");bw=(bz[0].offsetHeight===0);bz[0].style.display="";bz[1].style.display="none";bI.reliableHiddenOffsets=bw&&(bz[0].offsetHeight===0);if(bd.getComputedStyle){bv.innerHTML="";bR=av.createElement("div");bR.style.width="0";bR.style.marginRight="0";bv.style.width="2px";bv.appendChild(bR);bI.reliableMarginRight=(parseInt((bd.getComputedStyle(bR,null)||{marginRight:0}).marginRight,10)||0)===0}if(typeof bv.style.zoom!=="undefined"){bv.innerHTML="";bv.style.width=bv.style.padding="1px";bv.style.border=0;bv.style.overflow="hidden";bv.style.display="inline";bv.style.zoom=1;bI.inlineBlockNeedsLayout=(bv.offsetWidth===3);bv.style.display="block";bv.style.overflow="visible";bv.innerHTML="
";bI.shrinkWrapBlocks=(bv.offsetWidth!==3)}bv.style.cssText=bN+e;bv.innerHTML=bQ;bV=bv.firstChild;bW=bV.firstChild;bO=bV.nextSibling.firstChild.firstChild;bP={doesNotAddBorder:(bW.offsetTop!==5),doesAddBorderForTableAndCells:(bO.offsetTop===5)};bW.style.position="fixed";bW.style.top="20px";bP.fixedPosition=(bW.offsetTop===20||bW.offsetTop===15);bW.style.position=bW.style.top="";bV.style.overflow="hidden";bV.style.position="relative";bP.subtractsBorderForOverflowNotVisible=(bW.offsetTop===-5);bP.doesNotIncludeMarginInBodyOffset=(bS.offsetTop!==bL);if(bd.getComputedStyle){bv.style.marginTop="1%";bI.pixelMargin=(bd.getComputedStyle(bv,null)||{marginTop:0}).marginTop!=="1%"}if(typeof bM.style.zoom!=="undefined"){bM.style.zoom=1}bS.removeChild(bM);bR=bv=bM=null;b.extend(bI,bP)});return bI})();var aT=/^(?:\{.*\}|\[.*\])$/,aA=/([A-Z])/g;b.extend({cache:{},uuid:0,expando:"jQuery"+(b.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},hasData:function(e){e=e.nodeType?b.cache[e[b.expando]]:e[b.expando];return !!e&&!S(e)},data:function(bx,bv,bz,by){if(!b.acceptData(bx)){return}var bG,bA,bD,bE=b.expando,bC=typeof bv==="string",bF=bx.nodeType,e=bF?b.cache:bx,bw=bF?bx[bE]:bx[bE]&&bE,bB=bv==="events";if((!bw||!e[bw]||(!bB&&!by&&!e[bw].data))&&bC&&bz===L){return}if(!bw){if(bF){bx[bE]=bw=++b.uuid}else{bw=bE}}if(!e[bw]){e[bw]={};if(!bF){e[bw].toJSON=b.noop}}if(typeof bv==="object"||typeof bv==="function"){if(by){e[bw]=b.extend(e[bw],bv)}else{e[bw].data=b.extend(e[bw].data,bv)}}bG=bA=e[bw];if(!by){if(!bA.data){bA.data={}}bA=bA.data}if(bz!==L){bA[b.camelCase(bv)]=bz}if(bB&&!bA[bv]){return bG.events}if(bC){bD=bA[bv];if(bD==null){bD=bA[b.camelCase(bv)]}}else{bD=bA}return bD},removeData:function(bx,bv,by){if(!b.acceptData(bx)){return}var bB,bA,bz,bC=b.expando,bD=bx.nodeType,e=bD?b.cache:bx,bw=bD?bx[bC]:bC;if(!e[bw]){return}if(bv){bB=by?e[bw]:e[bw].data;if(bB){if(!b.isArray(bv)){if(bv in bB){bv=[bv]}else{bv=b.camelCase(bv);if(bv in bB){bv=[bv]}else{bv=bv.split(" ")}}}for(bA=0,bz=bv.length;bA1,null,false)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function a6(bx,bw,by){if(by===L&&bx.nodeType===1){var bv="data-"+bw.replace(aA,"-$1").toLowerCase();by=bx.getAttribute(bv);if(typeof by==="string"){try{by=by==="true"?true:by==="false"?false:by==="null"?null:b.isNumeric(by)?+by:aT.test(by)?b.parseJSON(by):by}catch(bz){}b.data(bx,bw,by)}else{by=L}}return by}function S(bv){for(var e in bv){if(e==="data"&&b.isEmptyObject(bv[e])){continue}if(e!=="toJSON"){return false}}return true}function bj(by,bx,bA){var bw=bx+"defer",bv=bx+"queue",e=bx+"mark",bz=b._data(by,bw);if(bz&&(bA==="queue"||!b._data(by,bv))&&(bA==="mark"||!b._data(by,e))){setTimeout(function(){if(!b._data(by,bv)&&!b._data(by,e)){b.removeData(by,bw,true);bz.fire()}},0)}}b.extend({_mark:function(bv,e){if(bv){e=(e||"fx")+"mark";b._data(bv,e,(b._data(bv,e)||0)+1)}},_unmark:function(by,bx,bv){if(by!==true){bv=bx;bx=by;by=false}if(bx){bv=bv||"fx";var e=bv+"mark",bw=by?0:((b._data(bx,e)||1)-1);if(bw){b._data(bx,e,bw)}else{b.removeData(bx,e,true);bj(bx,bv,"mark")}}},queue:function(bv,e,bx){var bw;if(bv){e=(e||"fx")+"queue";bw=b._data(bv,e);if(bx){if(!bw||b.isArray(bx)){bw=b._data(bv,e,b.makeArray(bx))}else{bw.push(bx)}}return bw||[]}},dequeue:function(by,bx){bx=bx||"fx";var bv=b.queue(by,bx),bw=bv.shift(),e={};if(bw==="inprogress"){bw=bv.shift()}if(bw){if(bx==="fx"){bv.unshift("inprogress")}b._data(by,bx+".run",e);bw.call(by,function(){b.dequeue(by,bx)},e)}if(!bv.length){b.removeData(by,bx+"queue "+bx+".run",true);bj(by,bx,"queue")}}});b.fn.extend({queue:function(e,bv){var bw=2;if(typeof e!=="string"){bv=e;e="fx";bw--}if(arguments.length1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,bv){return b.access(this,b.prop,e,bv,arguments.length>1)},removeProp:function(e){e=b.propFix[e]||e;return this.each(function(){try{this[e]=L;delete this[e]}catch(bv){}})},addClass:function(by){var bA,bw,bv,bx,bz,bB,e;if(b.isFunction(by)){return this.each(function(bC){b(this).addClass(by.call(this,bC,this.className))})}if(by&&typeof by==="string"){bA=by.split(ag);for(bw=0,bv=this.length;bw-1){return true}}return false},val:function(bx){var e,bv,by,bw=this[0];if(!arguments.length){if(bw){e=b.valHooks[bw.type]||b.valHooks[bw.nodeName.toLowerCase()];if(e&&"get" in e&&(bv=e.get(bw,"value"))!==L){return bv}bv=bw.value;return typeof bv==="string"?bv.replace(aV,""):bv==null?"":bv}return}by=b.isFunction(bx);return this.each(function(bA){var bz=b(this),bB;if(this.nodeType!==1){return}if(by){bB=bx.call(this,bA,bz.val())}else{bB=bx}if(bB==null){bB=""}else{if(typeof bB==="number"){bB+=""}else{if(b.isArray(bB)){bB=b.map(bB,function(bC){return bC==null?"":bC+""})}}}e=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()];if(!e||!("set" in e)||e.set(this,bB,"value")===L){this.value=bB}})}});b.extend({valHooks:{option:{get:function(e){var bv=e.attributes.value;return !bv||bv.specified?e.value:e.text}},select:{get:function(e){var bA,bv,bz,bx,by=e.selectedIndex,bB=[],bC=e.options,bw=e.type==="select-one";if(by<0){return null}bv=bw?by:0;bz=bw?by+1:bC.length;for(;bv=0});if(!e.length){bv.selectedIndex=-1}return e}}},attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(bA,bx,bB,bz){var bw,e,by,bv=bA.nodeType;if(!bA||bv===3||bv===8||bv===2){return}if(bz&&bx in b.attrFn){return b(bA)[bx](bB)}if(typeof bA.getAttribute==="undefined"){return b.prop(bA,bx,bB)}by=bv!==1||!b.isXMLDoc(bA);if(by){bx=bx.toLowerCase();e=b.attrHooks[bx]||(ao.test(bx)?aZ:bf)}if(bB!==L){if(bB===null){b.removeAttr(bA,bx);return}else{if(e&&"set" in e&&by&&(bw=e.set(bA,bB,bx))!==L){return bw}else{bA.setAttribute(bx,""+bB);return bB}}}else{if(e&&"get" in e&&by&&(bw=e.get(bA,bx))!==null){return bw}else{bw=bA.getAttribute(bx);return bw===null?L:bw}}},removeAttr:function(by,bA){var bz,bB,bw,e,bv,bx=0;if(bA&&by.nodeType===1){bB=bA.toLowerCase().split(ag);e=bB.length;for(;bx=0)}}})});var be=/^(?:textarea|input|select)$/i,n=/^([^\.]*)?(?:\.(.+))?$/,J=/(?:^|\s)hover(\.\S+)?\b/,aP=/^key/,bg=/^(?:mouse|contextmenu)|click/,T=/^(?:focusinfocus|focusoutblur)$/,U=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,Y=function(e){var bv=U.exec(e);if(bv){bv[1]=(bv[1]||"").toLowerCase();bv[3]=bv[3]&&new RegExp("(?:^|\\s)"+bv[3]+"(?:\\s|$)")}return bv},j=function(bw,e){var bv=bw.attributes||{};return((!e[1]||bw.nodeName.toLowerCase()===e[1])&&(!e[2]||(bv.id||{}).value===e[2])&&(!e[3]||e[3].test((bv["class"]||{}).value)))},bt=function(e){return b.event.special.hover?e:e.replace(J,"mouseenter$1 mouseleave$1")};b.event={add:function(bx,bC,bJ,bA,by){var bD,bB,bK,bI,bH,bF,e,bG,bv,bz,bw,bE;if(bx.nodeType===3||bx.nodeType===8||!bC||!bJ||!(bD=b._data(bx))){return}if(bJ.handler){bv=bJ;bJ=bv.handler;by=bv.selector}if(!bJ.guid){bJ.guid=b.guid++}bK=bD.events;if(!bK){bD.events=bK={}}bB=bD.handle;if(!bB){bD.handle=bB=function(bL){return typeof b!=="undefined"&&(!bL||b.event.triggered!==bL.type)?b.event.dispatch.apply(bB.elem,arguments):L};bB.elem=bx}bC=b.trim(bt(bC)).split(" ");for(bI=0;bI=0){bG=bG.slice(0,-1);bw=true}if(bG.indexOf(".")>=0){bx=bG.split(".");bG=bx.shift();bx.sort()}if((!bA||b.event.customEvent[bG])&&!b.event.global[bG]){return}bv=typeof bv==="object"?bv[b.expando]?bv:new b.Event(bG,bv):new b.Event(bG);bv.type=bG;bv.isTrigger=true;bv.exclusive=bw;bv.namespace=bx.join(".");bv.namespace_re=bv.namespace?new RegExp("(^|\\.)"+bx.join("\\.(?:.*\\.)?")+"(\\.|$)"):null;by=bG.indexOf(":")<0?"on"+bG:"";if(!bA){e=b.cache;for(bC in e){if(e[bC].events&&e[bC].events[bG]){b.event.trigger(bv,bD,e[bC].handle.elem,true)}}return}bv.result=L;if(!bv.target){bv.target=bA}bD=bD!=null?b.makeArray(bD):[];bD.unshift(bv);bF=b.event.special[bG]||{};if(bF.trigger&&bF.trigger.apply(bA,bD)===false){return}bB=[[bA,bF.bindType||bG]];if(!bJ&&!bF.noBubble&&!b.isWindow(bA)){bI=bF.delegateType||bG;bH=T.test(bI+bG)?bA:bA.parentNode;bz=null;for(;bH;bH=bH.parentNode){bB.push([bH,bI]);bz=bH}if(bz&&bz===bA.ownerDocument){bB.push([bz.defaultView||bz.parentWindow||bd,bI])}}for(bC=0;bCbC){bv.push({elem:this,matches:bD.slice(bC)})}for(bJ=0;bJ0?this.on(e,null,bx,bw):this.trigger(e)};if(b.attrFn){b.attrFn[e]=true}if(aP.test(e)){b.event.fixHooks[e]=b.event.keyHooks}if(bg.test(e)){b.event.fixHooks[e]=b.event.mouseHooks}}); -/*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){var bH=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,bC="sizcache"+(Math.random()+"").replace(".",""),bI=0,bL=Object.prototype.toString,bB=false,bA=true,bK=/\\/g,bO=/\r\n/g,bQ=/\W/;[0,0].sort(function(){bA=false;return 0});var by=function(bV,e,bY,bZ){bY=bY||[];e=e||av;var b1=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!bV||typeof bV!=="string"){return bY}var bS,b3,b6,bR,b2,b5,b4,bX,bU=true,bT=by.isXML(e),bW=[],b0=bV;do{bH.exec("");bS=bH.exec(b0);if(bS){b0=bS[3];bW.push(bS[1]);if(bS[2]){bR=bS[3];break}}}while(bS);if(bW.length>1&&bD.exec(bV)){if(bW.length===2&&bE.relative[bW[0]]){b3=bM(bW[0]+bW[1],e,bZ)}else{b3=bE.relative[bW[0]]?[e]:by(bW.shift(),e);while(bW.length){bV=bW.shift();if(bE.relative[bV]){bV+=bW.shift()}b3=bM(bV,b3,bZ)}}}else{if(!bZ&&bW.length>1&&e.nodeType===9&&!bT&&bE.match.ID.test(bW[0])&&!bE.match.ID.test(bW[bW.length-1])){b2=by.find(bW.shift(),e,bT);e=b2.expr?by.filter(b2.expr,b2.set)[0]:b2.set[0]}if(e){b2=bZ?{expr:bW.pop(),set:bF(bZ)}:by.find(bW.pop(),bW.length===1&&(bW[0]==="~"||bW[0]==="+")&&e.parentNode?e.parentNode:e,bT);b3=b2.expr?by.filter(b2.expr,b2.set):b2.set;if(bW.length>0){b6=bF(b3)}else{bU=false}while(bW.length){b5=bW.pop();b4=b5;if(!bE.relative[b5]){b5=""}else{b4=bW.pop()}if(b4==null){b4=e}bE.relative[b5](b6,b4,bT)}}else{b6=bW=[]}}if(!b6){b6=b3}if(!b6){by.error(b5||bV)}if(bL.call(b6)==="[object Array]"){if(!bU){bY.push.apply(bY,b6)}else{if(e&&e.nodeType===1){for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&(b6[bX]===true||b6[bX].nodeType===1&&by.contains(e,b6[bX]))){bY.push(b3[bX])}}}else{for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&b6[bX].nodeType===1){bY.push(b3[bX])}}}}}else{bF(b6,bY)}if(bR){by(bR,b1,bY,bZ);by.uniqueSort(bY)}return bY};by.uniqueSort=function(bR){if(bJ){bB=bA;bR.sort(bJ);if(bB){for(var e=1;e0};by.find=function(bX,e,bY){var bW,bS,bU,bT,bV,bR;if(!bX){return[]}for(bS=0,bU=bE.order.length;bS":function(bW,bR){var bV,bU=typeof bR==="string",bS=0,e=bW.length;if(bU&&!bQ.test(bR)){bR=bR.toLowerCase();for(;bS=0)){if(!bS){e.push(bV)}}else{if(bS){bR[bU]=false}}}}return false},ID:function(e){return e[1].replace(bK,"")},TAG:function(bR,e){return bR[1].replace(bK,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){by.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var bR=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(bR[1]+(bR[2]||1))-0;e[3]=bR[3]-0}else{if(e[2]){by.error(e[0])}}e[0]=bI++;return e},ATTR:function(bU,bR,bS,e,bV,bW){var bT=bU[1]=bU[1].replace(bK,"");if(!bW&&bE.attrMap[bT]){bU[1]=bE.attrMap[bT]}bU[4]=(bU[4]||bU[5]||"").replace(bK,"");if(bU[2]==="~="){bU[4]=" "+bU[4]+" "}return bU},PSEUDO:function(bU,bR,bS,e,bV){if(bU[1]==="not"){if((bH.exec(bU[3])||"").length>1||/^\w/.test(bU[3])){bU[3]=by(bU[3],null,null,bR)}else{var bT=by.filter(bU[3],bR,bS,true^bV);if(!bS){e.push.apply(e,bT)}return false}}else{if(bE.match.POS.test(bU[0])||bE.match.CHILD.test(bU[0])){return true}}return bU},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(bS,bR,e){return !!by(e[3],bS).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(bS){var e=bS.getAttribute("type"),bR=bS.type;return bS.nodeName.toLowerCase()==="input"&&"text"===bR&&(e===bR||e===null)},radio:function(e){return e.nodeName.toLowerCase()==="input"&&"radio"===e.type},checkbox:function(e){return e.nodeName.toLowerCase()==="input"&&"checkbox"===e.type},file:function(e){return e.nodeName.toLowerCase()==="input"&&"file"===e.type},password:function(e){return e.nodeName.toLowerCase()==="input"&&"password"===e.type},submit:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"submit"===bR.type},image:function(e){return e.nodeName.toLowerCase()==="input"&&"image"===e.type},reset:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"reset"===bR.type},button:function(bR){var e=bR.nodeName.toLowerCase();return e==="input"&&"button"===bR.type||e==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)},focus:function(e){return e===e.ownerDocument.activeElement}},setFilters:{first:function(bR,e){return e===0},last:function(bS,bR,e,bT){return bR===bT.length-1},even:function(bR,e){return e%2===0},odd:function(bR,e){return e%2===1},lt:function(bS,bR,e){return bRe[3]-0},nth:function(bS,bR,e){return e[3]-0===bR},eq:function(bS,bR,e){return e[3]-0===bR}},filter:{PSEUDO:function(bS,bX,bW,bY){var e=bX[1],bR=bE.filters[e];if(bR){return bR(bS,bW,bX,bY)}else{if(e==="contains"){return(bS.textContent||bS.innerText||bw([bS])||"").indexOf(bX[3])>=0}else{if(e==="not"){var bT=bX[3];for(var bV=0,bU=bT.length;bV=0)}}},ID:function(bR,e){return bR.nodeType===1&&bR.getAttribute("id")===e},TAG:function(bR,e){return(e==="*"&&bR.nodeType===1)||!!bR.nodeName&&bR.nodeName.toLowerCase()===e},CLASS:function(bR,e){return(" "+(bR.className||bR.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(bV,bT){var bS=bT[1],e=by.attr?by.attr(bV,bS):bE.attrHandle[bS]?bE.attrHandle[bS](bV):bV[bS]!=null?bV[bS]:bV.getAttribute(bS),bW=e+"",bU=bT[2],bR=bT[4];return e==null?bU==="!=":!bU&&by.attr?e!=null:bU==="="?bW===bR:bU==="*="?bW.indexOf(bR)>=0:bU==="~="?(" "+bW+" ").indexOf(bR)>=0:!bR?bW&&e!==false:bU==="!="?bW!==bR:bU==="^="?bW.indexOf(bR)===0:bU==="$="?bW.substr(bW.length-bR.length)===bR:bU==="|="?bW===bR||bW.substr(0,bR.length+1)===bR+"-":false},POS:function(bU,bR,bS,bV){var e=bR[2],bT=bE.setFilters[e];if(bT){return bT(bU,bS,bR,bV)}}}};var bD=bE.match.POS,bx=function(bR,e){return"\\"+(e-0+1)};for(var bz in bE.match){bE.match[bz]=new RegExp(bE.match[bz].source+(/(?![^\[]*\])(?![^\(]*\))/.source));bE.leftMatch[bz]=new RegExp(/(^(?:.|\r|\n)*?)/.source+bE.match[bz].source.replace(/\\(\d+)/g,bx))}bE.match.globalPOS=bD;var bF=function(bR,e){bR=Array.prototype.slice.call(bR,0);if(e){e.push.apply(e,bR);return e}return bR};try{Array.prototype.slice.call(av.documentElement.childNodes,0)[0].nodeType}catch(bP){bF=function(bU,bT){var bS=0,bR=bT||[];if(bL.call(bU)==="[object Array]"){Array.prototype.push.apply(bR,bU)}else{if(typeof bU.length==="number"){for(var e=bU.length;bS";e.insertBefore(bR,e.firstChild);if(av.getElementById(bS)){bE.find.ID=function(bU,bV,bW){if(typeof bV.getElementById!=="undefined"&&!bW){var bT=bV.getElementById(bU[1]);return bT?bT.id===bU[1]||typeof bT.getAttributeNode!=="undefined"&&bT.getAttributeNode("id").nodeValue===bU[1]?[bT]:L:[]}};bE.filter.ID=function(bV,bT){var bU=typeof bV.getAttributeNode!=="undefined"&&bV.getAttributeNode("id");return bV.nodeType===1&&bU&&bU.nodeValue===bT}}e.removeChild(bR);e=bR=null})();(function(){var e=av.createElement("div");e.appendChild(av.createComment(""));if(e.getElementsByTagName("*").length>0){bE.find.TAG=function(bR,bV){var bU=bV.getElementsByTagName(bR[1]);if(bR[1]==="*"){var bT=[];for(var bS=0;bU[bS];bS++){if(bU[bS].nodeType===1){bT.push(bU[bS])}}bU=bT}return bU}}e.innerHTML="";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){bE.attrHandle.href=function(bR){return bR.getAttribute("href",2)}}e=null})();if(av.querySelectorAll){(function(){var e=by,bT=av.createElement("div"),bS="__sizzle__";bT.innerHTML="

";if(bT.querySelectorAll&&bT.querySelectorAll(".TEST").length===0){return}by=function(b4,bV,bZ,b3){bV=bV||av;if(!b3&&!by.isXML(bV)){var b2=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b4);if(b2&&(bV.nodeType===1||bV.nodeType===9)){if(b2[1]){return bF(bV.getElementsByTagName(b4),bZ)}else{if(b2[2]&&bE.find.CLASS&&bV.getElementsByClassName){return bF(bV.getElementsByClassName(b2[2]),bZ)}}}if(bV.nodeType===9){if(b4==="body"&&bV.body){return bF([bV.body],bZ)}else{if(b2&&b2[3]){var bY=bV.getElementById(b2[3]);if(bY&&bY.parentNode){if(bY.id===b2[3]){return bF([bY],bZ)}}else{return bF([],bZ)}}}try{return bF(bV.querySelectorAll(b4),bZ)}catch(b0){}}else{if(bV.nodeType===1&&bV.nodeName.toLowerCase()!=="object"){var bW=bV,bX=bV.getAttribute("id"),bU=bX||bS,b6=bV.parentNode,b5=/^\s*[+~]/.test(b4);if(!bX){bV.setAttribute("id",bU)}else{bU=bU.replace(/'/g,"\\$&")}if(b5&&b6){bV=bV.parentNode}try{if(!b5||b6){return bF(bV.querySelectorAll("[id='"+bU+"'] "+b4),bZ)}}catch(b1){}finally{if(!bX){bW.removeAttribute("id")}}}}}return e(b4,bV,bZ,b3)};for(var bR in e){by[bR]=e[bR]}bT=null})()}(function(){var e=av.documentElement,bS=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector;if(bS){var bU=!bS.call(av.createElement("div"),"div"),bR=false;try{bS.call(av.documentElement,"[test!='']:sizzle")}catch(bT){bR=true}by.matchesSelector=function(bW,bY){bY=bY.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!by.isXML(bW)){try{if(bR||!bE.match.PSEUDO.test(bY)&&!/!=/.test(bY)){var bV=bS.call(bW,bY);if(bV||!bU||bW.document&&bW.document.nodeType!==11){return bV}}}catch(bX){}}return by(bY,null,null,[bW]).length>0}}})();(function(){var e=av.createElement("div");e.innerHTML="
";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}bE.order.splice(1,0,"CLASS");bE.find.CLASS=function(bR,bS,bT){if(typeof bS.getElementsByClassName!=="undefined"&&!bT){return bS.getElementsByClassName(bR[1])}};e=null})();function bv(bR,bW,bV,bZ,bX,bY){for(var bT=0,bS=bZ.length;bT0){bU=e;break}}}e=e[bR]}bZ[bT]=bU}}}if(av.documentElement.contains){by.contains=function(bR,e){return bR!==e&&(bR.contains?bR.contains(e):true)}}else{if(av.documentElement.compareDocumentPosition){by.contains=function(bR,e){return !!(bR.compareDocumentPosition(e)&16)}}else{by.contains=function(){return false}}}by.isXML=function(e){var bR=(e?e.ownerDocument||e:0).documentElement;return bR?bR.nodeName!=="HTML":false};var bM=function(bS,e,bW){var bV,bX=[],bU="",bY=e.nodeType?[e]:e;while((bV=bE.match.PSEUDO.exec(bS))){bU+=bV[0];bS=bS.replace(bE.match.PSEUDO,"")}bS=bE.relative[bS]?bS+"*":bS;for(var bT=0,bR=bY.length;bT0){for(bB=bA;bB=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(by,bx){var bv=[],bw,e,bz=this[0];if(b.isArray(by)){var bB=1;while(bz&&bz.ownerDocument&&bz!==bx){for(bw=0;bw-1:b.find.matchesSelector(bz,by)){bv.push(bz);break}else{bz=bz.parentNode;if(!bz||!bz.ownerDocument||bz===bx||bz.nodeType===11){break}}}}bv=bv.length>1?b.unique(bv):bv;return this.pushStack(bv,"closest",by)},index:function(e){if(!e){return(this[0]&&this[0].parentNode)?this.prevAll().length:-1}if(typeof e==="string"){return b.inArray(this[0],b(e))}return b.inArray(e.jquery?e[0]:e,this)},add:function(e,bv){var bx=typeof e==="string"?b(e,bv):b.makeArray(e&&e.nodeType?[e]:e),bw=b.merge(this.get(),bx);return this.pushStack(B(bx[0])||B(bw[0])?bw:b.unique(bw))},andSelf:function(){return this.add(this.prevObject)}});function B(e){return !e||!e.parentNode||e.parentNode.nodeType===11}b.each({parent:function(bv){var e=bv.parentNode;return e&&e.nodeType!==11?e:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(bv,e,bw){return b.dir(bv,"parentNode",bw)},next:function(e){return b.nth(e,2,"nextSibling")},prev:function(e){return b.nth(e,2,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(bv,e,bw){return b.dir(bv,"nextSibling",bw)},prevUntil:function(bv,e,bw){return b.dir(bv,"previousSibling",bw)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.makeArray(e.childNodes)}},function(e,bv){b.fn[e]=function(by,bw){var bx=b.map(this,bv,by);if(!ab.test(e)){bw=by}if(bw&&typeof bw==="string"){bx=b.filter(bw,bx)}bx=this.length>1&&!ay[e]?b.unique(bx):bx;if((this.length>1||bb.test(bw))&&aq.test(e)){bx=bx.reverse()}return this.pushStack(bx,e,P.call(arguments).join(","))}});b.extend({filter:function(bw,e,bv){if(bv){bw=":not("+bw+")"}return e.length===1?b.find.matchesSelector(e[0],bw)?[e[0]]:[]:b.find.matches(bw,e)},dir:function(bw,bv,by){var e=[],bx=bw[bv];while(bx&&bx.nodeType!==9&&(by===L||bx.nodeType!==1||!b(bx).is(by))){if(bx.nodeType===1){e.push(bx)}bx=bx[bv]}return e},nth:function(by,e,bw,bx){e=e||1;var bv=0;for(;by;by=by[bw]){if(by.nodeType===1&&++bv===e){break}}return by},sibling:function(bw,bv){var e=[];for(;bw;bw=bw.nextSibling){if(bw.nodeType===1&&bw!==bv){e.push(bw)}}return e}});function aH(bx,bw,e){bw=bw||0;if(b.isFunction(bw)){return b.grep(bx,function(bz,by){var bA=!!bw.call(bz,by,bz);return bA===e})}else{if(bw.nodeType){return b.grep(bx,function(bz,by){return(bz===bw)===e})}else{if(typeof bw==="string"){var bv=b.grep(bx,function(by){return by.nodeType===1});if(bp.test(bw)){return b.filter(bw,bv,!e)}else{bw=b.filter(bw,bv)}}}}return b.grep(bx,function(bz,by){return(b.inArray(bz,bw)>=0)===e})}function a(e){var bw=aS.split("|"),bv=e.createDocumentFragment();if(bv.createElement){while(bw.length){bv.createElement(bw.pop())}}return bv}var aS="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ah=/ jQuery\d+="(?:\d+|null)"/g,ar=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,d=/<([\w:]+)/,v=/]","i"),o=/checked\s*(?:[^=]|=\s*.checked.)/i,bn=/\/(java|ecma)script/i,aO=/^\s*",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},ac=a(av);ax.optgroup=ax.option;ax.tbody=ax.tfoot=ax.colgroup=ax.caption=ax.thead;ax.th=ax.td;if(!b.support.htmlSerialize){ax._default=[1,"div
","
"]}b.fn.extend({text:function(e){return b.access(this,function(bv){return bv===L?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||av).createTextNode(bv))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e)){return this.each(function(bw){b(this).wrapAll(e.call(this,bw))})}if(this[0]){var bv=b(e,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){bv.insertBefore(this[0])}bv.map(function(){var bw=this;while(bw.firstChild&&bw.firstChild.nodeType===1){bw=bw.firstChild}return bw}).append(this)}return this},wrapInner:function(e){if(b.isFunction(e)){return this.each(function(bv){b(this).wrapInner(e.call(this,bv))})}return this.each(function(){var bv=b(this),bw=bv.contents();if(bw.length){bw.wrapAll(e)}else{bv.append(e)}})},wrap:function(e){var bv=b.isFunction(e);return this.each(function(bw){b(this).wrapAll(bv?e.call(this,bw):e)})},unwrap:function(){return this.parent().each(function(){if(!b.nodeName(this,"body")){b(this).replaceWith(this.childNodes)}}).end()},append:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.appendChild(e)}})},prepend:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.insertBefore(e,this.firstChild)}})},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this)})}else{if(arguments.length){var e=b.clean(arguments);e.push.apply(e,this.toArray());return this.pushStack(e,"before",arguments)}}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this.nextSibling)})}else{if(arguments.length){var e=this.pushStack(this,"after",arguments);e.push.apply(e,b.clean(arguments));return e}}},remove:function(e,bx){for(var bv=0,bw;(bw=this[bv])!=null;bv++){if(!e||b.filter(e,[bw]).length){if(!bx&&bw.nodeType===1){b.cleanData(bw.getElementsByTagName("*"));b.cleanData([bw])}if(bw.parentNode){bw.parentNode.removeChild(bw)}}}return this},empty:function(){for(var e=0,bv;(bv=this[e])!=null;e++){if(bv.nodeType===1){b.cleanData(bv.getElementsByTagName("*"))}while(bv.firstChild){bv.removeChild(bv.firstChild)}}return this},clone:function(bv,e){bv=bv==null?false:bv;e=e==null?bv:e;return this.map(function(){return b.clone(this,bv,e)})},html:function(e){return b.access(this,function(by){var bx=this[0]||{},bw=0,bv=this.length;if(by===L){return bx.nodeType===1?bx.innerHTML.replace(ah,""):null}if(typeof by==="string"&&!ae.test(by)&&(b.support.leadingWhitespace||!ar.test(by))&&!ax[(d.exec(by)||["",""])[1].toLowerCase()]){by=by.replace(R,"<$1>");try{for(;bw1&&bw0?this.clone(true):this).get();b(bC[bA])[bv](by);bz=bz.concat(by)}return this.pushStack(bz,e,bC.selector)}}});function bh(e){if(typeof e.getElementsByTagName!=="undefined"){return e.getElementsByTagName("*")}else{if(typeof e.querySelectorAll!=="undefined"){return e.querySelectorAll("*")}else{return[]}}}function az(e){if(e.type==="checkbox"||e.type==="radio"){e.defaultChecked=e.checked}}function D(e){var bv=(e.nodeName||"").toLowerCase();if(bv==="input"){az(e)}else{if(bv!=="script"&&typeof e.getElementsByTagName!=="undefined"){b.grep(e.getElementsByTagName("input"),az)}}}function am(e){var bv=av.createElement("div");ac.appendChild(bv);bv.innerHTML=e.outerHTML;return bv.firstChild}b.extend({clone:function(by,bA,bw){var e,bv,bx,bz=b.support.html5Clone||b.isXMLDoc(by)||!ai.test("<"+by.nodeName+">")?by.cloneNode(true):am(by);if((!b.support.noCloneEvent||!b.support.noCloneChecked)&&(by.nodeType===1||by.nodeType===11)&&!b.isXMLDoc(by)){aj(by,bz);e=bh(by);bv=bh(bz);for(bx=0;e[bx];++bx){if(bv[bx]){aj(e[bx],bv[bx])}}}if(bA){s(by,bz);if(bw){e=bh(by);bv=bh(bz);for(bx=0;e[bx];++bx){s(e[bx],bv[bx])}}}e=bv=null;return bz},clean:function(bI,bw,bv,bx){var bA,bH,bD,bJ=[];bw=bw||av;if(typeof bw.createElement==="undefined"){bw=bw.ownerDocument||bw[0]&&bw[0].ownerDocument||av}for(var bE=0,bG;(bG=bI[bE])!=null;bE++){if(typeof bG==="number"){bG+=""}if(!bG){continue}if(typeof bG==="string"){if(!W.test(bG)){bG=bw.createTextNode(bG)}else{bG=bG.replace(R,"<$1>");var bN=(d.exec(bG)||["",""])[1].toLowerCase(),bz=ax[bN]||ax._default,bK=bz[0],bB=bw.createElement("div"),bL=ac.childNodes,bM;if(bw===av){ac.appendChild(bB)}else{a(bw).appendChild(bB)}bB.innerHTML=bz[1]+bG+bz[2];while(bK--){bB=bB.lastChild}if(!b.support.tbody){var by=v.test(bG),e=bN==="table"&&!by?bB.firstChild&&bB.firstChild.childNodes:bz[1]===""&&!by?bB.childNodes:[];for(bD=e.length-1;bD>=0;--bD){if(b.nodeName(e[bD],"tbody")&&!e[bD].childNodes.length){e[bD].parentNode.removeChild(e[bD])}}}if(!b.support.leadingWhitespace&&ar.test(bG)){bB.insertBefore(bw.createTextNode(ar.exec(bG)[0]),bB.firstChild)}bG=bB.childNodes;if(bB){bB.parentNode.removeChild(bB);if(bL.length>0){bM=bL[bL.length-1];if(bM&&bM.parentNode){bM.parentNode.removeChild(bM)}}}}}var bF;if(!b.support.appendChecked){if(bG[0]&&typeof(bF=bG.length)==="number"){for(bD=0;bD1)};b.extend({cssHooks:{opacity:{get:function(bw,bv){if(bv){var e=Z(bw,"opacity");return e===""?"1":e}else{return bw.style.opacity}}}},cssNumber:{fillOpacity:true,fontWeight:true,lineHeight:true,opacity:true,orphans:true,widows:true,zIndex:true,zoom:true},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(bx,bw,bD,by){if(!bx||bx.nodeType===3||bx.nodeType===8||!bx.style){return}var bB,bC,bz=b.camelCase(bw),bv=bx.style,bE=b.cssHooks[bz];bw=b.cssProps[bz]||bz;if(bD!==L){bC=typeof bD;if(bC==="string"&&(bB=I.exec(bD))){bD=(+(bB[1]+1)*+bB[2])+parseFloat(b.css(bx,bw));bC="number"}if(bD==null||bC==="number"&&isNaN(bD)){return}if(bC==="number"&&!b.cssNumber[bz]){bD+="px"}if(!bE||!("set" in bE)||(bD=bE.set(bx,bD))!==L){try{bv[bw]=bD}catch(bA){}}}else{if(bE&&"get" in bE&&(bB=bE.get(bx,false,by))!==L){return bB}return bv[bw]}},css:function(by,bx,bv){var bw,e;bx=b.camelCase(bx);e=b.cssHooks[bx];bx=b.cssProps[bx]||bx;if(bx==="cssFloat"){bx="float"}if(e&&"get" in e&&(bw=e.get(by,true,bv))!==L){return bw}else{if(Z){return Z(by,bx)}}},swap:function(by,bx,bz){var e={},bw,bv;for(bv in bx){e[bv]=by.style[bv];by.style[bv]=bx[bv]}bw=bz.call(by);for(bv in bx){by.style[bv]=e[bv]}return bw}});b.curCSS=b.css;if(av.defaultView&&av.defaultView.getComputedStyle){aJ=function(bA,bw){var bv,bz,e,by,bx=bA.style;bw=bw.replace(y,"-$1").toLowerCase();if((bz=bA.ownerDocument.defaultView)&&(e=bz.getComputedStyle(bA,null))){bv=e.getPropertyValue(bw);if(bv===""&&!b.contains(bA.ownerDocument.documentElement,bA)){bv=b.style(bA,bw)}}if(!b.support.pixelMargin&&e&&aE.test(bw)&&a1.test(bv)){by=bx.width;bx.width=bv;bv=e.width;bx.width=by}return bv}}if(av.documentElement.currentStyle){aY=function(bz,bw){var bA,e,by,bv=bz.currentStyle&&bz.currentStyle[bw],bx=bz.style;if(bv==null&&bx&&(by=bx[bw])){bv=by}if(a1.test(bv)){bA=bx.left;e=bz.runtimeStyle&&bz.runtimeStyle.left;if(e){bz.runtimeStyle.left=bz.currentStyle.left}bx.left=bw==="fontSize"?"1em":bv;bv=bx.pixelLeft+"px";bx.left=bA;if(e){bz.runtimeStyle.left=e}}return bv===""?"auto":bv}}Z=aJ||aY;function af(by,bw,bv){var bz=bw==="width"?by.offsetWidth:by.offsetHeight,bx=bw==="width"?1:0,e=4;if(bz>0){if(bv!=="border"){for(;bx=1&&b.trim(bw.replace(al,""))===""){bx.removeAttribute("filter");if(bv&&!bv.filter){return}}bx.filter=al.test(bw)?bw.replace(al,e):bw+" "+e}}}b(function(){if(!b.support.reliableMarginRight){b.cssHooks.marginRight={get:function(bv,e){return b.swap(bv,{display:"inline-block"},function(){if(e){return Z(bv,"margin-right")}else{return bv.style.marginRight}})}}}});if(b.expr&&b.expr.filters){b.expr.filters.hidden=function(bw){var bv=bw.offsetWidth,e=bw.offsetHeight;return(bv===0&&e===0)||(!b.support.reliableHiddenOffsets&&((bw.style&&bw.style.display)||b.css(bw,"display"))==="none")};b.expr.filters.visible=function(e){return !b.expr.filters.hidden(e)}}b.each({margin:"",padding:"",border:"Width"},function(e,bv){b.cssHooks[e+bv]={expand:function(by){var bx,bz=typeof by==="string"?by.split(" "):[by],bw={};for(bx=0;bx<4;bx++){bw[e+G[bx]+bv]=bz[bx]||bz[bx-2]||bz[0]}return bw}}});var k=/%20/g,ap=/\[\]$/,bs=/\r?\n/g,bq=/#.*$/,aD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,a0=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,aN=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,aR=/^(?:GET|HEAD)$/,c=/^\/\//,M=/\?/,a7=/)<[^<]*)*<\/script>/gi,p=/^(?:select|textarea)/i,h=/\s+/,br=/([?&])_=[^&]*/,K=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,z=b.fn.load,aa={},q={},aF,r,aW=["*/"]+["*"];try{aF=bm.href}catch(aw){aF=av.createElement("a");aF.href="";aF=aF.href}r=K.exec(aF.toLowerCase())||[];function f(e){return function(by,bA){if(typeof by!=="string"){bA=by;by="*"}if(b.isFunction(bA)){var bx=by.toLowerCase().split(h),bw=0,bz=bx.length,bv,bB,bC;for(;bw=0){var e=bw.slice(by,bw.length);bw=bw.slice(0,by)}var bx="GET";if(bz){if(b.isFunction(bz)){bA=bz;bz=L}else{if(typeof bz==="object"){bz=b.param(bz,b.ajaxSettings.traditional);bx="POST"}}}var bv=this;b.ajax({url:bw,type:bx,dataType:"html",data:bz,complete:function(bC,bB,bD){bD=bC.responseText;if(bC.isResolved()){bC.done(function(bE){bD=bE});bv.html(e?b("
").append(bD.replace(a7,"")).find(e):bD)}if(bA){bv.each(bA,[bD,bB,bC])}}});return this},serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?b.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||p.test(this.nodeName)||a0.test(this.type))}).map(function(e,bv){var bw=b(this).val();return bw==null?null:b.isArray(bw)?b.map(bw,function(by,bx){return{name:bv.name,value:by.replace(bs,"\r\n")}}):{name:bv.name,value:bw.replace(bs,"\r\n")}}).get()}});b.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,bv){b.fn[bv]=function(bw){return this.on(bv,bw)}});b.each(["get","post"],function(e,bv){b[bv]=function(bw,by,bz,bx){if(b.isFunction(by)){bx=bx||bz;bz=by;by=L}return b.ajax({type:bv,url:bw,data:by,success:bz,dataType:bx})}});b.extend({getScript:function(e,bv){return b.get(e,L,bv,"script")},getJSON:function(e,bv,bw){return b.get(e,bv,bw,"json")},ajaxSetup:function(bv,e){if(e){an(bv,b.ajaxSettings)}else{e=bv;bv=b.ajaxSettings}an(bv,e);return bv},ajaxSettings:{url:aF,isLocal:aN.test(r[1]),global:true,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:true,async:true,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":aW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":bd.String,"text html":true,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{context:true,url:true}},ajaxPrefilter:f(aa),ajaxTransport:f(q),ajax:function(bz,bx){if(typeof bz==="object"){bx=bz;bz=L}bx=bx||{};var bD=b.ajaxSetup({},bx),bS=bD.context||bD,bG=bS!==bD&&(bS.nodeType||bS instanceof b)?b(bS):b.event,bR=b.Deferred(),bN=b.Callbacks("once memory"),bB=bD.statusCode||{},bC,bH={},bO={},bQ,by,bL,bE,bI,bA=0,bw,bK,bJ={readyState:0,setRequestHeader:function(bT,bU){if(!bA){var e=bT.toLowerCase();bT=bO[e]=bO[e]||bT;bH[bT]=bU}return this},getAllResponseHeaders:function(){return bA===2?bQ:null},getResponseHeader:function(bT){var e;if(bA===2){if(!by){by={};while((e=aD.exec(bQ))){by[e[1].toLowerCase()]=e[2]}}e=by[bT.toLowerCase()]}return e===L?null:e},overrideMimeType:function(e){if(!bA){bD.mimeType=e}return this},abort:function(e){e=e||"abort";if(bL){bL.abort(e)}bF(0,e);return this}};function bF(bZ,bU,b0,bW){if(bA===2){return}bA=2;if(bE){clearTimeout(bE)}bL=L;bQ=bW||"";bJ.readyState=bZ>0?4:0;var bT,b4,b3,bX=bU,bY=b0?bk(bD,bJ,b0):L,bV,b2;if(bZ>=200&&bZ<300||bZ===304){if(bD.ifModified){if((bV=bJ.getResponseHeader("Last-Modified"))){b.lastModified[bC]=bV}if((b2=bJ.getResponseHeader("Etag"))){b.etag[bC]=b2}}if(bZ===304){bX="notmodified";bT=true}else{try{b4=F(bD,bY);bX="success";bT=true}catch(b1){bX="parsererror";b3=b1}}}else{b3=bX;if(!bX||bZ){bX="error";if(bZ<0){bZ=0}}}bJ.status=bZ;bJ.statusText=""+(bU||bX);if(bT){bR.resolveWith(bS,[b4,bX,bJ])}else{bR.rejectWith(bS,[bJ,bX,b3])}bJ.statusCode(bB);bB=L;if(bw){bG.trigger("ajax"+(bT?"Success":"Error"),[bJ,bD,bT?b4:b3])}bN.fireWith(bS,[bJ,bX]);if(bw){bG.trigger("ajaxComplete",[bJ,bD]);if(!(--b.active)){b.event.trigger("ajaxStop")}}}bR.promise(bJ);bJ.success=bJ.done;bJ.error=bJ.fail;bJ.complete=bN.add;bJ.statusCode=function(bT){if(bT){var e;if(bA<2){for(e in bT){bB[e]=[bB[e],bT[e]]}}else{e=bT[bJ.status];bJ.then(e,e)}}return this};bD.url=((bz||bD.url)+"").replace(bq,"").replace(c,r[1]+"//");bD.dataTypes=b.trim(bD.dataType||"*").toLowerCase().split(h);if(bD.crossDomain==null){bI=K.exec(bD.url.toLowerCase());bD.crossDomain=!!(bI&&(bI[1]!=r[1]||bI[2]!=r[2]||(bI[3]||(bI[1]==="http:"?80:443))!=(r[3]||(r[1]==="http:"?80:443))))}if(bD.data&&bD.processData&&typeof bD.data!=="string"){bD.data=b.param(bD.data,bD.traditional)}aX(aa,bD,bx,bJ);if(bA===2){return false}bw=bD.global;bD.type=bD.type.toUpperCase();bD.hasContent=!aR.test(bD.type);if(bw&&b.active++===0){b.event.trigger("ajaxStart")}if(!bD.hasContent){if(bD.data){bD.url+=(M.test(bD.url)?"&":"?")+bD.data;delete bD.data}bC=bD.url;if(bD.cache===false){var bv=b.now(),bP=bD.url.replace(br,"$1_="+bv);bD.url=bP+((bP===bD.url)?(M.test(bD.url)?"&":"?")+"_="+bv:"")}}if(bD.data&&bD.hasContent&&bD.contentType!==false||bx.contentType){bJ.setRequestHeader("Content-Type",bD.contentType)}if(bD.ifModified){bC=bC||bD.url;if(b.lastModified[bC]){bJ.setRequestHeader("If-Modified-Since",b.lastModified[bC])}if(b.etag[bC]){bJ.setRequestHeader("If-None-Match",b.etag[bC])}}bJ.setRequestHeader("Accept",bD.dataTypes[0]&&bD.accepts[bD.dataTypes[0]]?bD.accepts[bD.dataTypes[0]]+(bD.dataTypes[0]!=="*"?", "+aW+"; q=0.01":""):bD.accepts["*"]);for(bK in bD.headers){bJ.setRequestHeader(bK,bD.headers[bK])}if(bD.beforeSend&&(bD.beforeSend.call(bS,bJ,bD)===false||bA===2)){bJ.abort();return false}for(bK in {success:1,error:1,complete:1}){bJ[bK](bD[bK])}bL=aX(q,bD,bx,bJ);if(!bL){bF(-1,"No Transport")}else{bJ.readyState=1;if(bw){bG.trigger("ajaxSend",[bJ,bD])}if(bD.async&&bD.timeout>0){bE=setTimeout(function(){bJ.abort("timeout")},bD.timeout)}try{bA=1;bL.send(bH,bF)}catch(bM){if(bA<2){bF(-1,bM)}else{throw bM}}}return bJ},param:function(e,bw){var bv=[],by=function(bz,bA){bA=b.isFunction(bA)?bA():bA;bv[bv.length]=encodeURIComponent(bz)+"="+encodeURIComponent(bA)};if(bw===L){bw=b.ajaxSettings.traditional}if(b.isArray(e)||(e.jquery&&!b.isPlainObject(e))){b.each(e,function(){by(this.name,this.value)})}else{for(var bx in e){u(bx,e[bx],bw,by)}}return bv.join("&").replace(k,"+")}});function u(bw,by,bv,bx){if(b.isArray(by)){b.each(by,function(bA,bz){if(bv||ap.test(bw)){bx(bw,bz)}else{u(bw+"["+(typeof bz==="object"?bA:"")+"]",bz,bv,bx)}})}else{if(!bv&&b.type(by)==="object"){for(var e in by){u(bw+"["+e+"]",by[e],bv,bx)}}else{bx(bw,by)}}}b.extend({active:0,lastModified:{},etag:{}});function bk(bD,bC,bz){var bv=bD.contents,bB=bD.dataTypes,bw=bD.responseFields,by,bA,bx,e;for(bA in bw){if(bA in bz){bC[bw[bA]]=bz[bA]}}while(bB[0]==="*"){bB.shift();if(by===L){by=bD.mimeType||bC.getResponseHeader("content-type")}}if(by){for(bA in bv){if(bv[bA]&&bv[bA].test(by)){bB.unshift(bA);break}}}if(bB[0] in bz){bx=bB[0]}else{for(bA in bz){if(!bB[0]||bD.converters[bA+" "+bB[0]]){bx=bA;break}if(!e){e=bA}}bx=bx||e}if(bx){if(bx!==bB[0]){bB.unshift(bx)}return bz[bx]}}function F(bH,bz){if(bH.dataFilter){bz=bH.dataFilter(bz,bH.dataType)}var bD=bH.dataTypes,bG={},bA,bE,bw=bD.length,bB,bC=bD[0],bx,by,bF,bv,e;for(bA=1;bA=bw.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();bw.animatedProperties[this.prop]=true;for(bA in bw.animatedProperties){if(bw.animatedProperties[bA]!==true){e=false}}if(e){if(bw.overflow!=null&&!b.support.shrinkWrapBlocks){b.each(["","X","Y"],function(bC,bD){bz.style["overflow"+bD]=bw.overflow[bC]})}if(bw.hide){b(bz).hide()}if(bw.hide||bw.show){for(bA in bw.animatedProperties){b.style(bz,bA,bw.orig[bA]);b.removeData(bz,"fxshow"+bA,true);b.removeData(bz,"toggle"+bA,true)}}bv=bw.complete;if(bv){bw.complete=false;bv.call(bz)}}return false}else{if(bw.duration==Infinity){this.now=bx}else{bB=bx-this.startTime;this.state=bB/bw.duration;this.pos=b.easing[bw.animatedProperties[this.prop]](this.state,bB,0,1,bw.duration);this.now=this.start+((this.end-this.start)*this.pos)}this.update()}return true}};b.extend(b.fx,{tick:function(){var bw,bv=b.timers,e=0;for(;e").appendTo(e),bw=bv.css("display");bv.remove();if(bw==="none"||bw===""){if(!ba){ba=av.createElement("iframe");ba.frameBorder=ba.width=ba.height=0}e.appendChild(ba);if(!m||!ba.createElement){m=(ba.contentWindow||ba.contentDocument).document;m.write((b.support.boxModel?"":"")+"");m.close()}bv=m.createElement(bx);m.body.appendChild(bv);bw=b.css(bv,"display");e.removeChild(ba)}Q[bx]=bw}return Q[bx]}var a8,V=/^t(?:able|d|h)$/i,ad=/^(?:body|html)$/i;if("getBoundingClientRect" in av.documentElement){a8=function(by,bH,bw,bB){try{bB=by.getBoundingClientRect()}catch(bF){}if(!bB||!b.contains(bw,by)){return bB?{top:bB.top,left:bB.left}:{top:0,left:0}}var bC=bH.body,bD=aL(bH),bA=bw.clientTop||bC.clientTop||0,bE=bw.clientLeft||bC.clientLeft||0,bv=bD.pageYOffset||b.support.boxModel&&bw.scrollTop||bC.scrollTop,bz=bD.pageXOffset||b.support.boxModel&&bw.scrollLeft||bC.scrollLeft,bG=bB.top+bv-bA,bx=bB.left+bz-bE;return{top:bG,left:bx}}}else{a8=function(bz,bE,bx){var bC,bw=bz.offsetParent,bv=bz,bA=bE.body,bB=bE.defaultView,e=bB?bB.getComputedStyle(bz,null):bz.currentStyle,bD=bz.offsetTop,by=bz.offsetLeft;while((bz=bz.parentNode)&&bz!==bA&&bz!==bx){if(b.support.fixedPosition&&e.position==="fixed"){break}bC=bB?bB.getComputedStyle(bz,null):bz.currentStyle;bD-=bz.scrollTop;by-=bz.scrollLeft;if(bz===bw){bD+=bz.offsetTop;by+=bz.offsetLeft;if(b.support.doesNotAddBorder&&!(b.support.doesAddBorderForTableAndCells&&V.test(bz.nodeName))){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}bv=bw;bw=bz.offsetParent}if(b.support.subtractsBorderForOverflowNotVisible&&bC.overflow!=="visible"){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}e=bC}if(e.position==="relative"||e.position==="static"){bD+=bA.offsetTop;by+=bA.offsetLeft}if(b.support.fixedPosition&&e.position==="fixed"){bD+=Math.max(bx.scrollTop,bA.scrollTop);by+=Math.max(bx.scrollLeft,bA.scrollLeft)}return{top:bD,left:by}}}b.fn.offset=function(e){if(arguments.length){return e===L?this:this.each(function(bx){b.offset.setOffset(this,e,bx)})}var bv=this[0],bw=bv&&bv.ownerDocument;if(!bw){return null}if(bv===bw.body){return b.offset.bodyOffset(bv)}return a8(bv,bw,bw.documentElement)};b.offset={bodyOffset:function(e){var bw=e.offsetTop,bv=e.offsetLeft;if(b.support.doesNotIncludeMarginInBodyOffset){bw+=parseFloat(b.css(e,"marginTop"))||0;bv+=parseFloat(b.css(e,"marginLeft"))||0}return{top:bw,left:bv}},setOffset:function(bx,bG,bA){var bB=b.css(bx,"position");if(bB==="static"){bx.style.position="relative"}var bz=b(bx),bv=bz.offset(),e=b.css(bx,"top"),bE=b.css(bx,"left"),bF=(bB==="absolute"||bB==="fixed")&&b.inArray("auto",[e,bE])>-1,bD={},bC={},bw,by;if(bF){bC=bz.position();bw=bC.top;by=bC.left}else{bw=parseFloat(e)||0;by=parseFloat(bE)||0}if(b.isFunction(bG)){bG=bG.call(bx,bA,bv)}if(bG.top!=null){bD.top=(bG.top-bv.top)+bw}if(bG.left!=null){bD.left=(bG.left-bv.left)+by}if("using" in bG){bG.using.call(bx,bD)}else{bz.css(bD)}}};b.fn.extend({position:function(){if(!this[0]){return null}var bw=this[0],bv=this.offsetParent(),bx=this.offset(),e=ad.test(bv[0].nodeName)?{top:0,left:0}:bv.offset();bx.top-=parseFloat(b.css(bw,"marginTop"))||0;bx.left-=parseFloat(b.css(bw,"marginLeft"))||0;e.top+=parseFloat(b.css(bv[0],"borderTopWidth"))||0;e.left+=parseFloat(b.css(bv[0],"borderLeftWidth"))||0;return{top:bx.top-e.top,left:bx.left-e.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||av.body;while(e&&(!ad.test(e.nodeName)&&b.css(e,"position")==="static")){e=e.offsetParent}return e})}});b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(bw,bv){var e=/Y/.test(bv);b.fn[bw]=function(bx){return b.access(this,function(by,bB,bA){var bz=aL(by);if(bA===L){return bz?(bv in bz)?bz[bv]:b.support.boxModel&&bz.document.documentElement[bB]||bz.document.body[bB]:by[bB]}if(bz){bz.scrollTo(!e?bA:b(bz).scrollLeft(),e?bA:b(bz).scrollTop())}else{by[bB]=bA}},bw,bx,arguments.length,null)}});function aL(e){return b.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:false}b.each({Height:"height",Width:"width"},function(bw,bx){var bv="client"+bw,e="scroll"+bw,by="offset"+bw;b.fn["inner"+bw]=function(){var bz=this[0];return bz?bz.style?parseFloat(b.css(bz,bx,"padding")):this[bx]():null};b.fn["outer"+bw]=function(bA){var bz=this[0];return bz?bz.style?parseFloat(b.css(bz,bx,bA?"margin":"border")):this[bx]():null};b.fn[bx]=function(bz){return b.access(this,function(bC,bB,bD){var bF,bE,bG,bA;if(b.isWindow(bC)){bF=bC.document;bE=bF.documentElement[bv];return b.support.boxModel&&bE||bF.body&&bF.body[bv]||bE}if(bC.nodeType===9){bF=bC.documentElement;if(bF[bv]>=bF[e]){return bF[bv]}return Math.max(bC.body[e],bF[e],bC.body[by],bF[by])}if(bD===L){bG=b.css(bC,bB);bA=parseFloat(bG);return b.isNumeric(bA)?bA:bG}b(bC).css(bB,bD)},bx,bz,arguments.length,null)}});bd.jQuery=bd.$=b;if(typeof define==="function"&&define.amd&&define.amd.jQuery){define("jquery",[],function(){return b})}})(window);/*! - * jQuery UI 1.8.18 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(a,d){a.ui=a.ui||{};if(a.ui.version){return}a.extend(a.ui,{version:"1.8.18",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(e,f){return typeof e==="number"?this.each(function(){var g=this;setTimeout(function(){a(g).focus();if(f){f.call(g)}},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){e=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{e=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!e.length?a(document):e},zIndex:function(h){if(h!==d){return this.css("zIndex",h)}if(this.length){var f=a(this[0]),e,g;while(f.length&&f[0]!==document){e=f.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){g=parseInt(f.css("zIndex"),10);if(!isNaN(g)&&g!==0){return g}}f=f.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});a.each(["Width","Height"],function(g,e){var f=e==="Width"?["Left","Right"]:["Top","Bottom"],h=e.toLowerCase(),k={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};function j(m,l,i,n){a.each(f,function(){l-=parseFloat(a.curCSS(m,"padding"+this,true))||0;if(i){l-=parseFloat(a.curCSS(m,"border"+this+"Width",true))||0}if(n){l-=parseFloat(a.curCSS(m,"margin"+this,true))||0}});return l}a.fn["inner"+e]=function(i){if(i===d){return k["inner"+e].call(this)}return this.each(function(){a(this).css(h,j(this,i)+"px")})};a.fn["outer"+e]=function(i,l){if(typeof i!=="number"){return k["outer"+e].call(this,i)}return this.each(function(){a(this).css(h,j(this,i,true,l)+"px")})}});function c(g,e){var j=g.nodeName.toLowerCase();if("area"===j){var i=g.parentNode,h=i.name,f;if(!g.href||!h||i.nodeName.toLowerCase()!=="map"){return false}f=a("img[usemap=#"+h+"]")[0];return !!f&&b(f)}return(/input|select|textarea|button|object/.test(j)?!g.disabled:"a"==j?g.href||e:e)&&b(g)}function b(e){return !a(e).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.extend(a.expr[":"],{data:function(g,f,e){return !!a.data(g,e[3])},focusable:function(e){return c(e,!isNaN(a.attr(e,"tabindex")))},tabbable:function(g){var e=a.attr(g,"tabindex"),f=isNaN(e);return(f||e>=0)&&c(g,!f)}});a(function(){var e=document.body,f=e.appendChild(f=document.createElement("div"));f.offsetHeight;a.extend(f.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=f.offsetHeight===100;a.support.selectstart="onselectstart" in f;e.removeChild(f).style.display="none"});a.extend(a.ui,{plugin:{add:function(f,g,j){var h=a.ui[f].prototype;for(var e in j){h.plugins[e]=h.plugins[e]||[];h.plugins[e].push([g,j[e]])}},call:function(e,g,f){var j=e.plugins[g];if(!j||!e.element[0].parentNode){return}for(var h=0;h0){return true}h[e]=1;g=(h[e]>0);h[e]=0;return g},isOverAxis:function(f,e,g){return(f>e)&&(f<(e+g))},isOver:function(j,f,i,h,e,g){return a.ui.isOverAxis(j,i,e)&&a.ui.isOverAxis(f,h,g)}})})(jQuery);/*! - * jQuery UI Widget 1.8.18 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Widget - */ -(function(b,d){if(b.cleanData){var c=b.cleanData;b.cleanData=function(f){for(var g=0,h;(h=f[g])!=null;g++){try{b(h).triggerHandler("remove")}catch(j){}}c(f)}}else{var a=b.fn.remove;b.fn.remove=function(e,f){return this.each(function(){if(!f){if(!e||b.filter(e,[this]).length){b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(g){}})}}return a.call(b(this),e,f)})}}b.widget=function(f,h,e){var g=f.split(".")[0],j;f=f.split(".")[1];j=g+"-"+f;if(!e){e=h;h=b.Widget}b.expr[":"][j]=function(k){return !!b.data(k,f)};b[g]=b[g]||{};b[g][f]=function(k,l){if(arguments.length){this._createWidget(k,l)}};var i=new h();i.options=b.extend(true,{},i.options);b[g][f].prototype=b.extend(true,i,{namespace:g,widgetName:f,widgetEventPrefix:b[g][f].prototype.widgetEventPrefix||f,widgetBaseClass:j},e);b.widget.bridge(f,b[g][f])};b.widget.bridge=function(f,e){b.fn[f]=function(i){var g=typeof i==="string",h=Array.prototype.slice.call(arguments,1),j=this;i=!g&&h.length?b.extend.apply(null,[true,i].concat(h)):i;if(g&&i.charAt(0)==="_"){return j}if(g){this.each(function(){var k=b.data(this,f),l=k&&b.isFunction(k[i])?k[i].apply(k,h):k;if(l!==k&&l!==d){j=l;return false}})}else{this.each(function(){var k=b.data(this,f);if(k){k.option(i||{})._init()}else{b.data(this,f,new e(i,this))}})}return j}};b.Widget=function(e,f){if(arguments.length){this._createWidget(e,f)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(f,g){b.data(g,this.widgetName,this);this.element=b(g);this.options=b.extend(true,{},this.options,this._getCreateOptions(),f);var e=this;this.element.bind("remove."+this.widgetName,function(){e.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(f,g){var e=f;if(arguments.length===0){return b.extend({},this.options)}if(typeof f==="string"){if(g===d){return this.options[f]}e={};e[f]=g}this._setOptions(e);return this},_setOptions:function(f){var e=this;b.each(f,function(g,h){e._setOption(g,h)});return this},_setOption:function(e,f){this.options[e]=f;if(e==="disabled"){this.widget()[f?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",f)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(e,f,g){var j,i,h=this.options[e];g=g||{};f=b.Event(f);f.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase();f.target=this.element[0];i=f.originalEvent;if(i){for(j in i){if(!(j in f)){f[j]=i[j]}}}this.element.trigger(f,g);return !(b.isFunction(h)&&h.call(this.element[0],f,g)===false||f.isDefaultPrevented())}}})(jQuery);/*! - * jQuery UI Mouse 1.8.18 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Mouse - * - * Depends: - * jquery.ui.widget.js - */ -(function(b,c){var a=false;b(document).mouseup(function(d){a=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var d=this;this.element.bind("mousedown."+this.widgetName,function(e){return d._mouseDown(e)}).bind("click."+this.widgetName,function(e){if(true===b.data(e.target,d.widgetName+".preventClickEvent")){b.removeData(e.target,d.widgetName+".preventClickEvent");e.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(f){if(a){return}(this._mouseStarted&&this._mouseUp(f));this._mouseDownEvent=f;var e=this,g=(f.which==1),d=(typeof this.options.cancel=="string"&&f.target.nodeName?b(f.target).closest(this.options.cancel).length:false);if(!g||d||!this._mouseCapture(f)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){e.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=(this._mouseStart(f)!==false);if(!this._mouseStarted){f.preventDefault();return true}}if(true===b.data(f.target,this.widgetName+".preventClickEvent")){b.removeData(f.target,this.widgetName+".preventClickEvent")}this._mouseMoveDelegate=function(h){return e._mouseMove(h)};this._mouseUpDelegate=function(h){return e._mouseUp(h)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);f.preventDefault();a=true;return true},_mouseMove:function(d){if(b.browser.msie&&!(document.documentMode>=9)&&!d.button){return this._mouseUp(d)}if(this._mouseStarted){this._mouseDrag(d);return d.preventDefault()}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,d)!==false);(this._mouseStarted?this._mouseDrag(d):this._mouseUp(d))}return !this._mouseStarted},_mouseUp:function(d){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;if(d.target==this._mouseDownEvent.target){b.data(d.target,this.widgetName+".preventClickEvent",true)}this._mouseStop(d)}return false},_mouseDistanceMet:function(d){return(Math.max(Math.abs(this._mouseDownEvent.pageX-d.pageX),Math.abs(this._mouseDownEvent.pageY-d.pageY))>=this.options.distance)},_mouseDelayMet:function(d){return this.mouseDelayMet},_mouseStart:function(d){},_mouseDrag:function(d){},_mouseStop:function(d){},_mouseCapture:function(d){return true}})})(jQuery);(function(c,d){c.widget("ui.resizable",c.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000},_create:function(){var f=this,k=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!(k.aspectRatio),aspectRatio:k.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:k.helper||k.ghost||k.animate?k.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){this.element.wrap(c('
').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=k.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var l=this.handles.split(",");this.handles={};for(var g=0;g
');if(/sw|se|ne|nw/.test(j)){h.css({zIndex:++k.zIndex})}if("se"==j){h.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[j]=".ui-resizable-"+j;this.element.append(h)}}this._renderAxis=function(q){q=q||this.element;for(var n in this.handles){if(this.handles[n].constructor==String){this.handles[n]=c(this.handles[n],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var o=c(this.handles[n],this.element),p=0;p=/sw|ne|nw|se|n|s/.test(n)?o.outerHeight():o.outerWidth();var m=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");q.css(m,p);this._proportionallyResize()}if(!c(this.handles[n]).length){continue}}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!f.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}f.axis=i&&i[1]?i[1]:"se"}});if(k.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){if(k.disabled){return}c(this).removeClass("ui-resizable-autohide");f._handles.show()},function(){if(k.disabled){return}if(!f.resizing){c(this).addClass("ui-resizable-autohide");f._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var e=function(g){c(g).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){e(this.element);var f=this.element;f.after(this.originalElement.css({position:f.css("position"),width:f.outerWidth(),height:f.outerHeight(),top:f.css("top"),left:f.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);e(this.originalElement);return this},_mouseCapture:function(f){var g=false;for(var e in this.handles){if(c(this.handles[e])[0]==f.target){g=true}}return !this.options.disabled&&g},_mouseStart:function(g){var j=this.options,f=this.element.position(),e=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(e.is(".ui-draggable")||(/absolute/).test(e.css("position"))){e.css({position:"absolute",top:f.top,left:f.left})}this._renderProxy();var k=b(this.helper.css("left")),h=b(this.helper.css("top"));if(j.containment){k+=c(j.containment).scrollLeft()||0;h+=c(j.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:k,top:h};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:k,top:h};this.sizeDiff={width:e.outerWidth()-e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:g.pageX,top:g.pageY};this.aspectRatio=(typeof j.aspectRatio=="number")?j.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var i=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",i=="auto"?this.axis+"-resize":i);e.addClass("ui-resizable-resizing");this._propagate("start",g);return true},_mouseDrag:function(e){var h=this.helper,g=this.options,m={},q=this,j=this.originalMousePosition,n=this.axis;var r=(e.pageX-j.left)||0,p=(e.pageY-j.top)||0;var i=this._change[n];if(!i){return false}var l=i.apply(this,[e,r,p]),k=c.browser.msie&&c.browser.version<7,f=this.sizeDiff;this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey){l=this._updateRatio(l,e)}l=this._respectSize(l,e);this._propagate("resize",e);h.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(l);this._trigger("resize",e,this.ui());return false},_mouseStop:function(h){this.resizing=false;var i=this.options,m=this;if(this._helper){var g=this._proportionallyResizeElements,e=g.length&&(/textarea/i).test(g[0].nodeName),f=e&&c.ui.hasScroll(g[0],"left")?0:m.sizeDiff.height,k=e?0:m.sizeDiff.width;var n={width:(m.helper.width()-k),height:(m.helper.height()-f)},j=(parseInt(m.element.css("left"),10)+(m.position.left-m.originalPosition.left))||null,l=(parseInt(m.element.css("top"),10)+(m.position.top-m.originalPosition.top))||null;if(!i.animate){this.element.css(c.extend(n,{top:l,left:j}))}m.helper.height(m.size.height);m.helper.width(m.size.width);if(this._helper&&!i.animate){this._proportionallyResize()}}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",h);if(this._helper){this.helper.remove()}return false},_updateVirtualBoundaries:function(g){var j=this.options,i,h,f,k,e;e={minWidth:a(j.minWidth)?j.minWidth:0,maxWidth:a(j.maxWidth)?j.maxWidth:Infinity,minHeight:a(j.minHeight)?j.minHeight:0,maxHeight:a(j.maxHeight)?j.maxHeight:Infinity};if(this._aspectRatio||g){i=e.minHeight*this.aspectRatio;f=e.minWidth/this.aspectRatio;h=e.maxHeight*this.aspectRatio;k=e.maxWidth/this.aspectRatio;if(i>e.minWidth){e.minWidth=i}if(f>e.minHeight){e.minHeight=f}if(hl.width),s=a(l.height)&&i.minHeight&&(i.minHeight>l.height);if(h){l.width=i.minWidth}if(s){l.height=i.minHeight}if(t){l.width=i.maxWidth}if(m){l.height=i.maxHeight}var f=this.originalPosition.left+this.originalSize.width,p=this.position.top+this.size.height;var k=/sw|nw|w/.test(q),e=/nw|ne|n/.test(q);if(h&&k){l.left=f-i.minWidth}if(t&&k){l.left=f-i.maxWidth}if(s&&e){l.top=p-i.minHeight}if(m&&e){l.top=p-i.maxHeight}var n=!l.width&&!l.height;if(n&&!l.left&&l.top){l.top=null}else{if(n&&!l.top&&l.left){l.left=null}}return l},_proportionallyResize:function(){var k=this.options;if(!this._proportionallyResizeElements.length){return}var g=this.helper||this.element;for(var f=0;f');var e=c.browser.msie&&c.browser.version<7,g=(e?1:0),h=(e?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+h,height:this.element.outerHeight()+h,position:"absolute",left:this.elementOffset.left-g+"px",top:this.elementOffset.top-g+"px",zIndex:++i.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(g,f,e){return{width:this.originalSize.width+f}},w:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{left:i.left+f,width:g.width-f}},n:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{top:i.top+e,height:g.height-e}},s:function(g,f,e){return{height:this.originalSize.height+e}},se:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},sw:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[g,f,e]))},ne:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},nw:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[g,f,e]))}},_propagate:function(f,e){c.ui.plugin.call(this,f,[e,this.ui()]);(f!="resize"&&this._trigger(f,e,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});c.extend(c.ui.resizable,{version:"1.8.18"});c.ui.plugin.add("resizable","alsoResize",{start:function(f,g){var e=c(this).data("resizable"),i=e.options;var h=function(j){c(j).each(function(){var k=c(this);k.data("resizable-alsoresize",{width:parseInt(k.width(),10),height:parseInt(k.height(),10),left:parseInt(k.css("left"),10),top:parseInt(k.css("top"),10)})})};if(typeof(i.alsoResize)=="object"&&!i.alsoResize.parentNode){if(i.alsoResize.length){i.alsoResize=i.alsoResize[0];h(i.alsoResize)}else{c.each(i.alsoResize,function(j){h(j)})}}else{h(i.alsoResize)}},resize:function(g,i){var f=c(this).data("resizable"),j=f.options,h=f.originalSize,l=f.originalPosition;var k={height:(f.size.height-h.height)||0,width:(f.size.width-h.width)||0,top:(f.position.top-l.top)||0,left:(f.position.left-l.left)||0},e=function(m,n){c(m).each(function(){var q=c(this),r=c(this).data("resizable-alsoresize"),p={},o=n&&n.length?n:q.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];c.each(o,function(s,u){var t=(r[u]||0)+(k[u]||0);if(t&&t>=0){p[u]=t||null}});q.css(p)})};if(typeof(j.alsoResize)=="object"&&!j.alsoResize.nodeType){c.each(j.alsoResize,function(m,n){e(m,n)})}else{e(j.alsoResize)}},stop:function(e,f){c(this).removeData("resizable-alsoresize")}});c.ui.plugin.add("resizable","animate",{stop:function(i,n){var p=c(this).data("resizable"),j=p.options;var h=p._proportionallyResizeElements,e=h.length&&(/textarea/i).test(h[0].nodeName),f=e&&c.ui.hasScroll(h[0],"left")?0:p.sizeDiff.height,l=e?0:p.sizeDiff.width;var g={width:(p.size.width-l),height:(p.size.height-f)},k=(parseInt(p.element.css("left"),10)+(p.position.left-p.originalPosition.left))||null,m=(parseInt(p.element.css("top"),10)+(p.position.top-p.originalPosition.top))||null;p.element.animate(c.extend(g,m&&k?{top:m,left:k}:{}),{duration:j.animateDuration,easing:j.animateEasing,step:function(){var o={width:parseInt(p.element.css("width"),10),height:parseInt(p.element.css("height"),10),top:parseInt(p.element.css("top"),10),left:parseInt(p.element.css("left"),10)};if(h&&h.length){c(h[0]).css({width:o.width,height:o.height})}p._updateCache(o);p._propagate("resize",i)}})}});c.ui.plugin.add("resizable","containment",{start:function(f,r){var t=c(this).data("resizable"),j=t.options,l=t.element;var g=j.containment,k=(g instanceof c)?g.get(0):(/parent/.test(g))?l.parent().get(0):g;if(!k){return}t.containerElement=c(k);if(/document/.test(g)||g==document){t.containerOffset={left:0,top:0};t.containerPosition={left:0,top:0};t.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var n=c(k),i=[];c(["Top","Right","Left","Bottom"]).each(function(p,o){i[p]=b(n.css("padding"+o))});t.containerOffset=n.offset();t.containerPosition=n.position();t.containerSize={height:(n.innerHeight()-i[3]),width:(n.innerWidth()-i[1])};var q=t.containerOffset,e=t.containerSize.height,m=t.containerSize.width,h=(c.ui.hasScroll(k,"left")?k.scrollWidth:m),s=(c.ui.hasScroll(k)?k.scrollHeight:e);t.parentData={element:k,left:q.left,top:q.top,width:h,height:s}}},resize:function(g,q){var t=c(this).data("resizable"),i=t.options,f=t.containerSize,p=t.containerOffset,m=t.size,n=t.position,r=t._aspectRatio||g.shiftKey,e={top:0,left:0},h=t.containerElement;if(h[0]!=document&&(/static/).test(h.css("position"))){e=p}if(n.left<(t._helper?p.left:0)){t.size.width=t.size.width+(t._helper?(t.position.left-p.left):(t.position.left-e.left));if(r){t.size.height=t.size.width/i.aspectRatio}t.position.left=i.helper?p.left:0}if(n.top<(t._helper?p.top:0)){t.size.height=t.size.height+(t._helper?(t.position.top-p.top):t.position.top);if(r){t.size.width=t.size.height*i.aspectRatio}t.position.top=t._helper?p.top:0}t.offset.left=t.parentData.left+t.position.left;t.offset.top=t.parentData.top+t.position.top;var l=Math.abs((t._helper?t.offset.left-e.left:(t.offset.left-e.left))+t.sizeDiff.width),s=Math.abs((t._helper?t.offset.top-e.top:(t.offset.top-p.top))+t.sizeDiff.height);var k=t.containerElement.get(0)==t.element.parent().get(0),j=/relative|absolute/.test(t.containerElement.css("position"));if(k&&j){l-=t.parentData.left}if(l+t.size.width>=t.parentData.width){t.size.width=t.parentData.width-l;if(r){t.size.height=t.size.width/t.aspectRatio}}if(s+t.size.height>=t.parentData.height){t.size.height=t.parentData.height-s;if(r){t.size.width=t.size.height*t.aspectRatio}}},stop:function(f,n){var q=c(this).data("resizable"),g=q.options,l=q.position,m=q.containerOffset,e=q.containerPosition,i=q.containerElement;var j=c(q.helper),r=j.offset(),p=j.outerWidth()-q.sizeDiff.width,k=j.outerHeight()-q.sizeDiff.height;if(q._helper&&!g.animate&&(/relative/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}if(q._helper&&!g.animate&&(/static/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}}});c.ui.plugin.add("resizable","ghost",{start:function(g,h){var e=c(this).data("resizable"),i=e.options,f=e.size;e.ghost=e.originalElement.clone();e.ghost.css({opacity:0.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:"");e.ghost.appendTo(e.helper)},resize:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost){e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})}},stop:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost&&e.helper){e.helper.get(0).removeChild(e.ghost.get(0))}}});c.ui.plugin.add("resizable","grid",{resize:function(e,m){var p=c(this).data("resizable"),h=p.options,k=p.size,i=p.originalSize,j=p.originalPosition,n=p.axis,l=h._aspectRatio||e.shiftKey;h.grid=typeof h.grid=="number"?[h.grid,h.grid]:h.grid;var g=Math.round((k.width-i.width)/(h.grid[0]||1))*(h.grid[0]||1),f=Math.round((k.height-i.height)/(h.grid[1]||1))*(h.grid[1]||1);if(/^(se|s|e)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f}else{if(/^(ne)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f}else{if(/^(sw)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.left=j.left-g}else{p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f;p.position.left=j.left-g}}}}});var b=function(e){return parseInt(e,10)||0};var a=function(e){return !isNaN(parseInt(e,10))}})(jQuery);/*! - * jQuery hashchange event - v1.3 - 7/21/2010 - * http://benalman.com/projects/jquery-hashchange-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$(' + + + +
+ +
CBLFullTextIndexConfiguration Struct Reference
+
+
+ +

Full-Text Index Configuration. + More...

+ +

#include <cbl/CBLQuery.h>

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

+Data Fields

CBLQueryLanguage expressionLanguage
 The language used in the expressions. More...
 
FLString expressions
 The expressions describing each coloumn of the index. More...
 
bool ignoreAccents
 Should diacritical marks (accents) be ignored? Defaults to false. More...
 
FLString language
 The dominant language. More...
 
+

Detailed Description

+

Full-Text Index Configuration.

+

Field Documentation

+ +

◆ expressionLanguage

+ +
+
+ + + + +
CBLQueryLanguage CBLFullTextIndexConfiguration::expressionLanguage
+
+ +

The language used in the expressions.

+ +
+
+ +

◆ expressions

+ +
+
+ + + + +
FLString CBLFullTextIndexConfiguration::expressions
+
+ +

The expressions describing each coloumn of the index.

+

The expressions could be specified in a JSON Array or in N1QL syntax using comma delimiter.

+ +
+
+ +

◆ ignoreAccents

+ +
+
+ + + + +
bool CBLFullTextIndexConfiguration::ignoreAccents
+
+ +

Should diacritical marks (accents) be ignored? Defaults to false.

+

Generally this should be left false for non-English text.

+ +
+
+ +

◆ language

+ +
+
+ + + + +
FLString CBLFullTextIndexConfiguration::language
+
+ +

The dominant language.

+

Setting this enables word stemming, i.e. matching different cases of the same word ("big" and "bigger", for instance) and ignoring common "stop-words" ("the", "a", "of", etc.)

+

Can be an ISO-639 language code or a lowercase (English) language name; supported languages are: da/danish, nl/dutch, en/english, fi/finnish, fr/french, de/german, hu/hungarian, it/italian, no/norwegian, pt/portuguese, ro/romanian, ru/russian, es/spanish, sv/swedish, tr/turkish.

+

If left null, or set to an unrecognized language, no language-specific behaviors such as stemming and stop-word removal occur.

+ +
+
+
The documentation for this struct was generated from the following file: +
+ + + + diff --git a/docs/C/html/struct_c_b_l_log_file_configuration.html b/docs/C/html/struct_c_b_l_log_file_configuration.html index 3dcdcdd8..96d6146f 100644 --- a/docs/C/html/struct_c_b_l_log_file_configuration.html +++ b/docs/C/html/struct_c_b_l_log_file_configuration.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLLogFileConfiguration Struct Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
CBLLogFileConfiguration Struct Reference
+
CBLLogFileConfiguration Struct Reference
@@ -74,29 +74,29 @@

#include <cbl/CBLLog.h>

- - + - + - + - + - +

+

Data Fields

CBLLogLevel level
 The minimum level of message to write. More...
 The minimum level of message to write. More...
 
FLString directory
 The directory where log files will be created. More...
 The directory where log files will be created. More...
 
uint32_t maxRotateCount
 Max number of older log files to keep (in addition to current one.) More...
 Max number of older log files to keep (in addition to current one.) More...
 
size_t maxSize
 The size in bytes at which a file will be rotated out (best effort). More...
 The size in bytes at which a file will be rotated out (best effort). More...
 
bool usePlaintext
 Whether or not to log in plaintext (as opposed to binary.) Plaintext logging is slower and bigger. More...
 Whether or not to log in plaintext (as opposed to binary.) Plaintext logging is slower and bigger. More...
 

Detailed Description

-

The properties for configuring logging to files.

+

The properties for configuring logging to files.

Warning
usePlaintext results in significantly larger log files and higher CPU usage that may slow down your app; we recommend turning it off in production.

Field Documentation

- +

◆ directory

@@ -112,7 +112,7 @@

+

◆ level

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

+

◆ maxRotateCount

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

+

◆ maxSize

@@ -160,7 +160,7 @@

+

◆ usePlaintext

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

diff --git a/docs/C/html/struct_c_b_l_proxy_settings.html b/docs/C/html/struct_c_b_l_proxy_settings.html index 98e90f15..f08906fe 100644 --- a/docs/C/html/struct_c_b_l_proxy_settings.html +++ b/docs/C/html/struct_c_b_l_proxy_settings.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLProxySettings Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLProxySettings Struct Reference
+
CBLProxySettings Struct Reference
@@ -74,28 +74,28 @@

#include <cbl/CBLReplicator.h>

- - + - + - + - + - +

+

Data Fields

CBLProxyType type
 Type of proxy. More...
 Type of proxy. More...
 
FLString hostname
 Proxy server hostname or IP address. More...
 Proxy server hostname or IP address. More...
 
uint16_t port
 Proxy server port. More...
 Proxy server port. More...
 
FLString username
 Username for proxy auth (optional) More...
 Username for proxy auth (optional) More...
 
FLString password
 Password for proxy auth. More...
 Password for proxy auth. More...
 

Detailed Description

-

Proxy settings for the replicator.

+

Proxy settings for the replicator.

Field Documentation

- +

◆ hostname

@@ -111,7 +111,7 @@

+

◆ password

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

+

◆ port

@@ -143,7 +143,7 @@

+

◆ type

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

+

◆ username

@@ -181,9 +181,7 @@

diff --git a/docs/C/html/struct_c_b_l_replicated_document.html b/docs/C/html/struct_c_b_l_replicated_document.html index 17ce3106..516b66fb 100644 --- a/docs/C/html/struct_c_b_l_replicated_document.html +++ b/docs/C/html/struct_c_b_l_replicated_document.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLReplicatedDocument Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLReplicatedDocument Struct Reference
+
CBLReplicatedDocument Struct Reference
@@ -74,22 +74,22 @@

#include <cbl/CBLReplicator.h>

- - + - + - +

+

Data Fields

FLString ID
 The document ID. More...
 The document ID. More...
 
CBLDocumentFlags flags
 Indicates whether the document was deleted or removed. More...
 Indicates whether the document was deleted or removed. More...
 
CBLError error
 If the code is nonzero, the document failed to replicate. More...
 If the code is nonzero, the document failed to replicate. More...
 

Detailed Description

-

Information about a document that's been pushed or pulled.

+

Information about a document that's been pushed or pulled.

Field Documentation

- +

◆ error

@@ -105,7 +105,7 @@

+

◆ flags

@@ -121,7 +121,7 @@

+

◆ ID

@@ -143,9 +143,7 @@

diff --git a/docs/C/html/struct_c_b_l_replicator_configuration.html b/docs/C/html/struct_c_b_l_replicator_configuration.html index 29ffc154..ec8a2208 100644 --- a/docs/C/html/struct_c_b_l_replicator_configuration.html +++ b/docs/C/html/struct_c_b_l_replicator_configuration.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLReplicatorConfiguration Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLReplicatorConfiguration Struct Reference
+
CBLReplicatorConfiguration Struct Reference
@@ -74,65 +74,83 @@

#include <cbl/CBLReplicator.h>

- - + - + - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +

+

Data Fields

CBLDatabasedatabase
 The database to replicate. More...
 The database to replicate. More...
 
CBLEndpointendpoint
 The address of the other database to replicate with. More...
 The address of the other database to replicate with. More...
 
CBLReplicatorType replicatorType
 Push, pull or both. More...
 Push, pull or both. More...
 
bool continuous
 Continuous replication? More...
 Continuous replication? More...
 
CBLAuthenticatorauthenticator
 Authentication credentials, if needed. More...
 
const CBLProxySettingsproxy
 HTTP client proxy settings. More...
 
FLDict headers
 Extra HTTP headers to add to the WebSocket request. More...
 
bool disableAutoPurge
 Disable/Enable auto-purging documents when the user's access to the documents has been revoked. More...
 
unsigned maxAttempts
 Max retry attempts where the initial connect to replicate counts toward the given value. More...
 
unsigned maxAttemptWaitTime
 Max wait time between retry attempts in seconds. Specify 0 to use the default value of 300 seconds. More...
 
unsigned heartbeat
 The heartbeat interval in seconds. Specify 0 to use the default value of 300 seconds. More...
 
CBLAuthenticator *_cbl_nullable authenticator
 Authentication credentials, if needed. More...
 
const CBLProxySettings *_cbl_nullable proxy
 HTTP client proxy settings. More...
 
FLDict _cbl_nullable headers
 Extra HTTP headers to add to the WebSocket request. More...
 
FLSlice pinnedServerCertificate
 An X.509 cert to "pin" TLS connections to (PEM or DER) More...
 An X.509 cert to "pin" TLS connections to (PEM or DER) More...
 
FLSlice trustedRootCertificates
 Set of anchor certs (PEM format) More...
 Set of anchor certs (PEM format) More...
 
FLArray channels
 Optional set of channels to pull from. More...
 
FLArray documentIDs
 Optional set of document IDs to replicate. More...
 
CBLReplicationFilter pushFilter
 Optional callback to filter which docs are pushed. More...
 
CBLReplicationFilter pullFilter
 Optional callback to validate incoming docs. More...
 
CBLConflictResolver conflictResolver
 Optional conflict-resolver callback. More...
 
void * context
 Arbitrary value that will be passed to callbacks. More...
 
FLArray _cbl_nullable channels
 Optional set of channels to pull from. More...
 
FLArray _cbl_nullable documentIDs
 Optional set of document IDs to replicate. More...
 
CBLReplicationFilter _cbl_nullable pushFilter
 Optional callback to filter which docs are pushed. More...
 
CBLReplicationFilter _cbl_nullable pullFilter
 Optional callback to validate incoming docs. More...
 
CBLConflictResolver _cbl_nullable conflictResolver
 Optional conflict-resolver callback. More...
 
void *_cbl_nullable context
 Arbitrary value that will be passed to callbacks. More...
 
CBLPropertyEncryptor propertyEncryptor
 Optional callback to encrypt CBLEncryptable values. More...
 
CBLPropertyDecryptor propertyDecryptor
 Optional callback to decrypt encrypted CBLEncryptable values. More...
 

Detailed Description

-

The configuration of a replicator.

+

The configuration of a replicator.

Field Documentation

- -

◆ authenticator

+ +

◆ authenticator

- +
CBLAuthenticator* CBLReplicatorConfiguration::authenticatorCBLAuthenticator* _cbl_nullable CBLReplicatorConfiguration::authenticator
@@ -141,14 +159,14 @@

-

◆ channels

+ +

◆ channels

- +
FLArray CBLReplicatorConfiguration::channelsFLArray _cbl_nullable CBLReplicatorConfiguration::channels
@@ -157,14 +175,14 @@

-

◆ conflictResolver

+ +

◆ conflictResolver

- +
CBLConflictResolver CBLReplicatorConfiguration::conflictResolverCBLConflictResolver _cbl_nullable CBLReplicatorConfiguration::conflictResolver
@@ -173,14 +191,14 @@

-

◆ context

+ +

◆ context

- +
void* CBLReplicatorConfiguration::contextvoid* _cbl_nullable CBLReplicatorConfiguration::context
@@ -189,7 +207,7 @@

+

◆ continuous

@@ -205,7 +223,7 @@

+

◆ database

@@ -221,14 +239,30 @@

-

◆ documentIDs

+ +

◆ disableAutoPurge

- + + +
FLArray CBLReplicatorConfiguration::documentIDsbool CBLReplicatorConfiguration::disableAutoPurge
+
+ +

Disable/Enable auto-purging documents when the user's access to the documents has been revoked.

+ +
+
+ +

◆ documentIDs

+ +
+
+ + +
FLArray _cbl_nullable CBLReplicatorConfiguration::documentIDs
@@ -237,7 +271,7 @@

+

◆ endpoint

@@ -253,14 +287,14 @@

-

◆ headers

+ +

◆ headers

- +
FLDict CBLReplicatorConfiguration::headersFLDict _cbl_nullable CBLReplicatorConfiguration::headers
@@ -269,7 +303,56 @@

+ +

◆ heartbeat

+ +
+
+ + + + +
unsigned CBLReplicatorConfiguration::heartbeat
+
+ +

The heartbeat interval in seconds. Specify 0 to use the default value of 300 seconds.

+ +
+
+ +

◆ maxAttempts

+ +
+
+ + + + +
unsigned CBLReplicatorConfiguration::maxAttempts
+
+ +

Max retry attempts where the initial connect to replicate counts toward the given value.

+

Specify 0 to use the default value, 10 times for a non-continuous replicator and max-int time for a continuous replicator. Specify 1 means there will be no retry after the first attempt.

+ +
+
+ +

◆ maxAttemptWaitTime

+ +
+
+ + + + +
unsigned CBLReplicatorConfiguration::maxAttemptWaitTime
+
+ +

Max wait time between retry attempts in seconds. Specify 0 to use the default value of 300 seconds.

+ +
+
+

◆ pinnedServerCertificate

@@ -285,14 +368,46 @@

-

◆ proxy

+ +

◆ propertyDecryptor

+ +
+
+ + + + +
CBLPropertyDecryptor CBLReplicatorConfiguration::propertyDecryptor
+
+ +

Optional callback to decrypt encrypted CBLEncryptable values.

+ +
+
+ +

◆ propertyEncryptor

+ +
+
+ + + + +
CBLPropertyEncryptor CBLReplicatorConfiguration::propertyEncryptor
+
+ +

Optional callback to encrypt CBLEncryptable values.

+ +
+
+ +

◆ proxy

- +
const CBLProxySettings* CBLReplicatorConfiguration::proxyconst CBLProxySettings* _cbl_nullable CBLReplicatorConfiguration::proxy
@@ -301,14 +416,14 @@

-

◆ pullFilter

+ +

◆ pullFilter

- +
CBLReplicationFilter CBLReplicatorConfiguration::pullFilterCBLReplicationFilter _cbl_nullable CBLReplicatorConfiguration::pullFilter
@@ -317,14 +432,14 @@

-

◆ pushFilter

+ +

◆ pushFilter

- +
CBLReplicationFilter CBLReplicatorConfiguration::pushFilterCBLReplicationFilter _cbl_nullable CBLReplicatorConfiguration::pushFilter
@@ -333,7 +448,7 @@

+

◆ replicatorType

@@ -349,7 +464,7 @@

+

◆ trustedRootCertificates

@@ -371,9 +486,7 @@

diff --git a/docs/C/html/struct_c_b_l_replicator_progress.html b/docs/C/html/struct_c_b_l_replicator_progress.html index 74c29fef..2b261e55 100644 --- a/docs/C/html/struct_c_b_l_replicator_progress.html +++ b/docs/C/html/struct_c_b_l_replicator_progress.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLReplicatorProgress Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLReplicatorProgress Struct Reference
+
CBLReplicatorProgress Struct Reference
@@ -74,47 +74,47 @@

#include <cbl/CBLReplicator.h>

- - - + + - +

+

Data Fields

float fractionComplete
 
float complete
 
uint64_t documentCount
 Very-approximate completion, from 0.0 to 1.0. More...
 Very-approximate fractional completion, from 0.0 to 1.0. More...
 

Detailed Description

-

A fractional progress value, ranging from 0.0 to 1.0 as replication progresses.

-

The value is very approximate and may bounce around during replication; making it more accurate would require slowing down the replicator and incurring more load on the server. It's fine to use in a progress bar, though.

+

A fractional progress value, ranging from 0.0 to 1.0 as replication progresses.

+

The value is very approximate and may bounce around during replication; making it more accurate would require slowing down the replicator and incurring more load on the server. It's fine to use in a progress bar, though.

Field Documentation

- -

◆ documentCount

+ +

◆ complete

- +
uint64_t CBLReplicatorProgress::documentCountfloat CBLReplicatorProgress::complete
-

Very-approximate completion, from 0.0 to 1.0.

-

Number of documents transferred so far

-
- -

◆ fractionComplete

+ +

◆ documentCount

- +
float CBLReplicatorProgress::fractionCompleteuint64_t CBLReplicatorProgress::documentCount
+

Very-approximate fractional completion, from 0.0 to 1.0.

+

Number of documents transferred so far

+

The documentation for this struct was generated from the following file:
    @@ -123,9 +123,7 @@

    diff --git a/docs/C/html/struct_c_b_l_replicator_status.html b/docs/C/html/struct_c_b_l_replicator_status.html index 3943b292..3810ca9c 100644 --- a/docs/C/html/struct_c_b_l_replicator_status.html +++ b/docs/C/html/struct_c_b_l_replicator_status.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: CBLReplicatorStatus Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
CBLReplicatorStatus Struct Reference
+
CBLReplicatorStatus Struct Reference
@@ -74,22 +74,22 @@

#include <cbl/CBLReplicator.h>

- - + - + - +

+

Data Fields

CBLReplicatorActivityLevel activity
 Current state. More...
 Current state. More...
 
CBLReplicatorProgress progress
 Approximate fraction complete. More...
 Approximate fraction complete. More...
 
CBLError error
 Error, if any. More...
 Error, if any. More...
 

Detailed Description

-

A replicator's current status.

+

A replicator's current status.

Field Documentation

- +

◆ activity

@@ -105,7 +105,7 @@

+

◆ error

@@ -121,7 +121,7 @@

+

◆ progress

@@ -143,9 +143,7 @@

diff --git a/docs/C/html/struct_c_b_l_value_index_configuration.html b/docs/C/html/struct_c_b_l_value_index_configuration.html new file mode 100644 index 00000000..7c87aff7 --- /dev/null +++ b/docs/C/html/struct_c_b_l_value_index_configuration.html @@ -0,0 +1,131 @@ + + + + + + + +Couchbase Lite C: CBLValueIndexConfiguration Struct Reference + + + + + + + + + +
+
+ + + + + + +
+
Couchbase Lite C +
+
Couchbase Lite C API
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+
+ +
CBLValueIndexConfiguration Struct Reference
+
+
+ +

Value Index Configuration. + More...

+ +

#include <cbl/CBLQuery.h>

+ + + + + + + + +

+Data Fields

CBLQueryLanguage expressionLanguage
 The language used in the expressions. More...
 
FLString expressions
 The expressions describing each coloumn of the index. More...
 
+

Detailed Description

+

Value Index Configuration.

+

Field Documentation

+ +

◆ expressionLanguage

+ +
+
+ + + + +
CBLQueryLanguage CBLValueIndexConfiguration::expressionLanguage
+
+ +

The language used in the expressions.

+ +
+
+ +

◆ expressions

+ +
+
+ + + + +
FLString CBLValueIndexConfiguration::expressions
+
+ +

The expressions describing each coloumn of the index.

+

The expressions could be specified in a JSON Array or in N1QL syntax using comma delimiter.

+ +
+
+
The documentation for this struct was generated from the following file: +
+ + + + diff --git a/docs/C/html/struct_f_l_array_iterator.html b/docs/C/html/struct_f_l_array_iterator.html index 6f0ce4de..ad8e5029 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 @@ - - + + Couchbase Lite C: FLArrayIterator Struct Reference @@ -30,21 +30,22 @@

- + +/* @license-end */ +
-
-
FLArrayIterator Struct Reference
+
FLArrayIterator Struct Reference

Opaque array iterator. More...

-

#include </Users/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.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:
  • vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h
diff --git a/docs/C/html/struct_f_l_dict_iterator.html b/docs/C/html/struct_f_l_dict_iterator.html index 31ee5447..f0c6e400 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 @@ - - + + Couchbase Lite C: FLDictIterator Struct Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLDictIterator Struct Reference
+
FLDictIterator Struct Reference

Opaque dictionary iterator. More...

-

#include </Users/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.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:
  • vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h
diff --git a/docs/C/html/struct_f_l_dict_key.html b/docs/C/html/struct_f_l_dict_key.html index b026176b..3e041ed3 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 @@ - - + + Couchbase Lite C: FLDictKey Struct Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLDictKey Struct Reference
+
FLDictKey Struct Reference

Opaque key for a dictionary. More...

-

#include </Users/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.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:
  • vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h
diff --git a/docs/C/html/struct_f_l_path_component.html b/docs/C/html/struct_f_l_path_component.html index 498b8168..93b74365 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 @@ - - + + Couchbase Lite C: FLPathComponent Struct Reference @@ -30,21 +30,22 @@
- + +/* @license-end */ +
-
-
FLPathComponent Struct Reference
+
FLPathComponent Struct Reference
-

#include </Users/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/Fleece.h>

- - + - +

+

Data Fields

FLSlice key
 Dict key, or kFLSliceNull if none. More...
 Dict key, or kFLSliceNull if none. More...
 
uint32_t index
 Array index, only if there's no key. More...
 Array index, only if there's no key. More...
 

Field Documentation

- +

◆ index

@@ -97,7 +97,7 @@

+

◆ key

@@ -119,9 +119,7 @@

diff --git a/docs/C/html/struct_f_l_slice.html b/docs/C/html/struct_f_l_slice.html index 32842aa6..744dda87 100644 --- a/docs/C/html/struct_f_l_slice.html +++ b/docs/C/html/struct_f_l_slice.html @@ -2,8 +2,8 @@ - - + + Couchbase Lite C: 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/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

- @@ -82,10 +82,10 @@

+

Data Fields

const void * buf
 
 

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

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

+

◆ size

@@ -119,9 +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 3d37ce8f..f5c9c9c4 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 @@ - - + + Couchbase Lite C: 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/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

+

#include </Users/jim.borden/Development/couchbase-lite-C/vendor/couchbase-lite-core/vendor/fleece/API/fleece/FLSlice.h>

- @@ -82,11 +82,11 @@

+

Data Fields

const void * buf
 
 

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

@@ -100,7 +100,7 @@

+

◆ size

@@ -120,9 +120,7 @@

diff --git a/docs/C/html/tabs.css b/docs/C/html/tabs.css index 8ea7d549..00d1c602 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/include/cbl/CBLBlob.h b/include/cbl/CBLBlob.h index 86fae9af..43d48437 100644 --- a/include/cbl/CBLBlob.h +++ b/include/cbl/CBLBlob.h @@ -195,7 +195,7 @@ CBL_CAPI_BEGIN /** Instantiates a \ref CBLBlob object corresponding to a blob dictionary in a document. @param value The value (dictionary) in the document. @return A \ref CBLBlob instance for this blob, or `NULL` if the value is not a blob. - @Note The returned CBLBlob object will be released when its document is released. */ + \note The returned CBLBlob object will be released when its document is released. */ static inline const CBLBlob* _cbl_nullable FLValue_GetBlob(FLValue _cbl_nullable value) { return FLDict_GetBlob(FLValue_AsDict(value)); } @@ -236,7 +236,7 @@ CBL_CAPI_BEGIN (e.g. developing javascript binding) that you cannot retain the \ref CBLBlob object until the document containing the \ref CBLBlob object is successfully saved into the database. - @Note The saved \ref CBLBlob objects that are not associated with any documents + \note The saved \ref CBLBlob objects that are not associated with any documents will be removed from the database when compacting the database. @param db The database. @param blob The The CBLBlob to save. diff --git a/include/cbl/CBLDatabase.h b/include/cbl/CBLDatabase.h index f98200bf..d6a60997 100644 --- a/include/cbl/CBLDatabase.h +++ b/include/cbl/CBLDatabase.h @@ -95,7 +95,8 @@ bool CBL_DatabaseExists(FLString name, FLString inDirectory) CBLAPI; it from the original database when replicating. @param fromPath The full filesystem path to the original database (including extension). @param toName The new database name (without the ".cblite2" extension.) - @param config The database configuration (directory and encryption option.) */ + @param config The database configuration (directory and encryption option.) + @param outError On return, will be set to the error that occurred, if applicable.*/ bool CBL_CopyDatabase(FLString fromPath, FLString toName, const CBLDatabaseConfiguration* _cbl_nullable config, diff --git a/include/cbl/CBLEncryptable.h b/include/cbl/CBLEncryptable.h index 650acb8c..ed1ee32a 100644 --- a/include/cbl/CBLEncryptable.h +++ b/include/cbl/CBLEncryptable.h @@ -81,7 +81,7 @@ CBL_CAPI_BEGIN \ref CBLEncryptable object but not until its document is saved into the database. When a document is loaded from the database, call \ref FLDict_GetEncryptableValue on an - \ref Encryptable dictionary value to obtain a \ref CBLEncryptable object. + Encryptable dictionary value to obtain a \ref CBLEncryptable object. */ CBL_PUBLIC extern const FLSlice kCBLEncryptableType; ///< `"encryptable"` @@ -147,12 +147,12 @@ static inline bool FLValue_IsEncryptableValue(FLValue _cbl_nullable value) { /** Returns a \ref CBLEncryptable object corresponding to the given encryptable dictionary in a document or NULL if the dictionary is not a \ref CBLEncryptable. - @Note The returned CBLEncryptable object will be released when its document is released. */ + \note The returned CBLEncryptable object will be released when its document is released. */ const CBLEncryptable* _cbl_nullable FLDict_GetEncryptableValue(FLDict _cbl_nullable encryptableDict) CBLAPI; /** Returns a \ref CBLEncryptable object corresponding to the given \ref FLValue in a document or NULL if the value is not a \ref CBLEncryptable. - @Note The returned CBLEncryptable object will be released when its document is released. */ + \note The returned CBLEncryptable object will be released when its document is released. */ static inline const CBLEncryptable* _cbl_nullable FLValue_GetEncryptableValue(FLValue _cbl_nullable value) { return FLDict_GetEncryptableValue(FLValue_AsDict(value)); } diff --git a/include/cbl/CBLLog.h b/include/cbl/CBLLog.h index 8fedcd0f..dac67018 100644 --- a/include/cbl/CBLLog.h +++ b/include/cbl/CBLLog.h @@ -75,7 +75,7 @@ void CBL_LogMessage(CBLLogDomain domain, @{ */ /** A logging callback that the application can register. - @param domain The domain of the message; \ref kCBLLogDomainAll if it doesn't fall into a specific domain. + @param domain The domain of the message @param level The severity level of the message. @param message The actual formatted message. */ typedef void (*CBLLogCallback)(CBLLogDomain domain, diff --git a/include/cbl/CBLReplicator.h b/include/cbl/CBLReplicator.h index 885122a0..aae9b20f 100644 --- a/include/cbl/CBLReplicator.h +++ b/include/cbl/CBLReplicator.h @@ -152,7 +152,7 @@ typedef struct { #ifdef COUCHBASE_ENTERPRISE /** Callback that encrypts \ref CBLEncryptable properties in documents pushed by the replicator. - @Note If a null \ref FLSliceResult or an error is returned, the document will be failed to + \note If a null \ref FLSliceResult or an error is returned, the document will be failed to replicate with the \ref kCBLErrorCrypto error when. For security reason, the encryption cannot be skipped. */ typedef FLSliceResult (*CBLPropertyEncryptor) ( @@ -167,7 +167,7 @@ typedef FLSliceResult (*CBLPropertyEncryptor) ( ); /** Callback that decrypts encrypted \ref CBLEncryptable properties in documents pulled by the replicator. - @Note The decryption will be skipped (the encrypted data will be kept) when a null \ref FLSliceResult + \note The decryption will be skipped (the encrypted data will be kept) when a null \ref FLSliceResult without an error is returned. If an error is returned, the document will be failed to replicate with the \ref kCBLErrorCrypto error. */ typedef FLSliceResult (*CBLPropertyDecryptor) ( From 614bcd6cc99ecab1fea5b4790f8ce38381a08b5b Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 14 Sep 2021 18:30:32 -0700 Subject: [PATCH 03/90] Update LiteCore for Lithium --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index f1f28c2b..5e9f2b1e 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit f1f28c2bad1d42e530d1e909cd75a0b0b2562216 +Subproject commit 5e9f2b1e9a0db11ee02965ec3f6929b8b0261874 From 1863881d555bbff35f9e98d87950de43ac1a580c Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 8 Sep 2021 20:28:40 -0700 Subject: [PATCH 04/90] Use setProgressLevel and remove extra encodeOptions (#210) * Instead of using configuration to progress level for document replication listeners, used setProgressLevel when adding a document replication listeners. * Reset progress level in _documentsEnded. * Removed extra calls to encodeOptions as it is not needed anymore. CBL-2337 --- src/CBLReplicator_Internal.hh | 20 ++++++++++---------- test/ReplicatorEETest.cc | 28 ++++++++++++++++++++++++++++ test/ReplicatorTest.cc | 21 +++++++++++++++++++++ test/ReplicatorTest.hh | 23 +++++++++++++++-------- 4 files changed, 74 insertions(+), 18 deletions(-) diff --git a/src/CBLReplicator_Internal.hh b/src/CBLReplicator_Internal.hh index 5d1a1ed5..7396dbf0 100644 --- a/src/CBLReplicator_Internal.hh +++ b/src/CBLReplicator_Internal.hh @@ -180,10 +180,6 @@ public: void start(bool reset) { LOCK(_mutex); _retainSelf = this; // keep myself from being freed until the replicator stops - if (_optionsChanged) { - _c4repl->setOptions(encodeOptions()); - _optionsChanged = false; - } _useInitialStatus = false; if (_db->registerStoppable(this)) @@ -234,8 +230,10 @@ public: void *context) { LOCK(_mutex); - if (_docListeners.empty()) - _optionsChanged = true; + if (_docListeners.empty()) { + _c4repl->setProgressLevel(kC4ReplProgressPerDocument); + _progressLevel = kC4ReplProgressPerDocument; + } return _docListeners.add(listener, context); } @@ -245,8 +243,6 @@ private: Encoder enc; enc.beginDict(); _conf.writeOptions(enc); - if (!_docListeners.empty()) - enc[slice(kC4ReplicatorOptionProgressLevel)] = 1; enc.endDict(); return enc.finish(); } @@ -309,7 +305,11 @@ private: if (!_docListeners.empty()) { docs = std::make_unique>(); docs->reserve(numDocs); + } else if (_progressLevel != kC4ReplProgressOverall) { + _c4repl->setProgressLevel(kC4ReplProgressOverall); + _progressLevel = kC4ReplProgressOverall; } + for (size_t i = 0; i < numDocs; ++i) { auto src = *c4Docs[i]; if (!pushing && src.flags & kRevIsConflict) { @@ -333,7 +333,7 @@ private: if (docs) _docListeners.call(this, pushing, unsigned(docs->size()), docs->data()); } - + void _conflictResolverFinished(ConflictResolver *resolver) { CBLReplicatedDocument doc = resolver->result(); @@ -390,11 +390,11 @@ private: Retained _c4repl; bool _useInitialStatus; // For returning status before first start C4ReplicatorStatus _c4status {kC4Stopped}; - bool _optionsChanged {false}; Retained _retainSelf; int _activeConflictResolvers {0}; Listeners _changeListeners; Listeners _docListeners; + C4ReplicatorProgressLevel _progressLevel {kC4ReplProgressOverall}; }; CBL_ASSUME_NONNULL_END diff --git a/test/ReplicatorEETest.cc b/test/ReplicatorEETest.cc index adcbc602..ba9c4508 100644 --- a/test/ReplicatorEETest.cc +++ b/test/ReplicatorEETest.cc @@ -550,6 +550,34 @@ TEST_CASE_METHOD(ReplicatorConflictTest, "Custom resolver : merge", "[Replicator } +TEST_CASE_METHOD(ReplicatorLocalTest, "Document Replication Listener", "[Replicator]") { + // No listener: + MutableDocument doc("foo"); + doc["greeting"] = "Howdy!"; + db.saveDocument(doc); + + config.replicatorType = kCBLReplicatorTypePush; + enableDocReplicationListener = false; + replicate(); + CHECK(replicatedDocIDs.empty()); + + // Add listener: + doc["greeting"] = "Hello!"; + db.saveDocument(doc); + enableDocReplicationListener = true; + replicate(); + CHECK(asVector(replicatedDocIDs) == vector{"foo"}); + + // Remove listener: + doc["greeting"] = "Hi!"; + db.saveDocument(doc); + enableDocReplicationListener = false; + replicatedDocIDs.clear(); + replicate(); + CHECK(replicatedDocIDs.empty()); +} + + class ReplicatorFilterTest : public ReplicatorLocalTest { public: int count = 0; diff --git a/test/ReplicatorTest.cc b/test/ReplicatorTest.cc index daeda193..94ce620b 100644 --- a/test/ReplicatorTest.cc +++ b/test/ReplicatorTest.cc @@ -108,6 +108,27 @@ TEST_CASE_METHOD(ReplicatorTest, "Fake Replicate with auth and proxy", "[Replica } +// CBL-2337 +TEST_CASE_METHOD(ReplicatorTest, "Fake Replicate with freed auth and doc listener", "[Replicator]") { + CBLError error; + config.endpoint = CBLEndpoint_CreateWithURL("ws://fsdfds.vzcsg/foobar"_sl, &error); + + CBLAuthenticator* auth = CBLAuth_CreatePassword("username"_sl, "p@ssw0RD"_sl); + config.authenticator = auth; + + repl = CBLReplicator_Create(&config, &error); + + // Free the authenticator after creating the replicator + CBLAuth_Free(auth); + + // Note: replicate() will add a document listener + replicate({ kCBLNetworkDomain, kCBLNetErrUnknownHost }); + + // Clean up + config.authenticator = nullptr; +} + + #pragma mark - ACTUAL-NETWORK TESTS: diff --git a/test/ReplicatorTest.hh b/test/ReplicatorTest.hh index 82b79eac..35780534 100644 --- a/test/ReplicatorTest.hh +++ b/test/ReplicatorTest.hh @@ -31,11 +31,13 @@ public: CBLReplicatorConfiguration config = {}; CBLReplicator *repl = nullptr; + + bool enableDocReplicationListener = true; + bool logEveryDocument = true; set replicatedDocIDs; vector replicatedDocs; CBLError replError = {}; - bool logEveryDocument = true; IdleAction idleAction = IdleAction::kStopReplicator; double timeoutSeconds = 30.0; @@ -59,16 +61,21 @@ public: REQUIRE(repl); auto ctoken = CBLReplicator_AddChangeListener(repl, [](void *context, CBLReplicator *r, - const CBLReplicatorStatus *status) { + const CBLReplicatorStatus *status) { ((ReplicatorTest*)context)->statusChanged(r, *status); }, this); - auto dtoken = CBLReplicator_AddDocumentReplicationListener(repl, [](void *context, CBLReplicator *r, bool isPush, - unsigned numDocuments, - const CBLReplicatedDocument* documents) { - ((ReplicatorTest*)context)->docProgress(r, isPush, numDocuments, documents); - }, this); - + + CBLListenerToken* dtoken = nullptr; + if (enableDocReplicationListener) { + dtoken = CBLReplicator_AddDocumentReplicationListener(repl, [](void *context, CBLReplicator *r, + bool isPush, + unsigned numDocuments, + const CBLReplicatedDocument* documents) { + ((ReplicatorTest*)context)->docProgress(r, isPush, numDocuments, documents); + }, this); + } + CBLReplicator_Start(repl, false); time start = clock::now(); From 79035a15546b1411ec2838aa7ed8f8b32f0bc106 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 10 Sep 2021 13:13:21 -0700 Subject: [PATCH 05/90] Copy endpoint and authenticator config (#211) * Copied endpoint and authenticator in ReplicatorConfiguration copy constructor. * Added virtual clone function to CBLEndpoint and CBLAuthenticator that their subclasses will implement. --- src/CBLReplicatorConfig.hh | 19 +++++++- test/ReplicatorTest.cc | 88 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/CBLReplicatorConfig.hh b/src/CBLReplicatorConfig.hh index 4d73ff15..9eacbb6a 100644 --- a/src/CBLReplicatorConfig.hh +++ b/src/CBLReplicatorConfig.hh @@ -40,6 +40,7 @@ struct CBLEndpoint { virtual bool valid() const =0; const C4Address& remoteAddress() const {return _address;} virtual C4String remoteDatabaseName() const =0; + virtual CBLEndpoint* clone() const =0; #ifdef COUCHBASE_ENTERPRISE virtual CBLDatabase* _cbl_nullable otherLocalDB() const {return nullptr;} #endif @@ -68,6 +69,7 @@ namespace cbl_internal { bool valid() const override {return _dbName != fleece::nullslice;} C4String remoteDatabaseName() const override {return _dbName;} + virtual CBLEndpoint* clone() const override {return new CBLURLEndpoint(_url);} private: fleece::alloc_slice _url; @@ -84,6 +86,7 @@ namespace cbl_internal { bool valid() const override {return true;} virtual C4String remoteDatabaseName() const override {return fleece::nullslice;} virtual CBLDatabase* otherLocalDB() const override {return _db;} + virtual CBLEndpoint* clone() const override {return new CBLLocalEndpoint(_db);} private: fleece::Retained _db; @@ -104,6 +107,7 @@ protected: public: virtual ~CBLAuthenticator() =default; virtual void writeOptions(Encoder&) =0; + virtual CBLAuthenticator* clone() const =0; }; @@ -123,6 +127,10 @@ namespace cbl_internal { enc[slice(kC4ReplicatorAuthPassword)] = _password; enc.endDict(); } + + virtual CBLAuthenticator* clone() const override { + return new BasicAuthenticator(_username, _password); + } private: alloc_slice _username, _password; @@ -141,6 +149,10 @@ namespace cbl_internal { enc.writeKey(slice(kC4ReplicatorOptionCookies)); enc.writeString(_cookieName + "=" + _sessionID); } + + virtual CBLAuthenticator* clone() const override { + return new SessionAuthenticator(slice(_sessionID), slice(_cookieName)); + } private: std::string _sessionID, _cookieName; @@ -163,6 +175,8 @@ namespace cbl_internal { ReplicatorConfiguration(const CBLReplicatorConfiguration &conf) { *(CBLReplicatorConfiguration*)this = conf; retain(database); + endpoint = endpoint ? endpoint->clone() : nullptr; + authenticator = authenticator ? authenticator->clone() : nullptr; headers = FLDict_MutableCopy(headers, kFLDeepCopyImmutables); channels = FLArray_MutableCopy(channels, kFLDeepCopyImmutables); documentIDs = FLArray_MutableCopy(documentIDs, kFLDeepCopyImmutables); @@ -180,6 +194,8 @@ namespace cbl_internal { ~ReplicatorConfiguration() { release(database); + CBLEndpoint_Free(endpoint); + CBLAuth_Free(authenticator); FLDict_Release(headers); FLArray_Release(channels); FLArray_Release(documentIDs); @@ -266,8 +282,7 @@ namespace cbl_internal { allocated = alloc_slice(str); return allocated; } - - + alloc_slice _pinnedServerCert, _trustedRootCerts; CBLProxySettings _proxy; alloc_slice _proxyHostname, _proxyUsername, _proxyPassword; diff --git a/test/ReplicatorTest.cc b/test/ReplicatorTest.cc index 94ce620b..174c49fe 100644 --- a/test/ReplicatorTest.cc +++ b/test/ReplicatorTest.cc @@ -129,6 +129,94 @@ TEST_CASE_METHOD(ReplicatorTest, "Fake Replicate with freed auth and doc listene } +TEST_CASE_METHOD(ReplicatorTest, "Copy pointer configs", "[Replicator]") { + CBLReplicatorConfiguration config = {}; + config.database = db.ref(); + + CBLError error; + CBLEndpoint* endpoint = CBLEndpoint_CreateWithURL("ws://fsdfds.vzcsg/foobar"_sl, &error); + config.endpoint = endpoint; + + CBLAuthenticator* auth = nullptr; + SECTION("Password Auth") { + auth = CBLAuth_CreatePassword("username"_sl, "p@ssw0RD"_sl); + } + SECTION("Session Auth") { + auth = CBLAuth_CreateSession("abc123"_sl, "mycookie"_sl); + } + config.authenticator = auth; + + CBLProxySettings* proxy = new CBLProxySettings(); + proxy->type = kCBLProxyHTTP; + proxy->hostname = "jxnbgotn.dvmwk"_sl; + proxy->port = 9998; + proxy->username = "User Name"_sl; + proxy->password = "123456"_sl; + config.proxy = proxy; + + auto headers = FLMutableDict_New(); + FLMutableDict_SetString(headers, "sessionid"_sl, "abc"_sl); + config.headers = headers; + + auto repl1 = CBLReplicator_Create(&config, &error); + REQUIRE(repl1); + + CBLEndpoint_Free(endpoint); + CBLAuth_Free(auth); + delete(proxy); + FLMutableDict_Release(headers); + + auto copiedConfig = CBLReplicator_Config(repl1); + REQUIRE(copiedConfig); + CHECK(copiedConfig->endpoint); + CHECK(copiedConfig->authenticator); + + REQUIRE(copiedConfig->proxy); + CHECK(copiedConfig->proxy->type == kCBLProxyHTTP); + CHECK(copiedConfig->proxy->hostname == "jxnbgotn.dvmwk"_sl); + CHECK(copiedConfig->proxy->port == 9998); + CHECK(copiedConfig->proxy->username == "User Name"_sl); + CHECK(copiedConfig->proxy->password == "123456"_sl); + + REQUIRE(copiedConfig->headers); + FLValue sessionid = FLDict_Get(copiedConfig->headers, "sessionid"_sl); + REQUIRE(sessionid); + CHECK(FLValue_AsString(sessionid) == "abc"_sl); + + auto repl2 = CBLReplicator_Create(copiedConfig, &error); + CHECK(repl2); + + CBLReplicator_Release(repl1); + CBLReplicator_Release(repl2); +} + + +TEST_CASE_METHOD(ReplicatorTest, "Copy pointer configs with nullptr value", "[Replicator]") { + CBLReplicatorConfiguration config = {}; + config.database = db.ref(); + + CBLError error; + CBLEndpoint* endpoint = CBLEndpoint_CreateWithURL("ws://fsdfds.vzcsg/foobar"_sl, &error); + config.endpoint = endpoint; + + auto repl1 = CBLReplicator_Create(&config, &error); + REQUIRE(repl1); + + auto copiedConfig = CBLReplicator_Config(repl1); + REQUIRE(copiedConfig); + CHECK(copiedConfig->endpoint); + CHECK(!copiedConfig->authenticator); + CHECK(!copiedConfig->proxy); + CHECK(!copiedConfig->headers); + + auto repl2 = CBLReplicator_Create(copiedConfig, &error); + CHECK(repl2); + + CBLReplicator_Release(repl1); + CBLReplicator_Release(repl2); +} + + #pragma mark - ACTUAL-NETWORK TESTS: From 5907551409aaa8e62f1f1d5c43a084f995b6ae48 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 13 Sep 2021 18:42:50 -0700 Subject: [PATCH 06/90] Add note about getting nested collections as mutable (#212) --- include/cbl/CBLDocument.h | 2 + test/DatabaseTest.cc | 129 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/include/cbl/CBLDocument.h b/include/cbl/CBLDocument.h index e502dca3..42fee83a 100644 --- a/include/cbl/CBLDocument.h +++ b/include/cbl/CBLDocument.h @@ -253,6 +253,8 @@ FLDict CBLDocument_Properties(const CBLDocument*) CBLAPI; @note The dictionary object is owned by the document; you do not need to release it. @note Every call to this function returns the same mutable collection. This is the same collection returned by \ref CBLDocument_Properties. + @note When accessing nested collections inside the properties as a mutable collection + for modification, use \ref FLMutableDict_GetMutableDict or \ref FLMutableDict_GetMutableArray. @warning When the document is released, this reference to the properties becomes invalid. If you need to use any properties after releasing the document, you must retain them by calling \ref FLValue_Retain (and of course later release them.) */ diff --git a/test/DatabaseTest.cc b/test/DatabaseTest.cc index 287dfa4d..65eb1085 100644 --- a/test/DatabaseTest.cc +++ b/test/DatabaseTest.cc @@ -243,6 +243,135 @@ TEST_CASE_METHOD(DatabaseTest, "Mutable Copy Immutable Document") { } +TEST_CASE_METHOD(DatabaseTest, "Access nested collections from mutable props") { + CBLError error; + CBLDocument* doc = CBLDocument_CreateWithID("foo"_sl); + REQUIRE(doc); + REQUIRE(CBLDocument_SetJSON(doc, "{\"name\":{\"first\": \"Jane\"}, \"phones\": [\"650-123-4567\"]}"_sl, &error)); + REQUIRE(CBLDatabase_SaveDocument(db, doc, &error)); + + CBLDocument* mDoc = nullptr; + FLMutableDict mProps = nullptr; + + // Note: When a mutable properties of a document is created, the shallow copy from + // the original properties will be made. + + SECTION("A mutable doc") { + mDoc = doc; + CBLDocument_Retain(doc); + } + + SECTION("A mutable doc read from database") { + mDoc = CBLDatabase_GetMutableDocument(db, "foo"_sl, &error); + } + + SECTION("Mutable copy from an immutable doc") { + const CBLDocument* doc1 = CBLDatabase_GetDocument(db, "foo"_sl, &error); + mDoc = CBLDocument_MutableCopy(doc1); + CBLDocument_Release(doc1); + } + + SECTION("Mutable copy from a mutable doc") { + CBLDocument* mDoc1 = CBLDatabase_GetMutableDocument(db, "foo"_sl, &error); + mDoc = CBLDocument_MutableCopy(mDoc1); + CBLDocument_Release(mDoc1); + } + + mProps = CBLDocument_MutableProperties(mDoc); + + // Dict: + FLDict dict = FLValue_AsDict(FLDict_Get(mProps, "name"_sl)); + REQUIRE(dict); + CHECK(FLDict_Count(dict) == 1); + CHECK(FLValue_AsString(FLDict_Get(dict, "first"_sl)) == "Jane"_sl); + FLMutableDict mDict = FLDict_AsMutable(dict); // Immutable + CHECK(!mDict); + + mDict = FLMutableDict_GetMutableDict(mProps, "name"_sl); + REQUIRE(mDict); + CHECK(FLDict_Count(mDict) == 1); + CHECK(FLValue_AsString(FLDict_Get(mDict, "first"_sl)) == "Jane"_sl); + + // Array: + FLArray array = FLValue_AsArray(FLDict_Get(mProps, "phones"_sl)); + REQUIRE(array); + REQUIRE(FLArray_Count(array) == 1); + CHECK(FLValue_AsString(FLArray_Get(array, 0)) == "650-123-4567"_sl); + FLMutableArray mArray = FLArray_AsMutable(array); // Immutable + CHECK(!mArray); + + mArray = FLMutableDict_GetMutableArray(mProps, "phones"_sl); + REQUIRE(mArray); + REQUIRE(FLArray_Count(mArray) == 1); + CHECK(FLValue_AsString(FLArray_Get(mArray, 0)) == "650-123-4567"_sl); + + CBLDocument_Release(mDoc); + CBLDocument_Release(doc); +} + + +TEST_CASE_METHOD(DatabaseTest, "Access nested collections from a copy of modified mutable doc") { + CBLError error; + CBLDocument* doc = CBLDocument_CreateWithID("foo"_sl); + REQUIRE(doc); + REQUIRE(CBLDocument_SetJSON(doc, "{\"name\":{\"first\": \"Jane\"}, \"phones\": [\"650-123-4567\"]}"_sl, &error)); + REQUIRE(CBLDatabase_SaveDocument(db, doc, &error)); + + FLMutableDict mProps = CBLDocument_MutableProperties(doc); + + // Modify Dict: + FLMutableDict mDict = FLMutableDict_GetMutableDict(mProps, "name"_sl); + REQUIRE(mDict); + CHECK(FLDict_Count(mDict) == 1); + CHECK(FLValue_AsString(FLDict_Get(mDict, "first"_sl)) == "Jane"_sl); + FLMutableDict_SetString(mDict, "first"_sl, "Julie"_sl); + CHECK(FLValue_AsString(FLDict_Get(mDict, "first"_sl)) == "Julie"_sl); + + // Modify Array: + FLMutableArray mArray = FLMutableDict_GetMutableArray(mProps, "phones"_sl); + REQUIRE(mArray); + REQUIRE(FLArray_Count(mArray) == 1); + CHECK(FLValue_AsString(FLArray_Get(mArray, 0)) == "650-123-4567"_sl); + FLMutableArray_SetString(mArray, 0, "415-123-4567"_sl); + CHECK(FLValue_AsString(FLArray_Get(mArray, 0)) == "415-123-4567"_sl); + + // Copy: + CBLDocument* mDoc = CBLDocument_MutableCopy(doc); + mProps = CBLDocument_MutableProperties(mDoc); + + // Check Dict: + FLDict dict = FLValue_AsDict(FLDict_Get(mProps, "name"_sl)); + REQUIRE(dict); + CHECK(FLDict_Count(dict) == 1); + CHECK(FLValue_AsString(FLDict_Get(dict, "first"_sl)) == "Julie"_sl); + FLMutableDict mDict2 = FLDict_AsMutable(dict); // Already mutable + CHECK(mDict2); + + mDict2 = FLMutableDict_GetMutableDict(mProps, "name"_sl); + REQUIRE(mDict2); + CHECK(FLDict_Count(mDict2) == 1); + CHECK(FLValue_AsString(FLDict_Get(mDict2, "first"_sl)) == "Julie"_sl); + CHECK(mDict2 != mDict); + + // Check Array: + FLArray array = FLValue_AsArray(FLDict_Get(mProps, "phones"_sl)); + REQUIRE(array); + REQUIRE(FLArray_Count(array) == 1); + CHECK(FLValue_AsString(FLArray_Get(array, 0)) == "415-123-4567"_sl); + FLArray mArray2 = FLArray_AsMutable(array); + CHECK(mArray2); // Already mutable + + mArray2 = FLMutableDict_GetMutableArray(mProps, "phones"_sl); + REQUIRE(mArray2); + REQUIRE(FLArray_Count(mArray2) == 1); + CHECK(FLValue_AsString(FLArray_Get(mArray2, 0)) == "415-123-4567"_sl); + CHECK(mArray2 != mArray); + + CBLDocument_Release(mDoc); + CBLDocument_Release(doc); +} + + TEST_CASE_METHOD(DatabaseTest, "Get Non Existing Document") { CBLError error; const CBLDocument* doc = CBLDatabase_GetDocument(db, "foo"_sl, &error); From 8b4b156a6eace4a8fe86401811903f176eec42ee Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 14 Sep 2021 14:20:43 -0700 Subject: [PATCH 07/90] Fix missing nullable in CBLDatabase_AddDocumentChangeListener CBL-2355 --- include/cbl/CBLDocument.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cbl/CBLDocument.h b/include/cbl/CBLDocument.h index 42fee83a..2dba05f1 100644 --- a/include/cbl/CBLDocument.h +++ b/include/cbl/CBLDocument.h @@ -337,7 +337,7 @@ _cbl_warn_unused CBLListenerToken* CBLDatabase_AddDocumentChangeListener(const CBLDatabase* db, FLString docID, CBLDocumentChangeListener listener, - void *context) CBLAPI; + void* _cbl_nullable context) CBLAPI; /** @} */ /** @} */ From aab7cd818b757b60beeea28071ce31e7e3a11e87 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Sat, 2 Oct 2021 04:24:49 +0000 Subject: [PATCH 08/90] CBL-2440: Add API doc note about disableAutoPurge behavior (#226) --- include/cbl/CBLReplicator.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/cbl/CBLReplicator.h b/include/cbl/CBLReplicator.h index aae9b20f..bf803991 100644 --- a/include/cbl/CBLReplicator.h +++ b/include/cbl/CBLReplicator.h @@ -190,7 +190,16 @@ typedef struct { CBLReplicatorType replicatorType; ///< Push, pull or both bool continuous; ///< Continuous replication? //-- Auto Purge: - bool disableAutoPurge; ///< Disable/Enable auto-purging documents when the user's access to the documents has been revoked. + /** + If auto purge is active, then the library will automatically purge any documents that the replicating + user loses access to via the Sync Function on Sync Gateway. If disableAutoPurge is true, this behavior + is disabled and an access removed event will be sent to any document listeners that are active on the + replicator. + + IMPORTANT: For performance reasons, the document listeners must be added *before* the replicator is started + or they will not receive the events. + */ + bool disableAutoPurge; //-- Retry Logic: unsigned maxAttempts; ///< Max retry attempts where the initial connect to replicate counts toward the given value. ///< Specify 0 to use the default value, 10 times for a non-continuous replicator and max-int time for a continuous replicator. Specify 1 means there will be no retry after the first attempt. From 55ad21001c0158ad80dee019b5c656303446cbfe Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 20 Sep 2021 19:03:25 -0700 Subject: [PATCH 09/90] Add missing headers in modulemap file (#213) Added CBLEncryptable.h and CBLPlatform.h to CouchbaseLite.modulemap. --- Xcode/CouchbaseLite.modulemap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xcode/CouchbaseLite.modulemap b/Xcode/CouchbaseLite.modulemap index ba12e3c2..7e8d71f3 100644 --- a/Xcode/CouchbaseLite.modulemap +++ b/Xcode/CouchbaseLite.modulemap @@ -6,6 +6,8 @@ framework module CouchbaseLite { header "CBLBlob.h" header "CBLDatabase.h" header "CBLDocument.h" + header "CBLEncryptable.h" + header "CBLPlatform.h" header "CBLLog.h" header "CBLQuery.h" header "CBLReplicator.h" From 934dfa533cbf435481efe748b62935b85a98c079 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Tue, 21 Sep 2021 23:45:05 +0000 Subject: [PATCH 10/90] Update README.md (#214) Also remove samples for nim, python, rust. Significant work needs to be put in to make them usable again. --- README.md | 174 ++++++++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 4f4aac30..bb403c9d 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,6 @@ This is a cross-platform version of the [Couchbase Lite][CBL] embedded NoSQL syncable database, with a plain C API. The API can be used directly, or as the substrate for binding to other languages like Python, JavaScript or Rust. -## What's New (May 2020) - -**This project is close to beta status.** The API is nearly complete and almost all of the functionality is implemented, but there are still missing pieces and only limited testing. - -* New Rust and Nim language bindings! They're in the new top-level `bindings` directory. The Python binding has been moved there too. -* Added variants of many API functions, which take slices (`FLSlice`) instead of C strings. These are more efficient to call from languages whose native string type is not NUL-terminated, such as Rust. -* Added `CBLResultSet_RowArray()`, `CBLResultSet_RowDict()`, and `CBLResultSet_GetQuery()`. -* More of the logging API (in `CBLLog.h`) is implemented, including custom log callbacks. -* Updated to latest Couchbase Lite Core (LiteCore). - ## Goals - [x] C API @@ -36,13 +26,13 @@ This is a cross-platform version of the [Couchbase Lite][CBL] embedded NoSQL syn - [x] Replicator online/offline support and retry behavior - [x] Replicator TLS/SSL support - [ ] Peer-to-peer replication -- [x] Minimal platform dependencies: C++ standard library, filesystem, TCP/IP -- [ ] Broad OS support - - [x] macOS, for ease of development - - [x] Common Linux distros, esp. Ubuntu, Fedora, Raspbian (q.v.) - - [x] Windows - - [x] iOS - - [ ] Android (but we have a [Couchbase Lite For Android][ANDROID] already, with a Java API) +- [x] Minimal platform dependencies: C++ standard library, filesystem, TCP/IP, libz (macOS / Linux), libicu (Linux) +- [x] Broad official OS support + - [x] macOS (x86_64 and arm64) + - [x] Debian 9/10 (including Raspbian / Raspberry Pi OS) and Ubuntu 20.04 (x86_64, armhf, arm64) + - [x] Windows (x86_64 only) + - [x] iOS (device and simulator archs) + - [x] Android (armeabi-v7a, arm64-v8a, x86, x86_64) - [x] Runs on Raspberry-Pi-level embedded platforms with… - 32-bit or 64-bit CPU - ARM or x86 @@ -57,33 +47,32 @@ This is a cross-platform version of the [Couchbase Lite][CBL] embedded NoSQL syn ```c // Open a database: CBLError error; -CBLDatabaseConfiguration config = {"/tmp", kCBLDatabase_Create}; -CBLDatabase* db = CBLDatabase_Open("my_db", &config, &error); +CBLDatabaseConfiguration config = {FLSTR("/tmp")}; +CBLDatabase* db = CBLDatabase_Open(FLSTR("my_db"), &config, &error); // Create a document: -CBLDocument* doc = CBLDocument_New("foo"); +CBLDocument* doc = CBLDocument_CreateWithID(FLSTR("foo")); FLMutableDict props = CBLDocument_MutableProperties(doc); -FLSlot_SetString(FLMutableDict_Set(dict, FLStr("greeting")), FLStr("Howdy!")); +FLSlot_SetString(FLMutableDict_Set(props, FLStr("greeting")), FLStr("Howdy!")); // Save the document: -const CBLDocument *saved = CBLDatabase_SaveDocument(db, doc, - kCBLConcurrencyControlFailOnConflict, - &error); -CBLDocument_Release(saved); +CBLDatabase_SaveDocument(db, doc, &error); CBLDocument_Release(doc); // Read it back: -const CBLDocument *readDoc = CBLDatabase_GetDocument(db, "foo"); +const CBLDocument *readDoc = CBLDatabase_GetDocument(db, FLSTR("foo"), &error); FLDict readProps = CBLDocument_Properties(readDoc); FLSlice greeting = FLValue_AsString( FLDict_Get(readProps, FLStr("greeting")) ); CBLDocument_Release(readDoc); ``` -### C++ +### Others + +**NOTE**: The C++ API is not part of the official release. ```cpp // Open a database: -cbl::Database db(kDatabaseName, {"/tmp", kCBLDatabase_Create}); +cbl::Database db(FLSTR("my-db"), {FLSTR("/tmp")}); // Create a document: cbl::MutableDocument doc("foo"); @@ -91,97 +80,70 @@ doc["greeting"] = "Howdy!"; db.saveDocument(doc); // Read it back: -cbl::Document doc = db.getMutableDocument("foo"); -fleece::Dict readProps = doc->properties(); +cbl::Document readDoc = db.getMutableDocument("foo"); +fleece::Dict readProps = readDoc.properties(); fleece::slice greeting = readProps["greeting"].asString(); ``` -### Nim - -```nim -# Open a database: -let config = DatabaseConfiguration(directory: "/tmp", flags: {DatabaseFlag.create}) -var db = openDatabase("nim_db", config) - -# Create a document: -var doc = newDocument("foo") -doc["greeting"] = "Howdy!" -db.saveDocument(doc) - -# Read it back: -let readDoc = db.getDocument("foo") -let readProps = readDoc.properties -let greeting = readProps["greeting"] -``` - -### Python - -```python -# Open a database: -db = Database("python_db", DatabaseConfiguration("/tmp")); - -# Create a document: -doc = MutableDocument("foo") -doc["greeting"] = "Howdy!" -db.saveDocument(doc) - -# Read it back: -readDoc = db.getDocument("foo") -readProps = readDoc.properties -greeting = readProps["greeting"] -``` - -### Rust - -```rust -// Open a database: -let cfg = DatabaseConfiguration{directory: tmp_dir.path(), flags: CREATE}; -let mut db = Database::open("rust_db, Some(cfg)).expect("opening db"); - -// Create a document: -let mut doc = Document::new_with_id("foo"); -let mut props = doc.mutable_properties(); -props.at("greeting").put_string("Howdy!"); -db.save_document(&mut doc, ConcurrencyControl::FailOnConflict).expect("saving"); - -// Read it back: -let doc = db.get_document("foo").expect("reload document"); -let props = doc.properties(); -let greeting = props.get("greeting"); -``` - ## Documentation -* [Couchbase Lite documentation](https://docs.couchbase.com/couchbase-lite/2.7/introduction.html) is a must-read to learn the architecture and the API concepts, even though the API details are different here. -* [C API documentation](http://labs.couchbase.com/couchbase-lite-C/C/html/modules.html) (generated by Doxygen) -* Or you could just [read the header files](https://github.com/couchbaselabs/couchbase-lite-C/tree/master/include/cbl) +* [Couchbase Lite documentation](https://docs.couchbase.com/couchbase-lite/current/introduction.html) is a must-read to learn the architecture and the API concepts, even though the API details are different here. +* API documentation in [the header files](https://github.com/couchbaselabs/couchbase-lite-C/tree/master/include/cbl) * [Using Fleece](https://github.com/couchbaselabs/fleece/wiki/Using-Fleece) — Fleece is the API for document properties * [Contributor guidelines](CONTRIBUTING.md), should you wish to submit bug fixes, tests, or other improvements ## Building It -### With CMake on Unix (now including Raspberry Pi!) +### CMake on Unix (normal compile) Dependencies: * GCC 7+ or Clang -* CMake 3.9+ -* ICU libraries (`apt-get install icu-dev`) +* CMake 3.10+ +* (Linux) ICU development libraries (`apt-get install icu-dev`) +* (Linux) ZLIB development libraries (`apt-get install zlib1g-dev`) 1. Clone the repo 2. Check out submodules (recursively), i.e. `git submodule update --init --recursive` -3. Run the shellscript `build.sh` -6. Run the unit tests, with `test.sh` +3. Prepare the build project with CMake (e.g. `cmake `) +4. Build the project: `make cblite` -The library is at `build_cmake/libcblite.so`. (Or `.DLL` or `.dylib`) +The resulting (debug by default) libraries are +- Linux: `libcblite.so*` (e.g. libcblite.so.3.0.0 / libcblite.so.3 / libcblite.so) +- macOS: `libcblite.*.dylib` (e.g. libcblite.3.0.0.dylib / libcblite.3.dylib / libcblite.dylib) + +### CMake on Linux (cross compile) + +**NOTE**: Due to the complexity of cross compiling, these instructions are very high level on purpose. If you are curious about more fine-grained details you can check out the [cross compilation script](https://raw.githubusercontent.com/couchbase/couchbase-lite-C/master/jenkins/ci_cross_build.py) we use. + +Dependencies: +* Cross compiler based on GCC 7+ or clang +* CMake 3.10+ +* (in sysroot) ICU development libraries +* (in sysroot) ZLIB development libraries + +1. Clone the repo +2. Check out submodules (recursively), i.e. `git submodule update --init --recursive` +3. Create a CMake toolchain file that sets up the cross compiler and sysroot for the cross compilation +4. Prepare the build project with CMake and the toolchain from 3 (e.g. `cmake -DCMAKE_TOOLCHAIN_FILE= `) +5. Build the project `make cblite` ### With CMake on Windows -_(Much like building on Unix. Details TBD)_ +Dependencies: +* Visual Studio Toolset v141+ (Visual Studio 2017+) +* CMake 3.10+ + +1. Clone the repo +2. Check out submodules (recursively), i.e. `git submodule update --init --recursive` +3. Prepare the build project with CMake (e.g. `cmake -G -A x64`). Note even if you don't want to install, you should set the `CMAKE_INSTALL_PREFIX` (see issue #141). +4. Build the project: `cmake --build . --target cblite` (or open the resulting Visual Studio project and build from there) + +The resulting (debug by default) library is `Debug\cblite.dll`. ### With Xcode on macOS 1. Clone the repo -2. Check out submodules (recursively) +2. Check out submodules (recursively), i.e. `git submodule update --init --recursive` 3. Open the Xcode project in the `Xcode` subfolder 4. Select scheme `CBL_C Framework` 5. Build @@ -193,6 +155,26 @@ To run the unit tests: 4. Select scheme `CBL_Tests` 5. Run +## Testing It + +### CMake on Unix + +1. Follow the steps in building +2. Build the test project `make CBL_C_Tests` +3. Run the tests in `test` directory `./CBL_C_Tests -r list` (for cross compile, this step needs to be done on the target system) + +### CMake on Windows + +1. Follow the steps in building +2. Build the test project `cmake --build . --target CBL_C_Tests` +3. Run the tests in `test\Debug` directory `.\CBL_C_Tests.exe -r list` + +### With Xcode on macOS + +1. Open the Xcode project from the Building section +2. Select scheme `CBL_Tests` +3. Run + ## Using It ### Generic instructions @@ -216,7 +198,7 @@ To run the unit tests: ## Other Language Bindings -* **C++**: Already included; see [`include/cbl++`](https://github.com/couchbaselabs/couchbase-lite-C/tree/master/include/cbl%2B%2B) +* **C++**: Already included; see [`include/cbl++`](https://github.com/couchbase/couchbase-lite-C/tree/master/include/cbl%2B%2B), but not supported * **Python**: [Included](bindings/python/README.md) but unsupported * **Nim**: [Included](bindings/nim/README.md) but unsupported * **Rust**: [Included](bindings/rust/README.md) but unsupported From 11022a475a53d29b468b02652b9c79306c76a930 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 22 Sep 2021 20:40:04 -0700 Subject: [PATCH 11/90] Validate encryptable in arrays when saving doc (#219) * We do not support encryptables in arrays. * (EE Only) Extended the saveBlobs function (called ) that walks the properties tree to find and install blobs to also validate the encryptables in arrays. For CE, the method will work the same way. * When checking encryptables in arrays, it needs to also look into the immutable collections in the document properties as well because, for an example, the document can be set with JSON which will result to a shallow mutable properties. * Make the code more readable and add detailed comment CBL-2265 --- src/CBLDocument.cc | 59 +++++++++++++++---- src/CBLDocument_Internal.hh | 8 ++- test/ReplicatorPropEncTest.cc | 107 ++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 11 deletions(-) diff --git a/src/CBLDocument.cc b/src/CBLDocument.cc index 7038e623..33932542 100644 --- a/src/CBLDocument.cc +++ b/src/CBLDocument.cc @@ -27,6 +27,10 @@ #ifdef COUCHBASE_ENTERPRISE #include "CBLEncryptable_Internal.hh" +#else +// Used in saveBlobsAndCheckEncryptables(). As FLDict_IsEncryptableValue() is not available +// in CE, define a function macro to allow the function to compile in CE. +#define FLDict_IsEncryptableValue(d) false #endif @@ -176,8 +180,8 @@ alloc_slice CBLDocument::encodeBody(CBLDatabase* db, C4RevisionFlags &outRevFlags) const { auto c4doc = _c4doc.useLocked(); - // Save new blobs: - bool hasBlobs = saveBlobs(db, releaseNewBlob); + // Save new blobs and check encryptables in arrays: + bool hasBlobs = saveBlobsAndCheckEncryptables(db, releaseNewBlob); outRevFlags = hasBlobs ? kRevHasAttachments : 0; // Now encode the properties to Fleece: @@ -316,14 +320,17 @@ CBLEncryptable* CBLDocument::getEncryptableValue(FLDict dict) { #endif -bool CBLDocument::saveBlobs(CBLDatabase *db, bool releaseNewBlob) const { +bool CBLDocument::saveBlobsAndCheckEncryptables(CBLDatabase *db, bool releaseNewBlob) const { // Walk through the Fleece object tree, looking for new mutable blob Dicts to install, // and also checking if there are any blobs at all (mutable or not.) - // Once we've found at least one blob, we can skip immutable collections, because - // they can't contain new blobs. + // Once we've found at least one blob, we can skip checking blobs in immutable collections, + // because they can't contain new blobs. // // If the releaseNewBlob is enabled, the new blob will be released after it is installed. // + // (EE Only) While walking through the object tree, check if there are any encryptables in + // an array and throw an unsupported error if that occurs. + // // Note: If the same new blob is used in multiple places inside the object tree, the // blob will be installed only once as it will be unregistered from global sNewBlobs // HashTable. @@ -332,15 +339,44 @@ bool CBLDocument::saveBlobs(CBLDatabase *db, bool releaseNewBlob) const { return C4Blob::dictContainsBlobs(properties()); bool foundBlobs = false; + + // In EE, encryptables need to be checked, but this adds a lot of overhead so in CE this will be + // skipped. By defining a constant bool like this, the compiler should optimize out all of the + // branches that have a constant `false` inside, and the source can maintain a bit more readability. +#ifdef COUCHBASE_ENTERPRISE + const bool validateEncryptables = true; +#else + const bool validateEncryptables = false; +#endif + for (DeepIterator i(properties()); i; ++i) { Dict dict = i.value().asDict(); if (dict) { - if (!dict.asMutable()) { - if (!foundBlobs) + if (validateEncryptables && FLDict_IsEncryptableValue(dict)) { + // Encryptables inside of an array are not supported! + if (i.parent().asArray()) { + C4Error::raise(LiteCoreDomain, kC4ErrorUnsupported, + "No support for encryptables in an array"); + } + i.skipChildren(); + } else if (!dict.asMutable()) { + // This is an immutable dictionary, so it cannot be a new blob. It might be + // the first existing blob detected though. + if (!foundBlobs) { foundBlobs = FLDict_IsBlob(dict); - if (foundBlobs) + if (foundBlobs) { + i.skipChildren(); + } + } + if (foundBlobs && !validateEncryptables) { + // Found at least one blob, and the current dictionary is immutable + // Since encryptable validation is disabled, the rest of the keys + // are not relevant. i.skipChildren(); + } } else if (FLDict_IsBlob(dict)) { + // This is a mutable dictionary. Check if it's a new blob, so install it + // if it hasn't been already. foundBlobs = true; CBLNewBlob *newBlob = findNewBlob(dict); if (newBlob) { @@ -351,9 +387,12 @@ bool CBLDocument::saveBlobs(CBLDatabase *db, bool releaseNewBlob) const { } i.skipChildren(); } - } else if (!i.value().asArray().asMutable()) { - if (foundBlobs) + } else if (!validateEncryptables && !i.value().asArray().asMutable()) { + // If one blob has been found already, there is nothing interesting inside of + // an immutable array. It will only contain previously saved information. + if (foundBlobs) { i.skipChildren(); + } } } return foundBlobs; diff --git a/src/CBLDocument_Internal.hh b/src/CBLDocument_Internal.hh index fb1bf004..a7604e56 100644 --- a/src/CBLDocument_Internal.hh +++ b/src/CBLDocument_Internal.hh @@ -281,7 +281,13 @@ private: // installed. The flag is set to true only when saving new blobs while encoding the document // returned by the replicator's conflict resolved. The new blobs set to the resolved doc needs // to be retained until they are installed here. - bool saveBlobs(CBLDatabase *db, bool releaseNewBlob) const; // returns true if there are blobs + // + // The method will returns true if there are blobs. + // + // (EE Only) Furthermore, while walking through the object tree, check if there are + // any encryptables in an array and throw an unsupported error if that occurs. + // + bool saveBlobsAndCheckEncryptables(CBLDatabase *db, bool releaseNewBlob) const; // Encode the document body and install new blobs if found into the database. // diff --git a/test/ReplicatorPropEncTest.cc b/test/ReplicatorPropEncTest.cc index 3fa3f3a7..0d648acc 100644 --- a/test/ReplicatorPropEncTest.cc +++ b/test/ReplicatorPropEncTest.cc @@ -279,6 +279,113 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Save and Get document with E CBLDocument_Release(doc); } +TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Unsupport : Encryptables in array", "[Encryptable]") { + CBLError error; + auto doc = CBLDocument_CreateWithID("doc1"_sl); + auto array = FLMutableArray_New(); + auto enc1 = CBLEncryptable_CreateWithString("foo1"_sl); + auto enc2 = CBLEncryptable_CreateWithString("foo2"_sl); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc1)); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc2)); + + SECTION("Update mutable properties") { + FLMutableDict props = CBLDocument_MutableProperties(doc); + FLMutableDict_SetArray(props, "array"_sl, array); + } + + SECTION("Set doc with JSON") { // Doc with have shallow mutable properties + FLMutableDict props = FLMutableDict_New(); + FLMutableDict_SetArray(props, "array"_sl, array); + FLStringResult json = FLValue_ToJSON((FLValue)props); + REQUIRE(CBLDocument_SetJSON(doc, FLSliceResult_AsSlice(json), &error)); + FLMutableDict_Release(props); + } + + // Save doc: + ExpectingExceptions x; + REQUIRE(!CBLDatabase_SaveDocument(db.ref(), doc, &error)); + CHECK(error.domain == kCBLDomain); + CHECK(error.code == kCBLErrorUnsupported); + CBLDocument_Release(doc); + CBLEncryptable_Release(enc1); + CBLEncryptable_Release(enc2); + FLMutableArray_Release(array); +} + +TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Unsupport : Encryptables in nested array in dict", "[Encryptable]") { + CBLError error; + auto doc = CBLDocument_CreateWithID("doc1"_sl); + FLMutableDict dict = FLMutableDict_New(); + auto array = FLMutableArray_New(); + auto enc1 = CBLEncryptable_CreateWithString("foo1"_sl); + auto enc2 = CBLEncryptable_CreateWithString("foo2"_sl); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc1)); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc2)); + FLMutableDict_SetArray(dict, "array"_sl, array); + + SECTION("Update mutable properties") { + FLMutableDict props = CBLDocument_MutableProperties(doc); + FLMutableDict_SetDict(props, "dict"_sl, dict); + } + + SECTION("Set doc with JSON") { // Doc with have shallow mutable properties + FLMutableDict props = FLMutableDict_New(); + FLMutableDict_SetDict(props, "dict"_sl, dict); + FLStringResult json = FLValue_ToJSON((FLValue)props); + REQUIRE(CBLDocument_SetJSON(doc, FLSliceResult_AsSlice(json), &error)); + FLMutableDict_Release(dict); + } + + // Save doc: + ExpectingExceptions x; + REQUIRE(!CBLDatabase_SaveDocument(db.ref(), doc, &error)); + CHECK(error.domain == kCBLDomain); + CHECK(error.code == kCBLErrorUnsupported); + CBLDocument_Release(doc); + CBLEncryptable_Release(enc1); + CBLEncryptable_Release(enc2); + FLMutableArray_Release(array); + FLMutableDict_Release(dict); +} + +TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Unsupport : Encryptables in nested array in array", "[Encryptable]") { + CBLError error; + auto doc = CBLDocument_CreateWithID("doc1"_sl); + + FLMutableArray outerArray = FLMutableArray_New(); + FLMutableDict dict = FLMutableDict_New(); + auto array = FLMutableArray_New(); + auto enc1 = CBLEncryptable_CreateWithString("foo1"_sl); + auto enc2 = CBLEncryptable_CreateWithString("foo2"_sl); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc1)); + FLMutableArray_AppendDict(array, CBLEncryptable_Properties(enc2)); + FLMutableArray_AppendArray(outerArray, array); + + SECTION("Update mutable properties") { + FLMutableDict props = CBLDocument_MutableProperties(doc); + FLMutableDict_SetArray(props, "array"_sl, outerArray); + } + + SECTION("Set doc with JSON") { // Doc with have shallow mutable properties + FLMutableDict props = FLMutableDict_New(); + FLMutableDict_SetArray(props, "array"_sl, outerArray); + FLStringResult json = FLValue_ToJSON((FLValue)props); + REQUIRE(CBLDocument_SetJSON(doc, FLSliceResult_AsSlice(json), &error)); + FLMutableDict_Release(dict); + } + + // Save doc: + ExpectingExceptions x; + REQUIRE(!CBLDatabase_SaveDocument(db.ref(), doc, &error)); + CHECK(error.domain == kCBLDomain); + CHECK(error.code == kCBLErrorUnsupported); + CBLDocument_Release(doc); + CBLEncryptable_Release(enc1); + CBLEncryptable_Release(enc2); + FLMutableArray_Release(array); + FLMutableArray_Release(outerArray); +} + TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encrypt and decrypt one property", "[Replicator][Encryptable]") { { auto doc = CBLDocument_CreateWithID("doc1"_sl); From 808c3f66915a4408afdebf152d9a384f64d630bb Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Mon, 20 Sep 2021 17:15:30 -0700 Subject: [PATCH 12/90] Updated Doxyfile for newer Doxygen, added Xcode scheme Doxygen warned that the config file was out of date, so I allowed it to update the file. Looks like this bumped the version number at the top, updated a bunch of comments, added new configs with default values, etc. I did not make manual changes to the file. I also added an Xcode scheme to run the "Doxygen" target, which builds the docs. --- .../xcshareddata/xcschemes/Doxygen.xcscheme | 67 +++ Doxyfile | 543 ++++++++++++------ 2 files changed, 427 insertions(+), 183 deletions(-) create mode 100644 CBL_C.xcodeproj/xcshareddata/xcschemes/Doxygen.xcscheme diff --git a/CBL_C.xcodeproj/xcshareddata/xcschemes/Doxygen.xcscheme b/CBL_C.xcodeproj/xcshareddata/xcschemes/Doxygen.xcscheme new file mode 100644 index 00000000..a68abb5f --- /dev/null +++ b/CBL_C.xcodeproj/xcshareddata/xcschemes/Doxygen.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Doxyfile b/Doxyfile index 5f6ddd1d..f8001933 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.12 +# Doxyfile 1.9.2 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = "docs/C/" +OUTPUT_DIRECTORY = docs/C/ # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -171,7 +171,7 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = "include" +STRIP_FROM_INC_PATH = include # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -189,6 +189,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -209,6 +219,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -232,20 +250,19 @@ TAB_SIZE = 4 # the documentation. An alias has the form: # name=value # For example adding -# "sideeffect=@par Side Effects:\n" +# "sideeffect=@par Side Effects:^^" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -274,28 +291,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -307,7 +336,7 @@ MARKDOWN_SUPPORT = YES # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. -# Minimum value: 0, maximum value: 99, default value: 0. +# Minimum value: 0, maximum value: 99, default value: 5. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 0 @@ -337,7 +366,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -423,6 +452,19 @@ TYPEDEF_HIDES_STRUCT = YES LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -443,6 +485,12 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -480,6 +528,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -497,8 +552,8 @@ HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -517,11 +572,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = NO @@ -540,6 +602,12 @@ HIDE_SCOPE_NAMES = NO HIDE_COMPOUND_REFERENCE= NO +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. @@ -697,7 +765,8 @@ FILE_VERSION_FILTER = # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE @@ -708,7 +777,7 @@ LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -743,23 +812,35 @@ WARNINGS = YES WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = YES @@ -790,13 +871,14 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "include/cbl" "vendor/couchbase-lite-core/vendor/fleece/API/fleece" +INPUT = include/cbl \ + vendor/couchbase-lite-core/vendor/fleece/API/fleece # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -809,11 +891,15 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.h @@ -968,7 +1054,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -1000,12 +1086,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1038,13 +1124,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1144,8 +1223,8 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1154,7 +1233,7 @@ HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A +# in the HTML output. For a value of 0 the output will use gray-scales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1181,6 +1260,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1204,13 +1294,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1249,8 +1340,12 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1280,7 +1375,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1325,7 +1420,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1333,8 +1429,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1342,30 +1438,30 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1408,16 +1504,28 @@ DISABLE_INDEX = NO # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATOR_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # @@ -1442,6 +1550,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1451,7 +1570,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1462,8 +1581,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1473,11 +1598,29 @@ FORMULA_TRANSPARENT = YES USE_MATHJAX = NO +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + # When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). # Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1490,22 +1633,29 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see https://docs.mathjax.org/en/v2.7-latest/tex.html +# #tex-and-latex-extensions): # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1533,7 +1683,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1552,7 +1702,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1565,8 +1716,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1617,21 +1769,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1661,29 +1827,31 @@ PAPER_TYPE = a4 EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the -# generated LaTeX document. The header should contain everything until the first -# chapter. If it is left blank doxygen will generate a standard header. See -# section "Doxygen usage" for information on how to let doxygen write the -# default header to a separate file. +# The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for +# the generated LaTeX document. The header should contain everything until the +# first chapter. If it is left blank doxygen will generate a standard header. It +# is highly recommended to start with a default header using +# doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty +# and then modify the file new_header.tex. See also section "Doxygen usage" for +# information on how to generate the default header that doxygen normally uses. # -# Note: Only use a user-defined header if you know what you are doing! The -# following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber, -# $projectbrief, $projectlogo. Doxygen will replace $title with the empty -# string, for the replacement values of the other commands the user is referred -# to HTML_HEADER. +# Note: Only use a user-defined header if you know what you are doing! +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. The following +# commands have a special meaning inside the header (and footer): For a +# description of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_HEADER = -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the -# generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. See +# The LATEX_FOOTER tag can be used to specify a user-defined LaTeX footer for +# the generated LaTeX document. The footer should contain everything after the +# last chapter. If it is left blank doxygen will generate a standard footer. See # LATEX_HEADER for more information on how to generate a default footer and what -# special commands can be used inside the footer. -# -# Note: Only use a user-defined footer if you know what you are doing! +# special commands can be used inside the footer. See also section "Doxygen +# usage" for information on how to generate the default footer that doxygen +# normally uses. Note: Only use a user-defined footer if you know what you are +# doing! # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_FOOTER = @@ -1716,9 +1884,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1726,8 +1896,7 @@ USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode # command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. This option is also used -# when generating formulas in HTML. +# if errors occur, instead of asking the user for help. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1740,19 +1909,9 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1766,6 +1925,14 @@ LATEX_BIB_STYLE = plain LATEX_TIMESTAMP = NO +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1805,9 +1972,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1816,22 +1983,12 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = -# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code -# with syntax highlighting in the RTF output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_SOURCE_CODE = NO - #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- @@ -1903,6 +2060,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1921,23 +2085,14 @@ GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook -# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the -# program listings (including syntax highlighting and cross-referencing -# information) to the DOCBOOK output. Note that enabling this will significantly -# increase the size of the DOCBOOK output. -# The default value is: NO. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_PROGRAMLISTING = NO - #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2037,7 +2192,13 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = DOXYGEN_PARSING=1 CBLAPI= _cbl_nonnull= FLAPI= FLNONNULL= NONNULL= COUCHBASE_ENTERPRISE= +PREDEFINED = DOXYGEN_PARSING=1 \ + CBLAPI= \ + _cbl_nonnull= \ + FLAPI= \ + FLNONNULL= \ + NONNULL= \ + COUCHBASE_ENTERPRISE= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2046,7 +2207,9 @@ PREDEFINED = DOXYGEN_PARSING=1 CBLAPI= _cbl_nonnull= FLAPI= FLNONNUL # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = CBL_OPTIONS CBL_ENUM CBL_REFCOUNTED +EXPAND_AS_DEFINED = CBL_OPTIONS \ + CBL_ENUM \ + CBL_REFCOUNTED # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have @@ -2104,12 +2267,6 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -2123,15 +2280,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2229,10 +2377,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2359,6 +2529,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. @@ -2417,9 +2592,11 @@ DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc temporary +# files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES From 65d0eaab7a8ed6e8696a76338f2341b46b944282 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 23 Sep 2021 16:58:20 -0700 Subject: [PATCH 13/90] Fix missing CBLBlob_CreateJSON exported symbol (#220) --- src/exports/CBL_Exports.txt | 1 + src/exports/generated/CBL.def | 1 + src/exports/generated/CBL.exp | 1 + src/exports/generated/CBL.gnu | 1 + src/exports/generated/CBL_Android.gnu | 1 + src/exports/generated/CBL_EE.def | 1 + src/exports/generated/CBL_EE.exp | 1 + src/exports/generated/CBL_EE.gnu | 1 + src/exports/generated/CBL_EE_Android.gnu | 1 + 9 files changed, 9 insertions(+) diff --git a/src/exports/CBL_Exports.txt b/src/exports/CBL_Exports.txt index 8c277b4e..5ccdcd38 100644 --- a/src/exports/CBL_Exports.txt +++ b/src/exports/CBL_Exports.txt @@ -40,6 +40,7 @@ CBLBlob_Equals CBLBlob_Properties CBLBlob_Content CBLBlob_OpenContentStream +CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index ef5eb4d2..774e8b35 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -26,6 +26,7 @@ CBLBlob_Equals CBLBlob_Properties CBLBlob_Content CBLBlob_OpenContentStream +CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index fc11c366..ef7acf1c 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -24,6 +24,7 @@ _CBLBlob_Equals _CBLBlob_Properties _CBLBlob_Content _CBLBlob_OpenContentStream +_CBLBlob_CreateJSON _CBLBlob_CreateWithData _CBLBlob_CreateWithStream _CBLBlobReader_Read diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index bd6888f3..483454e4 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -24,6 +24,7 @@ CBL_C { CBLBlob_Properties; CBLBlob_Content; CBLBlob_OpenContentStream; + CBLBlob_CreateJSON; CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index 7cee2449..040b8165 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -25,6 +25,7 @@ CBL_C { CBLBlob_Properties; CBLBlob_Content; CBLBlob_OpenContentStream; + CBLBlob_CreateJSON; CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index f9876d3a..cdb65ffb 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -46,6 +46,7 @@ CBLBlob_Equals CBLBlob_Properties CBLBlob_Content CBLBlob_OpenContentStream +CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index ac5257b2..65e4ed6e 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -44,6 +44,7 @@ _CBLBlob_Equals _CBLBlob_Properties _CBLBlob_Content _CBLBlob_OpenContentStream +_CBLBlob_CreateJSON _CBLBlob_CreateWithData _CBLBlob_CreateWithStream _CBLBlobReader_Read diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index 0a5888f6..07b967c7 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -44,6 +44,7 @@ CBL_C { CBLBlob_Properties; CBLBlob_Content; CBLBlob_OpenContentStream; + CBLBlob_CreateJSON; CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index c9db29a1..5203a491 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -45,6 +45,7 @@ CBL_C { CBLBlob_Properties; CBLBlob_Content; CBLBlob_OpenContentStream; + CBLBlob_CreateJSON; CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; From 4c3f80394ade4bee704c5480d137b430f3aaf851 Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Tue, 21 Sep 2021 10:01:00 -0700 Subject: [PATCH 14/90] API: Added blob setters: FLMutableDict_SetBlob + 2 more Added three inline convenience functions that wrap FLSlot_SetBlob, matching the ones recently added to Fleece.h for the other data types. I removed the doc-comment from FLSlot_SetBlob, to make it less prominent in the API docs, and avoid confusing users. In the C++ API I added an implicit conversion from Blob to Dict, so that Blob can be assigned to a Dict or Array item, e.g. `dict["foo"] = blob`. (Since this is an API change, Pasin's got final approval.) --- include/cbl++/Blob.hh | 3 +++ include/cbl/CBLBlob.h | 28 ++++++++++++++++++++++++---- test/BlobTest.cc | 2 +- test/BlobTest_Cpp.cc | 10 +++------- test/DatabaseTest.cc | 6 +++--- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/include/cbl++/Blob.hh b/include/cbl++/Blob.hh index f89cdc58..a87c9598 100644 --- a/include/cbl++/Blob.hh +++ b/include/cbl++/Blob.hh @@ -69,6 +69,9 @@ namespace cbl { std::string digest() const {return asString(CBLBlob_Digest(ref()));} fleece::Dict properties() const {return CBLBlob_Properties(ref());} + // Allows Blob to be assigned to mutable Dict/Array item, e.g. `dict["foo"] = blob` + operator fleece::Dict() const {return properties();} + alloc_slice loadContent() { CBLError error; fleece::alloc_slice content = CBLBlob_Content(ref(), &error); diff --git a/include/cbl/CBLBlob.h b/include/cbl/CBLBlob.h index 43d48437..af0be2c6 100644 --- a/include/cbl/CBLBlob.h +++ b/include/cbl/CBLBlob.h @@ -200,12 +200,32 @@ CBL_CAPI_BEGIN return FLDict_GetBlob(FLValue_AsDict(value)); } - /** Stores a blob reference in a Fleece mutable Array or Dict. - @param slot The position in the collection, as returned by functions like - \ref FLMutableArray_Set or \ref FLMutableDict_Set. - @param blob The CBLBlob to store (as a Dict) in the collection. */ void FLSlot_SetBlob(FLSlot slot, CBLBlob* blob) CBLAPI; + /** Stores a blob reference into an array. + @param array The array to store into. + @param index The position in the array at which to store the blob reference. + @param blob The blob reference to be stored. */ + static inline void FLMutableArray_SetBlob(FLMutableArray array, uint32_t index, CBLBlob *blob) { + FLSlot_SetBlob(FLMutableArray_Set(array, index), blob); + } + + /** Appends a blob reference to an array. + @param array The array to store into. + @param blob The blob reference to be stored. */ + static inline void FLMutableArray_AppendBlob(FLMutableArray array, CBLBlob *blob) { + FLSlot_SetBlob(FLMutableArray_Append(array), blob); + } + + /** Stores a blob reference into a Dict. + @param dict The Dict to store into. + @param key The key to associate the blob reference with. + @param blob The blob reference to be stored. */ + static inline void FLMutableDict_SetBlob(FLMutableDict dict, FLString key, CBLBlob *blob) { + FLSlot_SetBlob(FLMutableDict_Set(dict, key), blob); + } + + #ifdef __APPLE__ #pragma mark - BINDING DEV SUPPORT FOR BLOB: #endif diff --git a/test/BlobTest.cc b/test/BlobTest.cc index 643f558f..1f295d0a 100644 --- a/test/BlobTest.cc +++ b/test/BlobTest.cc @@ -78,7 +78,7 @@ TEST_CASE_METHOD(BlobTest, "Create blob with stream", "[Blob]") { // Set blob in a document and save: auto doc = CBLDocument_CreateWithID("doc1"_sl); auto props = CBLDocument_MutableProperties(doc); - FLSlot_SetBlob(FLMutableDict_Set(props, "blob"_sl), blob); + FLMutableDict_SetBlob(props, "blob"_sl, blob); CHECK(CBLDatabase_SaveDocument(db, doc, &error)); // Check content: diff --git a/test/BlobTest_Cpp.cc b/test/BlobTest_Cpp.cc index 60282915..a3b0e424 100644 --- a/test/BlobTest_Cpp.cc +++ b/test/BlobTest_Cpp.cc @@ -151,19 +151,15 @@ TEST_CASE_METHOD(CBLTest_Cpp, "C++ Blobs in arrays/dicts", "[Blob]") { MutableDocument doc("blobbo"); MutableArray array = MutableArray::newArray(); array.insertNulls(0, 1); - CBLBlob *blob1 = CBLBlob_CreateWithData(slice(kBlobContentType), kBlobContents); - FLSlot_SetBlob(array[0], blob1); + Blob blob1(kBlobContentType, kBlobContents); + array[0] = blob1; MutableDict dict = MutableDict::newDict(); - CBLBlob *blob2 = CBLBlob_CreateWithData(slice(kBlobContentType), kBlobContents); - FLSlot_SetBlob(dict["b"], blob2); + dict["b"] = Blob(kBlobContentType, kBlobContents); doc["array"] = array; doc["dict"] = dict; db.saveDocument(doc); - - CBLBlob_Release(blob1); - CBLBlob_Release(blob2); } Document doc = db.getDocument("blobbo"); diff --git a/test/DatabaseTest.cc b/test/DatabaseTest.cc index 65eb1085..a0e9480e 100644 --- a/test/DatabaseTest.cc +++ b/test/DatabaseTest.cc @@ -1151,7 +1151,7 @@ TEST_CASE_METHOD(DatabaseTest, "Maintenance : Compact and Integrity Check") { FLMutableDict dict = CBLDocument_MutableProperties(doc); FLSlice blobContent = FLStr("I'm Blob."); CBLBlob *blob1 = CBLBlob_CreateWithData("text/plain"_sl, blobContent); - FLSlot_SetBlob(FLMutableDict_Set(dict, FLStr("blob")), blob1); + FLMutableDict_SetBlob(dict, FLStr("blob"), blob1); // Save doc: CBLError error; @@ -1433,7 +1433,7 @@ TEST_CASE_METHOD(DatabaseTest, "Set blob in document", "[Blob]") { // Set blob in document CBLDocument* doc = CBLDocument_CreateWithID("doc1"_sl); FLMutableDict docProps = CBLDocument_MutableProperties(doc); - FLSlot_SetBlob(FLMutableDict_Set(docProps, FLStr("blob")), blob); + FLMutableDict_SetBlob(docProps, FLSTR("blob"), blob); CHECK(CBLDatabase_SaveDocument(db, doc, &error)); CBLDocument_Release(doc); CBLBlob_Release(blob); @@ -1490,7 +1490,7 @@ TEST_CASE_METHOD(DatabaseTest, "Save blob and set blob in document", "[Blob]") { // Set blob in document CBLDocument* doc = CBLDocument_CreateWithID("doc1"_sl); FLMutableDict docProps = CBLDocument_MutableProperties(doc); - FLSlot_SetBlob(FLMutableDict_Set(docProps, FLStr("blob")), blob); + FLMutableDict_SetBlob(docProps, FLSTR("blob"), blob); CHECK(CBLDatabase_SaveDocument(db, doc, &error)); CBLDocument_Release(doc); CBLBlob_Release(blob); From 6449f2dbdb2fe7a09a9b4150f78506f42116e13a Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Tue, 21 Sep 2021 10:32:56 -0700 Subject: [PATCH 15/90] Avoid UB-Sanitizer warning in CBLReplicatorConfig The statement `endpoint = endpoint ? endpoint->clone() : nullptr` triggers an Undefined Behavior Sanitizer warning/breakpoint when `endpoint` is NULL, because it stores NULL into a pointer declared as `_cbl_nonnull`. This occurs during the "Bad config" unit test. I made a simple fix to avoid storing anything into it when it's NULL. --- src/CBLReplicatorConfig.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CBLReplicatorConfig.hh b/src/CBLReplicatorConfig.hh index 9eacbb6a..37c2e0b6 100644 --- a/src/CBLReplicatorConfig.hh +++ b/src/CBLReplicatorConfig.hh @@ -175,7 +175,8 @@ namespace cbl_internal { ReplicatorConfiguration(const CBLReplicatorConfiguration &conf) { *(CBLReplicatorConfiguration*)this = conf; retain(database); - endpoint = endpoint ? endpoint->clone() : nullptr; + if (endpoint) + endpoint = endpoint->clone(); authenticator = authenticator ? authenticator->clone() : nullptr; headers = FLDict_MutableCopy(headers, kFLDeepCopyImmutables); channels = FLArray_MutableCopy(channels, kFLDeepCopyImmutables); From d37efdfcc74dd90af37a3125bb2b71f4fd85c499 Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Thu, 23 Sep 2021 16:38:26 -0700 Subject: [PATCH 16/90] CBLDatabase+Apple.mm: Create config dir if it doesn't exist The default database parent directory (in the default configuration) is not created automatically. This makes creating a database fail until you create the directory yourself, which is very unintuitive. Fixed. CBL-2389 --- src/CBLDatabase+Apple.mm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/CBLDatabase+Apple.mm b/src/CBLDatabase+Apple.mm index 7f1c2ee3..546ea326 100644 --- a/src/CBLDatabase+Apple.mm +++ b/src/CBLDatabase+Apple.mm @@ -18,6 +18,7 @@ #import #include "CBLDatabase_Internal.hh" +#include "c4Error.h" std::string CBLDatabase::defaultDirectory() { @@ -34,8 +35,17 @@ appropriateForURL: nil create: YES error: &error].path; - NSCAssert(path, @"Cannot find or create the default directory with error : %@", error); - + if (!path) { + C4Error::raise(LiteCoreDomain, kC4ErrorUnexpectedError, +#if TARGET_OS_TV + "Could not create Caches directory: %s", +#else + "Could not create Application Support directory: %s", +#endif + error.localizedDescription.UTF8String); + + } + #if !TARGET_OS_IPHONE // On macOS, append the application's bundle ID to get a per-app directory: NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier]; @@ -47,6 +57,17 @@ #endif // Append a "CouchbaseLite" component to the path: - return [path stringByAppendingPathComponent: @"CouchbaseLite"].fileSystemRepresentation; + path = [path stringByAppendingPathComponent: @"CouchbaseLite"]; + + // Create the directory if necessary: + if (![NSFileManager.defaultManager createDirectoryAtPath: path + withIntermediateDirectories: YES + attributes: nil + error: &error]) { + C4Error::raise(LiteCoreDomain, kC4ErrorUnexpectedError, + "Could not create database directory %s : %s", + path.fileSystemRepresentation, error.localizedDescription.UTF8String); + } + return path.fileSystemRepresentation; } } From e6b2dce5404e7ba6dcb011e7df513d8c19080966 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 24 Sep 2021 10:50:23 -0700 Subject: [PATCH 17/90] Add FLMutableDict_SetEncryptableValue (#224) --- include/cbl/CBLEncryptable.h | 7 ++++++- test/ReplicatorPropEncTest.cc | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/cbl/CBLEncryptable.h b/include/cbl/CBLEncryptable.h index ed1ee32a..4bdcce0f 100644 --- a/include/cbl/CBLEncryptable.h +++ b/include/cbl/CBLEncryptable.h @@ -157,9 +157,14 @@ static inline const CBLEncryptable* _cbl_nullable FLValue_GetEncryptableValue(FL return FLDict_GetEncryptableValue(FLValue_AsDict(value)); } -/** Set a \ref CBLEncryptable's dictionary in a Fleece mutable Dict. */ +/** Set a \ref CBLEncryptable's dictionary into a mutable dictionary's slot. */ void FLSlot_SetEncryptableValue(FLSlot slot, const CBLEncryptable* encryptable) CBLAPI; +/** Set a \ref CBLEncryptable's dictionary into a mutable dictionary. */ +static inline void FLMutableDict_SetEncryptableValue(FLMutableDict dict, FLString key, CBLEncryptable* encryptable) { + FLSlot_SetEncryptableValue(FLMutableDict_Set(dict, key), encryptable); +} + /** @} */ CBL_CAPI_END diff --git a/test/ReplicatorPropEncTest.cc b/test/ReplicatorPropEncTest.cc index 0d648acc..45edbf06 100644 --- a/test/ReplicatorPropEncTest.cc +++ b/test/ReplicatorPropEncTest.cc @@ -245,7 +245,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Save and Get document with E // Set encryptable: FLMutableDict props = CBLDocument_MutableProperties(doc); auto encryptable = CBLEncryptable_CreateWithString("foo"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "encryptable"_sl), encryptable); + FLMutableDict_SetEncryptableValue(props, "encryptable"_sl, encryptable); // Set non encryptable dict: auto nonencryptable = FLMutableDict_New(); @@ -392,7 +392,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encrypt and decrypt one prop FLMutableDict props = CBLDocument_MutableProperties(doc); auto secret = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -430,14 +430,15 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encrypt and decrypt multiple auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); auto secret2 = CBLEncryptable_CreateWithInt(10); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret2"_sl), secret2); + FLMutableDict_SetEncryptableValue(props, "secret2"_sl, secret2); auto nestedDict = FLMutableDict_New(); auto secret3 = CBLEncryptable_CreateWithBool(true); - FLSlot_SetEncryptableValue(FLMutableDict_Set(nestedDict, "secret3"_sl), secret3); + FLMutableDict_SetEncryptableValue(nestedDict, "secret3"_sl, secret3); + FLSlot_SetDict(FLMutableDict_Set(props, "nested"_sl), nestedDict); CBLError error; @@ -498,7 +499,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "No encryptor : crypto error" auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -524,7 +525,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "No decryptor : ok", "[Replic auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -558,7 +559,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Skip encryption : crypto err auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -588,7 +589,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Skip decryption : ok", "[Rep auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -629,7 +630,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encryption error", "[Replica auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -657,7 +658,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Decryption error", "[Replica auto props = CBLDocument_MutableProperties(doc); auto secret1 = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret1); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret1); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); @@ -731,7 +732,7 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Key ID and Algorithm", "[Rep FLMutableDict props = CBLDocument_MutableProperties(doc); auto secret = CBLEncryptable_CreateWithString("Secret 1"_sl); - FLSlot_SetEncryptableValue(FLMutableDict_Set(props, "secret1"_sl), secret); + FLMutableDict_SetEncryptableValue(props, "secret1"_sl, secret); CBLError error; CHECK(CBLDatabase_SaveDocument(db.ref(), doc, &error)); From ec2aa8fa86fd66e69f88bcf0e7337942ffe4dcd9 Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Wed, 22 Sep 2021 16:22:48 -0700 Subject: [PATCH 18/90] Unofficial bindings moved elsewhere They will show up in new repos, never fear --- CBL_C.xcodeproj/project.pbxproj | 317 +--- README.md | 22 +- Xcode/build_python.sh | 19 - bindings/nim/CouchbaseLite.nimble | 11 - bindings/nim/README.md | 63 - bindings/nim/monitor.sh | 7 - bindings/nim/nim.cfg | 6 - bindings/nim/src/CouchbaseLite.nim | 33 - bindings/nim/src/CouchbaseLite/database.nim | 146 -- bindings/nim/src/CouchbaseLite/document.nim | 264 --- bindings/nim/src/CouchbaseLite/errors.nim | 141 -- bindings/nim/src/CouchbaseLite/fleece.nim | 395 ----- bindings/nim/src/CouchbaseLite/listener.nim | 33 - .../nim/src/CouchbaseLite/private/cbl.c2nim | 55 - .../nim/src/CouchbaseLite/private/cbl.nim | 1421 ----------------- bindings/nim/src/CouchbaseLite/private/fl.nim | 1004 ------------ .../src/CouchbaseLite/private/gen-bindings.sh | 23 - bindings/nim/src/CouchbaseLite/query.nim | 150 -- bindings/nim/src/CouchbaseLite/replicator.nim | 232 --- bindings/nim/tests/config.nims | 1 - bindings/nim/tests/test1Fleece.nim | 206 --- bindings/nim/tests/test2Database.nim | 93 -- bindings/python/BuildPyCBL.py | 430 ----- bindings/python/CouchbaseLite/Blob.py | 49 - bindings/python/CouchbaseLite/Collections.py | 208 --- bindings/python/CouchbaseLite/Database.py | 189 --- bindings/python/CouchbaseLite/Document.py | 139 -- bindings/python/CouchbaseLite/Query.py | 166 -- bindings/python/CouchbaseLite/__init__.py | 1 - bindings/python/CouchbaseLite/common.py | 86 - bindings/python/README.md | 46 - bindings/python/build.sh | 5 - bindings/python/test/test.py | 119 -- bindings/python/test/test.sh | 7 - bindings/rust/CouchbaseLite/Cargo.toml | 23 - bindings/rust/CouchbaseLite/build.rs | 120 -- bindings/rust/CouchbaseLite/src/blob.rs | 202 --- bindings/rust/CouchbaseLite/src/c_api.rs | 26 - bindings/rust/CouchbaseLite/src/database.rs | 224 --- bindings/rust/CouchbaseLite/src/document.rs | 231 --- bindings/rust/CouchbaseLite/src/error.rs | 286 ---- bindings/rust/CouchbaseLite/src/fleece.rs | 483 ------ .../rust/CouchbaseLite/src/fleece_mutable.rs | 316 ---- .../rust/CouchbaseLite/src/fleece_tests.rs | 128 -- bindings/rust/CouchbaseLite/src/lib.rs | 99 -- bindings/rust/CouchbaseLite/src/logging.rs | 159 -- bindings/rust/CouchbaseLite/src/main.rs | 47 - bindings/rust/CouchbaseLite/src/query.rs | 212 --- bindings/rust/CouchbaseLite/src/replicator.rs | 242 --- bindings/rust/CouchbaseLite/src/slice.rs | 130 -- .../rust/CouchbaseLite/tests/simple_tests.rs | 189 --- bindings/rust/CouchbaseLite/wrapper.h | 2 - bindings/rust/README.md | 65 - bindings/rust/rust.sublime-project | 24 - 54 files changed, 15 insertions(+), 9280 deletions(-) delete mode 100755 Xcode/build_python.sh delete mode 100644 bindings/nim/CouchbaseLite.nimble delete mode 100644 bindings/nim/README.md delete mode 100755 bindings/nim/monitor.sh delete mode 100644 bindings/nim/nim.cfg delete mode 100644 bindings/nim/src/CouchbaseLite.nim delete mode 100644 bindings/nim/src/CouchbaseLite/database.nim delete mode 100644 bindings/nim/src/CouchbaseLite/document.nim delete mode 100644 bindings/nim/src/CouchbaseLite/errors.nim delete mode 100644 bindings/nim/src/CouchbaseLite/fleece.nim delete mode 100644 bindings/nim/src/CouchbaseLite/listener.nim delete mode 100644 bindings/nim/src/CouchbaseLite/private/cbl.c2nim delete mode 100644 bindings/nim/src/CouchbaseLite/private/cbl.nim delete mode 100644 bindings/nim/src/CouchbaseLite/private/fl.nim delete mode 100755 bindings/nim/src/CouchbaseLite/private/gen-bindings.sh delete mode 100644 bindings/nim/src/CouchbaseLite/query.nim delete mode 100644 bindings/nim/src/CouchbaseLite/replicator.nim delete mode 100644 bindings/nim/tests/config.nims delete mode 100644 bindings/nim/tests/test1Fleece.nim delete mode 100644 bindings/nim/tests/test2Database.nim delete mode 100755 bindings/python/BuildPyCBL.py delete mode 100644 bindings/python/CouchbaseLite/Blob.py delete mode 100644 bindings/python/CouchbaseLite/Collections.py delete mode 100644 bindings/python/CouchbaseLite/Database.py delete mode 100644 bindings/python/CouchbaseLite/Document.py delete mode 100644 bindings/python/CouchbaseLite/Query.py delete mode 100644 bindings/python/CouchbaseLite/__init__.py delete mode 100644 bindings/python/CouchbaseLite/common.py delete mode 100644 bindings/python/README.md delete mode 100755 bindings/python/build.sh delete mode 100644 bindings/python/test/test.py delete mode 100755 bindings/python/test/test.sh delete mode 100644 bindings/rust/CouchbaseLite/Cargo.toml delete mode 100644 bindings/rust/CouchbaseLite/build.rs delete mode 100644 bindings/rust/CouchbaseLite/src/blob.rs delete mode 100644 bindings/rust/CouchbaseLite/src/c_api.rs delete mode 100644 bindings/rust/CouchbaseLite/src/database.rs delete mode 100644 bindings/rust/CouchbaseLite/src/document.rs delete mode 100644 bindings/rust/CouchbaseLite/src/error.rs delete mode 100644 bindings/rust/CouchbaseLite/src/fleece.rs delete mode 100644 bindings/rust/CouchbaseLite/src/fleece_mutable.rs delete mode 100644 bindings/rust/CouchbaseLite/src/fleece_tests.rs delete mode 100644 bindings/rust/CouchbaseLite/src/lib.rs delete mode 100644 bindings/rust/CouchbaseLite/src/logging.rs delete mode 100644 bindings/rust/CouchbaseLite/src/main.rs delete mode 100644 bindings/rust/CouchbaseLite/src/query.rs delete mode 100644 bindings/rust/CouchbaseLite/src/replicator.rs delete mode 100644 bindings/rust/CouchbaseLite/src/slice.rs delete mode 100644 bindings/rust/CouchbaseLite/tests/simple_tests.rs delete mode 100644 bindings/rust/CouchbaseLite/wrapper.h delete mode 100644 bindings/rust/README.md delete mode 100644 bindings/rust/rust.sublime-project diff --git a/CBL_C.xcodeproj/project.pbxproj b/CBL_C.xcodeproj/project.pbxproj index d8bc7db8..83d566d6 100644 --- a/CBL_C.xcodeproj/project.pbxproj +++ b/CBL_C.xcodeproj/project.pbxproj @@ -91,13 +91,13 @@ 9320631026BDB409006917A5 /* CBLPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 9320630126BDB340006917A5 /* CBLPlatform.h */; settings = {ATTRIBUTES = (Public, ); }; }; 93965A6326A7CD50008728EE /* LogTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93965A6226A7CD50008728EE /* LogTest.cc */; }; 93965A6426A7CD50008728EE /* LogTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93965A6226A7CD50008728EE /* LogTest.cc */; }; - 93C70D3426D01B5A0093E927 /* BlobTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D3326D01B5A0093E927 /* BlobTest.cc */; }; - 93C70D3526D01B5A0093E927 /* BlobTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D3326D01B5A0093E927 /* BlobTest.cc */; }; 93C70CE026C4D3F80093E927 /* CBLEncryptable.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C70CD226C4D3F20093E927 /* CBLEncryptable.h */; }; 93C70CE126C4D3F90093E927 /* CBLEncryptable.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C70CD226C4D3F20093E927 /* CBLEncryptable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 93C70CE326C5B4BC0093E927 /* CBLEncryptable_CAPI.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70CE226C5B4BC0093E927 /* CBLEncryptable_CAPI.cc */; }; 93C70D1726CB334D0093E927 /* ReplicatorPropEncTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D1626CB334D0093E927 /* ReplicatorPropEncTest.cc */; }; 93C70D1826CB535D0093E927 /* ReplicatorPropEncTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D1626CB334D0093E927 /* ReplicatorPropEncTest.cc */; }; + 93C70D3426D01B5A0093E927 /* BlobTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D3326D01B5A0093E927 /* BlobTest.cc */; }; + 93C70D3526D01B5A0093E927 /* BlobTest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93C70D3326D01B5A0093E927 /* BlobTest.cc */; }; 93EC366226C49AF700182B02 /* CBLEncryptable_Internal.hh in Headers */ = {isa = PBXBuildFile; fileRef = 93EC365D26C498AB00182B02 /* CBLEncryptable_Internal.hh */; }; /* End PBXBuildFile section */ @@ -207,13 +207,6 @@ remoteGlobalIDString = 27B61D6F21D6B64A0027CCDB; remoteInfo = "CBL_C Dylib"; }; - 2779ED5522E2881B0026ACD0 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 271C2A1B21CAC8920045856E /* Project object */; - proxyType = 1; - remoteGlobalIDString = 27B61D6F21D6B64A0027CCDB; - remoteInfo = "CBL_C Dylib"; - }; 277CC9A522BC23DF00B245CB /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 271C2A3821CAD5950045856E /* LiteCore.xcodeproj */; @@ -320,9 +313,6 @@ 275FA3342236E54D001C392D /* CBLPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLPrivate.h; sourceTree = ""; }; 276633A52602815000B9BD36 /* CBLDatabase_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLDatabase_CAPI.cc; sourceTree = ""; }; 276634182605338300B9BD36 /* CBLDocument_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLDocument_CAPI.cc; sourceTree = ""; }; - 2779ED2722DE83A60026ACD0 /* Blob.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Blob.py; sourceTree = ""; }; - 2779ED3622DE83A60026ACD0 /* Collections.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Collections.py; sourceTree = ""; }; - 2779ED5022E2493F0026ACD0 /* build_python.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = build_python.sh; path = Xcode/build_python.sh; sourceTree = SOURCE_ROOT; }; 277B77C6245B44BE00B222D3 /* CBLLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBLLog.h; sourceTree = ""; }; 277B77D4245B44E900B222D3 /* CBLLog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBLLog.cc; sourceTree = ""; }; 277CC99422BC23DE00B245CB /* ReplicatorTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ReplicatorTest.cc; sourceTree = ""; }; @@ -365,13 +355,7 @@ 27B61DC321DEE1C20027CCDB /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 27B61DD421DEE5DC0027CCDB /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 27B61DD821DEEC540027CCDB /* Database.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Database.hh; sourceTree = ""; }; - 27C9B5BA21F12C970040BC45 /* test.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = test.py; path = test/test.py; sourceTree = ""; }; - 27C9B5BF21F12C970040BC45 /* BuildPyCBL.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = BuildPyCBL.py; path = ../BuildPyCBL.py; sourceTree = ""; }; - 27C9B5C021F12C970040BC45 /* Database.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Database.py; sourceTree = ""; }; - 27C9B5C321F12C970040BC45 /* common.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = common.py; sourceTree = ""; }; - 27C9B5C421F12C970040BC45 /* Document.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = Document.py; sourceTree = ""; }; 27C9B5DB21F296C10040BC45 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - 27C9B5DC21F29D500040BC45 /* Query.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = Query.py; sourceTree = ""; }; 27C9B5E021F655110040BC45 /* CBLDatabase_Internal.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CBLDatabase_Internal.hh; sourceTree = ""; }; 27C9B5F121F7D74A0040BC45 /* Replicator.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Replicator.hh; sourceTree = ""; }; 27C9B5F221F7EE670040BC45 /* CBLTest.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CBLTest.c; sourceTree = ""; }; @@ -390,10 +374,10 @@ 9320631126BDB5CA006917A5 /* CBLPlatform_CAPI+Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "CBLPlatform_CAPI+Android.cc"; sourceTree = ""; }; 9320631426BDD059006917A5 /* CBLDatabase+Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "CBLDatabase+Android.cc"; sourceTree = ""; }; 93965A6226A7CD50008728EE /* LogTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogTest.cc; sourceTree = ""; }; - 93C70D3326D01B5A0093E927 /* BlobTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlobTest.cc; sourceTree = ""; }; 93C70CD226C4D3F20093E927 /* CBLEncryptable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLEncryptable.h; sourceTree = ""; }; 93C70CE226C5B4BC0093E927 /* CBLEncryptable_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLEncryptable_CAPI.cc; sourceTree = ""; }; 93C70D1626CB334D0093E927 /* ReplicatorPropEncTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ReplicatorPropEncTest.cc; sourceTree = ""; }; + 93C70D3326D01B5A0093E927 /* BlobTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlobTest.cc; sourceTree = ""; }; 93D0AFF1262619B800777AFC /* generate_edition_header.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_edition_header.sh; sourceTree = ""; }; 93E490C326BDE10F0091B587 /* DatabaseTest_Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseTest_Android.cc; sourceTree = ""; }; 93EC365D26C498AB00182B02 /* CBLEncryptable_Internal.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CBLEncryptable_Internal.hh; sourceTree = ""; }; @@ -455,7 +439,6 @@ 27B61DBF21DD33930027CCDB /* Doxyfile */, 27B61DC321DEE1C20027CCDB /* CMakeLists.txt */, 273CD2D025E81C8F00B93C59 /* cmake */, - 27C9B5B921F12C970040BC45 /* python */, 27B61D8321D6B9F60027CCDB /* Xcode */, 271C2A3721CAC9B50045856E /* vendor */, 271C2A2421CAC8920045856E /* Products */, @@ -663,31 +646,6 @@ path = xcconfigs; sourceTree = ""; }; - 27C9B5B921F12C970040BC45 /* python */ = { - isa = PBXGroup; - children = ( - 2779ED5022E2493F0026ACD0 /* build_python.sh */, - 27C9B5BA21F12C970040BC45 /* test.py */, - 27C9B5BB21F12C970040BC45 /* CouchbaseLite */, - ); - name = python; - path = bindings/python; - sourceTree = ""; - }; - 27C9B5BB21F12C970040BC45 /* CouchbaseLite */ = { - isa = PBXGroup; - children = ( - 27C9B5BF21F12C970040BC45 /* BuildPyCBL.py */, - 27C9B5C321F12C970040BC45 /* common.py */, - 2779ED2722DE83A60026ACD0 /* Blob.py */, - 2779ED3622DE83A60026ACD0 /* Collections.py */, - 27C9B5C021F12C970040BC45 /* Database.py */, - 27C9B5C421F12C970040BC45 /* Document.py */, - 27C9B5DC21F29D500040BC45 /* Query.py */, - ); - path = CouchbaseLite; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -763,21 +721,6 @@ passBuildSettingsInEnvironment = 1; productName = Doxygen; }; - 2779ED5122E287FB0026ACD0 /* Python */ = { - isa = PBXLegacyTarget; - buildArgumentsString = ""; - buildConfigurationList = 2779ED5222E287FB0026ACD0 /* Build configuration list for PBXLegacyTarget "Python" */; - buildPhases = ( - ); - buildToolPath = Xcode/build_python.sh; - buildWorkingDirectory = "$(SRCROOT)"; - dependencies = ( - 2779ED5622E2881B0026ACD0 /* PBXTargetDependency */, - ); - name = Python; - passBuildSettingsInEnvironment = 1; - productName = Python; - }; /* End PBXLegacyTarget section */ /* Begin PBXNativeTarget section */ @@ -900,9 +843,6 @@ 275B357B234812C700FE9CF0 = { CreatedOnToolsVersion = 11.1; }; - 2779ED5122E287FB0026ACD0 = { - CreatedOnToolsVersion = 11.0; - }; 27984E092249A126000FE777 = { CreatedOnToolsVersion = 10.2; }; @@ -938,7 +878,6 @@ 27B61DA721D6E49D0027CCDB /* CBL_Tests */, 275B357B234812C700FE9CF0 /* CouchbaseLiteTests */, 272F012A2279037600E62F72 /* Doxygen */, - 2779ED5122E287FB0026ACD0 /* Python */, ); }; /* End PBXProject section */ @@ -1322,11 +1261,6 @@ target = 27B61D6F21D6B64A0027CCDB /* CBL_C Dylib */; targetProxy = 275B358F234BCF6900FE9CF0 /* PBXContainerItemProxy */; }; - 2779ED5622E2881B0026ACD0 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 27B61D6F21D6B64A0027CCDB /* CBL_C Dylib */; - targetProxy = 2779ED5522E2881B0026ACD0 /* PBXContainerItemProxy */; - }; 277CC9AD22BC3E2800B245CB /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = LiteCoreWebSocket; @@ -1519,123 +1453,6 @@ }; name = Release; }; - 2779ED5322E287FB0026ACD0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUGGING_SYMBOLS = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = N2Q372V7W2; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 2779ED5422E287FB0026ACD0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = N2Q372V7W2; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; 27984E1C2249A127000FE777 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 27310FD7235F686D0046F8C8 /* CBL_Framework_Debug.xcconfig */; @@ -1945,69 +1762,6 @@ }; name = Debug_EE; }; - 27D055722358F9DF009BB0A1 /* Debug_EE */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUGGING_SYMBOLS = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = N2Q372V7W2; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug_EE; - }; 27D055812358F9FA009BB0A1 /* Release_EE */ = { isa = XCBuildConfiguration; baseConfigurationReference = 27D0558A2358FA67009BB0A1 /* Project_Release_EE.xcconfig */; @@ -2154,60 +1908,6 @@ }; name = Release_EE; }; - 27D055882358F9FA009BB0A1 /* Release_EE */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_STYLE = Automatic; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = N2Q372V7W2; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release_EE; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -2255,17 +1955,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 2779ED5222E287FB0026ACD0 /* Build configuration list for PBXLegacyTarget "Python" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2779ED5322E287FB0026ACD0 /* Debug */, - 27D055722358F9DF009BB0A1 /* Debug_EE */, - 2779ED5422E287FB0026ACD0 /* Release */, - 27D055882358F9FA009BB0A1 /* Release_EE */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 27984E1B2249A127000FE777 /* Build configuration list for PBXNativeTarget "CBL_C Framework" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/README.md b/README.md index bb403c9d..20b44a27 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,8 @@ This is a cross-platform version of the [Couchbase Lite][CBL] embedded NoSQL syn - [x] Similar to to other Couchbase Lite platforms (Java, C#, Swift, Objective-C) - [x] Clean and regular design - [x] Comes with a C++ wrapper API, implemented as inline calls to C - - [x] Experimental Python binding (made using `cffi`) - - [x] Can be bound to [other languages](#other-language-bindings) like Go or JavaScript -- [ ] Same feature set as other Couchbase Lite platforms + - [x] Can be bound to [other languages](#other-language-bindings) like Python, Go, or JavaScript +- [x] Same feature set as other Couchbase Lite platforms - [x] Schemaless JSON data model - [x] Standard CRUD operations - [x] Efficient binary blob support @@ -38,7 +37,6 @@ This is a cross-platform version of the [Couchbase Lite][CBL] embedded NoSQL syn - ARM or x86 - Hundreds of MB RAM, hundreds of MHz CPU, tens of MB storage - Linux-based OS - - Stretch goal: Simpler embedded kernels like mbedOS or ESP-IDF. ## Examples @@ -72,7 +70,7 @@ CBLDocument_Release(readDoc); ```cpp // Open a database: -cbl::Database db(FLSTR("my-db"), {FLSTR("/tmp")}); +cbl::Database db(kDatabaseName, {"/tmp"}); // Create a document: cbl::MutableDocument doc("foo"); @@ -198,8 +196,12 @@ To run the unit tests: ## Other Language Bindings -* **C++**: Already included; see [`include/cbl++`](https://github.com/couchbase/couchbase-lite-C/tree/master/include/cbl%2B%2B), but not supported -* **Python**: [Included](bindings/python/README.md) but unsupported -* **Nim**: [Included](bindings/nim/README.md) but unsupported -* **Rust**: [Included](bindings/rust/README.md) but unsupported -* **Go** (Golang): [Third-party, in progress](https://github.com/svr4/couchbase-lite-cgo). +All of these (even C++) have no official support by Couchbase. + +If you've created a language binding, please let us know by filing an issue, or a PR that updates the list below. + +* **C++**: Already included; see [`include/cbl++`](https://github.com/couchbase/couchbase-lite-C/tree/master/include/cbl%2B%2B) +* **Go** (Golang): [Third-party, in progress](https://github.com/svr4/couchbase-lite-cgo) +* **Nim**: [couchbase-lite-nim](https://github.com/couchbaselabs/couchbase-lite-nim) +* **Python**: [couchbase-lite-python](https://github.com/couchbaselabs/couchbase-lite-python) +* **Rust**: [couchbase-lite-rust](https://github.com/couchbaselabs/couchbase-lite-rust) diff --git a/Xcode/build_python.sh b/Xcode/build_python.sh deleted file mode 100755 index c988a655..00000000 --- a/Xcode/build_python.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash -e - -PY_SRC="$SRCROOT/python/CouchbaseLite" -PY_DST="$TARGET_BUILD_DIR/python/CouchbaseLite" - -# TEMP!! Fixes compatibility issue with distutils -export MACOSX_DEPLOYMENT_TARGET=10.14 - -# Create and populate the Python build directory -rm -rf "$PY_DST" -mkdir -p "$PY_DST" -cd "$PY_DST" -cp "$PY_SRC"/*.py . - -/usr/local/bin/python3 "$SRCROOT/python/BuildPyCBL.py" \ - --srcdir "$SRCROOT" \ - --libdir "$TARGET_BUILD_DIR" - -echo "Python package created at $PY_DST" diff --git a/bindings/nim/CouchbaseLite.nimble b/bindings/nim/CouchbaseLite.nimble deleted file mode 100644 index 840f96c7..00000000 --- a/bindings/nim/CouchbaseLite.nimble +++ /dev/null @@ -1,11 +0,0 @@ -# Package - -version = "0.1.0" -author = "Couchbase, Inc." -description = "Couchbase Lite embedded NoSQL database (Nim bindings)" -license = "Apache-2.0" -srcDir = "src" - -# Dependencies - -requires "nim >= 1.2.0" diff --git a/bindings/nim/README.md b/bindings/nim/README.md deleted file mode 100644 index a7210d1e..00000000 --- a/bindings/nim/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# Nim Language Bindings For Couchbase Lite - -10 May 2020 - -This directory is a package containing a [Couchbase Lite][CBL] API binding for the [Nim -language][NIM]. - -It's still in early development. It's incomplete, has only had some informal testing, and that -only on macOS. Also I (Jens) am a newbie at Nim and may not be doing things the write way. -Feedback gratefully accepted. - -## Building - -**_"Some assembly required..."_** - -You first need to build Couchbase Lite For C (the root of this repo) with CMake, by running the -`build.sh` script in the repo root directory. That will produce the shared library. - - $ cd ../.. - $ ./build.sh - -Symlink or copy the library into this directory. - - $ cd bindings/nim - $ ln -s ../../build_cmake/libcblite.dylib . - -After that, you can use [Nimble][NIMBLE] to build and run: - - $ nimble test - -When compiling on Linux system remember to set `LD_LIBRARY_PATH` to point to the -directory where `libcblite.so` exists. If you followed the above steps -this would look like this: - - $ LD_LIBRARY_PATH=. nimble test - -Without the symlink you can also do: - - $ LD_LIBRARY_PATH=../../build_cmake nimble test - -The supplied `CouchbaseLite.nimble` file is used to allow Nimble to run the -tests. If you want to try the bindings out you can create a `.nim` -file in this directory and add `bin = @[""]` to the -`CouchbaseLite.nimble` file. You can now run `nimble build` or `nimble run` to -build or build and run your file with the bindings. - -## Learning - -I've copied the doc-comments from the C API into the Nim files. But Couchbase Lite is fairly -complex, so if you're not already familiar with it, you'll want to start by reading through -the [official documentation][CBLDOCS]. - -The Nim API is mostly method-for-method compatible with the languages documented there, except -down at the document property level (dictionaries, arrays, etc.) where I haven't yet written -compatible bindings. For those APIs you can check out the document "[Using Fleece][FLEECE]". - -## Using - -[NIM]: https://nim-lang.org/ -[CBL]: https://www.couchbase.com/products/lite -[NIMBLE]: https://github.com/nim-lang/nimble#readme -[CBLDOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html -[FLEECE]: https://github.com/couchbaselabs/fleece/wiki/Using-Fleece diff --git a/bindings/nim/monitor.sh b/bindings/nim/monitor.sh deleted file mode 100755 index 5d3c44d3..00000000 --- a/bindings/nim/monitor.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash -e -# -# This uses the `entr` tool to re-run `nimble test` whenever any source file is saved. -# Very handy to leave running in a terminal window while you work. -# You can get `entr` from or your friendly local package manager. - -find . -name '*.nim' | entr -c -s "nimble test" diff --git a/bindings/nim/nim.cfg b/bindings/nim/nim.cfg deleted file mode 100644 index 7a96dd74..00000000 --- a/bindings/nim/nim.cfg +++ /dev/null @@ -1,6 +0,0 @@ ---path:src ---path:binding ---outdir:bin ---hints:off -#-d:nimDebugDlOpen -#--debugger:native diff --git a/bindings/nim/src/CouchbaseLite.nim b/bindings/nim/src/CouchbaseLite.nim deleted file mode 100644 index 059d5819..00000000 --- a/bindings/nim/src/CouchbaseLite.nim +++ /dev/null @@ -1,33 +0,0 @@ -# Couchbase Lite bindings for Nim; main module -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - - -import CouchbaseLite/database -import CouchbaseLite/document -import CouchbaseLite/errors -import CouchbaseLite/fleece -import CouchbaseLite/listener -import CouchbaseLite/query -import CouchbaseLite/replicator - -export database -export document -export errors -export fleece -export listener -export query -export replicator diff --git a/bindings/nim/src/CouchbaseLite/database.nim b/bindings/nim/src/CouchbaseLite/database.nim deleted file mode 100644 index bd277d94..00000000 --- a/bindings/nim/src/CouchbaseLite/database.nim +++ /dev/null @@ -1,146 +0,0 @@ -# Couchbase Lite Database class -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/errors -import CouchbaseLite/private/cbl - -import sugar - -{.experimental: "notnil".} - - -type - DatabaseObj* {.requiresInit.} = object - handle: CBLDatabase not nil - Database* = ref DatabaseObj not nil ## A connection to an open database. - - -proc `=destroy`(d: var DatabaseObj) = - release(d.handle) - -proc `=`(dst: var DatabaseObj, src: DatabaseObj) {.error.} - - -type - DatabaseFlag* {.size: sizeof(cint).} = enum - create, ## Create the database if it doesn't exist - readOnly, ## Open database read-only - noUpgrade ## Disable upgrading an older-version database - DatabaseFlags* = set[DatabaseFlag] ## Flags for how to open a database. - - EncryptionAlgorithm* = enum - ## Database encryption algorithms (available only in the Enterprise - ## Edition). - none = 0, - AES256 - EncryptionKey* = object - ## Encryption key specified in a DatabaseConfiguration. - algorithm*: EncryptionAlgorithm ## Encryption algorithm - bytes*: array[32, uint8] ## Raw key data - - DatabaseConfiguration* = object - ## Database configuration options. - directory*: string ## The parent directory of the database - flags*: DatabaseFlags ## Options for opening the database - encryptionKey*: ref EncryptionKey ## The database's encryption key (if any) - - -proc openDB(name: string; configP: ptr CBLDatabaseConfiguration): Database = - var err: CBLError - let dbRef = cbl.openDatabase(name, configP, err) - if dbRef == nil: - throw(err) - else: - return Database(handle: dbRef) - -proc openDatabase*(name: string; config: DatabaseConfiguration): Database = - ## Opens a database, or creates it if it doesn't exist yet, returning a new - ## Database instance. The database is closed when this object is - ## garbage-collected, or when you call ``close`` on it.It's OK to open the - ## same database file multiple times. Each Database instance is independent - ## of the others (and must be separately closed.) - var cblConfig = CBLDatabaseConfiguration( - directory: config.directory, - flags: cast[CBLDatabaseFlags](config.flags)) - var cblKey: CBLEncryptionKey - if config.encryptionKey != nil: - cblKey.algorithm = cast[CBLEncryptionAlgorithm]( - config.encryptionKey.algorithm) - cblKey.bytes = config.encryptionKey.bytes - cblConfig.encryptionKey = addr cblKey - return openDB(name, addr cblConfig) - -proc openDatabase*(name: string): Database = - ## Opens or creates a database, using the default configuration. - return openDB(name, nil) - -proc databaseExists*(name: string; inDirectory: string): bool = - ## Returns true if a database with the given name exists in the given - ## directory. - cbl.databaseExists(name, inDirectory) - -proc deleteDatabase*(name: string; inDirectory: string): bool {.discardable.} = - ## Deletes a database file. If the database file is open, an error is - ## returned. - var err: CBLError - if cbl.deleteDatabase(name, inDirectory, err): - return true - elif err.code == 0: - return false - else: - throw(err) - -proc name*(db: Database): string = - ## The database's name (without the ``.cblite2`` extension.) - $(db.handle.name) - -proc path*(db: Database): string = - ## The full path to the database file. - $(db.handle.path) - -proc count*(db: Database): uint64 = - ## The number of documents in the database. (Deleted documents don't count.) - db.handle.count - -proc close*(db: Database) = - ## Closes the database. You must not call this object any more afterwards. - checkBool( (err) => cbl.close(db.handle, err[])) - -proc delete*(db: Database) = - ## Closes and deletes a database. If there are any other open connections to - ## the database, an error is thrown. - checkBool( (err) => cbl.delete(db.handle, err[])) - -proc compact*(db: Database) = - ## Compacts a database file, freeing up disk space. - checkBool( (err) => cbl.compact(db.handle, err[])) - -proc inBatch*(db: Database; fn: proc()) = - ## Performs the callback proc within a batch operation, similar to a - ## transaction. Multiple writes are much faster if done inside a batch. - ## Changes wil not be visible to other Database instances until the batch - ## operaton ends. Batch operations can nest. Changes are not committed until - ## the outer batch ends. - checkBool( (err) => cbl.beginBatch(db.handle, err[])) - defer: checkBool( (err) => cbl.endBatch(db.handle, err[])) - fn() - -proc internal_handle*(db: Database): CBLDatabase = - # INTERNAL ONLY - db.handle - -#TODO: Listeners diff --git a/bindings/nim/src/CouchbaseLite/document.nim b/bindings/nim/src/CouchbaseLite/document.nim deleted file mode 100644 index 97ad7e25..00000000 --- a/bindings/nim/src/CouchbaseLite/document.nim +++ /dev/null @@ -1,264 +0,0 @@ -# Couchbase Lite Document class -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/[database, errors, fleece] -import CouchbaseLite/private/cbl - -import options -import sugar - -{.experimental: "notnil".} - - -type Database = database.Database - -type - DocumentObj* {.requiresInit.} = object of RootObj - handle: CBLDocument not nil - db: Option[Database] - Document* = ref DocumentObj - ## An in-memory copy of a document. - ## This object does not allow you to change the document; - ## the subclass ``MutableDocument`` does. - - - MutableDocumentObj* {.requiresInit.} = object of DocumentObj - MutableDocument* = ref MutableDocumentObj - ## An in-memory copy of a document that can be changed and then saved back - ## to the database. - - ConcurrencyControl* {.pure.} = - enum LastWriteWins = 0, FailOnConflict - ## Conflict-handling options when saving or deleting a document. - - SaveConflictHandler* = - proc (documentBeingSaved: MutableDocument; - conflictingDocument: Document): bool - ## Custom conflict handler for use when saving or deleting a document. - ## This handler is called if the save would cause a conflict, i.e. if - ## the document in the database has been updated (probably by a pull - ## replicator, or by application code on another thread) since it was - ## loaded into the Document being saved. - - Timestamp = CBLTimestamp - ## A moment in time, used by the document expiration API. - ## Interpreted as milliseconds since the Unix epoch (Jan 1 1970.) - -proc `=destroy`(d: var DocumentObj) = - release(d.handle) - -proc `=`(dst: var DocumentObj; src: DocumentObj) {.error.} = - echo "(can't copy a Document)" - -proc mustBeInDatabase(doc: Document; db: Database) = - if doc.db != some(db): throw(ErrorCode.InvalidParameter) - -#%%% Database's document-related methods: - -proc getDocument*(db: Database; docID: string): Document = - ## Reads a document from the database, creating a new (immutable) Document - ## object. If you are reading the document in order to make changes to it, - ## call ``getMutableDocument`` instead. - let doc = cbl.getDocument(db.internal_handle, docID) - if doc != nil: - return Document(handle: doc, db: some(db)) - -proc `[]`*(db: Database; docID: string): Document = db.getDocument(docID) - -proc getMutableDocument*(db: Database; docID: string): MutableDocument = - ## Reads a document from the database, in mutable form that can be updated - ## and saved. - let doc = getMutableDocument(db.internal_handle, docID) - if doc != nil: - return MutableDocument(handle: doc, db: some(db)) - -type SaveContext = tuple [doc: MutableDocument; handler: SaveConflictHandler] - -proc saveCallback(context: pointer; documentBeingSaved, - conflictingDocument: CBLDocument): bool = - let ctx = (cast[ptr SaveContext](context))[] - var conflicting: Document = nil - if conflictingDocument != nil: - conflicting = Document(handle: conflictingDocument, db: ctx.doc.db) - return ctx.handler(ctx.doc, conflicting) - -proc saveDocument*(db: Database; doc: MutableDocument; - concurrency: ConcurrencyControl = LastWriteWins): Document {.discardable.} = - ## Saves a (mutable) document to the database. - ## If a conflicting revision has been saved since the document was loaded, - ## the ``concurrency`` parameter specifies whether the save should fail, or - ## the conflicting revision should be overwritten with the revision being - ## saved. If you need finer-grained control, call the version of this method - ## that takes a ``SaveConflictHandler`` instead. - var err: CBLError - let newDoc = db.internal_handle.saveDocument(doc.handle, cast[ - CBLConcurrencyControl](concurrency), err) - if newDoc == nil: - raise mkError(err) - else: - return Document(handle: newDoc, db: some(db)) - -proc saveDocument*(db: Database; doc: MutableDocument; - handler: SaveConflictHandler): Document {.discardable.} = - ## Saves a (mutable) document to the database. - ## If a conflicting revision has been saved since the document was loaded, - ## the callback is called with (a) the document being saved, and (b) the - ## conflicting version already in the database (which may be nil, if the - ## conflict is that the document was deleted.) The callback should make the - ## appropriate changes to the document and return ``true``, or give up and - ## return ``false``, in which case a conflict exception will be thrown. - var context: SaveContext = (doc, handler) - var err: CBLError - let newDoc = db.internal_handle.saveDocumentResolving(doc.handle, - saveCallback, addr context, err) - if newDoc == nil: - throw(err) - else: - return Document(handle: newDoc, db: some(db)) - -proc deleteDocument*(db: Database; doc: Document; - concurrency: ConcurrencyControl = LastWriteWins) {.discardable.} = - ## Deletes a document from the database. Deletions are replicated, so - ## document metadata will be left behind that can later be pushed by the - ## replicator. - doc.mustBeInDatabase(db) - checkBool( (err) => doc.handle.delete(cast[CBLConcurrencyControl]( - concurrency), err[])) - -proc purgeDocument*(db: Database; doc: Document) = - ## Purges a document, removing all traces of the document from the database. - ## Purges are *not* replicated. If the document is changed on a server, it - ## will be re-created when pulled. - doc.mustBeInDatabase(db) - checkBool( (err) => doc.handle.purge(err[])) - -proc purgeDocument*(db: Database; docID: string): bool = - ## Purges a document, removing all traces of the document from the database. - ## Purges are *not* replicated. If the document is changed on a server, it - ## will be re-created when pulled. If no document with this ID exists, - ## returns false. - var err: CBLError - if db.internal_handle.purgeDocumentByID(docID, err): - return true - elif err.code == 0: - return false - else: - throw(err) - -proc getDocumentExpiration*(db: Database; docID: string): Timestamp = - ## Returns the time, if any, at which a given document will expire and be - ## purged. No expiration is indicated by a zero return value. Documents don't - ## normally expire; you have to set an expiration time yourself. - var err: CBLError - let t = db.internal_handle.getDocumentExpiration(docID, err) - if t < 0: throw(err) - return t - -proc setDocumentExpiration*(db: Database; docID: string; - expiration: Timestamp) = - ## Sets a document's expiration time, or clears it if the timestamp is zero. - checkBool( (err) => db.internal_handle.setDocumentExpiration(docID, - expiration, err[])) - - -#%%% Document accessors: - -proc id*(doc: Document): string = - ## The document's ID in the database. - $(doc.handle.id) - -proc revisionID*(doc: Document): string = - ## The document's revision ID, which is a short opaque string that's - ## guaranteed to be unique to every change made to the document. If the - ## document doesn't exist yet, returns an empty string. - $(doc.handle.revisionID) - -proc sequence*(doc: Document): uint64 = - ## Returns a document's current *sequence* in the local database. - ## This number increases every time the document is saved, and a more - ## recently saved document will have a greater sequence number than one saved - ## earlier, so sequences may be used as an abstract 'clock' to tell relative - ## local modification times. - doc.handle.sequence - - -#%%% Document properties: - -proc properties*(doc: Document): Dict = - ## The document's properties, a key/value dictionary. - ## This object is immutable; the subclass ``MutableDocument`` returns a - ## mutable Dict. - doc.handle.properties - -proc `[]`*(doc: Document; key: string): Value = - ## Returns the value of a property. Equivalent to ``doc.properties[key]``. - doc.properties[key] - -proc `[]`*(doc: Document; key: var DictKey): Value = - ## Returns the value of a property. Equivalent to ``doc.properties[key]``. - doc.properties[key] - -proc propertiesAsJSON*(doc: Document): cstring = - ## Returns a document's properties as a JSON string. - ## This can be useful for interoperating with other APIs that can operate on - ## JSON, but be aware that the extra encoding and parsing will hurt - ## performance; it's best to use the Fleece API directly. - doc.handle.propertiesAsJSON - - -#%%% MutableDicument: - -proc mkDoc(doc: CBLDocument): MutableDocument = - if doc == nil: - throw(CBLError(domain: CBLDomain, code: int32( - CBLErrorCode.ErrorMemoryError))) - else: - assert doc.mutableProperties != nil # Make sure it's mutable - return MutableDocument(handle: doc, db: none(Database)) - -proc newDocument*(): MutableDocument = - ## Creates a new, empty document in memory. It will not be added to a - ## database until saved. Its ID will be a randomly-generated UUID. - mkDoc(cbl.newDocument(nil)) - -proc newDocument*(docID: string): MutableDocument = - ## Creates a new, empty document in memory. It will not be added to a - ## database until saved. - mkDoc(cbl.newDocument(docID)) - -proc mutableCopy*(doc: Document): MutableDocument = - ## Creates a new MutableDocument instance that refers to the same document as - ## the original. If the original document is mutable and has unsaved changes, - ## the new one will also start out with the same changes; but mutating one - ## document thereafter will not affect the other. - mkDoc(doc.handle.mutableCopy()) - -proc properties*(doc: MutableDocument): MutableDict = - ## Returns a mutable document's properties as a mutable dictionary. - ## You may modify this dictionary and then call ``Database.saveDocument`` to - ## persist the changes. - wrap(doc.handle.mutableProperties) - -proc `[]=`*(doc: MutableDocument; key: string; value: Settable) = - ## Sets the value of a property. Equivalent to ``doc.properties[key] = - ## value``. - doc.properties[key] = value - -proc `propertiesAsJSON=`*(doc: MutableDocument; json: string) = - ## Sets the document's properties from the JSON string, which must contain an - ## object. - checkBool( (err) => doc.handle.setPropertiesAsJSON(json, err[])) diff --git a/bindings/nim/src/CouchbaseLite/errors.nim b/bindings/nim/src/CouchbaseLite/errors.nim deleted file mode 100644 index 1c01aebd..00000000 --- a/bindings/nim/src/CouchbaseLite/errors.nim +++ /dev/null @@ -1,141 +0,0 @@ -# Couchbase Lite exception classes -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/fleece -import CouchbaseLite/private/cbl - -import strformat -import sugar - -{.experimental: "notnil".} - - -type - - ErrorCode* = enum ## Couchbase Lite error codes, found in ``Error`` objects. - AssertionFailed = 1, ## Internal assertion failure - Unimplemented, ## Oops, an unimplemented API call - UnsupportedEncryption, ## Unsupported encryption algorithm - BadRevisionID, ## Invalid revision ID syntax - CorruptRevisionData, ## Revision contains corrupted/unreadable data - NotOpen, ## Database/KeyStore/index is not open - NotFound, ## Document not found - Conflict, ## Document update conflict - InvalidParameter, ## Invalid function parameter or struct value - UnexpectedError, ## Internal unexpected C++ exception - CantOpenFile, ## Database file can't be opened; may not exist - IOError, ## File I/O error - MemoryError, ## Memory allocation failed (out of memory?) - NotWriteable, ## File is not writeable - CorruptData, ## Data is corrupted - Busy, ## Database is busy/locked - NotInTransaction, ## Function must be called while in a transaction - TransactionNotClosed, ## Database can't be closed while a transaction is open - Unsupported, ## Operation not supported in this database - NotADatabaseFile, ## File is not a database, or encryption key is wrong - WrongFormat, ## Database exists but not in the format/storage requested - Crypto, ## Encryption/decryption error - InvalidQuery, ## Invalid query - MissingIndex, ## No such index, or query requires a nonexistent index - InvalidQueryParam, ## Unknown query param name, or param number out of range - RemoteError, ## Unknown error from remote server - DatabaseTooOld, ## Database file format is older than what I can open - DatabaseTooNew, ## Database file format is newer than what I can open - BadDocID, ## Invalid document ID - CantUpgradeDatabase ## DB can't be upgraded (might be unsupported dev version) - - NetworkErrorCode* = enum ## Network error codes, found in ``NetworkError`` objects. - DNSFailure = 1, ## DNS lookup failed - UnknownHost, ## DNS server doesn't know the hostname - Timeout, ## No response received before timeout - InvalidURL, ## Invalid URL - TooManyRedirects, ## HTTP redirect loop - TLSHandshakeFailed, ## Low-level error establishing TLS - TLSCertExpired, ## Server's TLS certificate has expired - TLSCertUntrusted, ## Cert isn't trusted for other reason - TLSClientCertRequired, ## Server requires client to have a TLS certificate - TLSClientCertRejected, ## Server rejected my TLS client certificate - TLSCertUnknownRoot, ## Self-signed cert, or unknown anchor cert - InvalidRedirect, ## Attempted redirect to invalid URL - Unknown, ## Unknown networking error - TLSCertRevoked, ## Server's cert has been revoked - TLSCertNameMismatch ## Server cert's name does not match DNS name - -type - Error* = ref object of CatchableError - ## Base class for Couchbase Lite exceptions. - cblErr: CBLError - CouchbaseLiteError* = ref object of Error - ## A Couchbase Lite-defined error. See its ``code`` for details. - code*: ErrorCode - POSIXError* = ref object of Error - ## An OS error. See the ``errno`` property for the specific error (defined - ## in ````) - errno*: int - SQLiteError* = ref object of Error - ## A SQLite database error. The ``code`` is defined in ``sqlite3.h``. - code*: int - FleeceError* = ref object of Error - ## A Fleece error. - code*: FleeceErrorCode - NetworkError* = ref object of Error - ## A Couchbase Lite network-related error; see the ``code`` for details. - code*: NetworkErrorCode - WebSocketError* = ref object of Error - ## An HTTP or WebSocket error. The ``code`` is an HTTP status if less than - ## 1000, else a WebSocket status. - code*: int - -proc message*(err: Error): string = $(message(err.cblErr)) - ## Gets the message associated with an error. - -proc codeStr*(err: Error): string = - ## Returns the name of the error's code. - case err.cblErr.domain: - of CBLDomain: $(cast[CBLErrorCode](err.cblErr.code)) - of FleeceDomain: $(cast[FleeceErrorCode](err.cblErr.code)) - of NetworkDomain: $(cast[NetworkErrorCode](err.cblErr.code)) - else: &"{err.cblErr.code}" - -proc `$`*(err: Error): string = - ## Formats an Error as a string, including the message, type and code. - &"{err.message} ({err.cblErr.domain}.{err.cblErr.code}: {err.codeStr})" - -#%%%% Internal error handling utilities: - -# TODO: Avoid making these public - -proc mkError*(err: CBLError): Error = - case err.domain: - of CBLDomain: CouchbaseLiteError(cblErr: err, code: ErrorCode(err.code)) - of POSIXDomain: POSIXError(cblErr: err, errno: err.code) - of SQLiteDomain: SQLiteError(cblErr: err, code: err.code) - of FleeceDomain: FleeceError(cblErr: err, code: FleeceErrorCode(err.code)) - of NetworkDomain: NetworkError(cblErr: err, code: NetworkErrorCode(err.code)) - of WebSocketDomain: WebSocketError(cblErr: err, code: err.code) - else: CouchbaseLiteError(cblErr: err, code: ErrorCode(UnexpectedError)) - -proc throw*(err: CBLError) {.noreturn.} = - raise mkError(err) - -proc throw*(code: ErrorCode) = - throw(CBLError(domain: cbl.CBLDomain, code: int32(code))) - -proc checkBool*(fn: (ptr CBLError) -> bool) = - var err: CBLError - if not fn(addr err): - throw(err) diff --git a/bindings/nim/src/CouchbaseLite/fleece.nim b/bindings/nim/src/CouchbaseLite/fleece.nim deleted file mode 100644 index bea7753b..00000000 --- a/bindings/nim/src/CouchbaseLite/fleece.nim +++ /dev/null @@ -1,395 +0,0 @@ -# Fleece, a JSON-like structured storage format -- https://github.com/couchbaselabs/fleece -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/private/fl - - -## This is a Nim binding for the Fleece binary encoding format. -## Fleece documentation is here: https://github.com/couchbaselabs/fleece/wiki -## "Using Fleece" is the best starting point. - -#TODO: Encoder -#TODO: DeepIterator -#TODO: JSON-Delta - - -#======== TYPES - - -type FleeceErrorCode* = enum - ## Types of Fleece errors. - MemoryError = 1, ## Out of memory, or allocation failed - OutOfRange, ## Array index or iterator out of range - InvalidData, ## Bad input data (NaN, non-string key, etc.) - EncodeError, ## Structural error encoding (missing value, too many ends, etc.) - JSONError, ## Error parsing JSON - UnknownValue, ## Unparseable data in a Value (corrupt? Or from some distant future?) - InternalError, ## Something that shouldn't happen - NotFound, ## Key not found - SharedKeysStateError, ## Misuse of shared keys (not in transaction, etc.) - POSIXError, ## POSIX API call failed - Unsupported ## Operation is unsupported - -type FleeceError* = ref object of CatchableError - ## Exception thrown by Fleece functions. - code*: FleeceErrorCode - -proc throw(flCode: FLError; msg: string) = - let code = cast[FleeceErrorCode](flCode) - raise FleeceError(code: code, msg: (if msg != "": msg else: $code)) - - -type - Value* = FLValue ## A value of any type (JSON types or raw data.) May also be null/undefined. - Array* = FLArray ## An array Value (unless empty/undefined) - Dict* = FLDict ## A dictionary/map/object Value (unless empty/undefined) - - Slot* = FLSlot ## Temporary reference to a settable value in a collection - - MutableArray* = object - ## A mutable, heap-based 'subclass' of Array. - mval: FLMutableArray - MutableDict* = object - ## A mutable, heap-based 'subclass' of Dict. - mval: FLMutableDict - - ArrayObject* = Array | MutableArray - DictObject* = Dict | MutableDict - ImmutableObject* = Value | Array | Dict - MutableObject* = MutableArray | MutableDict - FleeceObject* = ImmutableObject | MutableObject - - Settable* = bool | int64 | uint64 | cfloat | cdouble | string | openarray[ - uint8] | FleeceObject - - -#======== FLEECE DOCUMENT - - -type Fleece* = object - ## A container that holds Fleece-encoded data and exposes its object tree. - doc: FLDoc - -proc `=`(self: var Fleece; other: Fleece) = - if self.doc != other.doc: - release(self.doc) - self.doc = other.doc - discard retain(self.doc) - -proc `=destroy`(self: var Fleece) = - release(self.doc) - - -type Trust* = enum - ## Whether to trust that encoded Fleece data is valid - untrusted, ## Data is untrusted; will be validated during parse (safer!) - trusted ## Data is trusted, most validation skipped (faster) - -proc parse*(data: openarray[byte]; trust: Trust = untrusted): Fleece = - ## Parses Fleece-encoded data, producing a Fleece object. - let flData = asSlice(data).copy() - let doc = fl.newDocFromResultData(flData, FLTrust(trust), nil, FLSlice()) - if doc == nil: throw(FLError.InvalidData, "Invalid Fleece data") - return Fleece(doc: doc) - -proc parseJSON*(json: string): Fleece = - ## Parses JSON data, producing a Fleece object. (JSON is always assumed - ## untrusted and will be validated. Errors cause exceptions.) - var err: FLError - let doc = fl.newDocFromJSON(asSlice(json), err) - if doc == nil: throw(err, "Invalid JSON") - return Fleece(doc: doc) - -proc root*(self: Fleece): Value = - ## The root object. This reference and all children are only valid as long as - ## this ``Fleece`` object is. - if self.doc == nil: nil else: self.doc.getRoot() -proc asArray*(self: Fleece): Array = - ## The root array, or an empty/undefined value if the root is not an Array. - ## This reference and all children are only valid as long as this ``Fleece`` - ## object is. - self.root.asArray() -proc asDict*(self: Fleece): Dict = - ## The root dictionary, or an empty/undefined value if the root is not a Dict. - ## This reference and all children are only valid as long as this ``Fleece`` - ## object is. - self.root.asDict() - - -#======== VALUE - - -proc asValue*(v: ImmutableObject): Value = cast[Value](v) -proc asValue*(a: MutableArray): Value = cast[Value](a.mval) -proc asValue*(d: MutableDict): Value = cast[Value](d.mval) - -type - Type* = enum undefined = -1, null, bool, number, string, data, array, dict - Timestamp* = FLTimestamp - -proc type*(v: Value): Type = Type(fl.getType(v)) - -proc isNumber*(v: Value): bool = v.type == Type.number -proc isInt*(v: Value): bool = fl.isInteger(v) -proc isFloat*(v: Value): bool = v.isNumber and not v.isInt -proc isString*(v: Value): bool = v.type == Type.string - -proc asInt*[T](v: Value; dflt: T): T = - if not v.isNumber: return dflt - let i = fl.asInt(v) - try: - return T(i) - except RangeError: - return if i >= 0: high(T) else: low(T) - -proc asBool*(v: Value): bool = fl.asBool(v) -proc asInt64*(v: Value): int64 = fl.asInt(v) -proc asInt*(v: Value): int = v.asInt(0) -proc asFloat*(v: Value): float = fl.asDouble(v) -proc asString*(v: Value): string = fl.asString(v).toString() -proc asData*(v: Value): seq[uint8] = fl.asData(v).toByteArray() -proc asTimestamp*(v: Value): Timestamp = fl.asTimestamp(v) - -proc asBool*(v: Value; dflt: bool): bool = - if v.type == Type.bool: fl.asBool(v) else: dflt -proc asFloat*(v: Value; dflt: float): float = - if v.isNumber: v.asFloat else: dflt -proc asString*(v: Value; dflt: string): string = - if v.isString: v.asString else: dflt -proc asTimestamp*(v: Value; dflt: Timestamp): Timestamp = - let t = fl.asTimestamp(v) - if ord(t) > 0: t else: dflt - -proc `==`*(v: Value; n: int64): bool = v.isInt and v.asInt == n -proc `==`*(v: Value; n: float64): bool = v.isNumber and v.asFloat == n -proc `==`*(v: Value; str: string): bool = v.isString and v.asString == str - -type - ToJSONFlag* = enum JSON5, canonical - ToJSONFlags* = set[ToJSONFlag] - -proc toJSON*(v: FleeceObject; flags: ToJSONFlags = {}): string = - ## Converts any value to a JSON string. Returns "undefined" if the value is - ## undefined. - fl.toJSONX(v.asValue, ToJSONFlag.JSON5 in flags, ToJSONFlag.canonical in - flags).toString() - -proc `$`*(v: FleeceObject): string = toJSON(v, {}) - -#======== ARRAY - -proc asArray*(a: Array): Array = a -proc asArray*(a: MutableArray): Array = cast[Array](a.mval) -proc asArray*(v: Value): Array = fl.asArray(v) - -proc len*(a: ArrayObject): uint32 = fl.count(a.asArray) -proc isEmpty*(a: ArrayObject): bool = fl.isEmpty(a.asArray) -proc get*(a: ArrayObject; i: uint32): Value = fl.get(a.asArray, i) - -proc `[]`*(a: Array; i: uint32): Value = a.get(i) -proc `[]`*(v: Value; i: uint32): Value = v.asArray[i] -proc `[]`*(f: Fleece; i: uint32): Value = f.asArray[i] - -iterator items*(a: ArrayObject): Value = - ## Array iterator. - var i: FLArrayIterator - a.asArray.begin(addr i) - while true: - let v = getValue(addr i) - if v == nil: break - yield v - if not next(addr i): break - - -#======== DICT - -proc asDict*(d: Dict): Dict = d -proc asDict*(d: MutableDict): Dict = cast[Dict](d.mval) -proc asDict*(v: Value): Dict = fl.asDict(v) - -proc len*(d: DictObject): uint32 = fl.count(d.asDict) -proc isEmpty*(d: DictObject): bool = fl.isEmpty(d.asDict) -proc get*(d: DictObject; key: string): Value = fl.get(d.asDict, key.asSlice) - -proc `[]`*(d: DictObject; key: string): Value = d.get(key) -proc `[]`*(v: Value; key: string): Value = v.asDict[key] -proc `[]`*(f: Fleece; key: string): Value = f.asDict[key] - -iterator items*(d: DictObject): tuple [key: string; value: Value] = - ## Dict iterator. - var i: FLDictIterator - d.asDict.begin(addr i) - while true: - let v = getValue(addr i) - if v == nil: break - let k = getKeyString(addr i).toString() - yield (k, v) - if not next(addr i): break - - -type DictKey* {.requiresInit.} = object - ## A DictKey is a cached dictionary key. It works just like a string, but it's - ## faster because it can cache the internal representation of the key. - ## DictKey instances have to be created by the ``dictKey`` function. - flkey: FLDictKey - -proc dictKey*(key: string): DictKey = - ## Creates a DictKey representing the given string. - DictKey(flkey: fl.init(key.asSlice())) - -proc `$`*(key: var DictKey): string = - fl.getString(addr key.flkey).toString - -proc get*(d: DictObject; key: var DictKey): Value = - fl.getWithKey(d.asDict, addr key.flkey) - -proc `[]`*(d: DictObject; key: var DictKey): Value = d.asDict.get(key) -proc `[]`*(v: Value; key: var DictKey): Value = v.asDict[key] -proc `[]`*(f: Fleece; key: var DictKey): Value = f.asDict[key] - - -type KeyPath* {.requiresInit.} = object - ## KeyPath is like a multi-level DictKey: it's initialized with a path string - ## like "coords.lat" or "contacts[2].lastName" and can then be used like a key - ## to access the value at that path in any object. If any component in the - ## path is missing, the result is a null/undefined Value. - handle: FLKeyPath - -proc `=`(self: var KeyPath; other: KeyPath) {.error.} = - free(self.handle) - self.handle = other.handle - -proc `=destroy`(self: var KeyPath) = - free(self.handle) - -proc keyPath*(path: string): KeyPath = - ## Creates a new KeyPath from a path string like "coords.lat" or - ## "contacts[2].lastName". Throws an exception if the path syntax is invalid. - var err: FLError - let h = fl.newKeyPath(path.asSlice(), err) - if h == nil: throw(err, "Invalid KeyPath") - return KeyPath(handle: h) - -proc eval*(path: KeyPath; v: Value): Value = - path.handle.eval(v) - - -#======== MUTABLE ARRAY - - -type - CopyFlag = enum ## Options for making (mutable) copies of Fleece values. - deepCopy, ## Copy the entire object tree from here - copyImmutables ## Even copy immutable values from Fleece data - CopyFlags = set[CopyFlag] - -proc `=`(self: var MutableArray; other: MutableArray) = - if self.mval != other.mval: - release(self.mval) - self.mval = other.mval - discard retain(self.mval) - -proc `=destroy`(self: var MutableArray) = - release(self.mval) - -proc newMutableArray*(): MutableArray = - ## Creates an empty mutable array. Unlike the immutable values that point into - ## Fleece-formatted data, this object is not dependent on a container and - ## stays valid as long as you have a reference to it. - MutableArray(mval: fl.newMutableArray()) - -proc mutableCopy*(a: Array; flags: CopyFlags = {}): MutableArray = - ## Makes a mutable copy of an array. - MutableArray(mval: a.mutableCopy(cast[fl.CopyFlags](flags))) - -proc wrap*(a: FLMutableArray): MutableArray = - MutableArray(mval: retain(a)) - -proc source*(a: MutableArray): Array = - ## If this is a mutable copy of an immutable Array, returns the original. - a.mval.getSource() -proc isChanged*(a: MutableArray): bool = - ## Returns true if this array has been modified since created. - a.mval.isChanged() - -# (extra stuff for Slot to enable use of the Settable type) -proc set(s: Slot; v: string) = set(s, v.asSlice()) -proc set(s: Slot; v: openarray[uint8]) = setData(s, v.asSlice()) -proc set(s: Slot; v: FleeceObject) = set(s, v.asValue()) - -proc set*(a: MutableArray; index: uint32; value: Settable) = - ## Stores a value at an existing (zero-based) index in a mutable array. - a.mval.set(index).set(value) -proc `[]=`*(a: MutableArray; index: uint32; value: Settable) = - ## Stores a value at an existing (zero-based) index in a mutable array. - a.mval.set(index).set(value) -proc insert*(a: MutableArray; value: Settable; index: uint32) = - ## Inserts a value at a (zero-based) index in a mutable array. - ## Any items at that index and higher are pushed up by one. - a.mval.insert(index).set(value) -proc add*(a: MutableArray; value: Settable) = - ## Appends a value to the end of a mutable array. - a.mval.append().set(value) -proc delete*(a: MutableArray; index: uint32) = - ## Removes a value from a mutable array. Any items at higher indexes move down - ## one. - a.mval.remove(index, 1) - - -#======== MUTABLE DICT - - -proc `=`(self: var MutableDict; other: MutableDict) = - if self.mval != other.mval: - release(self.mval) - self.mval = other.mval - discard retain(self.mval) - -proc `=destroy`(self: var MutableDict) = - release(self.mval) - -proc newMutableDict*(): MutableDict = - ## Creates an empty mutable dictionary. Unlike the immutable values that point - ## into Fleece-formatted data, this object is not dependent on a container and - ## stays valid as long as you have a reference to it. - MutableDict(mval: fl.newMutableDict()) - -proc mutableCopy*(d: Dict; flags: CopyFlags = {}): MutableDict = - ## Makes a mutable copy of a dictionary. - MutableDict(mval: d.mutableCopy(cast[fl.CopyFlags](flags))) - -proc wrap*(d: FLMutableDict): MutableDict = - MutableDict(mval: retain(d)) - -proc source*(d: MutableDict): Dict = - ## If this is a mutable copy of an immutable Dict, returns the original. - d.mval.getSource() -proc isChanged*(d: MutableDict): bool = - ## Returns true if this array has been modified since created. - d.mval.isChanged() - -proc set*(d: MutableDict; key: string; value: Settable) = - ## Stores a value for a key in a mutable dictionary. - ## Any prior value for that key is replaced. - d.mval.set(key.asSlice()).set(value) -proc `[]=`*(d: MutableDict; key: string; value: Settable) = - ## Stores a value for a key in a mutable dictionary. - ## Any prior value for that key is replaced. - d.mval.set(key.asSlice()).set(value) -proc delete*(d: MutableDict; key: string) = - ## Removes the value, if any, for a key in a mutable dictionary. - d.mval.remove(key.asSlice()) diff --git a/bindings/nim/src/CouchbaseLite/listener.nim b/bindings/nim/src/CouchbaseLite/listener.nim deleted file mode 100644 index 9315a0f1..00000000 --- a/bindings/nim/src/CouchbaseLite/listener.nim +++ /dev/null @@ -1,33 +0,0 @@ -# Couchbase Lite listener token -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/private/cbl - -{.experimental: "notnil".} - - -type - ListenerToken* = object - ## A reference to a registered listener callback. When this object goes out - ## of scope, the listener is removed and the callback will no longer be - ## called. - handle: CBLListenerToken not nil - -proc `=destroy`(t: var ListenerToken) = - remove(t.handle) - -proc `=`(dst: var ListenerToken, src: ListenerToken) {.error.} diff --git a/bindings/nim/src/CouchbaseLite/private/cbl.c2nim b/bindings/nim/src/CouchbaseLite/private/cbl.c2nim deleted file mode 100644 index 63805820..00000000 --- a/bindings/nim/src/CouchbaseLite/private/cbl.c2nim +++ /dev/null @@ -1,55 +0,0 @@ -// Definitions for c2nim to parse CouchbaseLite headers - -#skipinclude -//#skipcomments - -#def FLPURE -#def FLAPI -#def FLNONNULL -#assumendef FL_IMPL -#assumendef DOXYGEN_PARSING -#assumendef CMAKE -#assumendef __OBJC__ -#assumedef FL_BINDING - -#def CBL_CORE_API -#def CBLAPI -#def CBL_ENUM(_type, _name) enum _name _name; enum _name -#def CBL_OPTIONS(_type, _name) enum _name _name; enum _name -#def CBLINLINE -#def _cbl_nonnull -#def _cbl_returns_nonnull -#def _cbl_warn_unused -#def __printflike(fmtarg, firstvararg) -#def CBL_REFCOUNTED(TYPE,NAME) - -#assumedef CBL_BINDING -#assumendef COUCHBASE_ENTERPRISE - - -// Exceptions to name mangling: -#mangle CBLDomain CBLDomain - -// CBL Name mangling: -#mangle "^'CBL'{[A-Z][a-zA-Z]*}'_New'" "New$1" -#mangle "^'CBL'{[A-Z][a-zA-Z]*}'_Create'" "Create$1" -#mangle "^'CBL'{[A-Z][a-zA-Z]*}'_Open'$" "Open$1" -#mangle "^'CBL'{[A-Z][a-zA-Z]*}'_Get'$" "Get$1" -#mangle "^'CBL'[A-Z][a-zA-Z]*'_'{.*}" "$1" - -#mangle "^'CBL_'{[a-z]*}" "$1" -#mangle "^'CBL'{[a-z]*}" "$1" -#mangle "^'kCBL'{[a-z]*}" "k$1" - -// Fleece name mangling: -#mangle "^'FL'{[A-Z][a-zA-Z]*}'_New'" "New$1" -#mangle "^'FL'{[A-Z][a-zA-Z]*}'_Create'" "Create$1" -#mangle "^'FL'{[A-Z][a-zA-Z]*}'_New'$" "Open$1" -#mangle "^'FL'[A-Z][a-zA-Z]*'_'{.*}" "$1" - -#mangle "^'FL_'{[a-z]*}" "$1" -#mangle "^'FL'{[a-z]*}" "$1" -#mangle "^'kFL'{[a-z]*}" "k$1" - -# Nim does not allow leading underscores in identifiers -#mangle "^'_'{.*}" "Internal$1" \ No newline at end of file diff --git a/bindings/nim/src/CouchbaseLite/private/cbl.nim b/bindings/nim/src/CouchbaseLite/private/cbl.nim deleted file mode 100644 index 52bc4be8..00000000 --- a/bindings/nim/src/CouchbaseLite/private/cbl.nim +++ /dev/null @@ -1,1421 +0,0 @@ -## *** NOTE: DO NOT MACHINE-UPDATE THIS FILE *** -## -## This started out as a machine-generated file (produced by `gen-bindings.sh`), -## but it has been hand-edited to fix issues that kept it from compiling. -## -## If you run the script again, it will generate a _new_ file `CouchbaseLite-new.nim`. -## You'll need to merge new/changed declarations from that file into this one, by hand. -## -## Status: Up-to-date as of 5 May 2020, commit 036cd9f7 "Export kCBLAuthDefaultCookieName...", -## except I've left out the new "_s"-suffixed alternate functions, which Nim doesn't need. - - -when defined(Linux): - {.push dynlib: "libcblite.so".} -elif defined(MacOS) or defined(MacOSX): - {.push dynlib: "libcblite.dylib".} -elif defined(Windows): - {.push dynlib: "cblite.dll".} - - -## -## CBLBase.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -import fl - -## \defgroup errors Errors -## Types and constants for communicating errors from API calls. -## CBLError domains, serving as namespaces for numeric error codes. -type - CBLErrorDomain* {.size: sizeof(cint).} = enum - CBLDomain = 1, ## code is a Couchbase Lite error code; see \ref CBLErrorCode - POSIXDomain, ## code is a POSIX `errno`; see "errno.h" - SQLiteDomain, ## code is a SQLite error; see "sqlite3.h" - FleeceDomain, ## code is a Fleece error; see "FleeceException.h" - NetworkDomain, ## code is a network error; see \ref CBLNetworkErrorCode - WebSocketDomain, ## code is a WebSocket close code (1000...1015) or HTTP error (300..599) - MaxErrorDomainPlus1 - - -## Couchbase Lite error codes, in the CBLDomain. -type - CBLErrorCode* {.size: sizeof(cint).} = enum - ErrorAssertionFailed = 1, ## Internal assertion failure - ErrorUnimplemented, ## Oops, an unimplemented API call - ErrorUnsupportedEncryption, ## Unsupported encryption algorithm - ErrorBadRevisionID, ## Invalid revision ID syntax - ErrorCorruptRevisionData, ## Revision contains corrupted/unreadable data - ErrorNotOpen, ## CBLDatabase/KeyStore/index is not open - ErrorNotFound, ## CBLDocument not found - ErrorConflict, ## CBLDocument update conflict - ErrorInvalidParameter, ## Invalid function parameter or struct value - ErrorUnexpectedError, ## Internal unexpected C++ exception - ErrorCantOpenFile, ## CBLDatabase file can't be opened; may not exist - ErrorIOError, ## File I/O error - ErrorMemoryError, ## Memory allocation failed (out of memory?) - ErrorNotWriteable, ## File is not writeable - ErrorCorruptData, ## Data is corrupted - ErrorBusy, ## CBLDatabase is busy/locked - ErrorNotInTransaction, ## Function must be called while in a transaction - ErrorTransactionNotClosed, ## CBLDatabase can't be closed while a transaction is open - ErrorUnsupported, ## Operation not supported in this database - ErrorNotADatabaseFile, ## File is not a database, or encryption key is wrong - ErrorWrongFormat, ## CBLDatabase exists but not in the format/storage requested - ErrorCrypto, ## Encryption/decryption error - ErrorInvalidQuery, ## Invalid query - ErrorMissingIndex, ## No such index, or query requires a nonexistent index - ErrorInvalidQueryParam, ## Unknown query param name, or param number out of range - ErrorRemoteError, ## Unknown error from remote server - ErrorDatabaseTooOld, ## CBLDatabase file format is older than what I can open - ErrorDatabaseTooNew, ## CBLDatabase file format is newer than what I can open - ErrorBadDocID, ## Invalid document ID - ErrorCantUpgradeDatabase, ## DB can't be upgraded (might be unsupported dev version) - NumErrorCodesPlus1 - - -## Network error codes, in the CBLNetworkDomain. -type - NetworkErrorCode* {.size: sizeof(cint).} = enum - NetErrDNSFailure = 1, ## DNS lookup failed - NetErrUnknownHost, ## DNS server doesn't know the hostname - NetErrTimeout, ## No response received before timeout - NetErrInvalidURL, ## Invalid URL - NetErrTooManyRedirects, ## HTTP redirect loop - NetErrTLSHandshakeFailed, ## Low-level error establishing TLS - NetErrTLSCertExpired, ## Server's TLS certificate has expired - NetErrTLSCertUntrusted, ## Cert isn't trusted for other reason - NetErrTLSClientCertRequired, ## Server requires client to have a TLS certificate - NetErrTLSClientCertRejected, ## Server rejected my TLS client certificate - NetErrTLSCertUnknownRoot, ## Self-signed cert, or unknown anchor cert - NetErrInvalidRedirect, ## Attempted redirect to invalid URL - NetErrUnknown, ## Unknown networking error - NetErrTLSCertRevoked, ## Server's cert has been revoked - NetErrTLSCertNameMismatch ## Server cert's name does not match DNS name - - -## A struct holding information about an error. It's declared on the stack by a caller, and -## its address is passed to an API function. If the function's return value indicates that -## there was an error (usually by returning NULL or false), then the CBLError will have been -## filled in with the details. -type - CBLError* {.byref.} = object - domain*: CBLErrorDomain ## Domain of errors; a namespace for the `code`. - code*: int32 ## CBLError code, specific to the domain. 0 always means no error. - internalInfo: int32 - - -## Returns a message describing an error. -proc message*(err: var CBLError): cstring {.importc: "CBLError_Message".} -proc message_s*(err: var CBLError): FLSliceResult {. - importc: "CBLError_Message_s".} - - -## \defgroup other_types Other Types -## A date/time representation used for document expiration (and in date/time queries.) -## Measured in milliseconds since the Unix epoch (1/1/1970, midnight UTC.) -type - CBLTimestamp* = int64 - -## Returns the current time, in milliseconds since 1/1/1970. -proc now*(): CBLTimestamp {.importc: "CBL_Now".} - -## \defgroup refcounting Reference Counting -## Couchbase Lite "objects" are reference-counted; the functions below are the shared -## _retain_ and _release_ operations. (But there are type-safe equivalents defined for each -## class, so you can call \ref CBLDatabase_Release() on a database, for instance, without having to -## type-cast.) -## -## API functions that **create** a ref-counted object (typically named `..._New()` or `..._Create()`) -## return the object with a ref-count of 1; you are responsible for releasing the reference -## when you're done with it, or the object will be leaked. -## -## Other functions that return an **existing** ref-counted object do not modify its ref-count. -## You do _not_ need to release such a reference. But if you're keeping a reference to the object -## for a while, you should retain the reference to ensure it stays alive, and then release it when -## finished (to balance the retain.) -## -type - CBLRefCounted = ptr object - -proc retain(a1: CBLRefCounted): CBLRefCounted {.importc: "CBL_Retain", discardable.} -proc release(a1: CBLRefCounted) {.importc: "CBL_Release".} - -## Returns the total number of Couchbase Lite objects. Useful for leak checking. -proc instanceCount*(): cuint {.importc: "CBL_InstanceCount".} - -## Logs the class and address of each Couchbase Lite object. Useful for leak checking. -proc dumpInstances*() {.importc: "CBL_DumpInstances".} - -## \defgroup database CBLDatabase -## A connection to an open database. -type - CBLDatabase* = ptr object - -proc retain*(obj: CBLDatabase): CBLDatabase {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLDatabase) {.inline.} = - release(cast[CBLRefCounted](obj)) - - -## \defgroup documents Documents -## An in-memory copy of a document. -## CBLDocument objects can be mutable or immutable. Immutable objects are referenced by _const_ -## pointers; mutable ones by _non-const_ pointers. This prevents you from accidentally calling -## a mutable-document function on an immutable document. -type - CBLDocument* = ptr object - -proc retain*(obj: CBLDocument): CBLDocument {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLDocument) {.inline.} = - release(cast[CBLRefCounted](obj)) - -## \defgroup blobs Blobs -## A binary data value associated with a \ref CBLDocument. -type - CBLBlob* = ptr object - -proc retain*(obj: CBLBlob): CBLBlob {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLBlob) {.inline.} = - release(cast[CBLRefCounted](obj)) - -## \defgroup queries Queries -## A compiled database query. -type - CBLQuery* = ptr object - -proc retain*(obj: CBLQuery): CBLQuery {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLQuery) {.inline.} = - release(cast[CBLRefCounted](obj)) - -## An iterator over the rows resulting from running a query. -type - CBLResultSet* = ptr object - -proc retain*(obj: CBLResultSet): CBLResultSet {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLResultSet) {.inline.} = - release(cast[CBLRefCounted](obj)) - -## \defgroup replication Replication -## A background task that syncs a \ref CBLDatabase with a remote server or peer. -type - CBLReplicator* = ptr object - -proc retain*(obj: CBLReplicator): CBLReplicator {.inline, discardable.} = - retain(cast[CBLRefCounted](obj)) - return obj -proc release*(obj: CBLReplicator) {.inline.} = - release(cast[CBLRefCounted](obj)) - -## \defgroup listeners Listeners -## Every API function that registers a listener callback returns an opaque token representing -## the registered callback. To unregister any type of listener, call \ref CBLListener_Remove. -## -## The steps to creating a listener are: -## 1. Define the type of contextual information the callback needs. This is usually one of -## your objects, or a custom struct. -## 2. Implement the listener function: -## - The parameters and return value must match the callback defined in the API. -## - The first parameter is always a `void*` that points to your contextual -## information, so cast that to the actual pointer type. -## - **The function may be called on a background thread!** And since the CBL API is not itself -## thread-safe, you'll need to take special precautions if you want to call the API -## from your listener, such as protecting all of your calls (inside and outside the -## listener) with a mutex. It's safer to use \ref CBLDatabase_BufferNotifications to -## schedule listener callbacks to a time of your own choosing, such as your thread's -## event loop; see that function's docs for details. -## 3. To register the listener, call the relevant `AddListener` function. -## - The parameters will include the CBL object to observe, the address of your listener -## function, and a pointer to the contextual information. (That pointer needs to remain -## valid for as long as the listener is registered, so it can't be a pointer to a local -## variable.) -## - The return value is a \ref CBLListenerToken pointer; save that. -## 4. To unregister the listener, pass the \ref CBLListenerToken to \ref CBLListener_Remove. -## - You **must** unregister the listener before the contextual information pointer is -## invalidated, e.g. before freeing the object it points to. -## -## An opaque 'cookie' representing a registered listener callback. -## It's returned from functions that register listeners, and used to remove a listener by -## calling \ref CBLListener_Remove. -type - CBLListenerToken* = ptr object - -## Removes a listener callback, given the token that was returned when it was added. -proc remove*(a1: CBLListenerToken) {.importc: "CBLListener_Remove".} - - - - -## -## CBLLog.h -## -## Copyright © 2019 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. -## - -## * \defgroup logging Logging -## Managing messages that Couchbase Lite logs at runtime. -## * Subsystems that log information. - - - -type - CBLLogDomain* {.size: sizeof(cint).} = enum - kLogDomainAll, kLogDomainDatabase, kLogDomainQuery, kLogDomainReplicator, kLogDomainNetwork - -## * Levels of log messages. Higher values are more important/severe. Each level includes the lower ones. -type - CBLLogLevel* {.size: sizeof(cint).} = enum - CBLLogDebug, ## /< Extremely detailed messages, only written by debug builds of CBL. - CBLLogVerbose, ## /< Detailed messages about normally-unimportant stuff. - CBLLogInfo, ## /< Messages about ordinary behavior. - CBLLogWarning, ## /< Messages warning about unlikely and possibly bad stuff. - CBLLogError, ## /< Messages about errors - CBLLogNone ## /< Disables logging entirely. - - -## * Formats and writes a message to the log, in the given domain at the given level. -## \warning This function takes a `printf`-style format string, with extra parameters to match the format placeholders, and has the same security vulnerabilities as other `printf`-style functions. -## If you are logging a fixed string, call \ref CBL_Log_s instead, otherwise any `%` characters in the -## `format` string will be misinterpreted as placeholders and the dreaded Undefined Behavior will result, -## possibly including crashes or overwriting the stack. -## @param domain The log domain to associate this message with. -## @param level The severity of the message. If this is lower than the current minimum level for the domain -## (as set by \ref CBL_SetLogLevel), nothing is logged. -## @param format A `printf`-style format string. `%` characters in this string introduce parameters, -## and corresponding arguments must follow. -proc log*(domain: CBLLogDomain; level: CBLLogLevel; format: cstring) {.varargs, - importc: "CBL_Log".} - -## * Writes a pre-formatted message to the log, exactly as given. -## @param domain The log domain to associate this message with. -## @param level The severity of the message. If this is lower than the current minimum level for the domain -## (as set by \ref CBL_SetLogLevel), nothing is logged. -## @param message The exact message to write to the log. - -proc logString*(domain: CBLLogDomain; level: CBLLogLevel; message: Slice) {. - importc: "CBL_Log_s".} -## * \name Console Logging and Custom Logging -## * A logging callback that the application can register. -## @param domain The domain of the message; \ref kCBLLogDomainAll if it doesn't fall into a specific domain. -## @param level The severity level of the message. -## @param message The actual formatted message. - -type - CBLLogCallback* = proc (domain: CBLLogDomain; level: CBLLogLevel; - message: cstring) - -## * Gets the current log level for debug console logging. -## Only messages at this level or higher will be logged to the console or callback. -proc consoleLevel*(): CBLLogLevel {.importc: "CBLLog_ConsoleLevel".} - -## * Sets the detail level of logging. -## Only messages whose level is ≥ the given level will be logged to the console or callback. -proc setConsoleLevel*(a1: CBLLogLevel) {.importc: "CBLLog_SetConsoleLevel".} - -## * Returns true if a message with the given domain and level would be logged to the console. -proc willLogToConsole*(domain: CBLLogDomain; level: CBLLogLevel): bool {. - importc: "CBLLog_WillLogToConsole".} - -## * Gets the current log callback. -proc callback*(): CBLLogCallback {.importc: "CBLLog_Callback".} - -## * Sets the callback for receiving log messages. If set to NULL, no messages are logged to the console. -proc setCallback*(a1: CBLLogCallback) {.importc: "CBLLog_SetCallback".} - -## * \name Log File Configuration -## * The properties for configuring logging to files. -## @warning `usePlaintext` results in significantly larger log files and higher CPU usage that may slow -## down your app; we recommend turning it off in production. -type - CBLLogFileConfiguration* {.bycopy.} = object - directory*: cstring ## /< The directory where log files will be created. - maxRotateCount*: uint32 ## /< Max number of older logs to keep (i.e. total number will be one more.) - maxSize*: csize_t ## /< The size in bytes at which a file will be rotated out (best effort). - usePlaintext*: bool ## /< Whether or not to log in plaintext (as opposed to binary) - - -## * Gets the current file logging configuration. -proc fileConfig*(): ptr CBLLogFileConfiguration {.importc: "CBLLog_FileConfig".} - -## * Sets the file logging configuration. -proc setFileConfig*(a1: CBLLogFileConfiguration) {. - importc: "CBLLog_SetFileConfig".} - - - - -## -## CBLDatabase.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -## \defgroup database CBLDatabase -## A \ref CBLDatabase is both a filesystem object and a container for documents. - -## \name CBLDatabase configuration -## Flags for how to open a database. -type - CBLDatabaseFlags* {.size: sizeof(cint).} = enum - kDatabaseCreate = 1, ## Create the file if it doesn't exist - kDatabaseReadOnly = 2, ## Open file read-only - kDatabaseNoUpgrade = 4 ## Disable upgrading an older-version database - - -## Encryption algorithms (available only in the Enterprise Edition). -type - CBLEncryptionAlgorithm* {.size: sizeof(cint).} = enum - kEncryptionNone = 0, ## No encryption (default) - ## #ifdef COUCHBASE_ENTERPRISE - kEncryptionAES256 ## AES with 256-bit key - ## #endif - - -## Encryption key sizes (in bytes). -type - CBLEncryptionKeySize* {.size: sizeof(cint).} = enum - kEncryptionKeySizeAES256 = 32 ## Key size for \ref kCBLEncryptionAES256 - - -## Encryption key specified in a \ref CBLDatabaseConfiguration. -type - CBLEncryptionKey* {.bycopy.} = object - algorithm*: CBLEncryptionAlgorithm ## Encryption algorithm - bytes*: array[32, uint8] ## Raw key data - - -## CBLDatabase configuration options. -type - CBLDatabaseConfiguration* = object - directory*: cstring ## The parent directory of the database - flags*: CBLDatabaseFlags ## Options for opening the database - encryptionKey*: ptr CBLEncryptionKey ## The database's encryption key (if any) - - -## \name CBLDatabase file operations -## These functions operate on database files without opening them. -## -## Returns true if a database with the given name exists in the given directory. -## absolute or relative path to the database. -proc databaseExists*(name: cstring; inDirectory: cstring): bool {. - importc: "CBL_DatabaseExists".} - -## Copies a database file to a new location, and assigns it a new internal UUID to distinguish -## it from the original database when replicating. -proc copyDatabase*(fromPath: cstring; toName: cstring; - config: CBLDatabaseConfiguration; err: var CBLError): bool {. - importc: "CBL_CopyDatabase".} - -## Deletes a database file. If the database file is open, an error is returned. -## absolute or relative path to the database. -## (You can tell the last two cases apart by looking at \p outError.) -proc deleteDatabase*(name: cstring; inDirectory: cstring; - err: var CBLError): bool {.importc: "CBL_DeleteDatabase".} - -## \name CBLDatabase lifecycle -## Opening, closing, and managing open databases. -## -## Opens a database, or creates it if it doesn't exist yet, returning a new \ref CBLDatabase -## instance. -## It's OK to open the same database file multiple times. Each \ref CBLDatabase instance is -## independent of the others (and must be separately closed and released.) -proc openDatabase*(name: cstring; config: ptr CBLDatabaseConfiguration; - err: var CBLError): CBLDatabase {.importc: "CBLDatabase_Open".} - -## Closes an open database. -proc close*(a1: CBLDatabase; err: var CBLError): bool {. - importc: "CBLDatabase_Close".} - -## Closes and deletes a database. If there are any other connections to the database, -## an error is returned. -proc delete*(a1: CBLDatabase; err: var CBLError): bool {. - importc: "CBLDatabase_Delete".} - -## Compacts a database file. -proc compact*(a1: CBLDatabase; err: var CBLError): bool {. - importc: "CBLDatabase_Compact".} - -## Begins a batch operation, similar to a transaction. You **must** later call \ref -## CBLDatabase_EndBatch to end (commit) the batch. -## the batch operation ends. -proc beginBatch*(a1: CBLDatabase; err: var CBLError): bool {. - importc: "CBLDatabase_BeginBatch".} - -## Ends a batch operation. This **must** be called after \ref CBLDatabase_BeginBatch. -proc endBatch*(a1: CBLDatabase; err: var CBLError): bool {. - importc: "CBLDatabase_EndBatch".} - -## Returns the nearest future time at which a document in this database will expire, -## or 0 if no documents will expire. -proc nextDocExpiration*(a1: CBLDatabase): CBLTimestamp {. - importc: "CBLDatabase_NextDocExpiration".} - -## Purges all documents whose expiration time has passed. -proc purgeExpiredDocuments*(db: CBLDatabase; err: var CBLError): int64 {. - importc: "CBLDatabase_PurgeExpiredDocuments".} - -## \name CBLDatabase accessors -## Getting information about a database. -## -## Returns the database's name. -proc name*(a1: CBLDatabase): cstring {.importc: "CBLDatabase_Name".} - -## Returns the database's full filesystem path. -proc path*(a1: CBLDatabase): cstring {.importc: "CBLDatabase_Path".} - -## Returns the number of documents in the database. -proc count*(a1: CBLDatabase): uint64 {.importc: "CBLDatabase_Count".} - -## Returns the database's configuration, as given when it was opened. -proc config*(a1: CBLDatabase): CBLDatabaseConfiguration {. - importc: "CBLDatabase_Config".} - -## \name CBLDatabase listeners -## A database change listener lets you detect changes made to all documents in a database. -## (If you only want to observe specific documents, use a \ref CBLDocumentChangeListener instead.) -## listeners will be notified of changes made by other database instances. -## A database change listener callback, invoked after one or more documents are changed on disk. -## prepared for that, you may want to use \ref CBLDatabase_BufferNotifications -## so that listeners will be called in a safe context. -type - DatabaseChangeListener* = proc (context: pointer; db: CBLDatabase; - numDocs: cuint; docIDs: cstringArray) - -## Registers a database change listener callback. It will be called after one or more -## documents are changed on disk. -## listener. -proc addChangeListener*(db: CBLDatabase; listener: DatabaseChangeListener; - context: pointer): CBLListenerToken {. - importc: "CBLDatabase_AddChangeListener".} - -## end of outer \defgroup -## \defgroup listeners Listeners -## \name Scheduling notifications -## Applications may want control over when Couchbase Lite notifications (listener callbacks) -## happen. They may want them called on a specific thread, or at certain times during an event -## loop. This behavior may vary by database, if for instance each database is associated with a -## separate thread. -## -## The API calls here enable this. When notifications are "buffered" for a database, calls to -## listeners will be deferred until the application explicitly allows them. Instead, a single -## callback will be issued when the first notification becomes available; this gives the app a -## chance to schedule a time when the notifications should be sent and callbacks called. -## -## Callback indicating that the database (or an object belonging to it) is ready to call one -## or more listeners. You should call \ref CBLDatabase_SendNotifications at your earliest -## convenience, in the context (thread, dispatch queue, etc.) you want them to run. -## is called. If you don't respond by (sooner or later) calling that function, -## you will not be informed that any listeners are ready. -## possible, just scheduling a future call to \ref CBLDatabase_SendNotifications. -type - NotificationsReadyCallback* = proc (context: pointer; db: CBLDatabase) - -## Switches the database to buffered-notification mode. Notifications for objects belonging -## to this database (documents, queries, replicators, and of course the database) will not be -## called immediately; your \ref CBLNotificationsReadyCallback will be called instead. -proc bufferNotifications*(db: CBLDatabase; callback: NotificationsReadyCallback; - context: pointer) {.importc: "CBLDatabase_BufferNotifications".} - -## Immediately issues all pending notifications for this database, by calling their listener -## callbacks. -proc sendNotifications*(db: CBLDatabase) {. - importc: "CBLDatabase_SendNotifications".} - - - - -## CBLDocument.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -## \defgroup documents Documents -## A \ref CBLDocument is essentially a JSON object with an ID string that's unique in its database. -## -## \name CBLDocument lifecycle -## Conflict-handling options when saving or deleting a document. -type - CBLConcurrencyControl* {.size: sizeof( - cint).} = enum ## The current save/delete will overwrite a conflicting revision if there is a conflict. - kConcurrencyControlLastWriteWins, ## The current save/delete will fail if there is a conflict. - kConcurrencyControlFailOnConflict - - -## Custom conflict handler for use when saving or deleting a document. This handler is called -## if the save would cause a conflict, i.e. if the document in the database has been updated -## (probably by a pull replicator, or by application code on another thread) -## since it was loaded into the CBLDocument being saved. -type - CBLSaveConflictHandler* = proc (context: pointer; - documentBeingSaved: CBLDocument; conflictingDocument: CBLDocument): bool - -## Reads a document from the database, creating a new (immutable) \ref CBLDocument object. -## Each call to this function creates a new object (which must later be released.) -## \ref CBLDatabase_GetMutableDocument instead. -proc getDocument*(database: CBLDatabase; docID: cstring): CBLDocument {. - importc: "CBLDatabase_GetDocument".} - -## Saves a (mutable) document to the database. -## If a conflicting revision has been saved since \p doc was loaded, the \p concurrency -## parameter specifies whether the save should fail, or the conflicting revision should -## be overwritten with the revision being saved. -## If you need finer-grained control, call \ref CBLDatabase_SaveDocumentResolving instead. -proc saveDocument*(db: CBLDatabase; doc: CBLDocument; - concurrency: CBLConcurrencyControl; err: var CBLError): CBLDocument {. - importc: "CBLDatabase_SaveDocument".} - -## Saves a (mutable) document to the database. This function is the same as \ref -## CBLDatabase_SaveDocument, except that it allows for custom conflict handling in the event -## that the document has been updated since \p doc was loaded. -proc saveDocumentResolving*(db: CBLDatabase; doc: CBLDocument; - conflictHandler: CBLSaveConflictHandler; context: pointer; - err: var CBLError): CBLDocument {. - importc: "CBLDatabase_SaveDocumentResolving".} - -## Deletes a document from the database. Deletions are replicated. -proc delete*(document: CBLDocument; concurrency: CBLConcurrencyControl; - err: var CBLError): bool {.importc: "CBLDocument_Delete".} - -## Purges a document. This removes all traces of the document from the database. -## Purges are _not_ replicated. If the document is changed on a server, it will be re-created -## when pulled. -## simpler shortcut. -proc purge*(document: CBLDocument; err: var CBLError): bool {. - importc: "CBLDocument_Purge".} - -## Purges a document, given only its ID. -## code will be zero. -## -proc purgeDocumentByID*(database: CBLDatabase; docID: cstring; - err: var CBLError): bool {.importc: "CBLDatabase_PurgeDocumentByID".} - -## \name Mutable documents -## The type `CBLDocument*` without a `const` qualifier refers to a _mutable_ document instance. -## A mutable document exposes its properties as a mutable dictionary, so you can change them -## in place and then call \ref CBLDatabase_SaveDocument to persist the changes. -## -## Reads a document from the database, in mutable form that can be updated and saved. -## (This function is otherwise identical to \ref CBLDatabase_GetDocument.) -proc getMutableDocument*(database: CBLDatabase; docID: cstring): CBLDocument {. - importc: "CBLDatabase_GetMutableDocument".} - -## Creates a new, empty document in memory. It will not be added to a database until saved. -proc newDocument*(docID: cstring): CBLDocument {.importc: "CBLDocument_New".} - -## Creates a new mutable CBLDocument instance that refers to the same document as the original. -## If the original document has unsaved changes, the new one will also start out with the same -## changes; but mutating one document thereafter will not affect the other. -proc mutableCopy*(original: CBLDocument): CBLDocument {. - importc: "CBLDocument_MutableCopy".} - -## \name CBLDocument properties and metadata -## A document's body is essentially a JSON object. The properties are accessed in memory -## using the Fleece API, with the body itself being a \ref FLDict "dictionary"). -## -## Returns a document's ID. -proc id*(doc: CBLDocument): cstring {.importc: "CBLDocument_ID".} - -## Returns a document's revision ID, which is a short opaque string that's guaranteed to be -## unique to every change made to the document. -## If the document doesn't exist yet, this function returns NULL. -proc revisionID*(doc: CBLDocument): cstring {. - importc: "CBLDocument_RevisionID".} - -## Returns a document's current sequence in the local database. -## This number increases every time the document is saved, and a more recently saved document -## will have a greater sequence number than one saved earlier, so sequences may be used as an -## abstract 'clock' to tell relative modification times. -proc sequence*(doc: CBLDocument): uint64 {.importc: "CBLDocument_Sequence".} - -## Returns a document's properties as a dictionary. -## If you need to use any properties after releasing the document, you must retain them -## by calling \ref FLValue_Retain (and of course later release them.) -## underlying dictionary itself is mutable and could be modified through a mutable -## reference obtained via \ref CBLDocument_MutableProperties. If you need to preserve the -## properties, call \ref FLDict_MutableCopy to make a deep copy. -proc properties*(doc: CBLDocument): FLDict {.importc: "CBLDocument_Properties".} - -## Returns a mutable document's properties as a mutable dictionary. -## You may modify this dictionary and then call \ref CBLDatabase_SaveDocument to persist the changes. -## same collection returned by \ref CBLDocument_Properties. -## If you need to use any properties after releasing the document, you must retain them -## by calling \ref FLValue_Retain (and of course later release them.) -proc mutableProperties*(doc: CBLDocument): FLMutableDict {. - importc: "CBLDocument_MutableProperties".} - -## Sets a mutable document's properties. -## Call \ref CBLDatabase_SaveDocument to persist the changes. -## releasing any retained reference(s) you have to it. -proc setProperties*(doc: CBLDocument; properties: FLMutableDict) {. - importc: "CBLDocument_SetProperties".} - -proc createDocumentFleeceDoc*(doc: CBLDocument): FLDoc {. - importc: "CBLDocument_CreateFleeceDoc".} - -## Returns a document's properties as a null-terminated JSON string. -proc propertiesAsJSON*(doc: CBLDocument): cstring {. - importc: "CBLDocument_PropertiesAsJSON".} - -## Sets a mutable document's properties from a JSON string. -proc setPropertiesAsJSON*(doc: CBLDocument; json: cstring; - err: var CBLError): bool {.importc: "CBLDocument_SetPropertiesAsJSON".} - -## Returns the time, if any, at which a given document will expire and be purged. -## Documents don't normally expire; you have to call \ref CBLDatabase_SetDocumentExpiration -## to set a document's expiration time. -## or 0 if the document does not have an expiration, -## or -1 if the call failed. -proc getDocumentExpiration*(db: CBLDatabase; docID: cstring; - err: var CBLError): CBLTimestamp {. - importc: "CBLDatabase_GetDocumentExpiration".} - -## Sets or clears the expiration time of a document. -## \ref CBLDatabase_PurgeExpiredDocuments when the time comes, to make it happen. -## or 0 if the document should never expire. -proc setDocumentExpiration*(db: CBLDatabase; docID: cstring; - expiration: CBLTimestamp; err: var CBLError): bool {. - importc: "CBLDatabase_SetDocumentExpiration".} - -## \name CBLDocument listeners -## A document change listener lets you detect changes made to a specific document after they -## are persisted to the database. -## document listeners will be notified of changes made by other database instances. -## -## A document change listener callback, invoked after a specific document is changed on disk. -## prepared for that, you may want to use \ref CBLDatabase_BufferNotifications -## so that listeners will be called in a safe context. -type - DocumentChangeListener* = proc (context: pointer; db: CBLDatabase; - docID: cstring) - -## Registers a document change listener callback. It will be called after a specific document -## is changed on disk. -## listener. -proc addDocumentChangeListener*(db: CBLDatabase; docID: cstring; - listener: DocumentChangeListener; context: pointer): CBLListenerToken {. - importc: "CBLDatabase_AddDocumentChangeListener".} - - - - -## -## CBLBlob.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -## \defgroup blobs Blobs -## A \ref CBLBlob is a binary data blob associated with a document. -## -## The content of the blob is not stored in the document, but externally in the database. -## It is loaded only on demand, and can be streamed. Blobs can be arbitrarily large, although -## Sync Gateway will only accept blobs under 20MB. -## -## The document contains only a blob reference: a dictionary with the special marker property -## blob's data. This digest is used as the key to retrieve the blob data. -## The dictionary usually also has the property `length`, containing the blob's length in bytes, -## and it may have the property `content_type`, containing a MIME type. -## -## A \ref CBLBlob object acts as a proxy for such a dictionary in a \ref CBLDocument. Once -## you've loaded a document and located the \ref FLDict holding the blob reference, call -## \ref CBLBlob_Get on it to create a \ref CBLBlob object you can call. -## The object has accessors for the blob's metadata and for loading the data itself. -## -## To create a new blob from in-memory data, call \ref CBLBlob_CreateWithData, then call -## \ref FLMutableDict_SetBlob or \ref FLMutableArray_SetBlob to add the \ref CBLBlob to the -## document (or to a dictionary or array property of the document.) -## -## To create a new blob from a stream, call \ref CBLBlobWriter_New to create a -## \ref CBLBlobWriteStream, then make one or more calls to \ref CBLBlobWriter_Write to write -## data to the blob, then finally call \ref CBLBlob_CreateWithStream to create the blob. -## To store the blob into a document, do as in the previous paragraph. -## -## -var kTypeProperty* {.importc: "kCBLTypeProperty".}: FLSlice - - -var kBlobType* {.importc: "kCBLBlobType".}: FLSlice - -## `"blob"` -var kBlobDigestProperty* {.importc: "kCBLBlobDigestProperty".}: FLSlice - -## `"digest"` -var kBlobLengthProperty* {.importc: "kCBLBlobLengthProperty".}: FLSlice - -## `"length"` -var kBlobContentTypeProperty* {.importc: "kCBLBlobContentTypeProperty".}: FLSlice - -## `"content_type"` -## Returns true if a dictionary in a document is a blob reference. -## If so, you can call \ref CBLBlob_Get to access it. -## whose value is `"blob"`. -proc isBlob*(a1: FLDict): bool {.importc: "CBL_IsBlob".} - -## Returns a CBLBlob object corresponding to a blob dictionary in a document. -proc getBlob*(blobDict: FLDict): CBLBlob {.importc: "CBLBlob_Get".} - -## Returns the length in bytes of a blob's content (from its `length` property). -proc length*(a1: CBLBlob): uint64 {.importc: "CBLBlob_Length".} - -## Returns the cryptographic digest of a blob's content (from its `digest` property). -proc digest*(a1: CBLBlob): cstring {.importc: "CBLBlob_Digest".} - -## Returns a blob's MIME type, if its metadata has a `content_type` property. -proc contentType*(a1: CBLBlob): cstring {.importc: "CBLBlob_ContentType".} - -## Returns a blob's metadata. This includes the `digest`, `length` and `content_type` -## properties, as well as any custom ones that may have been added. -proc properties*(a1: CBLBlob): FLDict {.importc: "CBLBlob_Properties".} - -## Reads the blob's contents into memory and returns them. -## You are responsible for calling \ref FLFLSliceResult_Release on the returned data when done. -proc loadContent*(a1: CBLBlob; err: var CBLError): FLSliceResult {. - importc: "CBLBlob_LoadContent".} - -## A stream for reading a blob's content. -type - BlobReadStream* = ptr object - -## Opens a stream for reading a blob's content. -proc openContentStream*(a1: CBLBlob; err: var CBLError): ptr BlobReadStream {. - importc: "CBLBlob_OpenContentStream".} - -## Reads data from a blob. -proc read*(stream: ptr BlobReadStream; dst: pointer; maxLength: csize_t; - err: var CBLError): cint {.importc: "CBLBlobReader_Read".} - -## Closes a CBLBlobReadStream. -proc close*(a1: ptr BlobReadStream) {.importc: "CBLBlobReader_Close".} - -## Creates a new blob given its contents as a single block of data. -## has been saved. -proc createBlobWithData*(contentType: cstring; contents: FLSlice): CBLBlob {. - importc: "CBLBlob_CreateWithData".} - -## A stream for writing a new blob to the database. -type - BlobWriteStream* = ptr object - -## Opens a stream for writing a new blob. -## You should next call \ref CBLBlobWriter_Write one or more times to write the data, -## then \ref CBLBlob_CreateWithStream to create the blob. -## -## If for some reason you need to abort, just call \ref CBLBlobWriter_Close. -proc newBlobWriter*(db: CBLDatabase; err: var CBLError): ptr BlobWriteStream {. - importc: "CBLBlobWriter_New".} - -## Closes a blob-writing stream, if you need to give up without creating a \ref CBLBlob. -proc close*(a1: ptr BlobWriteStream) {.importc: "CBLBlobWriter_Close".} - -## Writes data to a new blob. -proc write*(writer: ptr BlobWriteStream; data: pointer; length: csize_t; - err: var CBLError): bool {.importc: "CBLBlobWriter_Write".} - -## Creates a new blob after its data has been written to a \ref CBLBlobWriteStream. -## You should then add the blob to a mutable document as a property -- see -## \ref FLMutableDict_SetBlob and \ref FLMutableArray_SetBlob. -proc createBlobWithStream*(contentType: cstring; - writer: ptr BlobWriteStream): CBLBlob {. - importc: "CBLBlob_CreateWithStream".} -proc createBlobWithStream_s*(contentType: cstring; - writer: ptr BlobWriteStream): CBLBlob {. - importc: "CBLBlob_CreateWithStream".} - -## Returns true if a value in a document is a blob reference. -## If so, you can call \ref FLValue_GetBlob to access it. -proc isBlob*(v: FLValue): bool {.inline.} = - return isBlob(asDict(v)) - -## Instantiates a \ref CBLBlob object corresponding to a blob dictionary in a document. -proc getBlob*(value: FLValue): CBLBlob {.inline.} = - return getBlob(asDict(value)) - -## Stores a blob in a mutable array or dictionary. -proc setBlob*(slot: FLSlot; blob: CBLBlob) {.importc: "FLSlot_SetBlob".} - - - - -## -## CBLQuery.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -## \defgroup queries Queries -## A CBLQuery represents a compiled database query. The query language is a large subset of -## the [N1QL](https://www.couchbase.com/products/n1ql) language from Couchbase Server, which -## you can think of as "SQL for JSON" or "SQL++". -## -## Queries may be given either in -## [N1QL syntax](https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/index.html), -## or in JSON using a -## [schema](https://github.com/couchbase/couchbase-lite-core/wiki/JSON-CBLQuery-Schema) -## that resembles a parse tree of N1QL. The JSON syntax is harder for humans, but much more -## amenable to machine generation, if you need to create queries programmatically or translate -## them from some other form. -## -## CBLQuery languages -type - CBLQueryLanguage* {.size: sizeof(cint).} = enum - kJSONLanguage, ## [JSON query schema](https://github.com/couchbase/couchbase-lite-core/wiki/JSON-CBLQuery-Schema) - kN1QLLanguage ## [N1QL syntax](https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/index.html) - - -## \name CBLQuery objects -## Creates a new query by compiling the input string. -## This is fast, but not instantaneous. If you need to run the same query many times, keep the -## \ref CBLQuery around instead of compiling it each time. If you need to run related queries -## with only some values different, create one query with placeholder parameter(s), and substitute -## the desired value(s) with \ref CBLQuery_SetParameters each time you run the query. -## [JSON](https://github.com/couchbase/couchbase-lite-core/wiki/JSON-CBLQuery-Schema) or -## [N1QL](https://docs.couchbase.com/server/4.0/n1ql/n1ql-language-reference/index.html). -## input expression will be stored here (or -1 if not known/applicable.) -proc newQuery*(db: CBLDatabase; language: CBLQueryLanguage; - queryFLString: cstring; outErrorPos: ptr cint; - err: var CBLError): CBLQuery {.importc: "CBLQuery_New".} - -## Assigns values to the query's parameters. -## These values will be substited for those parameters whenever the query is executed, -## until they are next assigned. -## -## Parameters are specified in the query source as -## e.g. `$PARAM` (N1QL) or `["$PARAM"]` (JSON). In this example, the `parameters` dictionary -## to this call should have a key `PARAM` that maps to the value of the parameter. -## keys are the parameter names. (It's easiest to construct this by using the mutable -## API, i.e. calling \ref FLMutableDict_New and adding keys/values.) -proc setParameters*(query: CBLQuery; parameters: FLDict) {. - importc: "CBLQuery_SetParameters".} - -## Returns the query's current parameter bindings, if any. -proc parameters*(query: CBLQuery): FLDict {.importc: "CBLQuery_Parameters".} - -## Assigns values to the query's parameters, from JSON data. -## See \ref CBLQuery_SetParameters for details. -## keys are the parameter names. (You may use JSON5 syntax.) -proc setParametersAsJSON*(query: CBLQuery; json: cstring): bool {. - importc: "CBLQuery_SetParametersAsJSON".} - -## Runs the query, returning the results. -## To obtain the results you'll typically call \ref CBLResultSet_Next in a `while` loop, -## examining the values in the \ref CBLResultSet each time around. -proc execute*(a1: CBLQuery; err: var CBLError): CBLResultSet {. - importc: "CBLQuery_Execute".} - -## Returns information about the query, including the translated SQLite form, and the search -## strategy. You can use this to help optimize the query: the word `SCAN` in the strategy -## indicates a linear scan of the entire database, which should be avoided by adding an index. -## The strategy will also show which index(es), if any, are used. -proc explain*(a1: CBLQuery): FLSliceResult {.importc: "CBLQuery_Explain".} - -## Returns the number of columns in each result. -proc columnCount*(a1: CBLQuery): cuint {.importc: "CBLQuery_ColumnCount".} - -## Returns the name of a column in the result. -## The column name is based on its expression in the `SELECT...` or `WHAT:` section of the -## query. A column that returns a property or property path will be named after that property. -## A column that returns an expression will have an automatically-generated name like `$1`. -## To give a column a custom name, use the `AS` syntax in the query. -## Every column is guaranteed to have a unique name. -proc columnName*(a1: CBLQuery; columnIndex: cuint): FLSlice {. - importc: "CBLQuery_ColumnName".} - -## \name Result sets -## A `CBLResultSet` is an iterator over the results returned by a query. It exposes one -## result at a time -- as a collection of values indexed either by position or by name -- -## and can be stepped from one result to the next. -## -## It's important to note that the initial position of the iterator is _before_ the first -## result, so \ref CBLResultSet_Next must be called _first_. Example: -## -## ``` -## CBLResultSet *rs = CBLQuery_Execute(query, &error); -## assert(rs); -## while (CBLResultSet_Next(rs) { -## FLValue aValue = CBLResultSet_ValueAtIndex(rs, 0); -## ... -## } -## CBLResultSet_Release(rs); -## ``` -## -## Moves the result-set iterator to the next result. -## Returns false if there are no more results. -proc next*(a1: CBLResultSet): bool {.importc: "CBLResultSet_Next".} - -## Returns the value of a column of the current result, given its (zero-based) numeric index. -## This may return a NULL pointer, indicating `MISSING`, if the value doesn't exist, e.g. if -## the column is a property that doesn't exist in the document. -proc valueAtIndex*(a1: CBLResultSet; index: cuint): FLValue {. - importc: "CBLResultSet_ValueAtIndex".} - -## Returns the value of a column of the current result, given its name. -## This may return a NULL pointer, indicating `MISSING`, if the value doesn't exist, e.g. if -## the column is a property that doesn't exist in the document. (Or, of course, if the key -## is not a column name in this query.) -proc valueForKey*(a1: CBLResultSet; key: cstring): FLValue {. - importc: "CBLResultSet_ValueForKey".} - -## Returns the current result as an array of column values. -## @warning The array reference is only valid until the result-set is advanced or released. -## If you want to keep it for longer, call \ref FLArray_Retain (and release it when done.) -proc rowArray*(rs: CBLResultSet): FLArray {.importc: "CBLResultSet_RowArray".} - -## Returns the current result as a dictionary mapping column names to values. -## @warning The dict reference is only valid until the result-set is advanced or released. -## If you want to keep it for longer, call \ref FLDict_Retain (and release it when done.) -proc rowDict*(rs: CBLResultSet): FLDict {.importc: "CBLResultSet_RowDict".} - -## Returns the CBLQuery that created this CBLResultSet. -proc getQuery*(rs: CBLResultSet): CBLQuery {.importc: "CBLResultSet_GetQuery".} - -## \name Change listener -## Adding a change listener to a query turns it into a "live query". When changes are made to -## documents, the query will periodically re-run and compare its results with the prior -## results; if the new results are different, the listener callback will be called. -## -## rows that changed. -## -## A callback to be invoked after the query's results have changed. -## The actual result set can be obtained by calling \ref CBLQuery_CurrentResults, either during -## the callback or at any time thereafter. -## prepared for that, you may want to use \ref CBLDatabase_BufferNotifications -## so that listeners will be called in a safe context. -type - CBLQueryChangeListner* = proc (context: pointer; query: CBLQuery) - -## Registers a change listener callback with a query, turning it into a "live query" until -## the listener is removed (via \ref CBLListener_Remove). -## -## When the first change listener is added, the query will run (in the background) and notify -## the listener(s) of the results when ready. After that, it will run in the background after -## the database changes, and only notify the listeners when the result set changes. -## listener. -proc addChangeListener*(query: CBLQuery; listener: CBLQueryChangeListner; - context: pointer): CBLListenerToken {. - importc: "CBLQuery_AddChangeListener".} - -## Returns the query's _entire_ current result set, after it's been announced via a call to the -## listener's callback. -proc copyCurrentResults*(query: CBLQuery; listener: CBLListenerToken; - err: var CBLError): CBLResultSet {.importc: "CBLQuery_CopyCurrentResults".} - -## \name CBLDatabase Indexes -## Indexes are used to speed up queries by allowing fast -- O(log n) -- lookup of documents -## that have specific values or ranges of values. The values may be properties, or expressions -## based on properties. -## -## An index will speed up queries that use the expression it indexes, but it takes up space in -## the database file, and it slows down document saves slightly because it needs to be kept up -## to date when documents change. -## -## Tuning a database with indexes can be a tricky task. Fortunately, a lot has been written about -## it in the relational-database (SQL) realm, and much of that advice holds for Couchbase Lite. -## You may find SQLite's documentation particularly helpful since Couchbase Lite's querying is -## based on SQLite. -## -## Two types of indexes are currently supported: -## FLValue 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. -## Types of database indexes. -type - CBLIndexType* {.size: sizeof(cint).} = enum - kValueIndex, ## An index that stores property or expression values - kFullTextIndex ## An index of strings, that enables searching for words with `MATCH` - - -## Parameters for creating a database index. -type - CBLIndexSpec* {.bycopy.} = object - `type`*: CBLIndexType ## The type of index to create. - ## A JSON array describing each column of the index. - keyExpressionsJSON*: cstring ## In a full-text index, should diacritical marks (accents) be ignored? - ## Defaults to false. Generally this should be left `false` for non-English text. - ignoreAccents*: bool ## In a full-text index, the dominant language. Setting this enables word stemming, i.e. - ## matching different cases of the same word ("big" and "bigger", for instance) and ignoring - ## common "stop-words" ("the", "a", "of", etc.) - ## - ## Can be an ISO-639 language code or a lowercase (English) language name; supported - ## languages are: da/danish, nl/dutch, en/english, fi/finnish, fr/french, de/german, - ## hu/hungarian, it/italian, no/norwegian, pt/portuguese, ro/romanian, ru/russian, - ## es/spanish, sv/swedish, tr/turkish. - ## - ## If left null, or set to an unrecognized language, no language-specific behaviors - ## such as stemming and stop-word removal occur. - language*: cstring - - -## Creates a database index. -## Indexes are persistent. -## If an identical index with that name already exists, nothing happens (and no error is returned.) -## If a non-identical index with that name already exists, it is deleted and re-created. -proc createDatabaseIndex*(db: CBLDatabase; name: cstring; a3: CBLIndexSpec; - err: var CBLError): bool {.importc: "CBLDatabase_CreateIndex".} - -## Deletes an index given its name. -proc deleteIndex*(db: CBLDatabase; name: cstring; err: var CBLError): bool {. - importc: "CBLDatabase_DeleteIndex".} - -## Returns the names of the indexes on this database, as an array of strings. -proc indexNames*(db: CBLDatabase): FLMutableArray {. - importc: "CBLDatabase_IndexNames".} - - - - -## -## CBLReplicator.h -## -## Copyright (c) 2018 Couchbase, Inc 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. -## -## \defgroup replication Replication -## A replicator is a background task that synchronizes changes between a local database and -## another database on a remote server (or on a peer device, or even another local database.) -## \name Configuration -## The name of the HTTP cookie used by Sync Gateway to store session keys. -var kAuthDefaultCookieName* {.importc: "kCBLAuthDefaultCookieName".}: cstring - -type - CBLEndpoint* = ptr object - CBLAuthenticator* = ptr object ## An opaque object representing authentication credentials for a remote server. - -## Creates a new endpoint representing a server-based database at the given URL. -## The URL's scheme must be `ws` or `wss`, it must of course have a valid hostname, -## and its path must be the name of the database on that server. -## The port can be omitted; it defaults to 80 for `ws` and 443 for `wss`. -## For example: `wss://example.org/dbname` -proc newEndpointWithURL*(url: cstring): CBLEndpoint {. - importc: "CBLEndpoint_NewWithURL".} - -## Creates a new endpoint representing another local database. (Enterprise Edition only.) -proc newEndpointWithLocalDB*(db: CBLDatabase): CBLEndpoint {. - importc: "CBLEndpoint_NewWithLocalDB".} - -## Frees a CBLEndpoint object. -proc free*(a1: CBLEndpoint) {.importc: "CBLEndpoint_Free".} - - -## Creates an authenticator for HTTP Basic (username/password) auth. -proc newAuthBasic*(username: cstring; password: cstring): CBLAuthenticator {. - importc: "CBLAuth_NewBasic".} - -## Creates an authenticator using a Couchbase Sync Gateway login session identifier, -## and optionally a cookie name (pass NULL for the default.) -proc newAuthSession*(sessionID: cstring; - cookieName: cstring): CBLAuthenticator {.importc: "CBLAuth_NewSession".} - -## Frees a CBLAuthenticator object. -proc free*(a1: CBLAuthenticator) {.importc: "CBLAuth_Free".} - -## Direction of replication: push, pull, or both. -type - CBLReplicatorType* {.size: sizeof(cint).} = enum - kReplicatorTypePushAndPull = 0, ## Bidirectional; both push and pull - kReplicatorTypePush, ## Pushing changes to the target - kReplicatorTypePull ## Pulling changes from the target - - -## A callback that can decide whether a particular document should be pushed or pulled. -## It must pay attention to thread-safety. It should not take a long time to return, -## or it will slow down the replicator. -type - CBLReplicationFilter* = proc (context: pointer; document: CBLDocument; - isDeleted: bool): bool - -## Conflict-resolution callback for use in replications. This callback will be invoked -## when the replicator finds a newer server-side revision of a document that also has local -## changes. The local and remote changes must be resolved before the document can be pushed -## to the server. -## It must pay attention to thread-safety. However, unlike a filter callback, -## it does not need to return quickly. If it needs to prompt for user input, -## that's OK. -## or NULL if the local document has been deleted. -## or NULL if the document has been deleted on the server. -## This can be the same as \p localDocument or \p remoteDocument, or you can create -## a mutable copy of either one and modify it appropriately. -## Or return NULL if the resolution is to delete the document. -type - CBLConflictResolver* = proc (context: pointer; documentID: cstring; - localDocument: CBLDocument; remoteDocument: CBLDocument): CBLDocument - -## Default conflict resolver. This always returns `localDocument`. -var defaultConflictResolver* {.importc: "CBLDefaultConflictResolver".}: CBLConflictResolver - -## Types of proxy servers, for CBLProxySettings. -type - CBLProxyType* {.size: sizeof(cint).} = enum - kProxyHTTP, ## HTTP proxy; must support 'CONNECT' method - kProxyHTTPS ## HTTPS proxy; must support 'CONNECT' method - - -## Proxy settings for the replicator. -type - CBLProxySettings* {.bycopy.} = object - `type`*: CBLProxyType ## Type of proxy - hostname*: cstring ## Proxy server hostname or IP address - port*: uint16 ## Proxy server port - username*: cstring ## Username for proxy auth (optional) - password*: cstring ## Password for proxy auth - - -## The configuration of a replicator. -type - CBLReplicatorConfiguration* {.bycopy.} = object - database*: CBLDatabase ## The database to replicate - endpoint*: CBLEndpoint ## The address of the other database to replicate with - replicatorType*: CBLReplicatorType ## Push, pull or both - continuous*: bool ## Continuous replication? - ## -- HTTP settings: - authenticator*: CBLAuthenticator ## Authentication credentials, if needed - proxy*: ptr CBLProxySettings ## HTTP client proxy settings - headers*: FLDict ## Extra HTTP headers to add to the WebSocket request - ## -- TLS settings: - pinnedServerCertificate*: FLSlice ## An X.509 cert to "pin" TLS connections to (PEM or DER) - trustedRootCertificates*: FLSlice ## Set of anchor certs (PEM format) - ## -- Filtering: - channels*: FLArray ## Optional set of channels to pull from - documentIDs*: FLArray ## Optional set of document IDs to replicate - pushFilter*: CBLReplicationFilter ## Optional callback to filter which docs are pushed - pullFilter*: CBLReplicationFilter ## Optional callback to validate incoming docs - conflictResolver*: CBLConflictResolver ## Optional conflict-resolver callback - context*: pointer ## Arbitrary value that will be passed to callbacks - - -## \name Lifecycle -## Creates a replicator with the given configuration. -proc newReplicator*(a1: ptr CBLReplicatorConfiguration; - err: var CBLError): CBLReplicator {.importc: "CBLReplicator_New".} - -## Returns the configuration of an existing replicator. -proc config*(a1: CBLReplicator): ptr CBLReplicatorConfiguration {. - importc: "CBLReplicator_Config".} - -## Instructs the replicator to ignore existing checkpoints the next time it runs. -## This will cause it to scan through all the documents on the remote database, which takes -## a lot longer, but it can resolve problems with missing documents if the client and -## server have gotten out of sync somehow. -proc resetCheckpoint*(a1: CBLReplicator) {. - importc: "CBLReplicator_ResetCheckpoint".} - -## Starts a replicator, asynchronously. Does nothing if it's already started. -proc start*(a1: CBLReplicator) {.importc: "CBLReplicator_Start".} - -## Stops a running replicator, asynchronously. Does nothing if it's not already started. -## The replicator will call your \ref CBLReplicatorChangeListener with an activity level of -## \ref kCBLReplicatorStopped after it stops. Until then, consider it still active. -proc stop*(a1: CBLReplicator) {.importc: "CBLReplicator_Stop".} - -## Informs the replicator whether it's considered possible to reach the remote host with -## the current network configuration. The default value is true. This only affects the -## replicator's behavior while it's in the Offline state: -## Setting it to false will cancel any pending retry and prevent future automatic retries. -## Setting it back to true will initiate an immediate retry. -proc setHostReachable*(a1: CBLReplicator; reachable: bool) {. - importc: "CBLReplicator_SetHostReachable".} - -## Puts the replicator in or out of "suspended" state. The default is false. -## Setting suspended=true causes the replicator to disconnect and enter Offline state; -## it will not attempt to reconnect while it's suspended. -## Setting suspended=false causes the replicator to attempt to reconnect, _if_ it was -## connected when suspended, and is still in Offline state. -proc setSuspended*(repl: CBLReplicator; suspended: bool) {. - importc: "CBLReplicator_SetSuspended".} - -## \name Status and Progress -## -## The possible states a replicator can be in during its lifecycle. -type - CBLReplicatorActivityLevel* {.size: sizeof(cint).} = enum - kReplicatorStopped, ## The replicator is unstarted, finished, or hit a fatal error. - kReplicatorOffline, ## The replicator is offline, as the remote host is unreachable. - kReplicatorConnecting, ## The replicator is connecting to the remote host. - kReplicatorIdle, ## The replicator is inactive, waiting for changes to sync. - kReplicatorBusy ## The replicator is actively transferring data. - - -## A fractional progress value, ranging from 0.0 to 1.0 as replication progresses. -## The value is very approximate and may bounce around during replication; making it more -## accurate would require slowing down the replicator and incurring more load on the server. -## It's fine to use in a progress bar, though. -type - CBLReplicatorProgress* {.bycopy.} = object - fractionComplete*: cfloat ## / Very-approximate completion, from 0.0 to 1.0 - documentCount*: uint64 ## Number of documents transferred so far - - -## A replicator's current status. -type - ReplicatorStatus* {.bycopy.} = object - activity*: CBLReplicatorActivityLevel ## Current state - progress*: CBLReplicatorProgress ## Approximate fraction complete - error*: CBLError ## CBLError, if any - - -## Returns the replicator's current status. -proc getStatus*(a1: CBLReplicator): ReplicatorStatus {. - importc: "CBLReplicator_GetStatus".} - -## Indicates which documents have local changes that have not yet been pushed to the server -## by this replicator. This is of course a snapshot, that will go out of date as the replicator -## makes progress and/or documents are saved locally. -## -## The result is, effectively, a set of document IDs: a dictionary whose keys are the IDs and -## values are `true`. -## If there are no pending documents, the dictionary is empty. -## On error, NULL is returned. -## -## \note This function can be called on a stopped or un-started replicator. -## \note Documents that would never be pushed by this replicator, due to its configuration's -## `pushFilter` or `docIDs`, are ignored. -## \warning You are responsible for releasing the returned array via \ref FLValue_Release. -proc pendingDocumentIDs*(a1: CBLReplicator; err: var CBLError): FLDict {. - importc: "CBLReplicator_PendingDocumentIDs".} - -## Indicates whether the document with the given ID has local changes that have not yet been -## pushed to the server by this replicator. -## -## This is equivalent to, but faster than, calling \ref CBLReplicator_PendingDocumentIDs and -## checking whether the result contains \p docID. See that function's documentation for details. -## -## \note A `false` result means the document is not pending, _or_ there was an error. -## To tell the difference, compare the error code to zero. -proc isDocumentPending*(repl: CBLReplicator; docID: FLString; - err: var CBLError): bool {.importc: "CBLReplicator_IsDocumentPending".} - -## A callback that notifies you when the replicator's status changes. -## It must pay attention to thread-safety. It should not take a long time to return, -## or it will slow down the replicator. -type - CBLReplicatorChangeListener* = proc (context: pointer; - replicator: CBLReplicator; status: ptr ReplicatorStatus) - -## Adds a listener that will be called when the replicator's status changes. -proc addChangeListener*(a1: CBLReplicator; a2: CBLReplicatorChangeListener; - context: pointer): CBLListenerToken {. - importc: "CBLReplicator_AddChangeListener".} - -## Flags describing a replicated document. -type - CBLDocumentFlags* {.size: sizeof(cint).} = enum - kDocumentFlagsDeleted = 1 shl 0, ## The document has been deleted. - kDocumentFlagsAccessRemoved = 1 shl 1 - - -## Information about a document that's been pushed or pulled. -type - CBLReplicatedDocument* {.bycopy.} = object - id*: cstring ## The document ID - flags*: CBLDocumentFlags ## Indicates whether the document was deleted or removed - error*: CBLError ## If the code is nonzero, the document failed to replicate. - - -## A callback that notifies you when documents are replicated. -## It must pay attention to thread-safety. It should not take a long time to return, -## or it will slow down the replicator. -type - CBLReplicatedDocumentListener* = proc (context: pointer; - replicator: CBLReplicator; isPush: bool; numDocuments: cuint; - documents: ptr CBLReplicatedDocument) - -## Adds a listener that will be called when documents are replicated. -proc addDocumentListener*(a1: CBLReplicator; a2: CBLReplicatedDocumentListener; - context: pointer): CBLListenerToken {. - importc: "CBLReplicator_AddDocumentListener".} - -{.pop.} diff --git a/bindings/nim/src/CouchbaseLite/private/fl.nim b/bindings/nim/src/CouchbaseLite/private/fl.nim deleted file mode 100644 index 58c2859a..00000000 --- a/bindings/nim/src/CouchbaseLite/private/fl.nim +++ /dev/null @@ -1,1004 +0,0 @@ -## *** NOTE: DO NOT MACHINE-UPDATE THIS FILE *** -## -## This started out as a machine-generated file (produced by `gen-bindings.sh`), -## but it has been hand-edited to fix issues that kept it from compiling. -## -## If you run the script again, it will generate a _new_ file `Fleece-new.nim`. -## You'll need to merge new/changed declarations from that file into this one, by hand. -## -## Status: Up-to-date as of 5 May 2020, commit 036cd9f7 "Export kCBLAuthDefaultCookieName...", -## Fleece commit 4ca3dbf1, "Mutable.hh: Allow conversion of keyRef and FLSlot to FLSlot". - - -when defined(Linux): - {.push dynlib: "libcblite.so".} -elif defined(MacOS) or defined(MacOSX): - {.push dynlib: "libcblite.dylib".} -elif defined(Windows): - {.push dynlib: "cblite.dll".} - - -## FLSlice.h -## Fleece -## -## Created by Jens Alfke on 8/13/18. -## Copyright © 2018 Couchbase. All rights reserved. -## -## A simple reference to a block of memory. Does not imply ownership. -## (This is equivalent to the C++ class `slice`.) -type - FLSlice* {.bycopy.} = object - buf*: pointer - size*: csize_t - - -## A block of memory returned from an API call. The caller takes ownership, and must call -## FLSlice_Release (or FLSlice_Free) when done. The heap block may be shared with other users, -## so it must not be modified. -## (This is equivalent to the C++ class `alloc_slice`.) -type - FLSliceResult* {.bycopy.} = object - buf*: pointer - size*: csize_t - - -## 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. -type - FLHeapSlice* = FLSlice - -type - FLString* = FLSlice - FLStringResult* = FLSliceResult - -## Slice <-> string conversion: -proc flStr*(str: string): FLSlice = - FLSlice(buf: cstring(str), size: csize_t(len(str))) - - -## Equality test of two slices. -proc equal*(a: FLSlice; b: FLSlice): bool {.importc: "FLSlice_Equal".} - -## Lexicographic comparison of two slices; basically like memcmp(), but taking into account -## differences in length. -proc compare*(a1: FLSlice; a2: FLSlice): cint {.importc: "FLSlice_Compare".} - -## Allocates an FLSliceResult of the given size, without initializing the buffer. -proc newSliceResult*(a1: csize_t): FLSliceResult {.importc: "FLSliceResult_New".} - -## Allocates an FLSliceResult, copying the given slice. -proc copy*(a1: FLSlice): FLSliceResult {.importc: "FLSlice_Copy".} - -proc internalFLBufRetain(a1: pointer) {.importc: "_FLBuf_Retain".} -proc internalFLBufRelease(a1: pointer) {.importc: "_FLBuf_Release".} - - -# Hand-written: Automatic ref-counting for FLSliceResult -# (see: ) - -proc `=destroy`(s: var FLSliceResult) = - internalFLBufRelease(s.buf) - -proc `=`(dest: var FLSliceResult; source: FLSliceResult) = - let oldBuf = dest.buf - if oldBuf != source.buf: - internalFLBufRetain(source.buf) - dest.buf = source.buf - internalFLBufRelease(oldBuf) - dest.size = source.size - - -#%%%%%%% NIM CONVERSIONS FOR SLICES: -proc asSlice*(s: FLSliceResult): fl.FLSlice = - FLSlice(buf: s.buf, size: s.size) - -proc asSlice*(bytes: openarray[byte]): fl.FLSlice = - FLSlice(buf: unsafeAddr bytes[0], size: csize_t(bytes.len)) - -proc asSlice*(str: string): fl.FLSlice = - FLSlice(buf: unsafeAddr str[0], size: csize_t(str.len)) - -proc toString*(s: FLSlice): string = - if s.buf == nil: return "" - var str = newString(s.size) - copyMem(addr str[0], s.buf, s.size) - return str - -proc toString*(s: FLSliceResult): string = - toString(s.asSlice()) - -proc toByteArray*(s: FLSlice): seq[uint8] = - var bytes = newSeq[uint8](s.size) - copyMem(addr bytes[0], s.buf, s.size) - return bytes - -## -## Fleece.h -## -## Copyright (c) 2016 Couchbase, Inc 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. -## -## This is the C API! For the C++ API, see Fleece.hh. - -## ////// BASIC TYPES -type - FLValue* = ptr object ## A reference to a value of any type. - FLArray* = ptr object ## A reference to an array value. - FLDict* = ptr object ## A reference to a dictionary (map) value. - FLSlot* = ptr object ## A reference to a mutable array/dict item - FLMutableArray* = ptr object ## A reference to a mutable array. - FLMutableDict* = ptr object ## A reference to a mutable dictionary. - -## Error codes returned from some API calls. -type - FLError* {.size: sizeof(cint).} = enum - NoError = 0, - MemoryError, ## Out of memory, or allocation failed - OutOfRange, ## Array index or iterator out of range - InvalidData, ## Bad input data (NaN, non-string key, etc.) - EncodeError, ## Structural error encoding (missing value, too many ends, etc.) - JSONError, ## Error parsing JSON - UnknownValue, ## Unparseable data in a FLValue (corrupt? Or from some distant future?) - InternalError, ## Something that shouldn't happen - NotFound, ## Key not found - SharedKeysStateError, ## Misuse of shared keys (not in transaction, etc.) - POSIXError, ## POSIX API call failed - Unsupported ## Operation is unsupported - - - -## ////// DOCUMENT -## An FLDoc points to (and often owns) Fleece-encoded data and provides access to its -## Fleece values. -## -type - FLDoc* = ptr object ## A reference to a document. - SharedKeys* = ptr object ## A reference to a shared-keys mapping. - -## Specifies whether not input data is trusted to be 100% valid Fleece. -type ## Input data is not trusted to be valid, and will be fully validated by the API call. - FLTrust* {.size: sizeof(cint).} = enum - kUntrusted, ## 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 FLValue accessor functions can - ## crash or return bogus results (including data from arbitrary memory locations.) - kTrusted - - -## 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. -proc newDocFromResultData*(data: FLSliceResult; a2: FLTrust; a3: SharedKeys; externData: FLSlice): FLDoc {.importc: "FLDoc_FromResultData".} - -## 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. -proc newDocFromJSON*(json: FLSlice; outError: var FLError): FLDoc {.importc: "FLDoc_FromJSON".} - -## Releases a reference to an FLDoc. This must be called once to free an FLDoc you created. -proc release*(a1: FLDoc) {.importc: "FLDoc_Release".} - -## Adds a reference to an FLDoc. This extends its lifespan until at least such time as you -## call FLRelease to remove the reference. -proc retain*(a1: FLDoc): FLDoc {.importc: "FLDoc_Retain".} - -## Returns the encoded Fleece data backing the document. -proc getData*(a1: FLDoc): FLSlice {.importc: "FLDoc_GetData".} - -## Returns the FLSliceResult data owned by the document, if any, else a null slice. -proc getAllocedData*(a1: FLDoc): FLSliceResult {.importc: "FLDoc_GetAllocedData".} - -## Returns the root value in the FLDoc, usually an FLDict. -proc getRoot*(a1: FLDoc): FLValue {.importc: "FLDoc_GetRoot".} - -## Returns the FLSharedKeys used by this FLDoc, as specified when it was created. -proc getSharedKeys*(a1: FLDoc): SharedKeys {.importc: "FLDoc_GetSharedKeys".} - -## Looks up the FLDoc containing the FLValue, or NULL if the FLValue was created without a FLDoc. -## Caller must release the FLDoc reference!! -proc findDoc*(a1: FLValue): FLDoc {.importc: "FLValue_FindDoc".} - - - -## 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. -proc newValueFromData*(data: FLSlice; a2: FLTrust): FLValue {.importc: "FLValue_FromData".} - -## Directly converts JSON data to Fleece-encoded data. -## You can then call FLValue_FromData (in kFLTrusted mode) to get the root as a FLValue. -proc convertJSON*(json: FLSlice; outError: var FLError): FLSliceResult {.importc: "FLData_ConvertJSON".} - -## Produces a human-readable dump of the FLValue encoded in the data. -## This is only useful if you already know, or want to learn, the encoding format. -proc dump*(data: FLSlice): FLStringResult {.importc: "FLData_Dump".} - -## These are convenience functions that directly return JSON-encoded output. -## For more control over the encoding, use an FLEncoder. -## Encodes a Fleece value as JSON (or a JSON fragment.) -## Any Data values will become base64-encoded JSON strings. -proc toJSON*(a1: FLValue): FLStringResult {.importc: "FLValue_ToJSON".} - -## 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. -proc toJSON5*(v: FLValue): FLStringResult {.importc: "FLValue_ToJSON5".} - -## Most general Fleece to JSON converter. -proc toJSONX*(v: FLValue; json5: bool; canonicalForm: bool): FLStringResult {.importc: "FLValue_ToJSONX".} - -## Converts valid JSON5 to JSON. Among other things, it converts single -## quotes to double, adds missing quotes around dictionary keys, removes trailing commas, -## and removes comments. -## 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. -## As this is a \ref FLStringResult, you will be responsible for freeing it. -## will be stored here (if it's not NULL.) -proc jSON5ToJSON*(json5: FLString; outErrorMessage: ptr FLStringResult; outErrorPos: ptr csize_t; outError: var FLError): FLStringResult {.importc: "FLJSON5_ToJSON".} - -## Debugging function that returns a C string of JSON. Does not free the string's memory! -proc dump*(a1: FLValue): cstring {.importc: "FLDump".} - -## Debugging function that returns a C string of JSON. Does not free the string's memory! -proc dumpData*(data: FLSlice): cstring {.importc: "FLDumpData".} - - - -## ////// VALUE -## 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. - -## Types of Fleece values. Basically JSON, with the addition of Data (raw blob). -type - FLValueType* {.size: sizeof(cint).} = enum - kUndefined = -1, ## Type of a NULL pointer, i.e. no such value, like JSON `undefined`. Also the type of a value created by FLEncoder_WriteUndefined(). - kNull = 0, ## Equivalent to a JSON 'null' - kBoolean, ## A `true` or `false` value - kNumber, ## A numeric value, either integer or floating-point - kString, ## A string - kData, ## Binary data (no JSON equivalent) - kArray, ## An array of values - kDict ## A mapping of strings to values - - -## A timestamp, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) -type - FLTimestamp* = distinct int64 - -## A value representing a missing timestamp; returned when a date cannot be parsed. -const - TimestampNone* = FLTimestamp(-0x7FFFFFFFFFFFFFFF'i64) - -## Returns the data type of an arbitrary FLValue. -## (If the parameter is a NULL pointer, returns `kFLUndefined`.) -proc getType*(a1: FLValue): FLValueType {.importc: "FLValue_GetType".} - -## Returns true if the value is non-NULL and represents an integer. -proc isInteger*(a1: FLValue): bool {.importc: "FLValue_IsInteger".} - -## Returns true if the value is non-NULL and represents an integer >= 2^63. 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. -proc isUnsigned*(a1: FLValue): bool {.importc: "FLValue_IsUnsigned".} - -## Returns true if the value is non-NULL and represents a 64-bit floating-point number. -proc isDouble*(a1: FLValue): bool {.importc: "FLValue_IsDouble".} - -## Returns a value coerced to boolean. This will be true unless the value is NULL (undefined), -## null, false, or zero. -proc asBool*(a1: FLValue): bool {.importc: "FLValue_AsBool".} - -## Returns a value coerced to an integer. True and false are returned as 1 and 0, and -## floating-point numbers are rounded. All other types are returned as 0. -## check for these by calling `FLValueIsUnsigned`. -proc asInt*(a1: FLValue): int64 {.importc: "FLValue_AsInt".} - -## Returns a value coerced to an unsigned integer. -## This is the same as `FLValueAsInt` except that it _can't_ handle negative numbers, but -## does correctly return large `uint64_t` values of 2^63 and up. -proc asUnsigned*(a1: FLValue): uint64 {.importc: "FLValue_AsUnsigned".} - -## Returns a value coerced to a 32-bit floating point number. -## True and false are returned as 1.0 and 0.0, and integers are converted to float. All other -## types are returned as 0.0. -## limitations of IEEE 32-bit float format. -proc asFloat*(a1: FLValue): cfloat {.importc: "FLValue_AsFloat".} - -## Returns a value coerced to a 32-bit floating point number. -## True and false are returned as 1.0 and 0.0, and integers are converted to float. All other -## types are returned as 0.0. -## the limitations of IEEE 32-bit float format. -proc asDouble*(a1: FLValue): cdouble {.importc: "FLValue_AsDouble".} - -## Returns the exact contents of a string value, or null for all other types. -proc asString*(a1: FLValue): FLString {.importc: "FLValue_AsString".} - -## Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure. -## - A string is parsed as ISO-8601 (standard JSON date format). -## - A number is interpreted as a timestamp and returned as-is. -proc asTimestamp*(a1: FLValue): FLTimestamp {.importc: "FLValue_AsTimestamp".} - -## Returns the exact contents of a data value, or null for all other types. -proc asData*(a1: FLValue): FLSlice {.importc: "FLValue_AsData".} - -## If a FLValue represents an array, returns it cast to FLArray, else NULL. -proc asArray*(a1: FLValue): FLArray {.importc: "FLValue_AsArray".} - -## If a FLValue represents a dictionary, returns it as an FLDict, else NULL. -proc asDict*(a1: FLValue): FLDict {.importc: "FLValue_AsDict".} - -## Returns a string representation of any scalar value. Data values are returned in raw form. -## Arrays and dictionaries don't have a representation and will return NULL. -proc toString*(a1: FLValue): FLStringResult {.importc: "FLValue_ToString".} - -## Compares two values for equality. This is a deep recursive comparison. -proc isEqual*(v1: FLValue; v2: FLValue): bool {.importc: "FLValue_IsEqual".} - -## If this value is mutable (and thus heap-based) its ref-count is incremented. -## Otherwise, this call does nothing. -proc retain*(a1: FLValue): FLValue {.importc: "FLValue_Retain".} - -## If this value is mutable (and thus heap-based) its ref-count is decremented, and if it -## reaches zero the value is freed. -## If the value is not mutable, this call does nothing. -proc release*(a1: FLValue) {.importc: "FLValue_Release".} -proc retain*(v: FLArray): FLArray {.inline.} = - return cast[FLArray](retain(cast[FLValue](v))) - -proc release*(v: FLArray) {.inline.} = - release(cast[FLValue](v)) - -proc retain*(v: FLDict): FLDict {.inline.} = - return cast[FLDict](retain(cast[FLValue](v))) - -proc release*(v: FLDict) {.inline.} = - release(cast[FLValue](v)) - -var kNullValue* {.importc: "kFLNullValue".}: FLValue - - - -## ////// VALUE SLOT -proc setNull*(a1: FLSlot) {.importc: "FLSlot_SetNull".} ## Stores a JSON null into a slot. - -proc set*(a1: FLSlot; a2: bool) {.importc: "FLSlot_SetBool".} ## Stores a boolean into a slot. - -proc set*(a1: FLSlot; a2: int64) {.importc: "FLSlot_SetInt".} ## Stores an integer into a slot. - -proc set*(a1: FLSlot; a2: uint64) {.importc: "FLSlot_SetUInt".} ## Stores an unsigned integer into a slot. - -proc set*(a1: FLSlot; a2: cfloat) {.importc: "FLSlot_SetFloat".} ## Stores a float into a slot. - -proc set*(a1: FLSlot; a2: cdouble) {.importc: "FLSlot_SetDouble".} ## Stores a double into a slot. - -proc set*(a1: FLSlot; a2: FLString) {.importc: "FLSlot_SetString".} ## Stores a string into a slot. - -proc setData*(a1: FLSlot; a2: FLSlice) {.importc: "FLSlot_SetData".} ## Stores a data blob into a slot. - -proc set*(a1: FLSlot; a2: FLValue) {.importc: "FLSlot_SetValue".} ## Stores an FLValue into a slot. - - - -## ////// ARRAY -## 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. - -## Returns the number of items in an array, or 0 if the pointer is NULL. -proc count*(a1: FLArray): uint32 {.importc: "FLArray_Count".} - -## Returns true if an array is empty (or NULL). Depending on the array's representation, -## this can be faster than `FLArray_Count(a) == 0` -proc isEmpty*(a1: FLArray): bool {.importc: "FLArray_IsEmpty".} - -## If the array is mutable, returns it cast to FLMutableArray, else NULL. -proc asMutable*(a1: FLArray): FLMutableArray {.importc: "FLArray_AsMutable".} - -## Returns an value at an array index, or NULL if the index is out of range. -proc get*(a1: FLArray; index: uint32): FLValue {.importc: "FLArray_Get".} -var kEmptyArray* {.importc: "kFLEmptyArray".}: FLArray - -## Iterating an array typically looks like this: -## -## ``` -## FLArrayIterator iter; -## FLArrayIterator_Begin(theArray, &iter); -## FLValue value; -## while (NULL != (value = FLArrayIterator_GetValue(&iter))) { -## // ... -## FLArrayIterator_Next(&iter); -## } -## ``` - - -## Opaque array iterator. Declare one on the stack and pass its address to -## `FLArrayIteratorBegin`. -type - FLArrayIterator* {.bycopy.} = object - internalprivate1*: pointer - internalprivate2*: uint32 - internalprivate3*: bool - internalprivate4*: pointer - -## Initializes a FLArrayIterator struct to iterate over an array. -## Call FLArrayIteratorGetValue to get the first item, then FLArrayIteratorNext. -proc begin*(a1: FLArray; a2: ptr FLArrayIterator) {.importc: "FLArrayIterator_Begin".} - -## Returns the current value being iterated over. -proc getValue*(a1: ptr FLArrayIterator): FLValue {.importc: "FLArrayIterator_GetValue".} - -## Returns a value in the array at the given offset from the current value. -proc getValueAt*(a1: ptr FLArrayIterator; offset: uint32): FLValue {.importc: "FLArrayIterator_GetValueAt".} - -## Returns the number of items remaining to be iterated, including the current one. -proc getCount*(a1: ptr FLArrayIterator): uint32 {.importc: "FLArrayIterator_GetCount".} - -## Advances the iterator to the next value, or returns false if at the end. -proc next*(a1: ptr FLArrayIterator): bool {.importc: "FLArrayIterator_Next".} - - - -## ////// MUTABLE ARRAY - - -type - CopyFlags* {.size: sizeof(cint).} = enum - DefaultCopy = 0, DeepCopy = 1, CopyImmutables = 2, DeepCopyImmutables = 3 - - -## Creates a new mutable FLArray that's a copy of the source FLArray. -## Its initial ref-count is 1, so a call to FLMutableArray_Release will free it. -## -## Copying an immutable FLArray is very cheap (only one small allocation) unless the flag -## kFLCopyImmutables is set. -## -## Copying a mutable FLArray 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 FLArray is NULL, then NULL is returned. -proc mutableCopy*(a1: FLArray; a2: CopyFlags): FLMutableArray {.importc: "FLArray_MutableCopy".} - -## Creates a new empty mutable FLArray. -## Its initial ref-count is 1, so a call to FLMutableArray_Free will free it. -proc newMutableArray*(): FLMutableArray {.importc: "FLMutableArray_New".} - -## Increments the ref-count of a mutable FLArray. -proc retain*(d: FLMutableArray): FLMutableArray {.inline.} = - return cast[FLMutableArray](retain(cast[FLValue](d))) - -## Decrements the refcount of (and possibly frees) a mutable FLArray. -proc release*(d: FLMutableArray) {.inline.} = - release(cast[FLValue](d)) - -## If the FLArray was created by FLArray_MutableCopy, returns the original source FLArray. -proc getSource*(a1: FLMutableArray): FLArray {.importc: "FLMutableArray_GetSource".} - -## Returns true if the FLArray has been changed from the source it was copied from. -proc isChanged*(a1: FLMutableArray): bool {.importc: "FLMutableArray_IsChanged".} - -## Lets you store a value into a FLMutableArray, by returning a \ref FLSlot that you can call -## a function like \ref FLSlot_SetInt on. -proc set*(a1: FLMutableArray; index: uint32): FLSlot {.importc: "FLMutableArray_Set".} - -## Appends a null value to a FLMutableArray and returns a \ref FLSlot that you can call -## to store something else in the new value. -proc append*(a1: FLMutableArray): FLSlot {.importc: "FLMutableArray_Append".} - -## Inserts a contiguous range of JSON `null` values into the array. -proc insert*(array: FLMutableArray; firstIndex: uint32; count: uint32) {.importc: "FLMutableArray_Insert".} - -## Removes contiguous items from the array. -proc remove*(array: FLMutableArray; firstIndex: uint32; count: uint32) {.importc: "FLMutableArray_Remove".} - -## 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. -proc resize*(array: FLMutableArray; size: uint32) {.importc: "FLMutableArray_Resize".} - -## 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. -proc getMutableArray*(a1: FLMutableArray; index: uint32): FLMutableArray {.importc: "FLMutableArray_GetMutableArray".} - -## 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. -proc getMutableDict*(a1: FLMutableArray; index: uint32): FLMutableDict {.importc: "FLMutableArray_GetMutableDict".} - - - -## ////// DICT - -## Returns the number of items in a dictionary, or 0 if the pointer is NULL. -proc count*(a1: FLDict): uint32 {.importc: "FLDict_Count".} - -## Returns true if a dictionary is empty (or NULL). Depending on the dictionary's -## representation, this can be faster than `FLDict_Count(a) == 0` -proc isEmpty*(a1: FLDict): bool {.importc: "FLDict_IsEmpty".} - -## If the dictionary is mutable, returns it cast to FLMutableDict, else NULL. -proc asMutable*(a1: FLDict): FLMutableDict {.importc: "FLDict_AsMutable".} - -## Looks up a key in a dictionary, returning its value. -## Returns NULL if the value is not found or if the dictionary is NULL. -proc get*(a1: FLDict; keyString: FLSlice): FLValue {.importc: "FLDict_Get".} -var kEmptyDict* {.importc: "kFLEmptyDict".}: FLDict - -## Iterating a dictionary typically looks like this: -## -## ``` -## FLDictIterator iter; -## FLDictIterator_Begin(theDict, &iter); -## FLValue value; -## while (NULL != (value = FLDictIterator_GetValue(&iter))) { -## FLString key = FLDictIterator_GetKeyString(&iter); -## // ... -## FLDictIterator_Next(&iter); -## } -## ``` -## -## Opaque dictionary iterator. Declare one on the stack, and pass its address to -## FLDictIterator_Begin. -type - FLDictIterator* {.bycopy.} = object - internalprivate1*: pointer - internalprivate2*: uint32 - internalprivate3*: bool - internalprivate4*: array[4, pointer] - internalprivate5*: cint - -## Initializes a FLDictIterator struct to iterate over a dictionary. -## Call FLDictIterator_GetKey and FLDictIterator_GetValue to get the first item, -## then FLDictIterator_Next. -proc begin*(a1: FLDict; a2: ptr FLDictIterator) {.importc: "FLDictIterator_Begin".} - -## Returns the current key being iterated over. This FLValue will be a string or an integer. -proc getKey*(a1: ptr FLDictIterator): FLValue {.importc: "FLDictIterator_GetKey".} - -## Returns the current key's string value. -proc getKeyString*(a1: ptr FLDictIterator): FLString {.importc: "FLDictIterator_GetKeyString".} - -## Returns the current value being iterated over. -proc getValue*(a1: ptr FLDictIterator): FLValue {.importc: "FLDictIterator_GetValue".} - -## Returns the number of items remaining to be iterated, including the current one. -proc getCount*(a1: ptr FLDictIterator): uint32 {.importc: "FLDictIterator_GetCount".} - -## Advances the iterator to the next value, or returns false if at the end. -proc next*(a1: ptr FLDictIterator): bool {.importc: "FLDictIterator_Next".} - -## Cleans up after an iterator. Only needed if (a) the dictionary is a delta, and -## (b) you stop iterating before the end (i.e. before FLDictIterator_Next returns false.) -proc `end`*(a1: ptr FLDictIterator) {.importc: "FLDictIterator_End".} - -## 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. -type - FLDictKey* {.bycopy.} = object - internalprivate1*: FLSlice - internalprivate2*: pointer - internalprivate3*: uint32 - private4*: uint32 - private5*: bool - - -## Initializes an FLDictKey struct with a key string. -## use! (The FLDictKey stores a pointer to the string, but does not copy it.) -proc init*(string: FLSlice): FLDictKey {.importc: "FLDictKey_Init".} - -## Returns the string value of the key (which it was initialized with.) -proc getString*(a1: ptr FLDictKey): FLString {.importc: "FLDictKey_GetString".} - -## 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. -proc getWithKey*(a1: FLDict; a2: ptr FLDictKey): FLValue {.importc: "FLDict_GetWithKey".} - - - -## ////// MUTABLE DICT - -## Creates a new mutable FLDict that's a copy of the source FLDict. -## Its initial ref-count is 1, so a call to FLMutableDict_Release will free it. -## -## Copying an immutable FLDict is very cheap (only one small allocation.) The `deepCopy` flag -## is ignored. -## -## Copying a mutable FLDict 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. -proc mutableCopy*(source: FLDict; a2: CopyFlags): FLMutableDict {.importc: "FLDict_MutableCopy".} - -## Creates a new empty mutable FLDict. -## Its initial ref-count is 1, so a call to FLMutableDict_Free will free it. -proc newMutableDict*(): FLMutableDict {.importc: "FLMutableDict_New".} - -## Increments the ref-count of a mutable FLDict. -proc retain*(d: FLMutableDict): FLMutableDict {.inline.} = - return cast[FLMutableDict](retain(cast[FLValue](d))) - -## Decrements the refcount of (and possibly frees) a mutable FLDict. -proc release*(d: FLMutableDict) {.inline.} = - release(cast[FLValue](d)) - -## If the FLDict was created by FLDict_MutableCopy, returns the original source FLDict. -proc getSource*(a1: FLMutableDict): FLDict {.importc: "FLMutableDict_GetSource".} - -## Returns true if the FLDict has been changed from the source it was copied from. -proc isChanged*(a1: FLMutableDict): bool {.importc: "FLMutableDict_IsChanged".} - -## Returns the FLSlot storing the key's value, adding a new one if needed (with a null value.) -## To set the value itself, call one of the FLSlot functions, e.g. \ref FLSlot_SetInt. -proc set*(nonnull: FLMutableDict; key: FLString): FLSlot {.importc: "FLMutableDict_Set".} - -## Removes the value for a key. -proc remove*(a1: FLMutableDict; key: FLString) {.importc: "FLMutableDict_Remove".} - -## Removes all keys and values. -proc removeAll*(a1: FLMutableDict) {.importc: "FLMutableDict_RemoveAll".} - -## 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. -proc getMutableArray*(a1: FLMutableDict; key: FLString): FLMutableArray {.importc: "FLMutableDict_GetMutableArray".} - -## 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. -proc getMutableDict*(a1: FLMutableDict; key: FLString): FLMutableDict {.importc: "FLMutableDict_GetMutableDict".} - - - -## ////// DEEP ITERATOR - -## A deep iterator traverses every value contained in a dictionary, in depth-first order. -## You can skip any nested collection by calling FLDeepIterator_SkipChildren. -type - DeepIterator* = ptr object ## A reference to a deep iterator. - -## Creates a FLDeepIterator to iterate over a dictionary. -## Call FLDeepIterator_GetKey and FLDeepIterator_GetValue to get the first item, -## then FLDeepIterator_Next. -proc newDeepIterator*(a1: FLValue): DeepIterator {.importc: "FLDeepIterator_New".} -proc free*(a1: DeepIterator) {.importc: "FLDeepIterator_Free".} - -## Returns the current value being iterated over. or NULL at the end of iteration. -proc getValue*(a1: DeepIterator): FLValue {.importc: "FLDeepIterator_GetValue".} - -## Returns the key of the current value, or an empty slice if not in a dictionary. -proc getKey*(a1: DeepIterator): FLSlice {.importc: "FLDeepIterator_GetKey".} - -## Returns the array index of the current value, or 0 if not in an array. -proc getIndex*(a1: DeepIterator): uint32 {.importc: "FLDeepIterator_GetIndex".} - -## Returns the current depth in the hierarchy, starting at 1 for the top-level children. -proc getDepth*(a1: DeepIterator): csize_t {.importc: "FLDeepIterator_GetDepth".} - -## Tells the iterator to skip the children of the current value. -proc skipChildren*(a1: DeepIterator) {.importc: "FLDeepIterator_SkipChildren".} - -## Advances the iterator to the next value, or returns false if at the end. -proc next*(a1: DeepIterator): bool {.importc: "FLDeepIterator_Next".} -type - PathComponent* {.bycopy.} = object - key*: FLSlice ## FLDict key, or kFLSliceNull if none - index*: uint32 ## FLArray index, only if there's no key - -## Returns the path as an array of FLPathComponents. -proc getPath*(a1: DeepIterator; outPath: ptr ptr PathComponent; outDepth: ptr csize_t) {.importc: "FLDeepIterator_GetPath".} - -## Returns the current path in JavaScript format. -proc getPathString*(a1: DeepIterator): FLSliceResult {.importc: "FLDeepIterator_GetPathString".} - -## Returns the current path in JSONPointer format (RFC 6901). -proc getJSONPointer*(a1: DeepIterator): FLSliceResult {.importc: "FLDeepIterator_GetJSONPointer".} - - - -## ////// PATH - -## 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 FLKeyPath, 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.) -## -type - FLKeyPath* = ptr object ## A reference to a key path. - -## Creates a new FLKeyPath object by compiling a path specifier string. -proc newKeyPath*(specifier: FLSlice; error: var FLError): FLKeyPath {.importc: "FLKeyPath_New".} - -## Frees a compiled FLKeyPath object. (It's ok to pass NULL.) -proc free*(a1: FLKeyPath) {.importc: "FLKeyPath_Free".} - -## Evaluates a compiled key-path for a given Fleece root object. -proc eval*(a1: FLKeyPath; root: FLValue): FLValue {.importc: "FLKeyPath_Eval".} - -## 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. -proc evalOnce*(specifier: FLSlice; root: FLValue; error: var FLError): FLValue {.importc: "FLKeyPath_EvalOnce".} - - - -## ////// SHARED KEYS - -proc createSharedKeys*(): SharedKeys {.importc: "FLSharedKeys_Create".} -proc retain*(a1: SharedKeys): SharedKeys {.importc: "FLSharedKeys_Retain".} -proc release*(a1: SharedKeys) {.importc: "FLSharedKeys_Release".} -proc createSharedKeysFromStateData*(a1: FLSlice): SharedKeys {.importc: "FLSharedKeys_CreateFromStateData".} -proc getStateData*(a1: SharedKeys): FLSliceResult {.importc: "FLSharedKeys_GetStateData".} -proc encode*(a1: SharedKeys; a2: FLString; add: bool): cint {.importc: "FLSharedKeys_Encode".} -proc decode*(a1: SharedKeys; key: cint): FLString {.importc: "FLSharedKeys_Decode".} -proc count*(a1: SharedKeys): cuint {.importc: "FLSharedKeys_Count".} - - - -## ////// ENCODER - -## 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. -## -type - FLEncoder* = ptr object ## A reference to an encoder. - -## Output formats a FLEncoder can generate. -type - EncoderFormat* {.size: sizeof(cint).} = enum - Fleece, ## Fleece encoding - JSON, ## JSON encoding - JSON5 ## [JSON5](http://json5.org), an extension of JSON with a more readable syntax - - -## Creates a new encoder, for generating Fleece data. Call FLEncoder_Free when done. -proc newEncoder*(): FLEncoder {.importc: "FLEncoder_New".} - -## Creates a new encoder, allowing some options to be customized. -## as a single shared value. This saves space but makes encoding slightly slower. -## You should only turn this off if you know you're going to be writing large numbers -## of non-repeated strings. (Default is true) -proc newEncoderWithOptions*(format: EncoderFormat; reserveSize: csize_t; uniqueStrings: bool): FLEncoder {.importc: "FLEncoder_NewWithOptions".} - -## Creates a new Fleece encoder that writes to a file, not to memory. -proc newEncoderWritingToFile*(a1: ptr File; uniqueStrings: bool): FLEncoder {.importc: "FLEncoder_NewWritingToFile".} - -## Frees the space used by an encoder. -proc free*(a1: FLEncoder) {.importc: "FLEncoder_Free".} - -## Tells the encoder to use a shared-keys mapping when encoding dictionary keys. -proc setSharedKeys*(a1: FLEncoder; a2: SharedKeys) {.importc: "FLEncoder_SetSharedKeys".} - -## Associates an arbitrary user-defined value with the encoder. -proc setExtraInfo*(a1: FLEncoder; info: pointer) {.importc: "FLEncoder_SetExtraInfo".} - -## Returns the user-defined value associated with the encoder; NULL by default. -proc getExtraInfo*(a1: FLEncoder): pointer {.importc: "FLEncoder_GetExtraInfo".} - -## 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. -## just create a pointer back to the original. But the encoder has to scan the -## base for strings first. -## 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. -proc amend*(e: FLEncoder; base: FLSlice; reuseStrings: bool; externPointers: bool) {.importc: "FLEncoder_Amend".} - -## Returns the `base` value passed to FLEncoder_Amend. -proc getBase*(a1: FLEncoder): FLSlice {.importc: "FLEncoder_GetBase".} - -## 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. -proc suppressTrailer*(a1: FLEncoder) {.importc: "FLEncoder_SuppressTrailer".} - -## Resets the state of an encoder without freeing it. It can then be reused to encode -## another value. -proc reset*(a1: FLEncoder) {.importc: "FLEncoder_Reset".} - -## Returns the number of bytes encoded so far. -proc bytesWritten*(a1: FLEncoder): csize_t {.importc: "FLEncoder_BytesWritten".} - -## 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.) -proc getNextWritePos*(a1: FLEncoder): csize_t {.importc: "FLEncoder_GetNextWritePos".} - -## 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. -## Writes a `null` value to an encoder. (This is an explicitly-stored null, like the JSON -## `null`, not the "undefined" value represented by a NULL FLValue pointer.) -proc writeNull*(a1: FLEncoder): bool {.importc: "FLEncoder_WriteNull".} - -## Writes an `undefined` value to an encoder. (Its value when read will not be a `NULL` -## pointer, but it can be recognized by `FLValue_GetType` returning `kFLUndefined`.) -## An undefined dictionary value should be written simply by skipping the key and value. -proc writeUndefined*(a1: FLEncoder): bool {.importc: "FLEncoder_WriteUndefined".} - -## Writes a boolean value (true or false) to an encoder. -proc writeBool*(a1: FLEncoder; a2: bool): bool {.importc: "FLEncoder_WriteBool".} - -## Writes an integer to an encoder. The parameter is typed as `int64_t` but you can pass any -## integral type (signed or unsigned) except for huge `uint64_t`s. -## The number will be written in a compact form that uses only as many bytes as necessary. -proc writeInt*(a1: FLEncoder; a2: int64): bool {.importc: "FLEncoder_WriteInt".} - -## Writes an unsigned integer to an encoder. -## 64-bit integers greater than or equal to 2^63, which can't be represented as int64_t. -proc writeUInt*(a1: FLEncoder; a2: uint64): bool {.importc: "FLEncoder_WriteUInt".} - -## Writes a 32-bit floating point number to an encoder. -## represented exactly as an integer, it'll be encoded as an integer to save space. This is -## transparent to the reader, since if it requests the value as a float it'll be returned -## as floating-point. -proc writeFloat*(a1: FLEncoder; a2: cfloat): bool {.importc: "FLEncoder_WriteFloat".} - -## Writes a 64-bit floating point number to an encoder. -## as an integer, if this can be done without losing precision. For example, 123.0 will be -## written as an integer, and 123.75 as a float.) -proc writeDouble*(a1: FLEncoder; a2: cdouble): bool {.importc: "FLEncoder_WriteDouble".} - -## Writes a string to an encoder. The string must be UTF-8-encoded and must not contain any -## zero bytes. -proc writeString*(a1: FLEncoder; a2: FLString): bool {.importc: "FLEncoder_WriteString".} - -## Writes a timestamp to an encoder, as an ISO-8601 date string. -## metadata that distinguishes it as a date. It's just a string.) -proc writeDateString*(encoder: FLEncoder; ts: FLTimestamp; asUTC: bool): bool {.importc: "FLEncoder_WriteDateString".} - -## Writes a binary data value (a blob) to an encoder. This can contain absolutely anything -## including null bytes. -## If the encoder is generating JSON, the blob will be written as a base64-encoded string. -proc writeData*(a1: FLEncoder; a2: FLSlice): bool {.importc: "FLEncoder_WriteData".} - -## Writes raw data directly to the encoded output. -## (This is not the same as FLEncoder_WriteData, which safely encodes a blob.) -## it's quite unsafe, and only used for certain advanced purposes. -proc writeRaw*(a1: FLEncoder; a2: FLSlice): bool {.importc: "FLEncoder_WriteRaw".} - -## 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. -## of the array, providing it here speeds up encoding slightly. If you don't know, -## just use zero. -proc beginArray*(a1: FLEncoder; reserveCount: csize_t): bool {.importc: "FLEncoder_BeginArray".} - -## Ends writing an array value; pops back the previous encoding state. -proc endArray*(a1: FLEncoder): bool {.importc: "FLEncoder_EndArray".} - -## 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. -## of the dictionary, providing it here speeds up encoding slightly. If you don't know, -## just use zero. -proc beginDict*(a1: FLEncoder; reserveCount: csize_t): bool {.importc: "FLEncoder_BeginDict".} - -## Specifies the key for the next value to be written to the current dictionary. -proc writeKey*(a1: FLEncoder; a2: FLString): bool {.importc: "FLEncoder_WriteKey".} - -## Specifies the key for the next value to be written to the current dictionary. -## The key is given as a FLValue, which must be a string or integer. -proc writeKeyValue*(a1: FLEncoder; a2: FLValue): bool {.importc: "FLEncoder_WriteKeyValue".} - -## Ends writing a dictionary value; pops back the previous encoding state. -proc endDict*(a1: FLEncoder): bool {.importc: "FLEncoder_EndDict".} - -## Writes a Fleece FLValue to an FLEncoder. -proc writeValue*(a1: FLEncoder; a2: FLValue): bool {.importc: "FLEncoder_WriteValue".} - -## 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.) -proc convertJSON*(a1: FLEncoder; json: FLSlice): bool {.importc: "FLEncoder_ConvertJSON".} - -## Finishes encoding the current item, and returns its offset in the output data. -proc finishItem*(a1: FLEncoder): csize_t {.importc: "FLEncoder_FinishItem".} - -## Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in -## an FLDoc. (This function does not support JSON encoding.) -## This does not free the FLEncoder; call FLEncoder_Free (or FLEncoder_Reset) next. -proc finishDoc*(a1: FLEncoder; a2: var FLError): FLDoc {.importc: "FLEncoder_FinishDoc".} - -## Ends encoding; if there has been no error, it returns the encoded data, else null. -## This does not free the FLEncoder; call FLEncoder_Free (or FLEncoder_Reset) next. -proc finish*(e: FLEncoder; outError: var FLError): FLSliceResult {.importc: "FLEncoder_Finish".} - -## Returns the error code of an encoder, or NoError (0) if there's no error. -proc getError*(a1: FLEncoder): FLError {.importc: "FLEncoder_GetError".} - -## Returns the error message of an encoder, or NULL if there's no error. -proc getErrorMessage*(a1: FLEncoder): cstring {.importc: "FLEncoder_GetErrorMessage".} - - - -## ////// JSON 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. - - -## 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.) -## (extremely unlikely) failure. -proc createJSONDelta*(old: FLValue; nuu: FLValue): FLSliceResult {.importc: "FLCreateJSONDelta".} - -## Writes JSON that describes 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.) -## `FLEncoder_NewWithOptions`, with JSON or JSON5 format. -proc encodeJSONDelta*(old: FLValue; nuu: FLValue; jsonEncoder: FLEncoder): bool {.importc: "FLEncodeJSONDelta".} - -## 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. -## equal to the `old` value used when creating the `jsonDelta`. -proc applyJSONDelta*(old: FLValue; jsonDelta: FLSlice; error: var FLError): FLSliceResult {.importc: "FLApplyJSONDelta".} - -## 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. -## equal to the `old` value used when creating the `jsonDelta`. -## supported.) -proc encodeApplyingJSONDelta*(old: FLValue; jsonDelta: FLSlice; encoder: FLEncoder): bool {.importc: "FLEncodeApplyingJSONDelta".} - -{.pop.} diff --git a/bindings/nim/src/CouchbaseLite/private/gen-bindings.sh b/bindings/nim/src/CouchbaseLite/private/gen-bindings.sh deleted file mode 100755 index 951d1d08..00000000 --- a/bindings/nim/src/CouchbaseLite/private/gen-bindings.sh +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/bash -e -# -# NOTE: c2nim can be obtained from https://github.com/nim-lang/c2nim -# -# This script does not replace the binding source files cbl.nim and cbl.nim; -# instead it creates new ones, cbl-new.nim and fl-new.nim. -# The binding files started out as output from this tool, but have been hand-edited to work -# around limitations of c2nim. The files produced by this script will _not_ work. -# -# The best procedure for updating bindings would be to run this script before and after changing -# the C headers, compare the old and new generated files, and apply those diffs by hand to the -# bindings. - -SCRIPT_DIR=`dirname $0` -cd "$SCRIPT_DIR" - -ROOT="../../../../.." -INCLUDE="$ROOT/include/cbl" -FLEECE="$ROOT/vendor/couchbase-lite-core/vendor/fleece/API/fleece" - -c2nim --concat -o:fl-new.nim cbl.c2nim --dynlib:'"CouchbaseLite.dylib"' --nep1 "$FLEECE/FLSlice.h" "$FLEECE/Fleece.h" - -c2nim --concat -o:cbl-new.nim cbl.c2nim --dynlib:'"CouchbaseLite.dylib"' --nep1 "$INCLUDE"/CBLBase.h "$INCLUDE"/CBLDatabase.h "$INCLUDE"/CBLDocument.h "$INCLUDE"/CBLBlob.h "$INCLUDE"/CBLLog.h "$INCLUDE"/CBLQuery.h "$INCLUDE"/CBLReplicator.h diff --git a/bindings/nim/src/CouchbaseLite/query.nim b/bindings/nim/src/CouchbaseLite/query.nim deleted file mode 100644 index c4b3cad7..00000000 --- a/bindings/nim/src/CouchbaseLite/query.nim +++ /dev/null @@ -1,150 +0,0 @@ -# Couchbase Lite Query class -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/[database, errors, fleece] -import CouchbaseLite/private/cbl -import CouchbaseLite/private/fl # for slice utilities - -{.experimental: "notnil".} - - -type - QueryObj {.requiresInit.} = object - handle: CBLQuery not nil - Query* = ref QueryObj not nil - ## A compiled database query. - - QueryLanguage* {.pure.} = enum - ## A query language syntax. - JSON, ## JSON schema: github.com/couchbase/couchbase-lite-core/wiki/JSON-Query-Schema - N1QL ## N1QL syntax: docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/ - - QuerySyntaxError* = ref object of CouchbaseLiteError - ## Exception thrown by ``Query.newQuery``. It contains the byte offset of - ## the approximate position of the error in the input string. - byteOffset*: int - - Row* {.requiresInit.} = object - ## A result row from running a query. A collection that contains one - ## "column" value for each item specified in the query's ``SELECT`` clause. - ## The columns can be accessed by either position or name. - results: CBLResultSet - -proc `=destroy`(d: var QueryObj) = - release(d.handle) - -proc `=`(dst: var QueryObj, src: QueryObj) {.error.} = - echo "can't copy a query" - - -proc newQuery*(db: Database; str: string; - language: QueryLanguage = N1QL): Query = - ## Creates a new Query by compiling the input string. - ## This is fast, but not instantaneous. If you need to run the same query - ## many times, keep the Query instance around instead of compiling it each - ## time. If you need to run related queries with only some values different, - ## create one query with placeholder parameter(s), and substitute the desired - ## value(s) by setting the ``parameters`` property each time you run the - ## query. - var errPos: cint - var err: CBLError - let q = newQuery(db.internal_handle, CBLQueryLanguage(language), str, - addr errPos, err) - if q == nil: - if err.domain == CBLDomain and err.code == int( - CBLErrorCode.ErrorInvalidQuery): - raise QuerySyntaxError(code: ErrorCode.InvalidQuery, - msg: "Query syntax error", byteOffset: errPos) - else: - throw(err) - else: - return Query(handle: q) - -proc explain*(query: Query): string = - ## Returns information about the query, including the translated SQLite form, - ## and the search strategy. You can use this to help optimize the query: the - ## word ``SCAN`` in the strategy indicates a linear scan of the entire - ## database, which should be avoided by adding an index. The strategy will - ## also show which index(es), if any, are used. - query.handle.explain().toString() - -proc columnCount*(query: Query): uint = - ## The number of columns in each result ``Row``. Equal to the number of items - ## specified in the query string's ``SELECT`` clause. - query.handle.columnCount() - -proc columnNames*(query: Query): seq[string] = - ## The names of the result columns, in order. - for i in 0..query.columnCount: - result.add(query.handle.columnName(cuint(i)).toString()) - -proc parameters*(query: Query): Dict = - ## The query's current parameter bindings, if any. - query.handle.parameters() - -proc `parameters=`*(query: Query, parameters: Dict) = - ## Assigns values to the query's parameters. These values will be substited - ## for those parameters whenever the query is executed, until they are next - ## assigned. - ## - ## A parameter named e.g. ``PARAM`` is specified in the query source as - ## ``$PARAM`` (N1QL) or ``["$PARAM"]`` (JSON). In this example, the - ## `parameters` dictionary to this call should have a key `PARAM` that maps - ## to the value of the parameter. - query.handle.setParameters(parameters) - -proc `parameters=`*(query: Query, json: string) = - ## Assigns values to the query's parameters, in the form of a JSON string - ## containing an object whose keys are the parameter names. - if not query.handle.setParametersAsJSON(json): - raise errors.FleeceError(code: FleeceErrorCode.JSONError, - msg: "Invalid JSON for parameters") - - -iterator execute*(query: Query): Row = - ## Runs the query, iterating over the result rows. - var err: CBLError - let rs = query.handle.execute(err) - if rs == nil: - throw(err) - defer: release(rs) - while next(rs): - yield Row(results: rs) - -proc column*(row: Row, i: uint): Value = - ## The value of a column given its (zero-based) index. - row.results.valueAtIndex(cuint(i)) - -proc column*(row: Row, name: string): Value = - ## The value of a column given its name. - row.results.valueForKey(name) - -proc `[]`*(row: Row, i: uint): Value = - ## The value of a column given its (zero-based) index. - row.column(i) - -proc `[]`*(row: Row, name: string): Value = - ## The value of a column given its name. - row.column(name) - -proc asArray*(row: Row): Array = - ## An array of all the column values. - rowArray(row.results) - -proc asDict*(row: Row): Dict = - ## A Dict of all the column names/values. - rowDict(row.results) diff --git a/bindings/nim/src/CouchbaseLite/replicator.nim b/bindings/nim/src/CouchbaseLite/replicator.nim deleted file mode 100644 index d546d4f2..00000000 --- a/bindings/nim/src/CouchbaseLite/replicator.nim +++ /dev/null @@ -1,232 +0,0 @@ -# Couchbase Lite replicator API -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - -import CouchbaseLite/[database, document, errors, listener] -import CouchbaseLite/private/cbl - -import httpcore -import options -import sets -import uri - -{.experimental: "notnil".} - - -## WARNING: THIS API IS UNIMPLEMENTED SO FAR - - -#======== CONFIGURATION - - -type - EndpointType* = enum - WithURL, - WithLocalDB - Endpoint* = object - ## Represents the location of a database to replicate with. - case type*: EndpointType: - of WithURL: url*: Url ## WebSocket URL ("ws:" or "wss:") of remote database - of WithLocalDB: db*: Database ## Local database (available only in Enterprise Edition) - - AuthenticatorType* = enum - None, - Basic, - Session, - Cookie - Authenticator* = object - ## Represents authentication credentials for a remote server. - case type*: AuthenticatorType: - of None: discard - of Basic: username*, password*: string - of Session: sessionID*: string - of Cookie: name*, value*: string - - ReplicatorType* = enum - ## Direction of replication: push, pull, or both. - PushAndPull = 0 - Push - Pull - - ProxyType* = enum HTTP, HTTPS - ProxySettings* = object - ## HTTP client proxy settings for the replicator. - proxyType*: ProxyType - hostname*: string - port*: uint16 - username*: string - password*: string - - ReplicationFilter* = proc(document: Document; isDeleted: bool): bool - ## A callback that can decide whether a particular document should be pushed or pulled. - ConflictResolver* = proc(documentID: string; local, - remote: Document): Document - ## Conflict-resolution callback for use in replications. This callback will - ## be invoked when the replicator finds a newer server-side revision of a - ## document that also has local changes. The local and remote changes must - ## be resolved before the document can be pushed to the server. - - ReplicatorConfiguration* = object - ## The configuration of a replicator - database*: Database ## The database to replicate - endpoint*: Endpoint ## The address of the other database to replicate with - replicatorType*: ReplicatorType ## Push, pull or both - continuous*: bool ## Continuous replication? - - authenticator*: Authenticator ## Authentication credentials, if needed - proxy*: Option[ProxySettings] ## HTTP client proxy settings - headers*: HttpHeaders ## Extra HTTP headers to add to the WebSocket request - pinnedServerCertificate*: seq[uint8] ## An X.509 cert to "pin" TLS connections to (PEM or DER) - trustedRootCertificates*: seq[uint8] ## Set of anchor certs (PEM format) - - channels*: seq[string] ## Optional set of channels to pull from - documentIDs*: seq[string] ## Optional set of document IDs to replicate - pushFilter*: ReplicationFilter ## Optional callback to filter which docs are pushed - pullFilter*: ReplicationFilter ## Optional callback to validate incoming docs - conflictResolver*: ConflictResolver ## Optional conflict-resolver callback - - -#======== LIFECYCLE - - -type - ReplicatorObj {.requiresInit.} = object - handle: CBLReplicator not nil - Replicator* = ref ReplicatorObj not nil - ## A background task that syncs a Database with a remote server or peer. - -proc `=destroy`(r: var ReplicatorObj) = release(r.handle) -proc `=`(dst: var ReplicatorObj; src: ReplicatorObj) {.error.} - - -proc newReplicator*(configuration: ReplicatorConfiguration): Replicator = - ## Creates a replicator with the given configuration. - throw ErrorCode.Unimplemented - -proc configuration*(repl: Replicator): ReplicatorConfiguration = - ## Returns the configuration of an existing replicator. - throw ErrorCode.Unimplemented - -proc resetCheckpoint*(repl: Replicator) = - ## Instructs the replicator to ignore existing checkpoints the next time it - ## runs. This will cause it to scan through all the documents on the remote - ## database, which takes a lot longer, but it can resolve problems with - ## missing documents if the client and server have gotten out of sync - ## somehow. - throw ErrorCode.Unimplemented - -proc start*(repl: Replicator) = - ## Starts a replicator, asynchronously. Does nothing if it's already started. - throw ErrorCode.Unimplemented - -proc stop*(repl: Replicator) = - ## Stops a running replicator, asynchronously. Does nothing if it's not - ## already started. The replicator will call your ChangeListener with an - ## activity level of ``Stopped`` after it stops. Until then, consider it - ## still active. - throw ErrorCode.Unimplemented - -proc setHostReachable*(repl: Replicator; reachable: bool) = - ## Informs the replicator whether it's considered possible to reach the - ## remote host with the current network configuration. The default value is - ## true. This only affects the replicator's behavior while it's in the - ## Offline state: - ## * Setting it to false will cancel any pending retry and prevent future - ## automatic retries. - ## * Setting it back to true will initiate an immediate retry. - throw ErrorCode.Unimplemented - -proc setSuspended*(repl: Replicator; suspended: bool) = - ## Puts the replicator in or out of "suspended" state. The default is false. - ## * Setting suspended=true causes the replicator to disconnect and enter - ## Offline state; it will not attempt to reconnect while it's suspended. - ## * Setting suspended=false causes the replicator to attempt to reconnect, - ## _if_ it was connected when suspended, and is still in Offline state. - throw ErrorCode.Unimplemented - - -#======= STATUS AND PROGRESS - - -type - ActivityLevel* = enum - ## The possible states a replicator can be in during its lifecycle. - Stopped, ## unstarted, finished, or hit a fatal error. - Offline, ## offline, as the remote host is unreachable. - Connecting, ## connecting to the remote host. - Idle, ## inactive, waiting for changes to sync. - Busy ## actively transferring data. - - ReplicatorProgress* = object - ## The current progress status of a Replicator. The `fraction_complete` - ## ranges from 0.0 to 1.0 as replication progresses. The value is very - ## approximate and may bounce around during replication; making it more - ## accurate would require slowing down the replicator and incurring more - ## load on the server. It's fine to use in a progress bar, though. - fractionComplete*: float - documentCount*: uint64 - - ReplicatorStatus* = object - ## A replicator's current status. - activity*: ActivityLevel - progress*: ReplicatorProgress - error*: Error - -proc status*(repl: Replicator): ReplicatorStatus = - ## Returns the replicator's current status. - throw ErrorCode.Unimplemented - -proc pendingDocIDs*(repl: Replicator): HashSet[string] = - ## Indicates which documents have local changes that have not yet been pushed - ## to the server by this replicator. This is of course a snapshot, that will - ## go out of date as the replicator makes progress and/or documents are saved - ## locally. - throw ErrorCode.Unimplemented - -proc isDocumentPending*(repl: Replicator; docID: string): bool = - ## Indicates whether the document with the given ID has local changes that - ## have not yet been pushed to the server by this replicator. - ## - ## This is equivalent to, but faster than, calling ``pendingDocumentIDs`` and - ## checking whether the result contains ``docID``. See that function's - ## documentation for details. - throw ErrorCode.Unimplemented - -type - DocumentFlag = enum deleted, accessRemoved - Direction = enum pulled, pushed - - ReplicatedDocument* = object - ## Information about a document that's been pushed or pulled. - id: string - flags: set[DocumentFlag] - error: Error - - ChangeListener* = proc(replicator: Replicator; status: ReplicatorStatus) - ## A callback that notifies you when the replicator's status changes. - ReplicatedDocumentListener* = proc(replicator: Replicator; - direction: Direction; - documents: seq[ReplicatedDocument]) - ## A callback that notifies you when documents are replicated. - -proc addChangeListener*(repl: Replicator; - listener: ChangeListener): ListenerToken = - ## Adds a listener that will be called when the replicator's status changes. - throw ErrorCode.Unimplemented - -proc addDocumentListener*(repl: Replicator): ListenerToken = - ## Adds a listener that will be called when documents are replicated. - throw ErrorCode.Unimplemented diff --git a/bindings/nim/tests/config.nims b/bindings/nim/tests/config.nims deleted file mode 100644 index 3bb69f82..00000000 --- a/bindings/nim/tests/config.nims +++ /dev/null @@ -1 +0,0 @@ -switch("path", "$projectDir/../src") \ No newline at end of file diff --git a/bindings/nim/tests/test1Fleece.nim b/bindings/nim/tests/test1Fleece.nim deleted file mode 100644 index 2c9587e7..00000000 --- a/bindings/nim/tests/test1Fleece.nim +++ /dev/null @@ -1,206 +0,0 @@ -# Fleece unit tests -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - - -import CouchbaseLite/fleece -import unittest - - - -suite "Fleece Accessors": - let JSON = """{"integer": 1234, "string": "Hello, World!", "float": 1234.56, - "true":true, "false": false, "null": null, - "array": [null, false, true, 10, [], {}], - "dict": {"foo": "bar", "frob": -9}}""" - var doc: Fleece - - setup: - doc = parseJSON(JSON) - - test "Parse JSON": - check doc.root.toJSON == """{"array":[null,false,true,10,[],{}],"dict":{"foo":"bar","frob":-9},"false":false,"float":1234.56,"integer":1234,"null":null,"string":"Hello, World!","true":true}""" - - test "Null": - let n = doc["null"] - check n != nil - check n.type == Type.null - check n.asBool == false - - test "Bool": - let t = doc["true"] - check t != nil - check t.type == Type.bool - check not t.isNumber - check t.asBool == true - check t != 1 - - let f = doc["false"] - check f != nil - check f.type == Type.bool - check not f.isNumber - check f.asBool == false - check f != 0 - - test "Int": - check doc.root["integer"].asInt == 1234 - let i = doc["integer"] - check i != nil - check i.type == Type.number - check i.isInt - check not i.isFloat - check i == doc.root["integer"] - check i.asInt == 1234 - check i.asInt(0'i8) == 127'i8 - check i.asFloat == 1234.0 - check i.asString == "" - check i.asString("nope") == "nope" - check i == 1234 - check i == 1234.0f64 - check i != 4321 - - test "Float": - let f = doc["float"] - check f != nil - check f.type == Type.number - check f.isFloat - check not f.isInt - check f.asString == "" - check f.asInt == 1234 - check f.asFloat == 1234.56 - check f.asBool == true - check f == 1234.56 - check f != 1234 - - test "String": - let s = doc["string"] - check s != nil - check s.type == Type.string - check s.asString == "Hello, World!" - check s == "Hello, World!" - check s != 0 - check s != 3.14 - - test "Undefined": - let m = doc["MISSING"] - check m == nil - check m.type == Type.undefined - check m != 0 - - test "Array": - let v = doc["array"] - check v != nil - check v.type == Type.array - let a = v.asArray - check a != nil - check a.len == 6 - check not a.isEmpty - check a[0].type == Type.null - check a[1].type == Type.bool - check a[2].type == Type.bool - check a[3].type == Type.number - check a[4].type == Type.array - check a[5].type == Type.dict - - test "Array iterator": - var i = 0 - let expected = @["null", "false", "true", "10", "[]", "{}"] - for item in doc["array"].asArray: - check $item == expected[i] - i += 1 - check i == 6 - - test "Dict iterator": - var i = 0 - let expectedKeys = @["foo", "frob"] - let expectedVals = @["\"bar\"", "-9"] - for k, v in doc["dict"].asDict.items: - check k == expectedKeys[i] - check $v == expectedVals[i] - i += 1 - check i == 2 - - test "Empty array iterator": - let a = doc["array"][4].asArray - check a != nil - for item in a: - check false - - test "Empty dict iterator": - let d = doc["array"][5].asDict - check d != nil - for item in d: - check false - - test "KeyPath": - var path = keyPath("dict.frob") - check $(path.eval(doc.root)) == "-9" - path = keyPath("array[2]") - check $(path.eval(doc.root)) == "true" - - - -suite "Mutable Fleece": - test "mutable array": - var a = newMutableArray() - check a.len == 0 - check a.isEmpty - check not a.isChanged - a.add(17) - a.add(true) - a.add("howdy") - check a.len == 3 - check $a == "[17,true,\"howdy\"]" - a[1] = false - check $a == "[17,false,\"howdy\"]" - a.delete(0) - check $a == "[false,\"howdy\"]" - a.add(-3.14) - check $a == "[false,\"howdy\",-3.14]" - check a.source == nil - check a.isChanged - - test "mutable dict": - var d = newMutableDict() - check d.len == 0 - check d.isEmpty - check not d.isChanged - d["x"] = 17 - d["y"] = true - d["z"] = "howdy" - check d.len == 3 - check $d == """{"x":17,"y":true,"z":"howdy"}""" - d["y"] = false - check $d == """{"x":17,"y":false,"z":"howdy"}""" - d.delete("x") - check $d == """{"y":false,"z":"howdy"}""" - d["zz"] = -3.14 - check $d == """{"y":false,"z":"howdy","zz":-3.14}""" - check d.source == nil - check d.isChanged - - test "Assign mutable array": - var a = newMutableArray() - a.add(17) - a.add(true) - a.add("howdy") - - var b = newMutableArray() - b.add(false) - - a = b - check $a == "[false]" - check $b == "[false]" diff --git a/bindings/nim/tests/test2Database.nim b/bindings/nim/tests/test2Database.nim deleted file mode 100644 index 0d73fa66..00000000 --- a/bindings/nim/tests/test2Database.nim +++ /dev/null @@ -1,93 +0,0 @@ -# Couchbase Lite unit tests -# -# Copyright (c) 2020 Couchbase, Inc 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. -# - - -import CouchbaseLite - -import unittest - -{.experimental: "notnil".} - - -suite "Database": - var db: Database - - setup: - var config = DatabaseConfiguration(directory: "/tmp", flags: {DatabaseFlag.create}) - deleteDatabase("nimtest", config.directory) - db = openDatabase("nimtest", config) - - teardown: - db.close() - - test "Empty db": - check db.name == "nimtest" - check db.path == "/tmp/nimtest.cblite2/" - check db.count == 0 - check db.getDocument("foo") == nil - - test "Create doc": - var newDoc = newDocument("foo") - check newDoc.id == "foo" - check newDoc.revisionID == "" - check newDoc.propertiesAsJSON == "{}" - check newDoc.properties.len == 0 - check db.count == 0 - - newDoc.propertiesAsJSON = """{"language":"nim","rating":9.5}""" - let savedDoc = db.saveDocument(newDoc, FailOnConflict) - check savedDoc.id == "foo" - check savedDoc.revisionID == "1-157a814d5c032e28f674c08f46722e2b07e6d879" - check savedDoc.propertiesAsJSON == """{"language":"nim","rating":9.5}""" - check db.count == 1 - - # Load the doc from the db: - let doc = db.getDocument("foo") - check doc != nil - check doc["rating"] == 9.5 - var ratingKey = dictKey("rating") - check doc[ratingKey] == 9.5 - check doc["language"] == "nim" - check doc["nope"] == nil - - db.deleteDocument(doc) - check db.count == 0 - - test "Save conflict": - var newDoc = newDocument("foo") - db.saveDocument(newDoc, FailOnConflict) - - let conflict = newDocument("foo") - conflict.propertiesAsJSON = """{"oops":true}""" - expect(Error): - db.saveDocument(conflict, FailOnConflict) - - test "Modify doc": - var newDoc = newDocument("foo") - var props = newDoc.properties - props["language"] = "nim" - props["rating"] = 9.5 - var a = newMutableArray() - a.add(123.456) - a.add("hi") - props["array"] = a - - newDoc = db.saveDocument(newDoc).mutableCopy() - newDoc["rating"] = 9.6 - db.saveDocument(newDoc, FailOnConflict) - - check db["foo"].propertiesAsJSON == """{"array":[123.456,"hi"],"language":"nim","rating":9.6}""" diff --git a/bindings/python/BuildPyCBL.py b/bindings/python/BuildPyCBL.py deleted file mode 100755 index 269b658b..00000000 --- a/bindings/python/BuildPyCBL.py +++ /dev/null @@ -1,430 +0,0 @@ -#! /usr/bin/env python3 -# -# BuildPyCBL.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# - - -# Run this to build the PyCBL native glue library, in the current directory -# (Argument handling is at the end of the script) - -import argparse -import os.path -import platform -import shutil -from cffi import FFI - - -# Assume we are running this from bindings/python/CouchbaseLite/ -DEFAULT_SRC_DIR = "../../../" - -# Paths relative to the source root (--srcdir) -CBL_INCLUDE_DIR = "/include" -FLEECE_INCLUDE_DIR = "/vendor/couchbase-lite-core/vendor/fleece/API" - -# CMake settings are defaults, but overrideable on command-line -DEFAULT_LIBRARIES = "cblite z" -DEFAULT_LIBRARY_DIR = DEFAULT_SRC_DIR + "build_cmake/" - -# Extra linker arguments -- platform-specific -DEFAULT_LINK_ARGS = "" -if platform.system() == "Darwin": - DEFAULT_LINK_ARGS = "-rpath @loader_path" # Look for CBL dylib in same dir as bindings lib - - -def BuildLibrary(sourceDir, python_includedir, libdir, libraries, extra_link_args): - # when cross-compiling, use python headers for target rather than build system - include_dirs = [sourceDir+CBL_INCLUDE_DIR, sourceDir+FLEECE_INCLUDE_DIR] - if python_includedir: - include_dirs.insert(0, python_includedir) - - # python 3.5 distutils breaks on Linux with absolute library path, - # so make sure it is relative path - libdir = os.path.relpath(libdir) - - # Copy the CBL library here: - libpath = libdir + "/libcblite" - if platform.system() == "Darwin": - libpath += ".dylib" - else: - libpath += ".so" - shutil.copy(libpath, ".") - - # CFFI stuff -- see https://cffi.readthedocs.io/en/latest/index.html - - # This is passed to the real C compiler and should include the declarations of - # the symbols declared in cdef() - cHeaderSource = r"""#include """ - - ffibuilder = FFI() - ffibuilder.cdef(CDeclarations()) - ffibuilder.set_source( - "_PyCBL", # Module name - cHeaderSource, - libraries=libraries, - include_dirs=include_dirs, - library_dirs=["."], - extra_link_args=extra_link_args) - ffibuilder.compile(verbose=True) - - os.remove("_PyCBL.c") - os.remove("_PyCBL.o") - - -def CDeclarations(): - return r""" -// Declarations that are shared between Python and C -// (Careful, this supports only a subset of C syntax) -// Needs to be updated whenever public C API changes! - -void free(void *); -typedef int64_t CBLTimestamp; - -//////// Fleece (slices): -typedef struct {const void *buf; size_t size;} FLSlice; -typedef struct {const void *buf; size_t size;} FLSliceResult; -typedef FLSlice FLHeapSlice; -typedef FLSlice FLString; -typedef FLSliceResult FLStringResult; - -bool FLSlice_Equal(FLSlice a, FLSlice b); -int FLSlice_Compare(FLSlice, FLSlice); -FLSliceResult FLSliceResult_Retain(FLSliceResult); -void FLSliceResult_Release(FLSliceResult); -FLSliceResult FLSlice_Copy(FLSlice); - -//////// Fleece (values): -typedef ... * FLValue; ///< A reference to a value of any type. -typedef ... * FLArray; ///< A reference to an array value. -typedef ... * FLDict; ///< A reference to a dictionary (map) value. -typedef ... * FLMutableArray; ///< A reference to a mutable array. -typedef ... * FLMutableDict; ///< A reference to a mutable dictionary. -typedef ... * FLSlot; -typedef unsigned FLError; - -typedef enum { - kFLUndefined = -1, ///< Type of a NULL pointer, i.e. no such value, like JSON `undefined`. Also the type of a value created by FLEncoder_WriteUndefined(). - kFLNull = 0, ///< Equivalent to a JSON 'null' - kFLBoolean, ///< A `true` or `false` value - kFLNumber, ///< A numeric value, either integer or floating-point - kFLString, ///< A string - kFLData, ///< Binary data (no JSON equivalent) - kFLArray, ///< An array of values - kFLDict ///< A mapping of strings to values -} FLValueType; - -FLValueType FLValue_GetType(FLValue); -bool FLValue_IsInteger(FLValue); -bool FLValue_IsUnsigned(FLValue); -bool FLValue_IsDouble(FLValue); -bool FLValue_AsBool(FLValue); -int64_t FLValue_AsInt(FLValue); -uint64_t FLValue_AsUnsigned(FLValue); -float FLValue_AsFloat(FLValue); -double FLValue_AsDouble(FLValue); -FLString FLValue_AsString(FLValue); -FLArray FLValue_AsArray(FLValue); -FLDict FLValue_AsDict(FLValue); - -typedef struct { ...; } FLArrayIterator; -uint32_t FLArray_Count(FLArray); -FLValue FLArray_Get(FLArray, uint32_t index); -void FLArrayIterator_Begin(FLArray, FLArrayIterator*); -FLValue FLArrayIterator_GetValue(const FLArrayIterator*); -FLValue FLArrayIterator_GetValueAt(const FLArrayIterator*, uint32_t offset); -uint32_t FLArrayIterator_GetCount(const FLArrayIterator*); -bool FLArrayIterator_Next(FLArrayIterator*); - -typedef struct { ...; } FLDictIterator; -uint32_t FLDict_Count(FLDict); -FLValue FLDict_Get(FLDict, FLSlice keyString); -void FLDictIterator_Begin(FLDict, FLDictIterator*); -FLString FLDictIterator_GetKeyString(const FLDictIterator*); -FLValue FLDictIterator_GetValue(const FLDictIterator*); -uint32_t FLDictIterator_GetCount(const FLDictIterator* ); -bool FLDictIterator_Next(FLDictIterator*); -void FLDictIterator_End(FLDictIterator*); - - -//////// CBLBase.h -typedef uint32_t CBLErrorDomain; -typedef uint8_t CBLLogDomain; -typedef uint8_t CBLLogLevel; - -typedef struct { - CBLErrorDomain domain; ///< Domain of errors; a namespace for the `code`. - int32_t code; ///< Error code, specific to the domain. 0 always means no error. - int32_t internal_info; -} CBLError; -char* CBLError_Message(const CBLError*); -FLSliceResult CBLError_Message_s(const CBLError*); - -void CBL_Log(CBLLogDomain domain, CBLLogLevel level, const char *format, ...); -void CBL_Log_s(CBLLogDomain domain, CBLLogLevel level, FLSlice message); -CBLLogLevel CBLLog_ConsoleLevel(void); -void CBLLog_SetConsoleLevel(CBLLogLevel); -bool CBLLog_WillLogToConsole(CBLLogDomain domain, CBLLogLevel level); - -typedef ... CBLRefCounted; -CBLRefCounted* CBL_Retain(void*); -void CBL_Release(void*); - -typedef ... CBLBlob; -typedef ... CBLDatabase; -typedef ... CBLDocument; -typedef ... CBLQuery; -typedef ... CBLResultSet; -typedef ... CBLReplicator; -typedef ... CBLListenerToken; - -typedef enum { - kCBLDatabase_Create = 1, ///< Create the file if it doesn't exist - kCBLDatabase_ReadOnly = 2, ///< Open file read-only - kCBLDatabase_NoUpgrade = 4, ///< Disable upgrading an older-version database -} CBLDatabaseFlags; - -typedef struct { - const char *directory; - CBLDatabaseFlags flags; - ...; -} CBLDatabaseConfiguration; - -typedef struct { - FLString directory; - CBLDatabaseFlags flags; - ...; -} CBLDatabaseConfiguration_s; - -void CBLListener_Remove(CBLListenerToken*); - - -//////// CBLBlob.h -bool CBL_IsBlob(FLDict); -const CBLBlob* CBLBlob_Get(FLDict blobDict); -uint64_t CBLBlob_Length(const CBLBlob*); -const char* CBLBlob_Digest(const CBLBlob*); -const char* CBLBlob_ContentType(const CBLBlob*); -FLDict CBLBlob_Properties(const CBLBlob*); -FLSliceResult CBLBlob_LoadContent(const CBLBlob*, CBLError *outError); - -typedef ... CBLBlobReadStream; -CBLBlobReadStream* CBLBlob_OpenContentStream(const CBLBlob*, CBLError *outError); -int CBLBlobReader_Read(CBLBlobReadStream* stream, void *dst, size_t maxLength, CBLError *outError); -void CBLBlobReader_Close(CBLBlobReadStream*); - -CBLBlob* CBLBlob_CreateWithData(const char *contentType, FLSlice contents); -CBLBlob* CBLBlob_CreateWithData_s(FLString contentType, FLSlice contents); - -typedef ... CBLBlobWriteStream; -CBLBlobWriteStream* CBLBlobWriter_New(CBLDatabase *db, CBLError *outError); -void CBLBlobWriter_Close(CBLBlobWriteStream*); -bool CBLBlobWriter_Write(CBLBlobWriteStream* writer, const void *data, size_t length, CBLError *outError); -CBLBlob* CBLBlob_CreateWithStream(const char *contentType, CBLBlobWriteStream* writer); -CBLBlob* CBLBlob_CreateWithStream_s(FLString contentType, CBLBlobWriteStream* writer); - -void FLSlot_SetBlob(FLSlot slot, CBLBlob* blob); - - -//////// CBLDatabase.h -bool CBL_DatabaseExists(const char* name, const char *inDirectory); -bool CBL_DatabaseExists_s(FLString name, FLString inDirectory); -bool CBL_CopyDatabase(const char* fromPath, - const char* toName, - const CBLDatabaseConfiguration* config, - CBLError*); -bool CBL_CopyDatabase_s(FLString fromPath, - FLString toName, - const CBLDatabaseConfiguration_s* config, - CBLError*); -bool CBL_DeleteDatabase(const char *name, - const char *inDirectory, - CBLError*); -CBLDatabase* CBLDatabase_Open(const char *name, - const CBLDatabaseConfiguration* config, - CBLError* error); -bool CBLDatabase_Close(CBLDatabase*, CBLError*); -bool CBLDatabase_Delete(CBLDatabase*, CBLError*); -bool CBLDatabase_Compact(CBLDatabase*, CBLError*); -bool CBLDatabase_BeginBatch(CBLDatabase*, CBLError*); -bool CBLDatabase_EndBatch(CBLDatabase*, CBLError*); -const char* CBLDatabase_Name(const CBLDatabase*); -const char* CBLDatabase_Path(const CBLDatabase*); -uint64_t CBLDatabase_Count(const CBLDatabase*); -CBLDatabaseConfiguration CBLDatabase_Config(const CBLDatabase*); - -typedef void (*CBLDatabaseChangeListener)(void *context, - const CBLDatabase* db, - unsigned numDocs, - const char **docIDs); -extern "Python" void databaseListenerCallback(void *context, const CBLDatabase* db, - unsigned numDocs, const char **docIDs); -CBLListenerToken* CBLDatabase_AddChangeListener(const CBLDatabase* db, - CBLDatabaseChangeListener listener, - void *context); - - -//////// CBLDocument.h -typedef uint8_t CBLConcurrencyControl; -const CBLDocument* CBLDatabase_GetDocument(const CBLDatabase* database, - const char* docID); -const CBLDocument* CBLDatabase_GetDocument_s(const CBLDatabase* database, - FLString docID); -const CBLDocument* CBLDatabase_SaveDocument(CBLDatabase* db, - CBLDocument* doc, - CBLConcurrencyControl concurrency, - CBLError* error); -bool CBLDocument_Delete(const CBLDocument* document, - CBLConcurrencyControl concurrency, - CBLError* error); -bool CBLDocument_Purge(const CBLDocument* document, - CBLError* error); -bool CBLDatabase_PurgeDocumentByID(CBLDatabase* database, - const char* docID, - CBLError* error); -bool CBLDatabase_PurgeDocumentByID_s(CBLDatabase* database, - FLString docID, - CBLError* error); -CBLTimestamp CBLDatabase_GetDocumentExpiration(CBLDatabase* db, - const char *docID, - CBLError* error); -CBLTimestamp CBLDatabase_GetDocumentExpiration_s(CBLDatabase* db, - FLSlice docID, - CBLError* error); -bool CBLDatabase_SetDocumentExpiration(CBLDatabase* db, - const char *docID, - CBLTimestamp expiration, - CBLError* error); -bool CBLDatabase_SetDocumentExpiration_s(CBLDatabase* db, - FLSlice docID, - CBLTimestamp expiration, - CBLError* error); -CBLDocument* CBLDatabase_GetMutableDocument(CBLDatabase* database, - const char* docID); -CBLDocument* CBLDatabase_GetMutableDocument_s(CBLDatabase* database, - FLString docID); -CBLDocument* CBLDocument_New(const char *docID); -CBLDocument* CBLDocument_New_s(FLString docID); -CBLDocument* CBLDocument_MutableCopy(const CBLDocument* original); -const char* CBLDocument_ID(const CBLDocument*); -uint64_t CBLDocument_Sequence(const CBLDocument*); -FLDict CBLDocument_Properties(const CBLDocument*); -FLMutableDict CBLDocument_MutableProperties(CBLDocument*); -char* CBLDocument_PropertiesAsJSON(const CBLDocument*); -bool CBLDocument_SetPropertiesAsJSON(CBLDocument*, const char *json, CBLError*); -bool CBLDocument_SetPropertiesAsJSON_s(CBLDocument*, FLSlice json, CBLError*); - -typedef void (*CBLDocumentChangeListener)(void *context, - const CBLDatabase* db, - const char *docID); -CBLListenerToken* CBLDatabase_AddDocumentChangeListener(const CBLDatabase* db, - const char* docID, - CBLDocumentChangeListener listener, - void *context); -extern "Python" void documentListenerCallback(void *context, const CBLDatabase*, const char *docID); - -//////// CBLQuery.h -typedef enum { - kCBLJSONLanguage, - kCBLN1QLLanguage -} CBLQueryLanguage; -CBLQuery* CBLQuery_New(const CBLDatabase* db, - CBLQueryLanguage language, - const char *queryString, - int *outErrorPos, - CBLError* error); -CBLQuery* CBLQuery_New_s(const CBLDatabase* db, - CBLQueryLanguage language, - FLString queryString, - int *outErrorPos, - CBLError* error); -FLDict CBLQuery_Parameters(CBLQuery* query); -void CBLQuery_SetParameters(CBLQuery* query, - FLDict parameters); -void CBLQuery_SetParametersAsJSON(CBLQuery* query, const char* json); -bool CBLQuery_SetParametersAsJSON_s(CBLQuery* query, FLString json); -CBLResultSet* CBLQuery_Execute(CBLQuery*, CBLError*); -FLSliceResult CBLQuery_Explain(CBLQuery*); -unsigned CBLQuery_ColumnCount(CBLQuery*); -FLSlice CBLQuery_ColumnName(CBLQuery*, - unsigned columnIndex); -bool CBLResultSet_Next(CBLResultSet*); -FLValue CBLResultSet_ValueAtIndex(CBLResultSet*, unsigned index); -FLValue CBLResultSet_ValueForKey(CBLResultSet*, const char* key); -FLValue CBLResultSet_ValueForKey_s(const CBLResultSet*, FLString key); -FLArray CBLResultSet_RowArray(const CBLResultSet*); -FLDict CBLResultSet_RowDict(const CBLResultSet*); -CBLQuery* CBLResultSet_GetQuery(const CBLResultSet *rs); - -typedef void (*CBLQueryChangeListener)(void *context, - CBLQuery* query); -extern "Python" void queryListenerCallback(void *context, const CBLQuery *query); -CBLListenerToken* CBLQuery_AddChangeListener(CBLQuery* query, - CBLQueryChangeListener listener, - void *context); - -typedef enum { - kCBLValueIndex, ///< An index that stores property or expression values - kCBLFullTextIndex ///< An index of strings, that enables searching for words with `MATCH` -} CBLIndexType; - -typedef struct { - CBLIndexType type; - const char* keyExpressionsJSON; - bool ignoreAccents; - const char* language; -} CBLIndexSpec; - -typedef struct { - CBLIndexType type; - FLString keyExpressionsJSON; - bool ignoreAccents; - FLString language; -} CBLIndexSpec_s; - -bool CBLDatabase_CreateIndex(CBLDatabase *db, - const char* name, - CBLIndexSpec, - CBLError *outError); -bool CBLDatabase_CreateIndex_s(CBLDatabase *db, - FLString name, - CBLIndexSpec_s, - CBLError *outError); -bool CBLDatabase_DeleteIndex(CBLDatabase *db, - const char *name, - CBLError *outError); -FLMutableArray CBLDatabase_IndexNames(CBLDatabase *db); -""" - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="build Couchbase Lite Python bindings") - parser.add_argument('--srcdir', default=DEFAULT_SRC_DIR, - help="Source root directory") - parser.add_argument('--python_includedir', default='', - help="Directory containing python headers (specify for cross-compiling)") - parser.add_argument('--libdir', default=DEFAULT_LIBRARY_DIR, - help="Directory containing CBL libraries") - parser.add_argument('--libs', default=DEFAULT_LIBRARIES, - help="Library names") - parser.add_argument('--link_flags', default=DEFAULT_LINK_ARGS, - help="Linker flags") - args = parser.parse_args() - - linkFlags = None - if args.link_flags != None: - linkFlags = args.link_flags.split() - - BuildLibrary(args.srcdir, args.python_includedir, args.libdir, args.libs.split(), linkFlags) diff --git a/bindings/python/CouchbaseLite/Blob.py b/bindings/python/CouchbaseLite/Blob.py deleted file mode 100644 index 1392c029..00000000 --- a/bindings/python/CouchbaseLite/Blob.py +++ /dev/null @@ -1,49 +0,0 @@ -from ._PyCBL import ffi, lib -from .Collections import * -from .common import * - -class Blob (object): - def __init__(self, data, *, contentType =None, fdict =None): - if fdict != None: - super.__init__(lib.CBLBlob_Get(fdict), "Dict is not a Blob") - else: - super.__init__(lib.CBLBlob_CreateWithData(contentType, asSlice(data)), - "Failed to create Blob") - - @property - def digest(self): - return pystr(lib.CBLBlob_Digest(self._ref)) - - @property - def length(self): - return lib.CBLBlob_Length(self._ref) - - @property - def contentType(self): - return pystr(lib.CBLBlob_ContentType(self._ref)) - - @property - def data(self): - if "_data" in self.__dict__: - return self._data - elif self.digest != None: - sliceResult = lib.CBLBlob_LoadContent(self._ref, gError) - # OPT: This copies the bytes - result = sliceResultToBytes(sliceResult) - lib.FLSliceResult_Release(sliceResult) - return result - else: - return None - - def __repr__(self): - r = "Blob[" - if self.contentType != None: - r += self.contentType - if self.length != None: - if self.contentType != None: - r += ", " - r += self.length + " bytes" - return r + "]" - - def _jsonEncodable(self): - return decodeFleeceDict( lib.CBLBlob_Properties(self._ref), depth=99 ) diff --git a/bindings/python/CouchbaseLite/Collections.py b/bindings/python/CouchbaseLite/Collections.py deleted file mode 100644 index f32137ce..00000000 --- a/bindings/python/CouchbaseLite/Collections.py +++ /dev/null @@ -1,208 +0,0 @@ -from ._PyCBL import ffi, lib -from .common import * -from .Blob import Blob -from collections.abc import Sequence, Mapping -from functools import total_ordering -import json - - -FLArrayType = ffi.typeof("struct $$FLArray *") -FLDictType = ffi.typeof("struct $$FLDict *") - - -#### FLEECE DECODING: - - -# Most general function, accepts params of type FLValue, FLDict or FLArray. -def decodeFleece(f, *, depth =1, mutable =False): - ffitype = ffi.typeof(f) - if ffitype == FLDictType: - return decodeFleeceDict(f, depth=depth, mutable=mutable) - elif ffitype == FLArrayType: - return decodeFleeceArray(f, depth=depth, mutable=mutable) - else: - return decodeFleeceValue(f, depth=depth, mutable=mutable) - -# Decodes an FLValue (which may of course turn out to be an FLArray or FLDict) -def decodeFleeceValue(f, *, depth =1, mutable =False): - typ = lib.FLValue_GetType(f) - if typ == lib.kFLString: - return sliceToString(lib.FLValue_AsString(f)) - elif typ == lib.kFLDict: - return decodeFleeceDict(ffi.cast(FLDictType, f), depth=depth, mutable=mutable) - elif typ == lib.kFLArray: - return decodeFleeceArray(ffi.cast(FLArrayType, f), depth=depth, mutable=mutable) - elif typ == lib.kFLNumber: - if lib.FLValue_IsInteger(f): - return lib.FLValue_AsInt(f) - elif lib.FLValue_IsDouble(f): - return lib.FLValue_AsDouble(f) - else: - return lib.FLValue_AsFloat(f) - elif typ == lib.kFLBoolean: - return not not lib.FLValue_AsBool(f) - elif typ == lib.kFLNull: - return None # ??? - else: - assert(typ == lib.kFLUndefined) - return None - -# Decodes an FLArray -def decodeFleeceArray(farray, *, depth =1, mutable =False): - if depth <= 0: - if mutable: - return MutableArray(fleece=farray) - else: - return Array(fleece=farray) - result = [] - n = lib.FLArray_Count(farray) - for i in range(n): - value = lib.FLArray_Get(farray, i) - result.append(decodeFleeceValue(value, depth=depth-1, mutable=mutable)) - return result - -# Decodes an FLDict -def decodeFleeceDict(fdict, *, depth =1, mutable =False): - if lib.CBL_IsBlob(fdict): - return Blob(None, fdict=fdict) - elif depth <= 0: - if mutable: - return MutableDictionary(fleece=fdict) - else: - return Dictionary(fleece=fdict) - else: - result = {} - i = ffi.new("FLDictIterator*") - lib.FLDictIterator_Begin(fdict, i) - while True: - value = lib.FLDictIterator_GetValue(i) - if not value: - break - key = sliceToString( lib.FLDictIterator_GetKeyString(i) ) - result[key] = decodeFleeceValue(value, depth=depth-1, mutable=mutable) - lib.FLDictIterator_Next(i) - return result - - -### Array class - - -@total_ordering -class Array (Sequence): - "A Couchbase Lite array, decoded from a Document or Query. Behaves like a regular Python sequence." - - def __init__(self, *, fleece=None): - "Constructor: takes an FLArray" - if fleece != None: - self._flArray = fleece - else: - self._pyList = [] - - def __len__(self): - if not "_pyList" in self.__dict__: - return lib.FLArray_Count(self._flArray) - return len(self._pyList) - - @property - def _toList(self): - if not "_pyList" in self.__dict__: - # Convert Fleece array to Python list: - self._pyList = decodeFleeceArray(self._flArray, depth=1) - del self._flArray - print ("Converted Array to list") - return self._pyList - - def __getitem__(self, i): - return self._toList[i] - - def __repr__(self): - if not "_pyList" in self.__dict__: - # Don't convert in place; just return the converted form's representation - return decodeFleeceArray(self._flArray, depth=999).__repr__() - return self._pyList.__repr__() - - def __eq__(self, other): - return self._toList == other - - def __gt__(self, other): - return self._toList > other - - def _jsonEncodable(self): - return self._toList - - -class MutableArray (Array): - def __setitem__(self, i, value): - self._toList.__setitem__(i, value) - - def __delitem__(self, i): - self._toList.__deltem__(i) - - def insert(self, i, value): - self._toList.insert(i, value) - - -### Dictionary class - - -class Dictionary (Mapping): - "A Couchbase Lite dictionary, decoded from a Document or Query. Behaves like a regular Python mapping." - def __init__(self, *, fleece=None): - if fleece != None: - self._flDict = fleece - else: - self._pyDict = {} - - def __len__(self): - if not "_pyMap" in self.__dict__: - return lib.FLDict_Count(self._flDict) - return len(self._pyMap) - - @property - def _toDict(self): - if not "_pyMap" in self.__dict__: - # Convert Fleece dict to Python mapping: - self._pyMap = decodeFleeceDict(self._flDict) - del self._flDict - return self._pyMap - - def __getitem__(self, key): - return self._toDict.__getitem__(key) - - def __iter__(self): - return self._toDict.__iter__() - - def __repr__(self): - if not "_pyMap" in self.__dict__: - # Don't convert in place; just return the converted form's representation - return decodeFleeceDict(self._flDict, depth=999).__repr__() - return self._toDict.__repr__() - - def __eq__(self, other): - return self._toDict == other - def __ne__(self, other): - return not self.__eq__(other) - - def _jsonEncodable(self): - return self._toDict - - -class MutableDictionary (Dictionary): - def __setitem__(self, key, value): - self._toDict.__setitem__(key, value) - - def __delitem__(self, key): - self._toDict.__deltem__(key) - - -### JSON Encoder - - -def encodeJSON(root, sortKeys =False): - # Custom JSON encoding for Array, Dictionary, Blob objects - def _defaultEncodeJSON(o): - try: - return o._jsonEncodable() - except AttributeError: - raise TypeError("Couchbase Lite documents cannot contain objects of type " + str(type(o))) - return json.dumps(root, default=_defaultEncodeJSON, sort_keys=sortKeys, allow_nan=False) diff --git a/bindings/python/CouchbaseLite/Database.py b/bindings/python/CouchbaseLite/Database.py deleted file mode 100644 index 24049e90..00000000 --- a/bindings/python/CouchbaseLite/Database.py +++ /dev/null @@ -1,189 +0,0 @@ -# Database.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# - -import datetime -import math - -from ._PyCBL import ffi, lib -from .common import * -from .Document import * - -class DatabaseConfiguration: - def __init__(self, directory, create = True, readOnly = False, noUpgrade = False): - self.directory = directory - self._flags = 0 - if create: - self._flags |= lib.kCBLDatabase_Create - if readOnly: - self._flags |= lib.kCBLDatabase_ReadOnly - if noUpgrade: - self._flags |= lib.kCBLDatabase_NoUpgrade - - def _cblConfig(self): - self._cblDir = cstr(self.directory) # to keep string from being GC'd - return ffi.new("CBLDatabaseConfiguration*", [self._cblDir, self._flags]) - - def __repr__(self): - return "DatabaseConfiguration['" + self.directory + "']" - - -class Database (CBLObject): - def __init__(self, name, config =None): - if config != None: - config = config._cblConfig() - self.name = name - self.listeners = set() - CBLObject.__init__(self, lib.CBLDatabase_Open(cstr(name), config, gError), - "Couldn't open database", gError) - - def __repr__(self): - return "Database['" + self.name + "']" - - def close(self): - if not lib.CBLDatabase_Close(self._ref, gError): - print ("WARNING: Database.close() failed") - - def delete(self): - if not lib.CBLDatabase_Delete(self._ref, gError): - raise CBLException("Couldn't delete database", gError) - - @staticmethod - def deleteFile(name, dir): - if lib.CBL_DeleteDatabase(cstr(name), cstr(dir), gError): - return True - elif gError.code == 0: - return False - else: - raise CBLException("Couldn't delete database file", gError) - - def compact(self): - if not lib.CBLDatabase_Compact(self._ref, gError): - raise CBLException("Couldn't compact database", gError) - - # Attributes: - - def getPath(self): - return pystr(lib.CBLDatabase_Path(self._ref)) - path = property(getPath) - - @property - def config(self): - c_config = lib.CBLDatabase_Config(self._ref) - dir = pystr(c_config.directory) - return DatabaseConfiguration(dir) - - @property - def count(self): - return lib.CBLDatabase_Count(self._ref) - - # Documents: - - def getDocument(self, id): - return Document._get(self, id) - - def getMutableDocument(self, id): - return MutableDocument._get(self, id) - - def saveDocument(self, doc, concurrency = FailOnConflict): - doc._prepareToSave() - savedDocRef = lib.CBLDatabase_SaveDocument(self._ref, doc._ref, concurrency, gError) - if not savedDocRef: - raise CBLException("Couldn't save document", gError) - savedDoc = Document(doc.id) - savedDoc.database = self - savedDoc._ref = savedDocRef - return savedDoc - - def deleteDocument(self, id): - if not lib.CBLDatabase_DeleteDocument(self._ref, cstr(id), gError): - raise CBLException("Couldn't delete document", gError) - - def purgeDocument(self, id): - if not lib.CBLDatabase_PurgeDocument(self._ref, cstr(id), gError): - raise CBLException("Couldn't purge document", gError) - - def __getitem__(self, id): - return self.getMutableDocument(id) - - def __setitem__(self, id, doc): - if id != doc.id: - raise CBLException("key does not match document ID") - self.saveDocument(doc) - - def __delitem__(self, id): - self.deleteDocument(id) - - # Batch operations: (`with db: ...`) - - def __enter__(self): - if not lib.CBLDatabase_BeginBatch(self._ref, gError): - raise CBLException("Couldn't begin a batch operation", gError) - - def __exit__(self, exc_type, exc_value, traceback): - if not lib.CBLDatabase_EndBatch(self._ref, gError) and not exc_type: - raise CBLException("Couldn't commit a batch operation", gError) - - # Expiration: - - def getDocumentExpiration(self, id): - exp = lib.CBLDatabase_GetDocumentExpiration(self._ref, id, gError) - if exp > 0: - return datetime.fromtimestamp(exp) - elif exp == 0: - return None - else: - raise CBLException("Couldn't get document's expiration", gError) - - def setDocumentExpiration(self, id, expDateTime): - timestamp = 0 - if expDateTime != None: - timestamp = math.ceil(expDateTime.timestamp) - if not lib.CBLDatabase_SetDocumentExpiration(self._ref, id, timestamp, gError): - raise CBLException("Couldn't set document's expiration", gError) - - - # Listeners: - - def addListener(self, listener): - handle = ffi.new_handle(listener) - self.listeners.add(handle) - c_token = lib.CBLDatabase_AddChangeListener(self._ref, lib.databaseListenerCallback, handle) - return ListenerToken(self, handle, c_token) - - def addDocumentListener(self, docID, listener): - handle = ffi.new_handle(listener) - self.listeners.add(handle) - c_token = lib.CBLDatabase_AddDocumentChangeListener(self._ref, docID, - lib.databaseListenerCallback, handle) - return ListenerToken(self, handle, c_token) - - def removeListener(self, token): - token.remove() - - -@ffi.def_extern() -def databaseListenerCallback(context, db, numDocs, c_docIDs): - docIDs = [] - for i in range(numDocs): - docIDs.append(pystr(c_docIDs[i])) - listener = ffi.from_handle(context) - listener(docIDs) - -@ffi.def_extern() -def documentListenerCallback(context, db, docID): - listener = ffi.from_handle(context) - listener(pystr(docID)) diff --git a/bindings/python/CouchbaseLite/Document.py b/bindings/python/CouchbaseLite/Document.py deleted file mode 100644 index 57848587..00000000 --- a/bindings/python/CouchbaseLite/Document.py +++ /dev/null @@ -1,139 +0,0 @@ -# Document.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# -from ._PyCBL import ffi, lib -from .common import * -from .Collections import * -import json - -# Concurrency control: -LastWriteWins = 0 -FailOnConflict = 1 - -class Document (CBLObject): - def __init__(self, id): - self.id = id - self._ref = None - - def __repr__(self): - return self.__class__.__name__ + "['" + self.id + "']" - - @staticmethod - def _get(database, id): - ref = lib.CBLDatabase_GetDocument(database._ref, cstr(id)) - if not ref: - return None - doc = Document(id) - doc.database = database - doc._ref = ref - return doc - - def delete(self, concurrency = LastWriteWins): - assert(self._ref) - if not lib.CBLDocument_Delete(self._ref, concurrency, gError): - raise CBLException("Couldn't delete document", gError) - - def purge(self): - assert(self._ref) - if not lib.CBLDocument_Purge(self._ref, gError): - raise CBLException("Couldn't purge document", gError) - - def mutableCopy(self): - mdoc = MutableDocument(self.id) - mdoc.database = self.database - mdoc._ref = lib.CBLDocument_MutableCopy(self._ref) - return mdoc - - @property - def sequence(self): - if not self._ref: - return 0 - return lib.CBLDocument_Sequence(self._ref) - - def getProperties(self): - if not "_properties" in self.__dict__: - if self._ref: - fleeceProps = lib.CBLDocument_Properties(self._ref) - self._properties = decodeFleeceDict(fleeceProps, mutable=self.isMutable) - else: - self._properties = {} - return self._properties - properties = property(getProperties) - - @property - def JSON(self): - return pystr(lib.CBLDocument_PropertiesAsJSON(self._ref)) - - def get(self, key, dflt = None): - return self.properties.get(key, dflt) - def __getitem__(self, key): - return self.properties[key] - def __contains__(self, key): - return key in self.properties - - def addListener(self, listener): - self.database.addDocumentListener(listener) - - @property - def isMutable(self): - return False - - -class MutableDocument (Document): - def __init__(self, id): - Document.__init__(self, id) - - @staticmethod - def _get(database, id): - ref = lib.CBLDatabase_GetMutableDocument(database._ref, cstr(id)) - if not ref: - return None - doc = MutableDocument(id) - doc.database = database - doc._ref = ref - return doc - - @property - def JSON(self): - if "_properties" in self.__dict__: - return encodeJSON(self._properties) - else: - return pystr(lib.CBLDocument_PropertiesAsJSON(self._ref)) - - def setProperties(self, props): - self._properties = props - properties = property(Document.getProperties, setProperties) - - def __setitem__(self, key, value): - self.properties[key] = value - def __delitem__(self, key): - del self.properties[key] - - # Called from Database.saveDocument - def _prepareToSave(self): - if not self._ref: - self._ref = lib.CBLDocument_New(cstr(self.id)) - if "_properties" in self.__dict__: - jsonStr = encodeJSON(self._properties) - if not lib.CBLDocument_SetPropertiesAsJSON(self._ref, cstr(jsonStr), gError): - raise CBLException("Couldn't store properties", gError) - - def save(self, concurrency = FailOnConflict): - return self.database.saveDocument(self, concurrency) - - @property - def isMutable(self): - return True diff --git a/bindings/python/CouchbaseLite/Query.py b/bindings/python/CouchbaseLite/Query.py deleted file mode 100644 index cc7f2e23..00000000 --- a/bindings/python/CouchbaseLite/Query.py +++ /dev/null @@ -1,166 +0,0 @@ -# Query.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# -from ._PyCBL import ffi, lib -from .common import * -from .Collections import * -import json - -JSONLanguage = 0 -N1QLLanguage = 1 - -class Query (CBLObject): - - def __init__(self, database, queryString, language = N1QLLanguage): - errorPos = ffi.new("int*") - CBLObject.__init__(self, - lib.CBLQuery_New(database._ref, language, cstr(queryString), - errorPos, gError), - "Couldn't create query", gError) - self.database = database - self.columnCount = lib.CBLQuery_ColumnCount(self._ref) - self.sourceCode = queryString - self.listeners = set() - - def __repr__(self): - return self.__class__.__name__ + "['" + self.sourceCode + "']" - - @property - def explanation(self): - return sliceToString(lib.CBLQuery_Explain(self._ref)) - - @property - def columnNames(self): - if not "_columns" in self.__dict__: - cols = [] - for i in range(self.columnCount): - name = sliceToString( lib.CBLQuery_ColumnName(self._ref, i) ) - cols.append(name) - self._columns = cols - return self._columns - - def setParameters(self, params): - jsonStr = encodeJSON(params) - lib.CBLQuery_SetParametersAsJSON(self._ref, cstr(jsonStr)) - - def execute(self): - """Executes the query and returns a Generator of QueryResult objects.""" - results = lib.CBLQuery_Execute(self._ref, gError) - if not results: - raise CBLException("Query failed", gError) - try: - lastResult = None - while lib.CBLResultSet_Next(results): - if lastResult: - lastResult.invalidate() - lastResult = QueryResult(self, results) - yield lastResult - finally: - lib.CBL_Release(results) - - # Listeners: - - def addListener(self, listener): - handle = ffi.new_handle(listener) - self.listeners.add(handle) - c_token = lib.CBLQuery_AddChangeListener(self._ref, lib.queryListenerCallback, handle) - return ListenerToken(self, handle, c_token) - - def removeListener(self, token): - token.remove() - - -class JSONQuery (Query): - def __init__(self, database, jsonQuery): - if not isinstance(jsonQuery, str): - jsonQuery = encodeJSON(jsonQuery) - Query.__init__(self, database, jsonQuery, JSONLanguage) - - -class N1QLQuery (Query): - def __init__(self, database, n1ql): - Query.__init__(self, database, n1ql, N1QLLanguage) - - -class QueryResult (object): - """A container representing a query result. It can be indexed using either - integers (to access columns in the order they were declared in the query) - or strings (to access columns by name.)""" - def __init__(self, query, results): - self.query = query - self._ref = results - - def __repr__(self): - if self._ref == None: - return "QueryResult[invalidated]" - return "QueryResult" + encodeJSON(self.asDictionary()) - - def invalidate(self): - self._ref = None - self.query = None - - def __len__(self): - return self.query.columnCount - - def __getitem__(self, key): - if self._ref == None: - raise CBLException("Accessing a non-current query result row") - if isinstance(key, int): - if key < 0 or key >= self.query.columnCount: - raise IndexError("Column index out of range") - item = lib.CBLResultSet_ValueAtIndex(self._ref, key) - elif isinstance(key, str): - item = lib.CBLResultSet_ValueForKey(self._ref, key) - if item == None: - raise KeyError("No such column in Query") - else: - # TODO: Handle slices - raise KeyError("invalid query result key") - return decodeFleece(item) - - def __contains__(self, key): - if self._ref == None: - raise CBLException("Accessing a non-current query result row") - if isinstance(key, int): - if key < 0 or key >= self.query.columnCount: - return False - return (lib.CBLResultSet_ValueAtIndex(self._ref, key) != None) - elif isinstance(key, str): - return (lib.CBLResultSet_ValueForKey(self._ref, key) != None) - else: - return False - - def asArray(self): - result = [] - for i in range(0, self.query.columnCount): - result.append(self[i]) - return result - - def asDictionary(self): - result = {} - keys = self.query.columnNames - for i in range(0, self.query.columnCount): - item = lib.CBLResultSet_ValueAtIndex(self._ref, i) - if lib.FLValue_GetType(item) != lib.kFLUndefined: - result[keys[i]] = decodeFleece(item) - return result - - - -@ffi.def_extern() -def queryListenerCallback(context, query): - listener = ffi.from_handle(context) - listener() diff --git a/bindings/python/CouchbaseLite/__init__.py b/bindings/python/CouchbaseLite/__init__.py deleted file mode 100644 index 4a41f520..00000000 --- a/bindings/python/CouchbaseLite/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# placeholder file, to mark this directory as a Python package diff --git a/bindings/python/CouchbaseLite/common.py b/bindings/python/CouchbaseLite/common.py deleted file mode 100644 index 759ac8db..00000000 --- a/bindings/python/CouchbaseLite/common.py +++ /dev/null @@ -1,86 +0,0 @@ -# common.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# - - -from ._PyCBL import ffi, lib - -def cstr(str): - return ffi.new("char[]", str.encode("utf-8")) - -def pystr(cstr): - return str(ffi.string(cstr), "utf-8") - -def sliceToString(s): - if s.buf == None: - return None - return str(ffi.string(ffi.cast("const char*", s.buf), s.size), "utf-8") - -def sliceResultToBytes(sr): - if sr.buf == None: - return None - return bytes( ffi.buffer(sr.buf, sr.size) ) - -def asSlice(data): - buffer = ffi.from_buffer(data) - s = ffi.new("FLSlice*") - s.buf = buffer - s.size = len(buffer) - return s - - -# A global CBLError object to use in API calls, so each call doesn't have to -# allocate a new one. (This is fine as long as we're single-threaded.) -gError = ffi.new("CBLError*") - - -class CBLException (EnvironmentError): - def __init__(self, message, cblError = None): - if cblError != None: - self.domain = cblError.domain - self.code = cblError.code - self.error = pystr(lib.CBLError_Message(cblError)) - EnvironmentError.__init__(self, message + ": " + self.error) - else: - EnvironmentError.__init__(self, message) - - -class CBLObject (object): - def __init__(self, ref, message =None, error =None): - self._ref = ref - if not ref and message: - raise CBLException(message, error) - - def __del__(self): - if lib != None and "_ref" in self.__dict__ and self._ref != None: - lib.CBL_Release(self._ref) - - -class ListenerToken (object): - def __init__(self, owner, handle, c_token): - self.owner = owner - self.handle = handle - self.c_token = c_token - - def __del__(self): - self.remove() - - def remove(self): - if self.owner != None: - lib.CBLListener_Remove(self.c_token) - self.owner.listeners.remove(self.handle) - self.owner = None - self.handle = None diff --git a/bindings/python/README.md b/bindings/python/README.md deleted file mode 100644 index bbe008d4..00000000 --- a/bindings/python/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Python Bindings For Couchbase Lite - -10 May 2020 - -This directory contains a [Couchbase Lite][CBL] API binding for Python 3. - -It's still in early development. It's incomplete, has only had some informal testing, and that -only on macOS. - -## Building - -**_"Some assembly required..."_** - -You first need to build Couchbase Lite For C (the root of this repo) with CMake, by running the -`build.sh` script in the repo root directory. That will produce the shared library. - - $ cd ../.. - $ ./build.sh - -Then you can build the Python binding library, first installing Python's CFFI package if you haven't -already: - - $ pip install cffi - $ cd bindings/python - $ ./build.sh - -Now try the rudimentary tests: - - $ test/test.sh - -You can look at the test code in `test/test.py` for examples of how to use the API. - -## Learning - -If you're not already familiar with Couchbase Lite, you'll want to start by reading through its -[official documentation][CBLDOCS]. - -The Python API is mostly method-for-method compatible with the languages documented there, except -down at the document property level (dictionaries, arrays, etc.) where I haven't yet written -compatible bindings. For those APIs you can check out the document "[Using Fleece][FLEECE]". - -## Using - -[CBL]: https://www.couchbase.com/products/lite -[CBLDOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html -[FLEECE]: https://github.com/couchbaselabs/fleece/wiki/Using-Fleece diff --git a/bindings/python/build.sh b/bindings/python/build.sh deleted file mode 100755 index a182d2e0..00000000 --- a/bindings/python/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash -e - -SCRIPT_DIR=`dirname $0` -cd $SCRIPT_DIR/CouchbaseLite -python3 ../BuildPyCBL.py $@ diff --git a/bindings/python/test/test.py b/bindings/python/test/test.py deleted file mode 100644 index 41b44191..00000000 --- a/bindings/python/test/test.py +++ /dev/null @@ -1,119 +0,0 @@ -#! /usr/bin/env python3 -# -# test.py -# -# Copyright (c) 2019 Couchbase, Inc 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. -# - -from CouchbaseLite.Database import Database, DatabaseConfiguration -from CouchbaseLite.Document import Document, MutableDocument -from CouchbaseLite.Query import JSONQuery -import json - -Database.deleteFile("db", "/tmp") - -db = Database("db", DatabaseConfiguration("/tmp")) - -print ("db = ", db) -print ("name = ", db.name) -print ("dir = ", db.config) -print ("path = ", db.path) -print ("docs = ", db.count) - -assert(db.name == "db") -assert(db.path == "/tmp/db.cblite2/") -assert(db.count == 0) - -def dbListener(docIDs): - print ("######## DB changed!", docIDs) -dbListenerToken = db.addListener(dbListener) - -def canonicalJSON(str): - obj = json.loads(str) - return json.dumps(obj, sort_keys = True) - -with db: - doc = db.getDocument("foo") - assert(not doc) - doc = db.getMutableDocument("foo") - assert(not doc) - doc = MutableDocument("foo") - assert(doc.id == "foo") - - print ("doc = ", doc) - - props = doc.properties - print ("props=", props) - assert(props == {}) - - props["flavor"] = "cardamom" - props["numbers"] = [1, 0, 3.125] - doc["color"] = "green" - print ("props=", props) - - db.saveDocument(doc) - - doc2 = db.getDocument("foo") - assert(doc2.id == "foo") - print ("doc2 = ", doc2) - props2 = doc2.properties - print ("props2=", props2) - assert(props2 == props) - assert(doc2["color"] == "green") - - assert(db.count == 1) - - doc = MutableDocument("bar") - doc["color"] = "green" - doc["flavor"] = "pumpkin spice" - db["bar"] = doc # saves it - - assert(db.count == 2) - - doc = MutableDocument('nested_doc') - doc['flat'] = 'flat' - doc['empty_obj'] = {} - doc['nested'] = {'nested': 'nested'} - doc['empty_array'] = [] - doc['array'] = ['a'] - print("doc = ", canonicalJSON(doc.JSON)) - assert(canonicalJSON(doc.JSON) == """{"array": ["a"], "empty_array": [], "empty_obj": {}, "flat": "flat", "nested": {"nested": "nested"}}""") - db.saveDocument(doc) - - read_doc = db.getMutableDocument('nested_doc') - print("read_doc = ", canonicalJSON(read_doc.JSON)) - assert(canonicalJSON(read_doc.JSON) == """{"array": ["a"], "empty_array": [], "empty_obj": {}, "flat": "flat", "nested": {"nested": "nested"}}""") - db.saveDocument(read_doc) - - update_doc = db.getMutableDocument('nested_doc') - update_doc['a'] = 'b' - update_doc['nested']['foo'] = 'bar' - print("update_doc = ", canonicalJSON(update_doc.JSON)) - assert(canonicalJSON(update_doc.JSON) == """{"a": "b", "array": ["a"], "empty_array": [], "empty_obj": {}, "flat": "flat", "nested": {"foo": "bar", "nested": "nested"}}""") - db.saveDocument(update_doc) - - -dbListenerToken.remove() - -q = JSONQuery(db, {'WHAT': [['.flavor'], ['.numbers']], 'WHERE': ['=', ['.color'], 'green']}) -print ("-------- Explanation --------") -print (q.explanation) -print ("-----------------------------") -print ("Columns: ", q.columnNames) - -for row in q.execute(): - print ("row: ", row.asArray(), " ...or... ", row.asDictionary()) - -db.close() diff --git a/bindings/python/test/test.sh b/bindings/python/test/test.sh deleted file mode 100755 index 0cccb71b..00000000 --- a/bindings/python/test/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash -e - -SCRIPT_DIR=`dirname $0` -cd "$SCRIPT_DIR" - -export PYTHONPATH=.. -python3 test.py diff --git a/bindings/rust/CouchbaseLite/Cargo.toml b/bindings/rust/CouchbaseLite/Cargo.toml deleted file mode 100644 index 7d5df057..00000000 --- a/bindings/rust/CouchbaseLite/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "couchbase_lite" -version = "0.1.0" -authors = ["Jens Alfke "] - -[dependencies] -enum_primitive = "*" -tempdir = "*" - -[build-dependencies] -bindgen = "0.53.1" - -[lib] -bench = false -doctest = false -crate-type = ["lib", "dylib"] - -[profile.release] -opt-level = "z" -lto = true -codegen-units = 1 -incremental = false -# See: https://github.com/johnthagen/min-sized-rust diff --git a/bindings/rust/CouchbaseLite/build.rs b/bindings/rust/CouchbaseLite/build.rs deleted file mode 100644 index d41e1938..00000000 --- a/bindings/rust/CouchbaseLite/build.rs +++ /dev/null @@ -1,120 +0,0 @@ -// Couchbase Lite C API bindings generator -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -// This script runs during a Cargo build and generates the raw/unsafe Rust bindings, "bindings.rs", -// in an internal build directory, where they are included by `src/c_api.rs`. -// -// References: -// - https://rust-lang.github.io/rust-bindgen/tutorial-3.html -// - https://doc.rust-lang.org/cargo/reference/build-scripts.html - -extern crate bindgen; - -use std::env; -use std::fs; -use std::path::PathBuf; - -//TODO: This is likely not valid for your system, but I don't know how to find it automatically -static DEFAULT_LIBCLANG_PATH : &str = "/usr/local/Cellar/llvm/10.0.0_3/lib"; - -static INCLUDE_CBL_IN_LIB : bool = false; - -fn main() { - let root_dir = PathBuf::from("../../.."); // The root of the couchbase-lite-c repo - let cbl_headers = root_dir.join("include/cbl"); - let fleece_headers = root_dir.join("vendor/couchbase-lite-core/vendor/fleece/API"); - - // Set LIBCLANG_PATH environment variable if it's not already set: - if env::var("LIBCLANG_PATH").is_err() { - env::set_var("LIBCLANG_PATH", DEFAULT_LIBCLANG_PATH); - println!("cargo:rustc-env=LIBCLANG_PATH={}", DEFAULT_LIBCLANG_PATH); - } - - // The bindgen::Builder is the main entry point - // to bindgen, and lets you build up options for - // the resulting bindings. - let bindings = bindgen::Builder::default() - // The input header we would like to generate bindings for. - .header("wrapper.h") - // C '#include' search paths: - .clang_arg("-I".to_owned() + cbl_headers.to_str().unwrap()) - .clang_arg("-I".to_owned() + fleece_headers.to_str().unwrap()) - // Which symbols to generate bindings for: - .whitelist_type("CBL.*") - .whitelist_type("FL.*") - .whitelist_var("k?CBL.*") - .whitelist_var("k?FL.*") - .whitelist_function("CBL.*") - .whitelist_function("_?FL.*") - // Tell cargo to invalidate the built crate whenever any of the - // included header files changed. - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) - // Finish the builder and generate the bindings. - .generate() - // Unwrap the Result and panic on failure. - .expect("Unable to generate bindings"); - - // Write the bindings to the $OUT_DIR/bindings.rs file. - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - bindings - .write_to_file(out_dir.join("bindings.rs")) - .expect("Couldn't write bindings!"); - - // Tell cargo to tell rustc to link the cblite shared library. - //TODO: Abort the build now if the library does not exist, and tell the user to run CMake. - let root = root_dir.to_str().unwrap(); - - if INCLUDE_CBL_IN_LIB { - println!("cargo:rustc-link-search={}/build_cmake", root); - println!("cargo:rustc-link-search={}/build_cmake/vendor/couchbase-lite-core", root); - println!("cargo:rustc-link-search={}/build_cmake/vendor/couchbase-lite-core/vendor/BLIP-Cpp", root); - println!("cargo:rustc-link-search={}/build_cmake/vendor/couchbase-lite-core/vendor/fleece", root); - println!("cargo:rustc-link-search={}/build_cmake/vendor/couchbase-lite-core/vendor/mbedtls/library", root); - println!("cargo:rustc-link-search={}/build_cmake/vendor/couchbase-lite-core/vendor/sqlite3-unicodesn", root); - - println!("cargo:rustc-link-lib=static=cblite-static"); - println!("cargo:rustc-link-lib=static=FleeceStatic"); - - println!("cargo:rustc-link-lib=static=liteCoreStatic"); - println!("cargo:rustc-link-lib=static=liteCoreWebSocket"); - println!("cargo:rustc-link-lib=static=SQLite3_UnicodeSN"); - println!("cargo:rustc-link-lib=static=BLIPStatic"); - println!("cargo:rustc-link-lib=static=mbedtls"); - println!("cargo:rustc-link-lib=static=mbedcrypto"); - - println!("cargo:rustc-link-lib=c++"); - println!("cargo:rustc-link-lib=z"); - - println!("cargo:rustc-link-lib=framework=CoreFoundation"); - println!("cargo:rustc-link-lib=framework=Foundation"); - println!("cargo:rustc-link-lib=framework=CFNetwork"); - println!("cargo:rustc-link-lib=framework=Security"); - println!("cargo:rustc-link-lib=framework=SystemConfiguration"); - } else { - // Copy the CBL dylib: - let src = root_dir.join("build_cmake/libcblite.dylib"); - let dst = out_dir.join("libcblite.dylib"); - println!("cargo:rerun-if-changed={}", src.to_str().unwrap()); - fs::copy(src, dst).expect("copy dylib"); - // Tell rustc to link it: - println!("cargo:rustc-link-search={}", out_dir.to_str().unwrap()); - println!("cargo:rustc-link-lib=dylib=cblite"); - } - - // Tell cargo to invalidate the built crate whenever the wrapper changes - println!("cargo:rerun-if-changed=wrapper.h"); -} diff --git a/bindings/rust/CouchbaseLite/src/blob.rs b/bindings/rust/CouchbaseLite/src/blob.rs deleted file mode 100644 index 36ef632c..00000000 --- a/bindings/rust/CouchbaseLite/src/blob.rs +++ /dev/null @@ -1,202 +0,0 @@ -// Couchbase Lite Blob class -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use crate::slice::*; -use crate::c_api::*; - -use std::ffi::c_void; -use std::marker::PhantomData; - - -/** A binary attachment to a Document. */ -pub struct Blob { - pub(crate) _ref: *const CBLBlob -} - - -impl Blob { - - //////// CREATION - - /** Creates a new blob, given its contents as a byte array. */ - pub fn new_from_data(data: &[u8], content_type: &str) -> Blob { - unsafe { - let blob = CBLBlob_CreateWithData_s(as_slice(content_type), bytes_as_slice(data)); - return Blob{_ref: blob}; - } - } - - /** Creates a new blob from data that has has been written to a [`Writer`]. - You should then add the blob to a document as a property, using [`Slot::put_blob`]. */ - pub fn new_from_stream(mut stream: BlobWriter, content_type: &str) -> Blob { - unsafe { - let blob = CBLBlob_CreateWithStream_s(as_slice(content_type), stream._stream_ref); - stream._stream_ref = std::ptr::null_mut(); // stop `drop` from closing the stream - return Blob{_ref: blob}; - } - } - - // called by FleeceReference::as_blob() - pub(crate) fn from_value(value: &V) -> Option { - unsafe { - let blob = CBLBlob_Get(FLValue_AsDict(value._fleece_ref())); - return if blob.is_null() {None} else {Some(Blob{_ref: blob})}; - } - } - - //////// ACCESSORS - - - /** The length of the content data in bytes. */ - pub fn length(&self) -> u64 { - unsafe { CBLBlob_Length(self._ref) } - } - - /** The unique digest of the blob: A base64-encoded SHA-1 digest of its data. */ - pub fn digest(&self) -> String { - unsafe { to_string(CBLBlob_Digest(self._ref)) } - } - - /** The MIME type assigned to the blob, if any. */ - pub fn content_type(&self) -> Option { - unsafe { - let cstr = CBLBlob_ContentType(self._ref); - return if cstr.is_null() { None } else { Some(to_string(cstr)) }; - } - } - - /** The blob's metadata properties as a dictionary. */ - pub fn properties(&self) -> Dict { - unsafe { Dict{_ref: CBLBlob_Properties(self._ref), _owner: PhantomData} } - } - - - //////// READING: - - /** Reads the blob's contents into memory and returns them as a byte array. - This can potentially allocate a lot of memory! */ - pub fn load_content(&self) -> Result> { - unsafe { - let mut err = CBLError::default(); - let content = CBLBlob_LoadContent(self._ref, &mut err).to_vec(); - return if let Some(c) = content { Ok(c) } else { failure(err) }; - } - } - - /** Opens a stream for reading a blob's content from disk. */ - pub fn open_content(&self) -> Result { - check_ptr(|err| unsafe{ CBLBlob_OpenContentStream(self._ref, err) }, - |stream| BlobReader{blob: self, _stream_ref: stream}) - } -} - -impl Drop for Blob { - fn drop(&mut self) { - unsafe { release(self._ref as *mut CBLBlob); } - } -} - -impl Clone for Blob { - fn clone(&self) -> Self { - unsafe { Blob{_ref: retain(self._ref as *mut CBLBlob)} } - } -} - - -//////// BLOB ADDITIONS FOR ARRAY / DICT: - - -impl Slot<'_> { - /** Stores a Blob reference in an Array or Dict. This is how you add a Blob to a Document. */ - pub fn put_blob(self, blob: &mut Blob) { - unsafe { FLSlot_SetBlob(self._ref, blob._ref as *mut CBLBlob) } - } -} - - -//////// BLOB READER - - -/** A stream for reading Blob conents. */ -pub struct BlobReader<'r> { - pub blob: &'r Blob, - _stream_ref: *mut CBLBlobReadStream -} - -impl<'r> std::io::Read for BlobReader<'r> { - fn read(&mut self, buf: &mut [u8]) -> std::io::Result { - unsafe { - check_io(|err| CBLBlobReader_Read(self._stream_ref, - buf.as_mut_ptr() as *mut c_void, - buf.len() as u64, - err)) - } - } -} - -impl<'r> Drop for BlobReader<'r> { - fn drop(&mut self) { - unsafe { CBLBlobReader_Close(self._stream_ref); } - } -} - - -//////// BLOB WRITER - - -/** A stream for writing data that will become a Blob's contents. - After you're done writing the data, call [`Blob::new_from_stream`], - then add the Blob to a document property via [`Slot::put_blob`]. */ -pub struct BlobWriter<'d> { - _stream_ref: *mut CBLBlobWriteStream, - db: PhantomData<&'d mut Database> -} - -impl<'d> BlobWriter<'d> { - pub fn new(db: &'d mut Database) -> Result> { - unsafe { - let db_ref = db._ref; - check_ptr(|err| CBLBlobWriter_New(db_ref, err), - move |stream| BlobWriter{_stream_ref: stream, db: PhantomData}) - } - } -} - -impl<'r> std::io::Write for BlobWriter<'r> { - fn write(&mut self, data: &[u8]) -> std::result::Result { - unsafe { - check_io(|err| { - let ok = CBLBlobWriter_Write(self._stream_ref, - data.as_ptr() as *const c_void, - data.len() as u64, - err); - if ok {data.len() as i32} else {-1} - }) - } - } - - fn flush(&mut self) -> std::result::Result<(), std::io::Error> { - Ok(()) - } -} - -impl<'r> Drop for BlobWriter<'r> { - fn drop(&mut self) { - unsafe { CBLBlobWriter_Close(self._stream_ref) } - } -} diff --git a/bindings/rust/CouchbaseLite/src/c_api.rs b/bindings/rust/CouchbaseLite/src/c_api.rs deleted file mode 100644 index d4106e84..00000000 --- a/bindings/rust/CouchbaseLite/src/c_api.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Couchbase Lite internal bindings -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -// This module simply includes the auto-generated bindings of the C API. -// `bindings.rs` is generated at build time by `build.rs`. - -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(dead_code)] - -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/bindings/rust/CouchbaseLite/src/database.rs b/bindings/rust/CouchbaseLite/src/database.rs deleted file mode 100644 index ae54af02..00000000 --- a/bindings/rust/CouchbaseLite/src/database.rs +++ /dev/null @@ -1,224 +0,0 @@ -// Couchbase Lite database API -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::slice::*; -use super::error::*; -use super::c_api::*; - -use std::path::*; -use std::ptr; - - -// Database configuration flags: -pub static CREATE : u32 = kCBLDatabase_Create; -pub static READ_ONLY : u32 = kCBLDatabase_ReadOnly; -pub static NO_UPGRADE : u32 = kCBLDatabase_NoUpgrade; - - -/** Database configuration options. */ -pub struct DatabaseConfiguration<'a> { - pub directory: &'a std::path::Path, - pub flags: u32 -} - - -type ChangeListener = fn(db: &Database, doc_ids: Vec); - - -/** A connection to an open database. */ -pub struct Database { - pub(crate) _ref: *mut CBLDatabase -} - - -impl Database { - - //////// CONSTRUCTORS: - - - /** Opens a database, or creates it if it doesn't exist yet, returning a new `Database` - instance. - - It's OK to open the same database file multiple times. Each `Database` instance is - independent of the others (and must be separately closed and released.) */ - pub fn open(name: &str, config: Option) -> Result { - unsafe { - if let Some(cfg) = config { - let c_config = CBLDatabaseConfiguration_s { - directory: as_slice(cfg.directory.to_str().unwrap()), - flags: cfg.flags, - encryptionKey: ptr::null_mut() // TODO - }; - return Database::_open(name, &c_config); - } else { - return Database::_open(name, ptr::null()) - } - } - } - - - unsafe fn _open(name: &str, config_ptr: *const CBLDatabaseConfiguration_s) -> Result { - let mut err = CBLError::default(); - let db_ref = CBLDatabase_Open_s(as_slice(name), config_ptr, &mut err); - if db_ref.is_null() { - return failure(err); - } - return Ok(Database{_ref: db_ref}); - } - - - //////// OTHER STATIC METHODS: - - - /** Returns true if a database with the given name exists in the given directory. */ - pub fn exists>(name: &str, in_directory: P) -> bool { - unsafe { - return CBL_DatabaseExists_s(as_slice(name), - as_slice(in_directory.as_ref().to_str().unwrap())); - } - } - - - /** Deletes a database file. If the database file is open, an error is returned. */ - pub fn delete_file>(name: &str, in_directory: P) -> Result { - unsafe { - let mut error = CBLError::default(); - if CBL_DeleteDatabase_s(as_slice(name), - as_slice(in_directory.as_ref().to_str().unwrap()), - &mut error) { - return Ok(true); - } else if !error { - return Ok(false); - } else { - return failure(error); - } - } - } - - - //////// OPERATIONS: - - - /** Closes and deletes a database. If there are any other connections to the database, - an error is returned. */ - pub fn delete(self) -> Result<()> { - unsafe { check_bool(|error| CBLDatabase_Delete(self._ref, error)) } - } - - - /** Compacts a database file, freeing up unused disk space. */ - pub fn compact(&mut self) -> Result<()> { - unsafe { - return check_bool(|error| CBLDatabase_Compact(self._ref, error)); - } - } - - - /** Invokes the callback as a batch operation, similar to a transaction. - - Multiple writes are much faster when grouped inside a single batch. - - Changes will not be visible to other Database instances on the same database until - the batch operation ends. - - Batch operations can nest. Changes are not committed until the outer batch ends. */ - pub fn in_batch(&self, callback: fn()->T) -> Result { - let mut err = CBLError::default(); - unsafe { - if ! CBLDatabase_BeginBatch(self._ref, &mut err) { - return failure(err); - } - } - let result = callback(); - unsafe { - if ! CBLDatabase_EndBatch(self._ref, &mut err) { - return failure(err); - } - } - return Ok(result); - } - - - //////// ACCESSORS: - - - /** Returns the database's name. */ - pub fn name(&self) -> String { - unsafe { - return to_string(CBLDatabase_Name(self._ref)); - } - } - - - /** Returns the database's full filesystem path. */ - pub fn path(&self) -> PathBuf { - unsafe { - return PathBuf::from(to_string(CBLDatabase_Path(self._ref))); - } - } - - - /** Returns the number of documents in the database. */ - pub fn count(&self) -> u64 { - unsafe { - return CBLDatabase_Count(self._ref); - } - } - - - //////// NOTIFICATIONS: - - - /** Registers a database change listener function. It will be called after one or more - documents are changed on disk. */ - pub fn add_listener(&self, _listener: ChangeListener) -> ListenerToken { - todo!() - } - - /** Switches the database to buffered-notification mode. Notifications for objects belonging - to this database (documents, queries, replicators, and of course the database) will not be - called immediately; your callback function will be called instead. You can then call - `send_notifications` when you're ready. */ - pub fn buffer_notifications(&self, _callback: fn(&Database)) { - todo!() - } - - /** Immediately issues all pending notifications for this database, by calling their listener - callbacks. (Only useful after `buffer_notifications` has been called.) */ - pub fn send_notifications(&self) { - unsafe { - CBLDatabase_SendNotifications(self._ref); - } - } - -} - - -impl Drop for Database { - fn drop(&mut self) { - unsafe { - release(self._ref) - } - } -} - - -impl Clone for Database { - fn clone(&self) -> Self { - unsafe { - return Database{_ref: retain(self._ref)} - } - } -} diff --git a/bindings/rust/CouchbaseLite/src/document.rs b/bindings/rust/CouchbaseLite/src/document.rs deleted file mode 100644 index 045394d5..00000000 --- a/bindings/rust/CouchbaseLite/src/document.rs +++ /dev/null @@ -1,231 +0,0 @@ -// Couchbase Lite document API -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::slice::*; -use super::c_api::*; - - -/** An in-memory copy of a document. */ -pub struct Document { - _ref: *mut CBLDocument -} - - -//////// DATABASE'S DOCUMENT API: - - -/** Conflict-handling options when saving or deleting a document. */ -pub enum ConcurrencyControl { - LastWriteWins = kCBLConcurrencyControlLastWriteWins as isize, - FailOnConflict = kCBLConcurrencyControlFailOnConflict as isize -} - - -pub type SaveConflictHandler = fn(&mut Document, &Document) -> bool; - -pub type ChangeListener = fn(&Database, &str); - - -impl Database { - /** Reads a document from the database. Each call to this function returns a new object - containing the document's current state. */ - pub fn get_document(&self, id: &str) -> Result { - unsafe { - // we always get a mutable CBLDocument, - // since Rust doesn't let us have MutableDocument subclass. - let doc = CBLDatabase_GetMutableDocument_s(self._ref, as_slice(id)); - if doc.is_null() { - return Err(Error::cbl_error(CouchbaseLiteError::NotFound)); - } - return Ok(Document{_ref: doc}); - } - } - - /** Saves a new or modified document to the database. - If a conflicting revision has been saved since `doc` was loaded, the `concurrency` - parameter specifies whether the save should fail, or the conflicting revision should - be overwritten with the revision being saved. - If you need finer-grained control, call `save_document_resolving` instead. */ - pub fn save_document(&mut self, - doc: &mut Document, - concurrency: ConcurrencyControl) - -> Result - { - let mut error = CBLError::default(); - unsafe { - let doc2 = CBLDatabase_SaveDocument(self._ref, doc._ref, concurrency as u8, &mut error); - if doc2.is_null() { - return failure(error); - } - return Ok(Document{_ref: doc2 as *mut CBLDocument}); - } - } - - /** Saves a new or modified document to the database. This function is the same as - `save_document`, except that it allows for custom conflict handling in the event - that the document has been updated since `doc` was loaded. */ - pub fn save_document_resolving(&mut self, - _doc: &mut Document, - _conflict_handler: SaveConflictHandler) - -> Result - { - todo!() - } - - pub fn purge_document_by_id(&mut self, id: &str) -> Result<()> { - unsafe { - return check_bool(|error| CBLDatabase_PurgeDocumentByID_s(self._ref, as_slice(id), error)); - } - } - - /** Returns the time, if any, at which a given document will expire and be purged. - Documents don't normally expire; you have to call `set_document_expiration` - to set a document's expiration time. */ - pub fn document_expiration(&self, doc_id: &str) -> Result> { - unsafe { - let mut error = CBLError::default(); - let exp = CBLDatabase_GetDocumentExpiration_s(self._ref, as_slice(doc_id), &mut error); - if exp < 0 { - return failure(error); - } else if exp == 0 { - return Ok(None); - } else { - return Ok(Some(Timestamp(exp))); - } - } - } - - /** Sets or clears the expiration time of a document. */ - pub fn set_document_expiration(&mut self, doc_id: &str, when: Option) -> Result<()> { - let exp :i64 = match when { - Some(Timestamp(n)) => n, - _ => 0, - }; - unsafe { - return check_bool(|error| CBLDatabase_SetDocumentExpiration_s(self._ref, as_slice(doc_id), exp, error)); - } - } - - /** Registers a document change listener callback. It will be called after a specific document - is changed on disk. */ - pub fn add_document_change_listener(&self, _doc_id: &str, _listener: ChangeListener) -> ListenerToken { - todo!() - } - -} - - -//////// DOCUMENT API: - - -impl Document { - - /** Creates a new, empty document in memory, with an automatically generated unique ID. - It will not be added to a database until saved. */ - pub fn new() -> Self { - unsafe { Document{_ref: CBLDocument_New_s(NULL_SLICE)} } - } - - /** Creates a new, empty document in memory, with the given ID. - It will not be added to a database until saved. */ - pub fn new_with_id(id: &str) -> Self { - unsafe { Document{_ref: CBLDocument_New_s(as_slice(id))} } - } - - /** Deletes a document from the database. (Deletions are replicated, unlike purges.) */ - pub fn delete(self) -> Result<()> { - todo!() - } - - /** Purges a document. This removes all traces of the document from the database. - Purges are _not_ replicated. If the document is changed on a server, it will be re-created - when pulled. */ - pub fn purge(self) -> Result<()> { - todo!() - } - - /** Returns the document's ID. */ - pub fn id(&self) -> String { - unsafe { to_string(CBLDocument_ID(self._ref)) } - } - - /** Returns a document's revision ID, which is a short opaque string that's guaranteed to be - unique to every change made to the document. - If the document doesn't exist yet, this method returns None. */ - pub fn revision_id(&self) -> Option { - unsafe { - let revid = CBLDocument_RevisionID(self._ref); - return if revid.is_null() {None} else {Some(to_string(revid))} - } - } - - /** Returns a document's current sequence in the local database. - This number increases every time the document is saved, and a more recently saved document - will have a greater sequence number than one saved earlier, so sequences may be used as an - abstract 'clock' to tell relative modification times. */ - pub fn sequence(&self) -> u64 { - unsafe { CBLDocument_Sequence(self._ref) } - } - - /** Returns a document's properties as a dictionary. - This dictionary cannot be mutated; call `mutable_properties` if you want to make - changes to the document's properties. */ - pub fn properties<'a>(&'a self) -> Dict { - unsafe { Dict::wrap(CBLDocument_Properties(self._ref), self) } - } - - /** Returns a document's properties as an mutable dictionary. Any changes made to this - dictionary will be saved to the database when this Document instance is saved. */ - pub fn mutable_properties(&mut self) -> MutableDict { - unsafe { MutableDict::adopt(CBLDocument_MutableProperties(self._ref)) } - } - - /** Replaces a document's properties with the contents of the dictionary. - The dictionary is retained, not copied, so further changes _will_ affect the document. */ - pub fn set_properties(&mut self, properties: MutableDict) { - unsafe { CBLDocument_SetProperties(self._ref, properties._ref) } - } - - /** Returns a document's properties as a JSON string. */ - pub fn properties_as_json(&self) -> String { - unsafe { to_string(CBLDocument_PropertiesAsJSON(self._ref)) } - } - - /** Sets a mutable document's properties from a JSON string. */ - pub fn set_properties_as_json(&mut self, json: &str) -> Result<()> { - unsafe { - let mut err = CBLError::default(); - let ok = CBLDocument_SetPropertiesAsJSON_s(self._ref, as_slice(json), &mut err); - return check_failure(ok, &err); - } - } -} - - -impl Drop for Document { - fn drop(&mut self) { - unsafe { release(self._ref); } - } -} - - -impl Clone for Document { - fn clone(&self) -> Self { - unsafe { Document{_ref: retain(self._ref)} } - } -} diff --git a/bindings/rust/CouchbaseLite/src/error.rs b/bindings/rust/CouchbaseLite/src/error.rs deleted file mode 100644 index f34b95e2..00000000 --- a/bindings/rust/CouchbaseLite/src/error.rs +++ /dev/null @@ -1,286 +0,0 @@ -// Couchbase Lite error classs -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -#![allow(non_upper_case_globals)] - -use super::c_api::*; -use enum_primitive::FromPrimitive; -use std::fmt; - - -//////// ERROR STRUCT: - - -/** Error type. Wraps multiple types of errors in an enum. */ -pub struct Error { - pub code: ErrorCode, - pub(crate) internal_info: Option -} - - -/** The enum that stores the error domain and code for an Error. */ -#[derive(Debug, PartialEq)] -pub enum ErrorCode { - CouchbaseLite (CouchbaseLiteError), - POSIX (i32), - SQLite (i32), - Fleece (FleeceError), - Network (NetworkError), - WebSocket (i32) -} - -// Redefine `Result` to assume our `Error` type -pub type Result = std::result::Result; - - -enum_from_primitive! { - /** Couchbase Lite error codes. */ - #[derive(Debug, Copy, Clone, PartialEq)] - pub enum CouchbaseLiteError { - AssertionFailed = 1, // Internal assertion failure - Unimplemented, // Oops, an unimplemented API call - UnsupportedEncryption, // Unsupported encryption algorithm - BadRevisionID, // Invalid revision ID syntax - CorruptRevisionData, // Revision contains corrupted/unreadable data - NotOpen, // Database/KeyStore/index is not open - NotFound, // Document not found - Conflict, // Document update conflict - InvalidParameter, // Invalid function parameter or struct value - UnexpectedError, /*10*/ // Internal unexpected C++ exception - CantOpenFile, // Database file can't be opened; may not exist - IOError, // File I/O error - MemoryError, // Memory allocation failed (out of memory?) - NotWriteable, // File is not writeable - CorruptData, // Data is corrupted - Busy, // Database is busy/locked - NotInTransaction, // Function must be called while in a transaction - TransactionNotClosed, // Database can't be closed while a transaction is open - Unsupported, // Operation not supported in this database - NotADatabaseFile,/*20*/ // File is not a database, or encryption key is wrong - WrongFormat, // Database exists but not in the format/storage requested - Crypto, // Encryption/decryption error - InvalidQuery, // Invalid query - MissingIndex, // No such index, or query requires a nonexistent index - InvalidQueryParam, // Unknown query param name, or param number out of range - RemoteError, // Unknown error from remote server - DatabaseTooOld, // Database file format is older than what I can open - DatabaseTooNew, // Database file format is newer than what I can open - BadDocID, // Invalid document ID - CantUpgradeDatabase,/*30*/ // DB can't be upgraded (might be unsupported dev version) - - UntranslatableError = 1000, // Can't translate native error (unknown domain or code) - } -} - -enum_from_primitive! { - /** Fleece error codes. */ - #[derive(Debug, Copy, Clone, PartialEq)] - pub enum FleeceError { - MemoryError = 1, // Out of memory, or allocation failed - OutOfRange, // Array index or iterator out of range - InvalidData, // Bad input data (NaN, non-string key, etc.) - EncodeError, // Structural error encoding (missing value, too many ends, etc.) - JSONError, // Error parsing JSON - UnknownValue, // Unparseable data in a Value (corrupt? Or from some distant future?) - InternalError, // Something that shouldn't happen - NotFound, // Key not found - SharedKeysStateError, // Misuse of shared keys (not in transaction, etc.) - POSIXError, // Something went wrong at the OS level (file I/O, etc.) - Unsupported, // Operation is unsupported - } -} - -enum_from_primitive! { - /** Network error codes defined by Couchbase Lite. */ - #[derive(Debug, Copy, Clone, PartialEq)] - pub enum NetworkError { - DNSFailure = 1, // DNS lookup failed - UnknownHost, // DNS server doesn't know the hostname - Timeout, // No response received before timeout - InvalidURL, // Invalid URL - TooManyRedirects, // HTTP redirect loop - TLSHandshakeFailed, // Low-level error establishing TLS - TLSCertExpired, // Server's TLS certificate has expired - TLSCertUntrusted, // Cert isn't trusted for other reason - TLSClientCertRequired, // Server requires client to have a TLS certificate - TLSClientCertRejected, // Server rejected my TLS client certificate - TLSCertUnknownRoot, // Self-signed cert, or unknown anchor cert - InvalidRedirect, // Attempted redirect to invalid URL - Unknown, // Unknown networking error - TLSCertRevoked, // Server's cert has been revoked - TLSCertNameMismatch, // Server cert's name does not match DNS name - } -} - - -impl Error { - pub(crate) fn new(err: &CBLError) -> Error { - Error{code: ErrorCode::new(err), internal_info: Some(err.internal_info)} - } - - pub(crate) fn cbl_error(e: CouchbaseLiteError) -> Error { - Error{code: ErrorCode::CouchbaseLite(e), internal_info: None} - } - - pub(crate) fn fleece_error(e: FLError) -> Error { - Error{code: ErrorCode::from_fleece(e), internal_info: None} - } - - pub(crate) fn as_cbl_error(&self) -> CBLError { - let domain: CBLErrorDomain; - let code: i32; - match &self.code { - ErrorCode::CouchbaseLite(e) => {domain = CBLDomain; code = *e as i32;}, - ErrorCode::Fleece(e) => {domain = CBLFleeceDomain; code = *e as i32;}, - ErrorCode::Network(e) => {domain = CBLNetworkDomain; code = *e as i32;}, - ErrorCode::POSIX(e) => {domain = CBLPOSIXDomain; code = *e as i32;}, - ErrorCode::SQLite(e) => {domain = CBLSQLiteDomain; code = *e as i32;} - ErrorCode::WebSocket(e) => {domain = CBLWebSocketDomain; code = *e as i32;} - } - return CBLError{domain: domain, code: code, internal_info: self.internal_info.unwrap_or(0)} - } - - pub fn message(&self) -> String { - if let ErrorCode::CouchbaseLite(e) = self.code { - if e == CouchbaseLiteError::UntranslatableError { - return "Unknown error".to_string(); - } - } - unsafe { CBLError_Message_s(&self.as_cbl_error()).to_string().unwrap() } - } -} - -impl std::error::Error for Error { } -impl std::error::Error for &Error { } - -impl fmt::Debug for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> std::result::Result<(), fmt::Error> { - return fmt.write_fmt(format_args!("{:?}: {})", self.code, self.message())); - } -} - -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> std::result::Result<(), fmt::Error> { - return fmt.write_str(&self.message()); - } -} - - -impl ErrorCode { - fn new(err: &CBLError) -> ErrorCode { - match err.domain { - CBLDomain => { - if let Some(e) = CouchbaseLiteError::from_i32(err.code) { - return ErrorCode::CouchbaseLite(e) - } - } - CBLNetworkDomain => { - if let Some(e) = NetworkError::from_i32(err.code as i32) { - return ErrorCode::Network(e) - } - } - CBLPOSIXDomain => return ErrorCode::POSIX(err.code), - CBLSQLiteDomain => return ErrorCode::SQLite(err.code), - CBLFleeceDomain => return ErrorCode::from_fleece(err.code as u32), - CBLWebSocketDomain => return ErrorCode::WebSocket(err.code), - _ => { } - } - return ErrorCode::untranslatable(); - } - - fn from_fleece(fleece_error: u32) -> ErrorCode { - if let Some(e) = FleeceError::from_u32(fleece_error) { - return ErrorCode::Fleece(e) - } - return ErrorCode::untranslatable() - } - - fn untranslatable() -> ErrorCode { - ErrorCode::CouchbaseLite(CouchbaseLiteError::UntranslatableError) - } -} - - -//////// CBLERROR UTILITIES: - - -impl Default for CBLError { - fn default() -> CBLError { CBLError{domain: 0, code: 0, internal_info: 0} } -} - -impl std::ops::Not for CBLError { - type Output = bool; - fn not(self) -> bool {self.code == 0} -} - -impl std::ops::Not for &CBLError { - type Output = bool; - fn not(self) -> bool {self.code == 0} -} - - -// Convenient way to return a Result from a failed CBLError -pub(crate) fn failure(err: CBLError) -> Result { - assert!(err.code != 0); - return Err(Error::new(&err)); -} - -pub(crate) fn check_failure(status: bool, err: &CBLError) -> Result<()> { - if status { - return Ok(()); - } else { - assert!(err.code != 0); - return Err(Error::new(err)); - } -} - -pub(crate) fn check_bool(func: F) -> Result<()> - where F: Fn(*mut CBLError)->bool -{ - let mut error = CBLError::default(); - let ok = func(&mut error); - return check_failure(ok, &error); -} - -// The first parameter is a function that returns a non-null pointer or sets the error. -// The second parameter is a function that takes the returned pointer and returns the final result. -pub(crate) fn check_ptr(func: F, map: MAPF) -> Result - where F: Fn(*mut CBLError)->*mut PTR, - MAPF: FnOnce(*mut PTR) -> RESULT -{ - let mut error = CBLError::default(); - let ptr = func(&mut error); - return if ptr.is_null() {failure(error)} else {Ok(map(ptr))}; -} - -// The first parameter is a function that returns a non-null pointer or sets the error. -// The second parameter is a function that takes the returned pointer and returns the final result. -pub(crate) fn check_io(mut func: F) -> std::io::Result - where F: FnMut(*mut CBLError)->i32 -{ - let mut error = CBLError::default(); - let n = func(&mut error); - if n < 0 { - // TODO: Better error mapping! - return Err(std::io::Error::new(std::io::ErrorKind::NotFound, Error::new(&error))); - } else { - return Ok(n as usize); - } -} - - - diff --git a/bindings/rust/CouchbaseLite/src/fleece.rs b/bindings/rust/CouchbaseLite/src/fleece.rs deleted file mode 100644 index d4c9db3d..00000000 --- a/bindings/rust/CouchbaseLite/src/fleece.rs +++ /dev/null @@ -1,483 +0,0 @@ -// Fleece API bindings, for Couchbase Lite document properties -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::slice::*; -use super::error::*; -use super::c_api::*; - -use enum_primitive::FromPrimitive; -use std::fmt; -use std::marker::PhantomData; -use std::mem::MaybeUninit; -use std::ptr; -use std::str; - - -//////// CONTAINER - - -pub enum Trust { - Untrusted, - Trusted, -} - -/// Equivalent to FLDoc -pub struct Fleece { - pub(crate) _ref: FLDoc, -} - -impl Fleece { - pub fn parse(data: &[u8], trust: Trust) -> Result { - unsafe { - let mut copied = FLSlice_Copy(bytes_as_slice(data)); - let doc = FLDoc_FromResultData(copied, trust as u32, ptr::null_mut(), NULL_SLICE); - if doc.is_null() { - copied.release(); - return Err(Error::fleece_error(FLError_kFLInvalidData)); - } - return Ok(Fleece{_ref: doc}); - } - } - - pub fn parse_json(json: &str) -> Result { - unsafe { - let mut error: FLError = 0; - let doc = FLDoc_FromJSON(as_slice(json), &mut error); - if doc.is_null() { - return Err(Error::fleece_error(error)); - } - return Ok(Fleece{_ref: doc}); - } - } - - pub fn root(&self) -> Value { - unsafe { - Value::wrap(FLDoc_GetRoot(self._ref), self) - } - } - - pub fn as_array(&self) -> Array { - self.root().as_array() - } - - pub fn as_dict(&self) -> Dict { - self.root().as_dict() - } - - pub fn data<'a>(&self) -> &'a[u8] { - unsafe { - return FLDoc_GetData(self._ref).as_byte_array().unwrap(); - } - } -} - -impl Drop for Fleece { - fn drop(&mut self) { - unsafe { - FLDoc_Release(self._ref); - } - } -} - -impl Clone for Fleece { - fn clone(&self) -> Self { - unsafe { - return Fleece{_ref: FLDoc_Retain(self._ref)} - } - } -} - - -//////// VALUE - - -enum_from_primitive! { - #[derive(Debug, PartialEq)] - pub enum ValueType { - Undefined = -1, // Type of a NULL pointer, i.e. no such value, like JSON `undefined` - Null = 0, // Equivalent to a JSON 'null' - Bool, // A `true` or `false` value - Number, // A numeric value, either integer or floating-point - String, // A string - Data, // Binary data (no JSON equivalent) - Array, // An array of values - Dict // A mapping of strings to values - } -} - - -/** A trait for Value, Array and Dict. */ -pub trait FleeceReference : Default + PartialEq + Eq + std::ops::Not + fmt::Debug + fmt::Display { - fn _fleece_ref(&self) -> FLValue; // not for public consumption - - fn as_value(&self) -> Value { Value{_ref: self._fleece_ref(), _owner: PhantomData} } - - fn to_json(&self) -> String { - unsafe { FLValue_ToJSON(self._fleece_ref()).to_string().unwrap() } - } - - // Blob accessors: - - fn is_blob(&self) -> bool { - unsafe { CBL_IsBlob(FLValue_AsDict(self._fleece_ref())) } - } - - fn as_blob(&self) -> Option { - Blob::from_value(self) - } - -} - - -/** A Fleece value. It could be any type, including Undefined (empty). */ -#[derive(Clone, Copy)] -pub struct Value<'f> { - pub(crate) _ref: FLValue, - pub(crate) _owner : PhantomData<&'f Fleece> -} - - -impl<'f> Value<'f> { - pub const UNDEFINED : Value<'static> = Value{_ref: ptr::null(), _owner: PhantomData}; - - pub(crate) fn wrap<'a, T>(value: FLValue, _owner: &'a T) -> Value<'a> { - Value{_ref: value, _owner: PhantomData} - } - - pub fn get_type(&self) -> ValueType { - unsafe { return ValueType::from_i32(FLValue_GetType(self._ref)).unwrap(); } - } - pub fn is_type(&self, t: ValueType) -> bool { self.get_type() == t } - - pub fn is_number(&self) -> bool {self.is_type(ValueType::Number)} - pub fn is_integer(&self) -> bool {unsafe { FLValue_IsInteger(self._ref) } } - - pub fn as_i64(&self) -> Option {if self.is_integer() {Some(self.as_i64_or_0())} else {None} } - pub fn as_u64(&self) -> Option {if self.is_integer() {Some(self.as_u64_or_0())} else {None} } - pub fn as_f64(&self) -> Option {if self.is_number() {Some(self.as_f64_or_0())} else {None} } - pub fn as_f32(&self) -> Option {if self.is_number() {Some(self.as_f32_or_0())} else {None} } - pub fn as_bool(&self)-> Option {if self.is_type(ValueType::Bool) {Some(self.as_bool_or_false())} else {None} } - - pub fn as_i64_or_0(&self) -> i64 {unsafe { FLValue_AsInt(self._ref) } } - pub fn as_u64_or_0(&self) -> u64 {unsafe { FLValue_AsUnsigned(self._ref) } } - pub fn as_f64_or_0(&self) -> f64 {unsafe { FLValue_AsDouble(self._ref) } } - pub fn as_f32_or_0(&self) -> f32 {unsafe { FLValue_AsFloat(self._ref) } } - pub fn as_bool_or_false(&self) -> bool {unsafe { FLValue_AsBool(self._ref) } } - - pub fn as_timestamp(&self) -> Option { - unsafe { - let t = FLValue_AsTimestamp(self._ref); - if t == 0 { - return None; - } - return Some(Timestamp(t)); - } - } - - pub fn as_string(&self) -> Option<&'f str> { - unsafe { FLValue_AsString(self._ref).as_str() } - } - - pub fn as_data(&self) -> Option<&'f [u8]> { - unsafe { FLValue_AsData(self._ref).as_byte_array() } - } - - pub fn as_array(&self) -> Array<'f> { - unsafe { Array{_ref: FLValue_AsArray(self._ref), _owner: self._owner} } - } - - pub fn as_dict(&self) -> Dict<'f> { - unsafe { Dict{_ref: FLValue_AsDict(self._ref), _owner: self._owner} } - } -} - -impl<'f> FleeceReference for Value<'f> { - fn _fleece_ref(&self) -> FLValue { self._ref } -} - -impl Default for Value<'_> { - fn default() -> Value<'static> { Value::UNDEFINED } -} - -impl PartialEq for Value<'_> { - fn eq(&self, other: &Self) -> bool { - unsafe { FLValue_IsEqual(self._ref, other._ref) } - } -} - -impl Eq for Value<'_> { } - -impl std::ops::Not for Value<'_> { - type Output = bool; - fn not(self) -> bool {self._ref.is_null()} -} - -impl fmt::Debug for Value<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Value") - .field("type", &self.get_type()) - .finish() - } -} - -impl fmt::Display for Value<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - return f.write_str(&self.to_json()); - } -} - - -//////// ARRAY - - -/** A Fleece array value. */ -#[derive(Clone, Copy)] -pub struct Array<'f> { - pub(crate) _ref: FLArray, - pub(crate) _owner : PhantomData<&'f Fleece> -} - -impl<'f> Array<'f> { - pub(crate) fn wrap<'a, T>(array: FLArray, _owner: &'a T) -> Array<'a> { - Array{_ref: array, _owner: PhantomData} - } - - pub fn count(&self) -> u32 { unsafe { FLArray_Count(self._ref) }} - pub fn empty(&self) -> bool { unsafe { FLArray_IsEmpty(self._ref) }} - - pub fn get(&self, index: u32) -> Value<'f> { - unsafe { Value{_ref: FLArray_Get(self._ref, index), _owner: self._owner} } - } - - pub fn iter(&self) -> ArrayIterator<'f> { - unsafe { - let mut i = MaybeUninit::::uninit(); - FLArrayIterator_Begin(self._ref, i.as_mut_ptr()); - return ArrayIterator{_innards: i.assume_init(), _owner: self._owner}; - } - } -} - -impl<'f> FleeceReference for Array<'f> { - fn _fleece_ref(&self) -> FLValue { self._ref as FLValue } -} - -impl Default for Array<'_> { - fn default() -> Array<'static> { Array{_ref: ptr::null(), _owner: PhantomData} } -} - -impl PartialEq for Array<'_> { - fn eq(&self, other: &Self) -> bool { self.as_value() == other.as_value() } -} - -impl Eq for Array<'_> { } - -impl std::ops::Not for Array<'_> { - type Output = bool; - fn not(self) -> bool {self._ref.is_null()} -} - -impl fmt::Debug for Array<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Array") - .field("count", &self.count()) - .finish() - } -} - -impl fmt::Display for Array<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - return f.write_str(&self.as_value().to_json()); - } -} - -impl<'a> IntoIterator for Array<'a> { - type Item = Value<'a>; - type IntoIter = ArrayIterator<'a>; - fn into_iter(self) -> Self::IntoIter { self.iter() } -} - -// This doesn't work because it requires the return value be a ref! -// impl std::ops::Index for Array { -// type Output = Value; -// fn index(&self, index: usize) -> Value { self.get(index) } -// } - - -//////// ARRAY ITERATOR - - -pub struct ArrayIterator<'a> { - _innards : FLArrayIterator, - _owner : PhantomData<&'a Fleece> -} - -impl<'a> ArrayIterator<'a> { - pub fn count(&self) -> u32 { - unsafe { FLArrayIterator_GetCount(&self._innards) } - } - - pub fn get(&self, index: usize) -> Value { - unsafe { - Value::wrap(FLArrayIterator_GetValueAt(&self._innards, index as u32), self) - } - } -} - -impl<'f> Iterator for ArrayIterator<'f> { - type Item = Value<'f>; - - fn next(&mut self) -> Option> { - unsafe { - let val = FLArrayIterator_GetValue(&self._innards); - if val.is_null() { - return None; - } - FLArrayIterator_Next(&mut self._innards); - return Some(Value{_ref: val, _owner: PhantomData}); - } - } -} -//TODO: Implement FusedIterator, ExactSizeIterator, FromIterator - - -//////// DICT - - -/** A Fleece dictionary (object) value. */ -#[derive(Clone, Copy)] -pub struct Dict<'f> { - pub(crate) _ref: FLDict, - pub(crate) _owner : PhantomData<&'f Fleece> -} - -impl<'f> Dict<'f> { - pub(crate) fn wrap<'a, T>(dict: FLDict, _owner: &'a T) -> Dict<'a> { Dict{_ref: dict, _owner: PhantomData} } - - pub fn as_value(&self) -> Value<'f> { Value{_ref: self._ref as FLValue, _owner: self._owner} } - - pub fn count(&self) -> u32 { unsafe { FLDict_Count(self._ref) }} - pub fn empty(&self) -> bool { unsafe { FLDict_IsEmpty(self._ref) }} - - pub fn get(&self, key: &str) -> Value<'f> { - unsafe { Value{_ref: FLDict_Get(self._ref, as_slice(key)), _owner: self._owner} } - } - - pub fn get_key(&self, key: &mut DictKey) -> Value<'f> { - unsafe { Value{_ref: FLDict_GetWithKey(self._ref, &mut key._innards), _owner: self._owner} } - } - - pub fn iter(&self) -> DictIterator<'f> { - unsafe { - let mut i = MaybeUninit::::uninit(); - FLDictIterator_Begin(self._ref, i.as_mut_ptr()); - return DictIterator{_innards: i.assume_init(), _owner: self._owner}; - } - } -} - -impl<'f> FleeceReference for Dict<'f> { - fn _fleece_ref(&self) -> FLValue { self._ref as FLValue } -} - -impl Default for Dict<'_> { - fn default() -> Dict<'static> { Dict{_ref: ptr::null(), _owner: PhantomData} } -} - -impl PartialEq for Dict<'_> { - fn eq(&self, other: &Self) -> bool { self.as_value() == other.as_value() } -} - -impl Eq for Dict<'_> { } - -impl std::ops::Not for Dict<'_> { - type Output = bool; - fn not(self) -> bool {self._ref.is_null()} -} - -impl fmt::Debug for Dict<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Dict") - .field("count", &self.count()) - .finish() - } -} - -impl fmt::Display for Dict<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - return f.write_str(&self.as_value().to_json()); - } -} - -impl<'a> IntoIterator for Dict<'a> { - type Item = (&'a str, Value<'a>); - type IntoIter = DictIterator<'a>; - fn into_iter(self) -> Self::IntoIter { self.iter() } -} - - -//////// DICT KEY - - -pub struct DictKey { - pub(crate) _innards: FLDictKey -} - -impl DictKey { - pub fn new(key: &str) -> DictKey { - unsafe { - return DictKey{_innards: FLDictKey_Init(as_slice(key))}; - } - } - - pub fn string(&self) -> &str { - unsafe { FLDictKey_GetString(&self._innards).as_str().unwrap() } - } -} - - -//////// DICT ITERATOR - - -pub struct DictIterator<'a> { - _innards : FLDictIterator, - _owner : PhantomData<&'a Fleece> -} - -impl<'a> DictIterator<'a> { - pub fn count(&self) -> u32 { - unsafe { FLDictIterator_GetCount(&self._innards) } - } -} - -impl<'a> Iterator for DictIterator<'a> { - type Item = (&'a str, Value<'a>); - - fn next(&mut self) -> Option { - unsafe { - let val = FLDictIterator_GetValue(&self._innards); - if val.is_null() { - return None; - } - let key = FLDictIterator_GetKeyString(&self._innards).as_str().unwrap(); - FLDictIterator_Next(&mut self._innards); - return Some( (key, Value{_ref: val, _owner: PhantomData}) ); - } - } -} -//TODO: Implement FusedIterator, ExactSizeIterator, FromIterator diff --git a/bindings/rust/CouchbaseLite/src/fleece_mutable.rs b/bindings/rust/CouchbaseLite/src/fleece_mutable.rs deleted file mode 100644 index 05831fe1..00000000 --- a/bindings/rust/CouchbaseLite/src/fleece_mutable.rs +++ /dev/null @@ -1,316 +0,0 @@ -// Fleece mutable-object API bindings, for Couchbase Lite document properties -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::slice::*; -use super::c_api::*; -use super::fleece::*; - -use std::fmt; -use std::marker::PhantomData; -use std::ptr; - - - -pub enum CopyFlags { - Default = 0, // Shallow copy of mutable values - Deep = 1, // Deep copy of mutable values - CopyImmutables = 2, // Make copies of immutable values too - DeepCopyImmutables = 3, // The works -} - - -//////// MUTABLE ARRAY: - - -pub struct MutableArray { - pub(crate) _ref: FLMutableArray, -} - -impl MutableArray { - pub fn new() -> MutableArray { - unsafe { MutableArray{_ref: FLMutableArray_New()} } - } - - pub fn from_array(array: &Array) -> MutableArray { - MutableArray::from_array_(array, CopyFlags::Default) - } - - pub fn from_array_(array: &Array, flags: CopyFlags) -> MutableArray { - unsafe { MutableArray{_ref: FLArray_MutableCopy(array._ref, flags as u32)} } - } - - pub(crate) unsafe fn adopt(array: FLMutableArray) -> MutableArray { - FLValue_Retain(array as FLValue); - return MutableArray{_ref: array}; - } - - pub fn is_changed(&self) -> bool { - unsafe { FLMutableArray_IsChanged(self._ref) } - } - - pub fn at<'s>(&'s mut self, index: u32) -> Slot<'s> { - unsafe { Slot{_ref: FLMutableArray_Set(self._ref, index), _owner: PhantomData} } - } - - pub fn append<'s>(&'s mut self) -> Slot<'s> { - unsafe { Slot{_ref: FLMutableArray_Append(self._ref), _owner: PhantomData} } - } - - pub fn insert<'s>(&'s mut self, index: u32) { - unsafe { FLMutableArray_Insert(self._ref, index, 1) } - } - - pub fn remove(&mut self, index: u32) { - unsafe { FLMutableArray_Remove(self._ref, index, 1) } - } - - pub fn remove_all(&mut self) { - unsafe { FLMutableArray_Remove(self._ref, 0, self.count()) } - } -} - -// "Inherited" API: -impl MutableArray { - pub fn as_array(&self) -> Array { Array::wrap(self._ref, self) } - pub fn count(&self) -> u32 { self.as_array().count() } - pub fn empty(&self) -> bool { self.as_array().empty() } - pub fn get(&self, index: u32) -> Value { self.as_array().get(index) } - pub fn iter(&self) -> ArrayIterator { self.as_array().iter() } -} - -impl FleeceReference for MutableArray { - fn _fleece_ref(&self) -> FLValue { self._ref as FLValue } -} - -impl Clone for MutableArray{ - fn clone(&self) -> Self { - unsafe{ return MutableArray{_ref: FLValue_Retain(self._ref as FLValue) as FLMutableArray} } - } -} - -impl Drop for MutableArray { - fn drop(&mut self) { - unsafe{ FLValue_Release(self._ref as FLValue); } - } -} - -impl Default for MutableArray { - fn default() -> MutableArray { MutableArray{_ref: ptr::null_mut()} } -} - -impl PartialEq for MutableArray { - fn eq(&self, other: &Self) -> bool { self.as_value() == other.as_value() } -} - -impl Eq for MutableArray { } - -impl std::ops::Not for MutableArray { - type Output = bool; - fn not(self) -> bool {self._ref.is_null()} -} - -impl fmt::Debug for MutableArray { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("MutableArray") - .field("count", &self.count()) - .finish() - } -} - -impl fmt::Display for MutableArray { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - return f.write_str(&self.as_value().to_json()); - } -} - -impl<'a> IntoIterator for &'a MutableArray { - type Item = Value<'a>; - type IntoIter = ArrayIterator<'a>; - fn into_iter(self) -> Self::IntoIter { self.iter() } -} - - -// Mutable API additions for Array: -impl<'d> Array<'d> { - pub fn as_mutable(self) -> Option { - unsafe { - let md = FLArray_AsMutable(self._ref); - return if md.is_null() { None } else { Some(MutableArray::adopt(md)) }; - } - } - - pub fn mutable_copy(&self) -> MutableArray { - MutableArray::from_array(self) - } -} - - -//////// MUTABLE DICT: - - -pub struct MutableDict { - pub(crate) _ref: FLMutableDict, -} - -impl MutableDict { - pub fn new() -> MutableDict { - unsafe { MutableDict{_ref: FLMutableDict_New()} } - } - - pub fn from_dict(dict: &Dict) -> MutableDict { - MutableDict::from_dict_(dict, CopyFlags::Default) - } - - pub fn from_dict_(dict: &Dict, flags: CopyFlags) -> MutableDict { - unsafe { MutableDict{_ref: FLDict_MutableCopy(dict._ref, flags as u32)} } - } - - pub(crate) unsafe fn adopt(dict: FLMutableDict) -> MutableDict { - FLValue_Retain(dict as FLValue); - return MutableDict{_ref: dict}; - } - - pub fn is_changed(&self) -> bool { - unsafe { FLMutableDict_IsChanged(self._ref) } - } - - pub fn at<'s>(&'s mut self, key: &str) -> Slot<'s> { - unsafe { Slot{_ref: FLMutableDict_Set(self._ref, as_slice(key)), _owner: PhantomData} } - } - - pub fn remove(&mut self, key: &str) { - unsafe { FLMutableDict_Remove(self._ref, as_slice(key)) } - } - - pub fn remove_all(&mut self) { - unsafe { FLMutableDict_RemoveAll(self._ref) } - } -} - -// "Inherited" API: -impl MutableDict { - pub fn as_dict(&self) -> Dict { Dict::wrap(self._ref, self) } - pub fn count(&self) -> u32 { self.as_dict().count() } - pub fn empty(&self) -> bool { self.as_dict().empty() } - pub fn get(&self, key: &str) -> Value { self.as_dict().get(key) } - pub fn get_key(&self, key: &mut DictKey) -> Value { self.as_dict().get_key(key) } - pub fn iter(&self) -> DictIterator { self.as_dict().iter() } -} - -impl FleeceReference for MutableDict { - fn _fleece_ref(&self) -> FLValue { self._ref as FLValue } -} - -impl Clone for MutableDict{ - fn clone(&self) -> Self { - unsafe{ return MutableDict{_ref: FLValue_Retain(self._ref as FLValue) as FLMutableDict} } - } -} - -impl Drop for MutableDict { - fn drop(&mut self) { - unsafe{ FLValue_Release(self._ref as FLValue); } - } -} - -impl Default for MutableDict { - fn default() -> MutableDict { MutableDict{_ref: ptr::null_mut()} } -} - -impl PartialEq for MutableDict { - fn eq(&self, other: &Self) -> bool { self.as_value() == other.as_value() } -} - -impl Eq for MutableDict { } - -impl std::ops::Not for MutableDict { - type Output = bool; - fn not(self) -> bool {self._ref.is_null()} -} - -impl fmt::Debug for MutableDict { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("MutableDict") - .field("count", &self.count()) - .finish() - } -} - -impl fmt::Display for MutableDict { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - return f.write_str(&self.as_value().to_json()); - } -} - -impl<'a> IntoIterator for &'a MutableDict { - type Item = (&'a str, Value<'a>); - type IntoIter = DictIterator<'a>; - fn into_iter(self) -> Self::IntoIter { self.iter() } -} - - -// Mutable API for Dict: -impl<'d> Dict<'d> { - pub fn as_mutable(self) -> Option { - unsafe { - let md = FLDict_AsMutable(self._ref); - return if md.is_null() { None } else { Some(MutableDict::adopt(md)) }; - } - } - - pub fn mutable_copy(&self) -> MutableDict { - MutableDict::from_dict(self) - } -} - - -//////// SLOT: - - -/** A reference to an element of a MutableArray or MutableDict, - for the sole purpose of storing a value in it. */ -pub struct Slot<'s> { - pub(crate) _ref: FLSlot, - _owner: PhantomData<&'s mut MutableDict> -} - -impl<'s> Slot<'s> { - pub fn put_null(self) { unsafe { FLSlot_SetNull(self._ref) } } - - pub fn put_bool(self, value: bool) { unsafe { FLSlot_SetBool(self._ref, value) } } - - pub fn put_i64>(self, value: INT) { - unsafe { FLSlot_SetInt(self._ref, value.into()) } - } - - pub fn put_f64>(self, value: F) { - unsafe { FLSlot_SetDouble(self._ref, value.into()) } - } - - pub fn put_string>(self, value: STR) { - unsafe { FLSlot_SetString(self._ref, as_slice(value.as_ref())) } - } - - pub fn put_data>(self, value: DATA) { - unsafe { FLSlot_SetString(self._ref, bytes_as_slice(value.as_ref())) } - } - - pub fn put_value(self, value: &VALUE) { - unsafe { FLSlot_SetValue(self._ref, value._fleece_ref()) } - } -} diff --git a/bindings/rust/CouchbaseLite/src/fleece_tests.rs b/bindings/rust/CouchbaseLite/src/fleece_tests.rs deleted file mode 100644 index bd998bd8..00000000 --- a/bindings/rust/CouchbaseLite/src/fleece_tests.rs +++ /dev/null @@ -1,128 +0,0 @@ -// Unit tests for Fleece -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -#![cfg(test)] - -use crate::fleece::*; -use crate::fleece_mutable::*; - -#[test] -fn empty_values() { - let v = Value::default(); - assert_eq!(v.get_type(), ValueType::Undefined); - assert!(!v.is_type(ValueType::Bool)); - assert!(!v.is_number()); - assert!(!v.is_integer()); - assert_eq!(v.as_i64(), None); - assert!(!v.as_array()); - assert!(!v.as_dict()); - assert!(!v); - assert_eq!(v, Value::UNDEFINED); - assert!(v == v); -} - -#[test] -fn basic_values() { - let doc = Fleece::parse_json(r#"{"i":1234,"f":12.34,"a":[1, 2],"s":"Foo"}"#).unwrap(); - let dict = doc.as_dict(); - assert_eq!(dict.count(), 4); - - let i = dict.get("i"); - assert!(i.is_number()); - assert!(i.is_integer()); - assert_eq!(i.as_i64(), Some(1234)); - assert_eq!(i.as_i64_or_0(), 1234); - assert_eq!(i.as_f64(), Some(1234.0)); - assert_eq!(i.as_string(), None); - - let f = dict.get("f"); - assert!(f.is_number()); - assert!(!f.is_integer()); - assert_eq!(f.as_i64(), None); - assert_eq!(f.as_i64_or_0(), 12); - assert_eq!(f.as_f64(), Some(12.34)); - assert_eq!(f.as_string(), None); - - assert_eq!(dict.get("j"), Value::UNDEFINED); - - assert_eq!(dict.get("s").as_string(), Some("Foo")); - - let a = dict.get("a").as_array(); - assert!(a); - assert_eq!(a, a); - assert_eq!(a.count(), 2); - assert_eq!(a.get(0).as_i64(), Some(1)); - assert_eq!(a.get(1).as_i64(), Some(2)); - assert_eq!(a.get(2).as_i64(), None); - - assert_eq!(doc.root().to_json(), r#"{"a":[1,2],"f":12.34,"i":1234,"s":"Foo"}"#); - assert_eq!(format!("{}", doc.root()), r#"{"a":[1,2],"f":12.34,"i":1234,"s":"Foo"}"#); -} - -#[test] -fn nested_borrow_check() { - let v : Value; - let str : &str; - - let doc = Fleece::parse_json(r#"{"i":1234,"f":12.34,"a":[1, 2],"s":"Foo"}"#).unwrap(); - { - let dict = doc.as_dict(); - v = dict.get("a"); - str = dict.get("s").as_string().unwrap(); -} - // It's OK that `dict` has gone out of scope, because `v`s scope is `doc`, not `dict`. - println!("v = {:?}", v); - println!("str = {}", str); -} - -/* -// This test doesn't and shouldn't compile -- it tests that the borrow-checker will correctly -// prevent Fleece data from being used after its document has been freed. -#[test] -fn borrow_check() { - let v : Value; - let str : &str; - { - let doc = Fleece::parse_json(r#"{"i":1234,"f":12.34,"a":[1, 2],"s":"Foo"}"#).unwrap(); - let dict = doc.as_dict(); - v = dict.get("a"); - str = dict.get("s").as_string().unwrap(); - } - println!("v = {:?}", v); - println!("str = {}", str); -} -*/ - -#[test] -fn mutable_dict() { - let mut dict = MutableDict::new(); - assert_eq!(dict.count(), 0); - assert_eq!(dict.get("a"), Value::UNDEFINED); - - dict.at("i").put_i64(1234); - dict.at("s").put_string("Hello World!"); - - assert_eq!(format!("{}", dict), r#"{"i":1234,"s":"Hello World!"}"#); - - assert_eq!(dict.count(), 2); - assert_eq!(dict.get("i").as_i64(), Some(1234)); - assert_eq!(dict.get("s").as_string(), Some("Hello World!")); - assert!(!dict.get("?")); - - dict.remove("i"); - assert!(!dict.get("i")); -} diff --git a/bindings/rust/CouchbaseLite/src/lib.rs b/bindings/rust/CouchbaseLite/src/lib.rs deleted file mode 100644 index 61b9e552..00000000 --- a/bindings/rust/CouchbaseLite/src/lib.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Couchbase Lite main module -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -//#![allow(unused_imports)] -//#![allow(dead_code)] - -#[macro_use] extern crate enum_primitive; - -pub mod blob; -pub mod database; -pub mod document; -pub mod error; -pub mod fleece; -pub mod fleece_mutable; -pub mod logging; -pub mod query; -pub mod replicator; - -mod slice; -mod c_api; - -mod fleece_tests; - -use self::c_api::*; - - -//////// RE-EXPORT: - - -pub use blob::*; -pub use database::*; -pub use document::*; -pub use error::*; -pub use fleece::*; -pub use fleece_mutable::*; -pub use query::*; -pub use replicator::*; - - -//////// TOP-LEVEL TYPES: - - -/// A time value for document expiration. Defined as milliseconds since the Unix epoch (1/1/1970.) -pub struct Timestamp(i64); - - -/// An opaque token representing a registered listener. -/// When this object is dropped, the listener function will not be called again. -pub struct ListenerToken { - _ref: *mut CBLListenerToken -} - - -impl Drop for ListenerToken { - fn drop(&mut self) { - unsafe { CBLListener_Remove(self._ref) } - } -} - - -//////// MISC. API FUNCTIONS - - -/** Returns the total number of Couchbase Lite objects. Useful for leak checking. */ -pub fn instance_count() -> usize { - unsafe { return CBL_InstanceCount() as usize } -} - -/** Logs the class and address of each Couchbase Lite object. Useful for leak checking. - @note May only be functional in debug builds of Couchbase Lite. */ -pub fn dump_instances() { - unsafe { CBL_DumpInstances() } -} - - -//////// REFCOUNT SUPPORT (INTERNAL) - - -pub(crate) unsafe fn retain(cbl_ref: *mut T) -> *mut T { - return CBL_Retain(cbl_ref as *mut CBLRefCounted) as *mut T -} - -pub(crate) unsafe fn release(cbl_ref: *mut T) { - CBL_Release(cbl_ref as *mut CBLRefCounted) -} diff --git a/bindings/rust/CouchbaseLite/src/logging.rs b/bindings/rust/CouchbaseLite/src/logging.rs deleted file mode 100644 index f1939486..00000000 --- a/bindings/rust/CouchbaseLite/src/logging.rs +++ /dev/null @@ -1,159 +0,0 @@ -// Couchbase Lite logging API -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::slice::*; -use super::c_api::*; - -use enum_primitive::FromPrimitive; -use std::fmt; - - -enum_from_primitive! { - /** Logging domains: subsystems that generate log messages. */ - #[derive(Debug, Clone, Copy, PartialEq)] - pub enum Domain { - All, - Database, - Query, - Replicator, - Network - } -} - -enum_from_primitive! { - /** Levels of log messages. Higher values are more important/severe. - Each level includes the lower ones. */ - #[derive(Debug, Clone, Copy, PartialEq)] - pub enum Level { - Debug, - Verbose, - Info, - Warning, - Error, - None - } -} - - -pub type LogCallback = Option; - - -/** Sets the detail level of logging. - Only messages whose level is ≥ the given level will be logged to the console or callback. */ -pub fn set_level(level: Level, domain: Domain) { - unsafe { CBLLog_SetConsoleLevelOfDomain(domain as u8, level as u8) } -} - -/** Registers a function that will receive log messages. After this is called, messages will no - longer be written to stderr, but will be passed to this callback instead. */ -pub fn set_callback(callback: LogCallback) { - unsafe { - LOG_CALLBACK = callback; - if callback.is_some() { - CBLLog_SetCallback(Some(invoke_log_callback)); - } else { - CBLLog_SetCallback(None); - } - } -} - -/** Writes a log message. */ -pub fn write(domain: Domain, level: Level, message: &str) { - unsafe { - CBL_Log_s(domain as u8, level as u8, as_slice(message)); - - // CBL_Log doesn't invoke the callback, so do it manually: - if let Some(callback) = LOG_CALLBACK { - if CBLLog_WillLogToConsole(domain as u8, level as u8) { - callback(domain, level, message); - } - } - } -} - -/** Writes a log message using the given format arguments. */ -pub fn write_args(domain: Domain, level: Level, args: fmt::Arguments) { - unsafe { - if CBLLog_WillLogToConsole(domain as u8, level as u8) { - write(domain, level, &format!("{:?}", args)); - } - } -} - - -//////// LOGGING MACROS: - - -/// A macro that writes a formatted Error-level log message. -#[macro_export] -macro_rules! error { - ($($arg:tt)*) => ($crate::logging::write_args( - $crate::logging::Domain::All, $crate::logging::Level::Error, - format_args!($($arg)*))); -} - -/// A macro that writes a formatted Warning-level log message. -#[macro_export] -macro_rules! warn { - ($($arg:tt)*) => ($crate::logging::write_args( - $crate::logging::Domain::All, $crate::logging::Level::Warning, - format_args!($($arg)*))); -} - -/// A macro that writes a formatted Info-level log message. -#[macro_export] -macro_rules! info { - ($($arg:tt)*) => ($crate::logging::write_args( - $crate::logging::Domain::All, $crate::logging::Level::Info, - format_args!($($arg)*))); -} - -/// A macro that writes a formatted Verbose-level log message. -#[macro_export] -macro_rules! verbose { - ($($arg:tt)*) => ($crate::logging::write_args( - $crate::logging::Domain::All, $crate::logging::Level::Verbose, - format_args!($($arg)*))); -} - -/// A macro that writes a formatted Debug-level log message. -#[macro_export] -macro_rules! debug { - ($($arg:tt)*) => ($crate::logging::write_args( - $crate::logging::Domain::All, $crate::logging::Level::Debug, - format_args!($($arg)*))); -} - - -//////// INTERNALS: - - -static mut LOG_CALLBACK : LogCallback = Some(default_callback); - -fn default_callback(_domain: Domain, _level: Level, msg: &str) { - println!("CBL: {}", msg); -} - -unsafe extern "C" fn invoke_log_callback(c_domain: CBLLogDomain, c_level: CBLLogLevel, - msg: *const ::std::os::raw::c_char) -{ - let domain = Domain::from_u8(c_domain).unwrap(); - let level = Level::from_u8(c_level).unwrap(); - if let Some(cb) = LOG_CALLBACK { - cb(domain, level, &to_str(msg)); - } -} diff --git a/bindings/rust/CouchbaseLite/src/main.rs b/bindings/rust/CouchbaseLite/src/main.rs deleted file mode 100644 index 41221e07..00000000 --- a/bindings/rust/CouchbaseLite/src/main.rs +++ /dev/null @@ -1,47 +0,0 @@ -// A very simple program using Couchbase Lite -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -extern crate couchbase_lite; -extern crate tempdir; - -use couchbase_lite::*; -use tempdir::TempDir; - - -fn main() { - // Create a new database in a temporary directory: - let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir"); - let cfg = DatabaseConfiguration{directory: tmp_dir.path(), flags: CREATE}; - let mut db = Database::open("main_db", Some(cfg)).expect("open db"); - - // Create and save a new document: - { - //logging::set_level(logging::Level::Info, logging::Domain::All); - let mut doc = Document::new_with_id("foo"); - let mut props = doc.mutable_properties(); - props.at("i").put_i64(1234); - props.at("s").put_string("Hello World!"); - - db.save_document(&mut doc, ConcurrencyControl::FailOnConflict).expect("save"); - } - // Reload the document and verify its properties: - { - let doc = db.get_document("foo").expect("reload document"); - let props = doc.properties(); - assert_eq!(props.to_json(), r#"{"i":1234,"s":"Hello World!"}"#); - } -} diff --git a/bindings/rust/CouchbaseLite/src/query.rs b/bindings/rust/CouchbaseLite/src/query.rs deleted file mode 100644 index 56f87cd5..00000000 --- a/bindings/rust/CouchbaseLite/src/query.rs +++ /dev/null @@ -1,212 +0,0 @@ -// Couchbase Lite query API -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::slice::*; -use super::c_api::*; - -use std::marker::PhantomData; -use std::os::raw::c_uint; - - -/** Query languages. */ -pub enum QueryLanguage { - JSON, // JSON query schema: github.com/couchbase/couchbase-lite-core/wiki/JSON-Query-Schema - N1QL, // N1QL syntax: docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/index.html -} - - -/** A compiled database query. */ -pub struct Query { - _ref: *mut CBLQuery -} - -impl Query { - /** Creates a new query by compiling the input string. - This is fast, but not instantaneous. If you need to run the same query many times, keep the - `Query` around instead of compiling it each time. If you need to run related queries - with only some values different, create one query with placeholder parameter(s), and substitute - the desired value(s) with `set_parameters` before each time you run the query. */ - pub fn new(db: &Database, language: QueryLanguage, str: &str) -> Result { - unsafe { - let mut pos: i32 = 0; - let mut err = CBLError::default(); - let q = CBLQuery_New_s(db._ref, language as CBLQueryLanguage, as_slice(str), - &mut pos, &mut err); - if q.is_null() { - // TODO: Return the error pos somehow - return failure(err); - } - return Ok(Query{_ref: q}); - } - } - - /** Assigns values to the query's parameters. - These values will be substited for those parameters whenever the query is executed, - until they are next assigned. - - Parameters are specified in the query source as - e.g. `$PARAM` (N1QL) or `["$PARAM"]` (JSON). In this example, the `parameters` dictionary - to this call should have a key `PARAM` that maps to the value of the parameter. */ - pub fn set_parameters(&self, parameters: MutableDict) { - unsafe { - CBLQuery_SetParameters(self._ref, parameters._ref); - } - } - - /** Returns the query's current parameter bindings, if any. */ - pub fn parameters(&self) -> Dict { - unsafe { return Dict{_ref: CBLQuery_Parameters(self._ref), _owner: PhantomData}; } - } - - /** Assigns values to the query's parameters, from JSON data. - See `set_parameters` for details. */ - pub fn set_parameters_json(&self, json: &str) { - unsafe { CBLQuery_SetParametersAsJSON_s(self._ref, as_slice(json)); } - } - - /** Returns information about the query, including the translated SQLite form, and the search - strategy. You can use this to help optimize the query: the word `SCAN` in the strategy - indicates a linear scan of the entire database, which should be avoided by adding an index. - The strategy will also show which index(es), if any, are used. */ - pub fn explain(&self) -> String { - unsafe { CBLQuery_Explain(self._ref).to_string().unwrap() } - } - - /** Runs the query, returning the results as a `ResultSet` object, which is an iterator - of `Row` objects, each of which has column values. */ - pub fn execute(&self) -> Result { - unsafe { - let mut err = CBLError::default(); - let r = CBLQuery_Execute(self._ref, &mut err); - if r.is_null() { - return failure(err); - } - return Ok(ResultSet{_ref: r}); - } - } - - /** Returns the number of columns in each result. - This comes directly from the number of "SELECT..." values in the query string. */ - pub fn column_count(&self) -> usize { - unsafe { CBLQuery_ColumnCount(self._ref) as usize } - } - - /** Returns the name of a column in the result. - The column name is based on its expression in the `SELECT...` or `WHAT:` section of the - query. A column that returns a property or property path will be named after that property. - A column that returns an expression will have an automatically-generated name like `$1`. - To give a column a custom name, use the `AS` syntax in the query. - Every column is guaranteed to have a unique name. */ - pub fn column_name(&self, col: usize) -> Option<&str> { - unsafe { CBLQuery_ColumnName(self._ref, col as u32).as_str() } - } - - /** Returns the column names as a Vec. */ - pub fn column_names(&self) -> Vec<&str> { - (0..self.column_count()).map(|i| self.column_name(i).unwrap()).collect() - } -} - -impl Drop for Query { - fn drop(&mut self) { - unsafe { release(self._ref); } - } -} - -impl Clone for Query { - fn clone(&self) -> Self { - unsafe { Query{_ref: retain(self._ref)} } - } -} - - -//////// RESULT SET: - - -/** An iterator over the rows resulting from running a query. */ -pub struct ResultSet { - _ref: *mut CBLResultSet -} - -impl<'r> Iterator for &'r ResultSet { - type Item = Row<'r>; - - fn next(&mut self) -> Option> { - unsafe { - if !CBLResultSet_Next(self._ref) { - return None; - } - return Some(Row{results: &self}) - } - } -} - -impl Drop for ResultSet { - fn drop(&mut self) { - unsafe { release(self._ref); } - } -} - - -//////// ROW: - - -/** A single result row from a Query. */ -pub struct Row<'r> { - results: &'r ResultSet -} - -impl<'r> Row<'r> { - /** Returns the value of a column, given its (zero-based) index. */ - pub fn get(&self, index: isize) -> Value<'r> { - unsafe { Value{_ref: CBLResultSet_ValueAtIndex(self.results._ref, index as c_uint), - _owner: PhantomData} } - } - - /** Returns the value of a column, given its name. */ - pub fn get_key(&self, key: &str) -> Value<'r> { - unsafe { Value{_ref: CBLResultSet_ValueForKey_s(self.results._ref, as_slice(key)), - _owner: PhantomData} } - } - - /** Returns the number of columns. (This is the same as `Query`::column_count.) */ - pub fn column_count(&self) -> isize { - unsafe { - let query = CBLResultSet_GetQuery(self.results._ref); - return CBLQuery_ColumnCount(query) as isize; - } - } - - /** Returns the name of a column. */ - pub fn column_name(&self, col: isize) -> Option<&str> { - unsafe { - let query = CBLResultSet_GetQuery(self.results._ref); - return CBLQuery_ColumnName(query, col as c_uint).as_str(); - } - } - - /** Returns all of the columns as a Fleece array. */ - pub fn as_array(&self) -> Array { - unsafe { Array{_ref: CBLResultSet_RowArray(self.results._ref), _owner: PhantomData} } - } - - /** Returns all of the columns as a Fleece dictionary. */ - pub fn as_dict(&self) -> Dict { - unsafe { Dict{_ref: CBLResultSet_RowDict(self.results._ref), _owner: PhantomData} } - } -} diff --git a/bindings/rust/CouchbaseLite/src/replicator.rs b/bindings/rust/CouchbaseLite/src/replicator.rs deleted file mode 100644 index 5dd85033..00000000 --- a/bindings/rust/CouchbaseLite/src/replicator.rs +++ /dev/null @@ -1,242 +0,0 @@ -// Couchbase Lite replicator API -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::*; -use super::c_api::*; - -use std::collections::HashMap; -use std::collections::HashSet; - - -// WARNING: THIS API IS UNIMPLEMENTED SO FAR - - -//======== CONFIGURATION - - -/** Represents the location of a database to replicate with. */ -pub enum Endpoint<'e> { - WithURL (String), - WithLocalDB (&'e Database) -} - - -pub enum Authenticator<'a> { - None, - Basic {username: &'a str, password: &'a str}, - Session {session_id: &'a str}, - Cookie {name: &'a str, value: &'a str} -} - - -/** Direction of replication: push, pull, or both. */ -#[derive(Debug)] -pub enum ReplicatorType { PushAndPull, Push, Pull } - - -/** Types of proxy servers, for CBLProxySettings. */ -#[derive(Debug)] -pub enum ProxyType { HTTP, HTTPS } - -/** Proxy settings for the replicator. */ -pub struct ProxySettings<'p> { - pub proxy_type: ProxyType, // Type of proxy - pub hostname: &'p str, // Proxy server hostname or IP address - pub port: u16, // Proxy server port - pub username: Option<&'p str>, // Username for proxy auth - pub password: Option<&'p str> // Password for proxy auth -} - - -/** A callback that can decide whether a particular document should be pushed or pulled. */ -pub type ReplicationFilter = fn(document: &Document, - is_deleted: bool) -> bool; - -/** Conflict-resolution callback for use in replications. This callback will be invoked - when the replicator finds a newer server-side revision of a document that also has local - changes. The local and remote changes must be resolved before the document can be pushed - to the server. */ -pub type ConflictResolver = fn(document_id: &str, - local_document: Option, - remote_document: Option) -> Document; - - -/** The configuration of a replicator. */ -pub struct ReplicatorConfiguration<'c> { - pub database: &'c Database, // The database to replicate - pub endpoint: Endpoint<'c>, // The address of the other database to replicate with - pub replicator_type: ReplicatorType, // Push, pull or both - pub continuous: bool, // Continuous replication? - pub authenticator: Authenticator<'c>, // Authentication credentials, if needed - pub proxy: Option>, // HTTP client proxy settings - pub headers: Option>, // Extra HTTP headers to add to the WebSocket request - pub pinned_server_certificate: Option>, // An X.509 cert to "pin" TLS connections to (PEM or DER) - pub trusted_root_certificates: Option>, // Set of anchor certs (PEM format) - pub channels: Option>, // Optional set of channels to pull from - pub document_ids: Option>, // Optional set of document IDs to replicate - pub push_filter: ReplicationFilter, // Optional callback to filter which docs are pushed - pub pull_filter: ReplicationFilter, // Optional callback to validate incoming docs - pub conflict_resolver: ConflictResolver, // Optional conflict-resolver callback -} - - -//======== LIFECYCLE - -/** A background task that syncs a \ref Database with a remote server or peer. */ -pub struct Replicator { - _ref: *mut CBLReplicator -} - -impl Replicator { - /** Creates a replicator with the given configuration. */ - pub fn new(_config: ReplicatorConfiguration) -> Result { - todo!() - } - - /** Returns the configuration of an existing replicator. */ - pub fn config(&self) -> ReplicatorConfiguration { - todo!() - } - - /** Instructs the replicator to ignore existing checkpoints the next time it runs. - This will cause it to scan through all the documents on the remote database, which takes - a lot longer, but it can resolve problems with missing documents if the client and - server have gotten out of sync somehow. */ - pub fn reset_checkpoint(&mut self) { - todo!() - } - - /** Starts a replicator, asynchronously. Does nothing if it's already started. */ - pub fn start(&mut self) { - todo!() - } - - /** Stops a running replicator, asynchronously. Does nothing if it's not already started. - The replicator will call your \ref CBLReplicatorChangeListener with an activity level of - \ref kCBLReplicatorStopped after it stops. Until then, consider it still active. */ - pub fn stop(&mut self) { - todo!() - } - - /** Informs the replicator whether it's considered possible to reach the remote host with - the current network configuration. The default value is true. This only affects the - replicator's behavior while it's in the Offline state: - * Setting it to false will cancel any pending retry and prevent future automatic retries. - * Setting it back to true will initiate an immediate retry.*/ - pub fn set_host_reachable(&mut self, _reachable: bool) { - todo!() - } - - /** Puts the replicator in or out of "suspended" state. The default is false. - * Setting suspended=true causes the replicator to disconnect and enter Offline state; - it will not attempt to reconnect while it's suspended. - * Setting suspended=false causes the replicator to attempt to reconnect, _if_ it was - connected when suspended, and is still in Offline state. */ - pub fn set_suspended(&mut self, _suspended: bool) { - todo!() - } - -} - -impl Drop for Replicator { - fn drop(&mut self) { unsafe { CBL_Release(self._ref as *mut CBLRefCounted) } } -} - - -//======== STATUS AND PROGRESS - - -/** The possible states a replicator can be in during its lifecycle. */ -#[derive(Debug)] -pub enum ReplicatorActivityLevel { - Stopped, // The replicator is unstarted, finished, or hit a fatal error. - Offline, // The replicator is offline, as the remote host is unreachable. - Connecting, // The replicator is connecting to the remote host. - Idle, // The replicator is inactive, waiting for changes to sync. - Busy // The replicator is actively transferring data. -} - -/** The current progress status of a Replicator. The `fraction_complete` ranges from 0.0 to 1.0 as - replication progresses. The value is very approximate and may bounce around during replication; - making it more accurate would require slowing down the replicator and incurring more load on the - server. It's fine to use in a progress bar, though. */ -pub struct ReplicatorProgress { - pub fraction_complete: f32, // Very-approximate completion, from 0.0 to 1.0 - pub document_count: u64 // Number of documents transferred so far -} - -/** A replicator's current status. */ -pub struct ReplicatorStatus { - pub activity: ReplicatorActivityLevel, // Current state - pub progress: ReplicatorProgress, // Approximate fraction complete - pub error: Result<()> // Error, if any -} - -/** A callback that notifies you when the replicator's status changes. */ -pub type ReplicatorChangeListener = fn(&Replicator, ReplicatorStatus); - -/** Flags describing a replicated document. */ -pub static DELETED : u32 = kCBLDocumentFlagsDeleted; -pub static ACCESS_REMOVED : u32 = kCBLDocumentFlagsAccessRemoved; - -/** Information about a document that's been pushed or pulled. */ -pub struct ReplicatedDocument<'d> { - pub id: &'d str, // The document ID - pub flags: u32, // Indicates whether the document was deleted or removed - pub error: Result<()> // Error, if document failed to replicate -} - -/** Direction of document transfer. */ -#[derive(Debug)] -pub enum Direction {Pulled, Pushed } - -/** A callback that notifies you when documents are replicated. */ -pub type ReplicatedDocumentListener = fn(&Replicator, Direction, Vec); - -impl Replicator { - - /** Returns the replicator's current status. */ - pub fn status(&self) -> ReplicatorStatus { - todo!() - } - - /** Indicates which documents have local changes that have not yet been pushed to the server - by this replicator. This is of course a snapshot, that will go out of date as the replicator - makes progress and/or documents are saved locally. */ - pub fn pending_document_ids(&self) -> Result> { - todo!() - } - - /** Indicates whether the document with the given ID has local changes that have not yet been - pushed to the server by this replicator. - - This is equivalent to, but faster than, calling \ref pending_document_ids and - checking whether the result contains \p docID. See that function's documentation for details. */ - pub fn is_document_pending(_doc_id: &str) -> Result { - todo!() - } - - /** Adds a listener that will be called when the replicator's status changes. */ - pub fn add_change_listener(&mut self, _listener: ReplicatorChangeListener) -> ListenerToken { - todo!() - } - - /** Adds a listener that will be called when documents are replicated. */ - pub fn add_document_listener(&mut self, _listener: ReplicatedDocumentListener) -> ListenerToken { - todo!() - } -} diff --git a/bindings/rust/CouchbaseLite/src/slice.rs b/bindings/rust/CouchbaseLite/src/slice.rs deleted file mode 100644 index fc08c641..00000000 --- a/bindings/rust/CouchbaseLite/src/slice.rs +++ /dev/null @@ -1,130 +0,0 @@ -// Internal API for working with FLSlice, FLSliceResult, and C strings -// -// Copyright (c) 2020 Couchbase, Inc 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. -// - -use super::c_api::*; - -use std::borrow::Cow; -use std::ffi::c_void; -use std::ffi::CStr; -use std::ptr; -use std::str; - - -//////// SLICES - - -pub const NULL_SLICE : FLSlice = FLSlice{buf: ptr::null(), size: 0}; - - -pub fn as_slice(s: &str) -> FLSlice { - return FLSlice{buf: s.as_ptr() as *const c_void, - size: s.len() as u64}; -} - -pub fn bytes_as_slice(s: &[u8]) -> FLSlice { - return FLSlice{buf: s.as_ptr() as *const c_void, - size: s.len() as u64}; -} - -impl FLSlice { - // A slice may be null, so in Rust terms it's an Option. - - pub unsafe fn as_byte_array<'a>(&self) -> Option<&'a [u8]> { - if !self { return None } - return Some(std::slice::from_raw_parts(self.buf as *const u8, self.size as usize)) - } - pub unsafe fn as_str<'a>(&self) -> Option<&'a str> { - match self.as_byte_array() { - None => None, - Some(b) => { str::from_utf8(b).ok() } - } - } - pub unsafe fn to_string(&self) -> Option { - return self.as_str().map(|s| s.to_string()); - } - - pub unsafe fn to_vec(&self) -> Option> { - return self.as_byte_array().map(|a| a.to_owned()); - } - - pub fn map(&self, f : F) -> Option - where F: Fn(&FLSlice)->T - { - if !self {None} else {Some(f(self))} - } -} - -impl std::ops::Not for &FLSlice { - type Output = bool; - fn not(self) -> bool {self.buf.is_null()} -} - -impl std::ops::Not for FLSlice { - type Output = bool; - fn not(self) -> bool {self.buf.is_null()} -} - -impl FLSliceResult { - pub fn as_slice(&self) -> FLSlice { - return FLSlice{buf: self.buf, size: self.size}; - } - - // pub unsafe fn retain(&mut self) { - // _FLBuf_Retain(self.buf); - // } - - // It's not possible to implement Drop for FLSliceResult, because the generated interface - // makes it implement Copy. So it has to be released by hand. - pub unsafe fn release(&mut self) { - _FLBuf_Release(self.buf); - } - - // Consumes & releases self - pub unsafe fn to_string(mut self) -> Option { - let str = self.as_slice().to_string(); - self.release(); - return str; - } - - // Consumes & releases self - pub unsafe fn to_vec(mut self) -> Option> { - let vec = self.as_slice().to_vec(); - self.release(); - return vec; - } -} - - -//////// C STRINGS - - -// Convenience to convert a raw `char*` to an unowned `&str` -pub unsafe fn to_str<'a>(cstr: *const ::std::os::raw::c_char) -> Cow<'a, str> { - return CStr::from_ptr(cstr).to_string_lossy() -} - - -// Convenience to convert a raw `char*` to an owned String -pub unsafe fn to_string(cstr: *const ::std::os::raw::c_char) -> String { - return to_str(cstr).to_string(); -} - -/* -pub(crate) unsafe fn free_cstr(cstr: *const ::std::os::raw::c_char) { - todo!(); // Implement this by calling `free()` -} -*/ diff --git a/bindings/rust/CouchbaseLite/tests/simple_tests.rs b/bindings/rust/CouchbaseLite/tests/simple_tests.rs deleted file mode 100644 index ecee7fd0..00000000 --- a/bindings/rust/CouchbaseLite/tests/simple_tests.rs +++ /dev/null @@ -1,189 +0,0 @@ -// Couchbase Lite unit tests -// -// Copyright (c) 2020 Couchbase, Inc 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. -// -#![allow(unused_imports)] - -extern crate couchbase_lite; -extern crate tempdir; - -use couchbase_lite::*; -use tempdir::TempDir; - -// Enables check for leaks of native CBL objects after `with_db()` finishes. -// WARNING: These checks only work if one test method runs at a time, i.e. testing is single -// threaded. Run as `cargo test -- --test-threads=1` or you'll get false positives. -const LEAK_CHECKS : bool = true; - -const DB_NAME : &str = "test_db"; - -const LEVEL_PREFIX : [&str;5] = ["((", "_", "", "WARNING: ", "***ERROR: "]; -const LEVEL_SUFFIX : [&str;5] = ["))", "_", "", "", " ***"]; - - -fn logger(domain: logging::Domain, level: logging::Level, message: &str) { - // Log to stdout, not stderr, so that `cargo test` will buffer the output. - let i = level as usize; - println!("CBL {:?}: {}{}{}", - domain, LEVEL_PREFIX[i], message, LEVEL_SUFFIX[i]) - -} - -fn init_logging() { - logging::set_callback(Some(logger)); -} - -// Test wrapper function -- takes care of creating and deleting the database. -fn with_db(f: F) - where F: Fn(&mut Database) -{ - init_logging(); - - let start_inst_count = instance_count() as isize; - let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir"); - let cfg = DatabaseConfiguration{directory: tmp_dir.path(), flags: CREATE}; - let mut db = Database::open(DB_NAME, Some(cfg)).expect("open db"); - assert!(Database::exists(DB_NAME, tmp_dir.path())); - - f(&mut db); - - drop(db); - if LEAK_CHECKS && instance_count() as isize > start_inst_count { - dump_instances(); - panic!("Native object leak: {} objects, was {}", - instance_count(), start_inst_count); - } -} - -fn add_doc(db: &mut Database, id: &str, i: i64, s: &str) { - let mut doc = Document::new_with_id(id); - let mut props = doc.mutable_properties(); - props.at("i").put_i64(i); - props.at("s").put_string(s); - db.save_document(&mut doc, ConcurrencyControl::FailOnConflict).expect("save"); -} - - -//////// TESTS: - -#[test] -fn db_properties() { - with_db(|db| { - assert_eq!(db.name(), DB_NAME); - assert_eq!(db.count(), 0); - }); -} - -#[test] -fn create_document() { - with_db(|_db| { - let doc = Document::new_with_id("foo"); - assert_eq!(doc.id(), "foo"); - assert_eq!(doc.sequence(), 0); - assert!(doc.properties()); - assert_eq!(doc.properties().count(), 0); - }); -} - -#[test] -fn save_document() { - with_db(|db| { - { - logging::set_level(logging::Level::Info, logging::Domain::All); - let mut doc = Document::new_with_id("foo"); - let mut props = doc.mutable_properties(); - props.at("i").put_i64(1234); - props.at("s").put_string("Hello World!"); - - db.save_document(&mut doc, ConcurrencyControl::FailOnConflict).expect("save"); - } - { - let doc = db.get_document("foo").expect("reload document"); - let props = doc.properties(); - verbose!("Blah blah blah"); - info!("Interesting: {} = {}", 2+2, 4); - warn!("Some warning"); - error!("Oh no, props = {}", props); - assert_eq!(props.to_json(), r#"{"i":1234,"s":"Hello World!"}"#); - } - }); -} - -#[test] -fn query() { - with_db(|db| { - add_doc(db, "doc-1", 1, "one"); - add_doc(db, "doc-2", 2, "two"); - add_doc(db, "doc-3", 3, "three"); - - let query = Query::new(db, QueryLanguage::N1QL, "select i, s where i > 1 order by i").expect("create query"); - assert_eq!(query.column_count(), 2); - assert_eq!(query.column_name(0), Some("i")); - assert_eq!(query.column_name(1), Some("s")); - - // Step through the iterator manually: - let results = query.execute().expect("execute"); - let mut row = (&results).next().unwrap(); //FIXME: Do something about the (&results). requirement - let mut i = row.get(0).as_i64().unwrap(); - let mut s = row.get(1).as_string().unwrap(); - assert_eq!(i, 2); - assert_eq!(s, "two"); - assert_eq!(row.as_dict().to_json(), r#"{"i":2,"s":"two"}"#); - - row = (&results).next().unwrap(); - i = row.get(0).as_i64().unwrap(); - s = row.get(1).as_string().unwrap(); - assert_eq!(i, 3); - assert_eq!(s, "three"); - assert_eq!(row.as_dict().to_json(), r#"{"i":3,"s":"three"}"#); - - assert!((&results).next().is_none()); - - // Now try a for...in loop: - let mut n = 0; - for row in &query.execute().expect("execute") { - match n { - 0 => { - assert_eq!(row.as_array().to_json(), r#"[2,"two"]"#); - assert_eq!(row.as_dict().to_json(), r#"{"i":2,"s":"two"}"#); - }, - 1 => { - assert_eq!(row.as_array().to_json(), r#"[3,"three"]"#); - assert_eq!(row.as_dict().to_json(), r#"{"i":3,"s":"three"}"#); - }, - _ => {panic!("Too many rows ({})", n);} - } - n += 1; - - } - assert_eq!(n, 2); - }); -} - - -/* -// This test doesn't and shouldn't compile -- it tests that the borrow-checker will correctly -// prevent Fleece data from being used after its document has been freed. -#[test] -fn document_borrow_check() { - let mut db = Database::open(DB_NAME, None).expect("open db"); - let v : Value; - { - let doc = db.get_document("foo").expect("get doc"); - v = doc.properties().get("a"); - } - println!("v = {:?}", v); -} -*/ diff --git a/bindings/rust/CouchbaseLite/wrapper.h b/bindings/rust/CouchbaseLite/wrapper.h deleted file mode 100644 index 10e9af61..00000000 --- a/bindings/rust/CouchbaseLite/wrapper.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../../include/cbl/CouchbaseLite.h" -#include "../../../src/CBLPrivate.h" diff --git a/bindings/rust/README.md b/bindings/rust/README.md deleted file mode 100644 index 16bf1ebb..00000000 --- a/bindings/rust/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Rust Language Bindings For Couchbase Lite - -10 May 2020 - -The `CouchbaseLite` subdirectory of this directory is a Cargo package containing a [Couchbase -Lite][CBL] API binding for the [Rust language][RUST]. - -It's still in early development. It's incomplete, has only had some informal testing, and that -only on macOS. Also I (Jens) am a newbie at Rust and may not be doing things the write way. -Feedback gratefully accepted. - -## Prerequisites - -In addition to Rust, you'll need to install [bindgen][BINDGEN], which generates Rust FFI APIs -from C headers. Installation instructions are [here][BINDGEN_INSTALL] -- the main thing you'll need -to do is install Clang. - -## Building - -**_"Some assembly required..."_** - -You first need to build Couchbase Lite For C (the root of this repo) with CMake, by running the -`build.sh` script in the repo root directory. That will produce the shared library. - - $ cd ../.. - $ ./build.sh - -After that, go to the `CouchbaseLite` package directory and fix the hardcoded path I left in the -`build.rs` file: it's the value of `DEFAULT_LIBCLANG_PATH` at line 32. You'll need to find out where -your LLVM installation directory is, and set this string constant to the path to its `lib` -subdirectory. - - $ cd bindings/rust/CouchbaseLite/ - $ my_favorite_editor build.rs - -Now that this is set up, you can build normally with Cargo: - - $ cargo build - -**Unit tests must be run single-threaded.** This is because each test case checks for leaks by -counting the number of extant Couchbase Lite objects before and after it runs, and failing if the -number increases. This works only if a single test runs at a time. - - $ cargo test -- --test-threads 1 - -The library itself has no thread-safety problems; if you want to run the tests multi-threaded, just -edit `tests/simple_tests.rs` and change the value of `LEAK_CHECKS` to `false`. - -## Learning - -I've copied the doc-comments from the C API into the Rust files. But Couchbase Lite is fairly -complex, so if you're not already familiar with it, you'll want to start by reading through -the [official documentation][CBLDOCS]. - -The Rust API is mostly method-for-method compatible with the languages documented there, except -down at the document property level (dictionaries, arrays, etc.) where I haven't yet written -compatible bindings. For those APIs you can check out the document "[Using Fleece][FLEECE]". - - -[RUST]: https://www.rust-lang.org -[CBL]: https://www.couchbase.com/products/lite -[CBLDOCS]: https://docs.couchbase.com/couchbase-lite/current/introduction.html -[FLEECE]: https://github.com/couchbaselabs/fleece/wiki/Using-Fleece -[BINDGEN]: https://rust-lang.github.io/rust-bindgen/ -[BINDGEN_INSTALL]: https://rust-lang.github.io/rust-bindgen/requirements.html diff --git a/bindings/rust/rust.sublime-project b/bindings/rust/rust.sublime-project deleted file mode 100644 index 8cae4287..00000000 --- a/bindings/rust/rust.sublime-project +++ /dev/null @@ -1,24 +0,0 @@ -{ - "folders": [ - { - "path": "CouchbaseLite/src" - }, - { - "path": "CouchbaseLite/tests" - }, - { - "path": "CouchbaseLite", - "name": "Crate", - "file_include_patterns": ["*.toml", "*.h", "bindings.rs"], - "folder_include_patterns": ["target", "debug", "build", "out", "couchbase_lite-*"] - } - ], - "settings": { - "tab_size": 4, - "translate_tabs_to_spaces": true, - "rulers": [100], - "trim_trailing_white_space_on_save": true, - "ensure_newline_at_eof_on_save": true, - "default_line_ending": "unix", - }, -} From 7592162f835b942f7ed7cb53f639d0b26d4d05fd Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 30 Sep 2021 20:37:43 -0700 Subject: [PATCH 19/90] Minor cleanup saveBlobsAndCheckEncryptables (#221) --- src/CBLDocument.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CBLDocument.cc b/src/CBLDocument.cc index 33932542..a9dc370c 100644 --- a/src/CBLDocument.cc +++ b/src/CBLDocument.cc @@ -367,8 +367,7 @@ bool CBLDocument::saveBlobsAndCheckEncryptables(CBLDatabase *db, bool releaseNew if (foundBlobs) { i.skipChildren(); } - } - if (foundBlobs && !validateEncryptables) { + } else if (!validateEncryptables) { // Found at least one blob, and the current dictionary is immutable // Since encryptable validation is disabled, the rest of the keys // are not relevant. From efb17bfcbf6e55b61a22234b6e0b3e865b46c612 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 30 Sep 2021 20:38:05 -0700 Subject: [PATCH 20/90] Add tests checking if mutable props is properly retained (#225) * Added a test to confirm that the mutable properties properly retained after setting to a doc. * Updated merge conflict resolution test to create a new merged doc, set properties from the local doc, and set value from remote doc. --- test/DatabaseTest.cc | 15 ++++++++++ test/ReplicatorEETest.cc | 60 ++++++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/test/DatabaseTest.cc b/test/DatabaseTest.cc index a0e9480e..9bb4b310 100644 --- a/test/DatabaseTest.cc +++ b/test/DatabaseTest.cc @@ -371,6 +371,21 @@ TEST_CASE_METHOD(DatabaseTest, "Access nested collections from a copy of modifie CBLDocument_Release(doc); } +TEST_CASE_METHOD(DatabaseTest, "Set MutableProperties") { + CBLDocument* doc1 = CBLDocument_Create(); + FLMutableDict prop1 = CBLDocument_MutableProperties(doc1); + FLMutableDict_SetString(prop1, "greeting"_sl, "hello"_sl); + + CBLDocument* doc2 = CBLDocument_Create(); + CBLDocument_SetProperties(doc2, prop1); + FLMutableDict prop2 = CBLDocument_MutableProperties(doc2); + CHECK(FLValue_AsString(FLDict_Get(prop2, "greeting"_sl)) == "hello"_sl ); + CHECK(prop1 == prop2); + + CBLDocument_Release(doc1); + CHECK(FLValue_AsString(FLDict_Get(prop2, "greeting"_sl)) == "hello"_sl ); + CBLDocument_Release(doc2); +} TEST_CASE_METHOD(DatabaseTest, "Get Non Existing Document") { CBLError error; diff --git a/test/ReplicatorEETest.cc b/test/ReplicatorEETest.cc index ba9c4508..516f675e 100644 --- a/test/ReplicatorEETest.cc +++ b/test/ReplicatorEETest.cc @@ -411,8 +411,8 @@ class ReplicatorConflictTest : public ReplicatorLocalTest { REQUIRE(!localDoc); } else { REQUIRE(localDoc); - CHECK(localDoc["greeting"].asString() == "¡Hola!"_sl); - CHECK(localDoc["expletive"] == nullptr); + CHECK(localDoc["greeting"].asString() == "Howdy!"_sl); + CHECK(localDoc["expletive"].asString() == "Frak!"_sl); Blob blob(localDoc["signature"].asDict()); CHECK(blob.loadContent() == "Bob!"_sl); Blob blob2(localDoc["signature2"].asDict()); @@ -451,8 +451,8 @@ class ReplicatorConflictTest : public ReplicatorLocalTest { REQUIRE(!remoteDoc); } else { REQUIRE(remoteDoc); - CHECK(remoteDoc["greeting"].asString() == "¡Hola!"_sl); - CHECK(remoteDoc["expletive"] == nullptr); + CHECK(remoteDoc["greeting"].asString() == "Howdy!"_sl); + CHECK(remoteDoc["expletive"].asString() == "Frak!"_sl); Blob blob(localDoc["signature"].asDict()); CHECK(blob.loadContent() == "Bob!"_sl); Blob blob2(localDoc["signature2"].asDict()); @@ -503,24 +503,48 @@ class ReplicatorConflictTest : public ReplicatorLocalTest { case ResolverMode::kRemoteWins: return remoteDocument; default: - CBLDocument *merged; + // NOTE: The merged doc will be: + // {'greeting': 'Howdy!', 'expletive': 'Frak!', 'signature': blob, 'signature2': blob} + // ** signature and signature2 have the same blob + + CBLDocument *mergedDoc; if (resolverMode == ResolverMode::kMergeAutoID) - merged = CBLDocument_Create(); // Allowed but there will be a warning message + mergedDoc = CBLDocument_Create(); // Allowed but there will be a warning message else - merged = CBLDocument_CreateWithID(documentID); - MutableDict mergedProps(CBLDocument_MutableProperties(merged)); - mergedProps["greeting"] = "¡Hola!"; + mergedDoc = CBLDocument_CreateWithID(documentID); + + FLMutableDict mergedProps; + if (localDocument) { + FLDict props = CBLDocument_Properties(localDocument); + FLMutableDict mProps = FLDict_MutableCopy(props, kFLDefaultCopy); + CBLDocument_SetProperties(mergedDoc, mProps); + FLMutableDict_Release(mProps); + mergedProps = CBLDocument_MutableProperties(mergedDoc); + } else if (remoteDocument) { + FLDict props = CBLDocument_Properties(remoteDocument); + FLMutableDict mProps = FLDict_MutableCopy(props, kFLDefaultCopy); + CBLDocument_SetProperties(mergedDoc, mProps); + FLMutableDict_Release(mProps); + mergedProps = CBLDocument_MutableProperties(mergedDoc); + } else { + mergedProps = CBLDocument_MutableProperties(mergedDoc); + FLMutableDict_SetString(mergedProps, "greeting"_sl, "Howdy!"_sl); + } + + if (remoteDocument) { + FLDict props = CBLDocument_Properties(remoteDocument); + FLValue expletive = FLDict_Get(props, "expletive"_sl); + FLMutableDict_SetValue(mergedProps, "expletive"_sl, expletive); + } else { + FLMutableDict_SetString(mergedProps, "expletive"_sl, "Frak!"_sl); + } - auto blob = Blob("text/plain"_sl, "Bob!"_sl); // C++ Blob (RefCounted) - mergedProps["signature"] = blob.properties(); - mergedProps["signature2"] = blob.properties(); - // Prevent blob from being released after returning, blob will be released - // after the blob is installed when the merged document body is encoded - // to save. - CBLBlob_Retain(blob.ref()); + CBLBlob* blob = CBLBlob_CreateWithData("text/plain"_sl, "Bob!"_sl); + FLMutableDict_SetBlob(mergedProps, "signature"_sl, blob); + FLMutableDict_SetBlob(mergedProps, "signature2"_sl, blob); // Use same blob - // Do not release `merged`, otherwise it would be freed before returning! - return merged; + // Do not release `mergedDoc`, otherwise it would be freed before returning! + return mergedDoc; } } } From b79d176dd6b80b1379d731f74b71eca916baadd6 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Tue, 12 Oct 2021 22:15:36 +0000 Subject: [PATCH 21/90] CBL-2261: Check findNewBlob as the last step of getBlob (#229) Since findNewBlob will often log a warning about the blob possibly already being installed, eliminate other possibilities first to keep the warning log quieter. --- src/CBLBlob_Internal.hh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CBLBlob_Internal.hh b/src/CBLBlob_Internal.hh index 1a1fec21..a6254750 100644 --- a/src/CBLBlob_Internal.hh +++ b/src/CBLBlob_Internal.hh @@ -238,14 +238,15 @@ inline const CBLBlob* _cbl_nullable CBLBlob::getBlob(Dict blobDict) noexcept { if (!C4Blob::isBlob(blobDict)) return nullptr; - // Check if it's a new unsaved blob: - if (auto newBlob = CBLDocument::findNewBlob(blobDict); newBlob) - return newBlob; - // Check if it's a blob in a query result set: if (auto rs = CBLResultSet::containing(blobDict); rs) return rs->getBlob(blobDict, *key); - return nullptr; + + // CBL-2261: Keep this condition last because if this returns null it + // often logs a warning (so before, every time CBLResultSet::containing + // was true a benign warning would be logged) + // Check if it's a new unsaved blob: + return CBLDocument::findNewBlob(blobDict); } From 4b2c1cc7fe18e8b95c8787826f6a5f375245f12f Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 7 Oct 2021 11:21:06 -0700 Subject: [PATCH 22/90] Fix console log enabled at INFO instead of WARNING (#227) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Background : The default log level of each domain in LiteCore is INFO. Without configuring anything, LiteCore will write logs at INFO+ level to the console via vprintf. However, the default console log level in CBL is WARNING. An attempt to use static intitalizer to setup the default console log level to WARNING was failed as some extern constants were not initialized prior the static inititalizer. * Changed the previous static init() function to CBL_Init() function that will be called by the top level functions that expects log messages including CBLDatabase’s open(), copyDatabase(), deleteDatabase(), Android’s CBL_Init(), and any functions used for configuring logging. * NOTE: If calling CBL_Init() becomes hard to track in the future, we should consider changing the default log level in LiteCore from INFO to WARNING. CBL-2449 --- CBL_C.xcodeproj/project.pbxproj | 2 ++ src/CBLDatabase_Internal.hh | 4 ++++ src/CBLLog.cc | 13 ++++++------ src/CBLLog_Internal.hh | 37 +++++++++++++++++++++++++++++++++ src/Internal.cc | 3 +++ 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 src/CBLLog_Internal.hh diff --git a/CBL_C.xcodeproj/project.pbxproj b/CBL_C.xcodeproj/project.pbxproj index 83d566d6..9f6364f3 100644 --- a/CBL_C.xcodeproj/project.pbxproj +++ b/CBL_C.xcodeproj/project.pbxproj @@ -373,6 +373,7 @@ 9320630126BDB340006917A5 /* CBLPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLPlatform.h; sourceTree = ""; }; 9320631126BDB5CA006917A5 /* CBLPlatform_CAPI+Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "CBLPlatform_CAPI+Android.cc"; sourceTree = ""; }; 9320631426BDD059006917A5 /* CBLDatabase+Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "CBLDatabase+Android.cc"; sourceTree = ""; }; + 934AD381270E797D0038D62E /* CBLLog_Internal.hh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CBLLog_Internal.hh; sourceTree = ""; }; 93965A6226A7CD50008728EE /* LogTest.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogTest.cc; sourceTree = ""; }; 93C70CD226C4D3F20093E927 /* CBLEncryptable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLEncryptable.h; sourceTree = ""; }; 93C70CE226C5B4BC0093E927 /* CBLEncryptable_CAPI.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLEncryptable_CAPI.cc; sourceTree = ""; }; @@ -496,6 +497,7 @@ 271C2A7721CC750E0045856E /* CBLDocument.cc */, 277FEE7A21ED6C0000B60E3C /* CBLDocument_Internal.hh */, 93EC365D26C498AB00182B02 /* CBLEncryptable_Internal.hh */, + 934AD381270E797D0038D62E /* CBLLog_Internal.hh */, 277B77D4245B44E900B222D3 /* CBLLog.cc */, 932062DA26BC6B43006917A5 /* CBLQuery.cc */, 27DBCF2E246B4352002FD7A7 /* CBLQuery_Internal.hh */, diff --git a/src/CBLDatabase_Internal.hh b/src/CBLDatabase_Internal.hh index be3f5232..c9743623 100644 --- a/src/CBLDatabase_Internal.hh +++ b/src/CBLDatabase_Internal.hh @@ -19,6 +19,7 @@ #pragma once #include "CBLDatabase.h" #include "CBLDocument_Internal.hh" +#include "CBLLog_Internal.hh" #include "CBLPrivate.h" #include "c4Collection.hh" #include "c4Database.hh" @@ -60,11 +61,13 @@ public: slice toName, const CBLDatabaseConfiguration* _cbl_nullable config) { + CBLLog_Init(); C4DatabaseConfig2 c4config = asC4Config(config); C4Database::copyNamed(fromPath, toName, c4config); } static void deleteDatabase(slice name, slice inDirectory) { + CBLLog_Init(); C4Database::deleteNamed(name, effectiveDir(inDirectory)); } @@ -77,6 +80,7 @@ public: "The context hasn't been initialized. Call CBL_Init(CBLInitContext*) to initialize the context"); } #endif + CBLLog_Init(); C4DatabaseConfig2 c4config = asC4Config(config); Retained c4db = C4Database::openNamed(name, c4config); return new CBLDatabase(c4db, name, c4config.parentDirectory); diff --git a/src/CBLLog.cc b/src/CBLLog.cc index 5f81cf16..a153ad5d 100644 --- a/src/CBLLog.cc +++ b/src/CBLLog.cc @@ -17,6 +17,7 @@ // #include "CBLLog.h" +#include "CBLLog_Internal.hh" #include "CBLPrivate.h" #include "c4Base.hh" #include "Internal.hh" @@ -50,8 +51,6 @@ static alloc_slice sLogFileDir; static void c4LogCallback(C4LogDomain domain, C4LogLevel level, const char *fmt, va_list args); -static void init(); - static C4LogLevel effectiveC4CallbackLogLevel(); static void updateC4CallbackLogLevel(); @@ -61,7 +60,7 @@ static CBLLogDomain getCBLLogDomain(C4LogDomain domain); // Note: Cannot use static initializing here as the order of initializing static C4LogDomain // constants such as kC4DatabaseLog cannot be guaranteed to be done prior. static once_flag initFlag; -static void init() { +void CBLLog_Init() { call_once(initFlag, [](){ // Initialize log level of each domain to debug (lowest level): for (int i = 0; i < sizeof(kC4Domains)/sizeof(kC4Domains[0]); ++i) { @@ -81,7 +80,7 @@ CBLLogLevel CBLLog_ConsoleLevel() CBLAPI { void CBLLog_SetConsoleLevel(CBLLogLevel level) CBLAPI { - init(); + CBLLog_Init(); if (sConsoleLogLevel.exchange(level) != level) updateC4CallbackLogLevel(); } @@ -93,7 +92,7 @@ CBLLogLevel CBLLog_CallbackLevel() CBLAPI { void CBLLog_SetCallbackLevel(CBLLogLevel level) CBLAPI { - init(); + CBLLog_Init(); if (sCustomLogLevel.exchange(level) != level) updateC4CallbackLogLevel(); } @@ -105,7 +104,7 @@ CBLLogCallback CBLLog_Callback() CBLAPI { void CBLLog_SetCallback(CBLLogCallback callback) CBLAPI { - init(); + CBLLog_Init(); if (sCustomCallback.exchange(callback) != callback) updateC4CallbackLogLevel(); } @@ -195,7 +194,7 @@ const CBLLogFileConfiguration* CBLLog_FileConfig() CBLAPI { bool CBLLog_SetFileConfig(CBLLogFileConfiguration config, CBLError *outError) CBLAPI { - init(); + CBLLog_Init(); sLogFileDir = config.directory; // copy string to the heap config.directory = sLogFileDir; // and put the heap copy in the struct diff --git a/src/CBLLog_Internal.hh b/src/CBLLog_Internal.hh new file mode 100644 index 00000000..cfc6fcde --- /dev/null +++ b/src/CBLLog_Internal.hh @@ -0,0 +1,37 @@ +// +// CBLLog_Internal.hh +// +// Copyright © 2021 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. +// + +/** + * Initialize the log level of each log domains to DEBUG so that + * the log level of all domains could be controlled by using c4log_setCallbackLevel() + * and c4log_writeToBinaryFile() and setup the log callback with the WARNING as its default + * log level. + * + * This method is safe to call multiple times but the initializing logic will be executed only + * once when the method is called the first time. + * + * @NOTE As we cannot use static initializer to initialize the log level and the log callback, + * we will need to call CBLLog_Init() from the top level methods that logs (level < Warnings) + * are expected including CBLDatabase's open(), copyDatabase(), deleteDatabase(), + * Andriod's CBL_Init(), and any methods used for configuring logs in CBLLog.cc. + * + * In the future, if calling CBLLog_Init() becomes painfully hard to track, we could consider + * changing the default log level of each domain in LiteCore from INFO to WARNING so that calling + * CBLLog_Init() is not needed beside from the methods used for configuring logs. + */ +void CBLLog_Init(); diff --git a/src/Internal.cc b/src/Internal.cc index 66db1103..3e9a4d90 100644 --- a/src/Internal.cc +++ b/src/Internal.cc @@ -17,6 +17,7 @@ // #include "Internal.hh" +#include "CBLLog_Internal.hh" #include "c4Base.hh" #include "fleece/Fleece.h" #include "betterassert.hh" @@ -66,6 +67,8 @@ namespace cbl_internal { precondition(context.filesDir != nullptr); precondition(context.tempDir != nullptr); + CBLLog_Init(); + litecore::FilePath filesDir(context.filesDir, ""); filesDir.mustExistAsDir(); From 42e0dafe9c50ca92da029040d92dcb1dea7a33c4 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 12 Oct 2021 16:12:57 -0700 Subject: [PATCH 23/90] CBL-2358 : Update fleece export (#231) * Update fleece export for FLMutableArray_NewFromJSON and FLMutableDict_NewFromJSON * Added generated exports --- src/exports/Fleece_Exports.txt | 2 ++ src/exports/generated/CBL.def | 2 ++ src/exports/generated/CBL.exp | 2 ++ src/exports/generated/CBL.gnu | 2 ++ src/exports/generated/CBL_Android.gnu | 2 ++ src/exports/generated/CBL_EE.def | 2 ++ src/exports/generated/CBL_EE.exp | 2 ++ src/exports/generated/CBL_EE.gnu | 2 ++ src/exports/generated/CBL_EE_Android.gnu | 2 ++ 9 files changed, 18 insertions(+) diff --git a/src/exports/Fleece_Exports.txt b/src/exports/Fleece_Exports.txt index b82f92b4..197fe272 100644 --- a/src/exports/Fleece_Exports.txt +++ b/src/exports/Fleece_Exports.txt @@ -71,6 +71,7 @@ FLArrayIterator_GetValueAt FLArrayIterator_Next FLMutableArray_New +FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged FLMutableArray_Append @@ -141,6 +142,7 @@ FLApplyJSONDelta FLEncodeApplyingJSONDelta FLMutableDict_New +FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged FLMutableDict_Set diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index 774e8b35..bcde7059 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -189,6 +189,7 @@ FLArrayIterator_GetValue FLArrayIterator_GetValueAt FLArrayIterator_Next FLMutableArray_New +FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged FLMutableArray_Append @@ -253,6 +254,7 @@ FLEncodeJSONDelta FLApplyJSONDelta FLEncodeApplyingJSONDelta FLMutableDict_New +FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged FLMutableDict_Set diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index ef7acf1c..e1821f1c 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -187,6 +187,7 @@ _FLArrayIterator_GetValue _FLArrayIterator_GetValueAt _FLArrayIterator_Next _FLMutableArray_New +_FLMutableArray_NewFromJSON _FLMutableArray_GetSource _FLMutableArray_IsChanged _FLMutableArray_Append @@ -251,6 +252,7 @@ _FLEncodeJSONDelta _FLApplyJSONDelta _FLEncodeApplyingJSONDelta _FLMutableDict_New +_FLMutableDict_NewFromJSON _FLMutableDict_GetSource _FLMutableDict_IsChanged _FLMutableDict_Set diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index 483454e4..87288203 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -187,6 +187,7 @@ CBL_C { FLArrayIterator_GetValueAt; FLArrayIterator_Next; FLMutableArray_New; + FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; FLMutableArray_Append; @@ -251,6 +252,7 @@ CBL_C { FLApplyJSONDelta; FLEncodeApplyingJSONDelta; FLMutableDict_New; + FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; FLMutableDict_Set; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index 040b8165..a623e7c6 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -188,6 +188,7 @@ CBL_C { FLArrayIterator_GetValueAt; FLArrayIterator_Next; FLMutableArray_New; + FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; FLMutableArray_Append; @@ -252,6 +253,7 @@ CBL_C { FLApplyJSONDelta; FLEncodeApplyingJSONDelta; FLMutableDict_New; + FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; FLMutableDict_Set; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index cdb65ffb..a0017878 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -209,6 +209,7 @@ FLArrayIterator_GetValue FLArrayIterator_GetValueAt FLArrayIterator_Next FLMutableArray_New +FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged FLMutableArray_Append @@ -273,6 +274,7 @@ FLEncodeJSONDelta FLApplyJSONDelta FLEncodeApplyingJSONDelta FLMutableDict_New +FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged FLMutableDict_Set diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index 65e4ed6e..6f8650ad 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -207,6 +207,7 @@ _FLArrayIterator_GetValue _FLArrayIterator_GetValueAt _FLArrayIterator_Next _FLMutableArray_New +_FLMutableArray_NewFromJSON _FLMutableArray_GetSource _FLMutableArray_IsChanged _FLMutableArray_Append @@ -271,6 +272,7 @@ _FLEncodeJSONDelta _FLApplyJSONDelta _FLEncodeApplyingJSONDelta _FLMutableDict_New +_FLMutableDict_NewFromJSON _FLMutableDict_GetSource _FLMutableDict_IsChanged _FLMutableDict_Set diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index 07b967c7..d6baf17e 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -207,6 +207,7 @@ CBL_C { FLArrayIterator_GetValueAt; FLArrayIterator_Next; FLMutableArray_New; + FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; FLMutableArray_Append; @@ -271,6 +272,7 @@ CBL_C { FLApplyJSONDelta; FLEncodeApplyingJSONDelta; FLMutableDict_New; + FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; FLMutableDict_Set; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index 5203a491..48beb658 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -208,6 +208,7 @@ CBL_C { FLArrayIterator_GetValueAt; FLArrayIterator_Next; FLMutableArray_New; + FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; FLMutableArray_Append; @@ -272,6 +273,7 @@ CBL_C { FLApplyJSONDelta; FLEncodeApplyingJSONDelta; FLMutableDict_New; + FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; FLMutableDict_Set; From d1016d69edc2de81cd4329751f4c4e647618eedc Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 12 Oct 2021 16:28:44 -0700 Subject: [PATCH 24/90] =?UTF-8?q?Use=20Undefined=20value=20for=20missing?= =?UTF-8?q?=20values=20in=20Query=E2=80=99s=20array=20results=20(#230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * When creating an array result, use kFLUndefinedValue for the missing values. * Updated Fleece export symbol CBL-2409 --- src/CBLQuery.cc | 4 ++-- src/exports/Fleece_Exports.txt | 1 + src/exports/generated/CBL.def | 1 + src/exports/generated/CBL.exp | 1 + src/exports/generated/CBL.gnu | 1 + src/exports/generated/CBL_Android.gnu | 1 + src/exports/generated/CBL_EE.def | 1 + src/exports/generated/CBL_EE.exp | 1 + src/exports/generated/CBL_EE.gnu | 1 + src/exports/generated/CBL_EE_Android.gnu | 1 + test/CBLTest.cc | 1 + test/QueryTest.cc | 11 +++++++---- 12 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/CBLQuery.cc b/src/CBLQuery.cc index 065efb74..f7f3ad51 100644 --- a/src/CBLQuery.cc +++ b/src/CBLQuery.cc @@ -88,12 +88,12 @@ Value CBLResultSet::property(slice prop) const { Array CBLResultSet::asArray() const { if (!_asArray) { - auto array = fleece::MutableArray::newArray(); + auto array = MutableArray::newArray(); unsigned nCols = _query->columnCount(); array.resize(uint32_t(nCols)); for (unsigned i = 0; i < nCols; ++i) { Value val = column(i); - array[i] = val ? val : Value::null(); + array[i] = val ? val : Value(kFLUndefinedValue); } _asArray = array; } diff --git a/src/exports/Fleece_Exports.txt b/src/exports/Fleece_Exports.txt index 197fe272..078d66f3 100644 --- a/src/exports/Fleece_Exports.txt +++ b/src/exports/Fleece_Exports.txt @@ -6,6 +6,7 @@ # (See the master list at vendor/couchbase-lite-core/vendor/fleece/Fleece/Support/Fleece.exp) kFLNullValue +kFLUndefinedValue kFLEmptyArray kFLEmptyDict diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index bcde7059..5132c7ab 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -132,6 +132,7 @@ CBLReplicator_AddChangeListener CBLReplicator_AddDocumentReplicationListener CBLDefaultConflictResolver kFLNullValue +kFLUndefinedValue kFLEmptyArray kFLEmptyDict FLSlice_Equal diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index e1821f1c..b41672f8 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -130,6 +130,7 @@ _CBLReplicator_AddChangeListener _CBLReplicator_AddDocumentReplicationListener _CBLDefaultConflictResolver _kFLNullValue +_kFLUndefinedValue _kFLEmptyArray _kFLEmptyDict _FLSlice_Equal diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index 87288203..9bd3cb43 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -130,6 +130,7 @@ CBL_C { CBLReplicator_AddDocumentReplicationListener; CBLDefaultConflictResolver; kFLNullValue; + kFLUndefinedValue; kFLEmptyArray; kFLEmptyDict; FLSlice_Equal; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index a623e7c6..f33933bf 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -131,6 +131,7 @@ CBL_C { CBLReplicator_AddDocumentReplicationListener; CBLDefaultConflictResolver; kFLNullValue; + kFLUndefinedValue; kFLEmptyArray; kFLEmptyDict; FLSlice_Equal; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index a0017878..d404a4af 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -152,6 +152,7 @@ CBLReplicator_AddChangeListener CBLReplicator_AddDocumentReplicationListener CBLDefaultConflictResolver kFLNullValue +kFLUndefinedValue kFLEmptyArray kFLEmptyDict FLSlice_Equal diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index 6f8650ad..3cc8222e 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -150,6 +150,7 @@ _CBLReplicator_AddChangeListener _CBLReplicator_AddDocumentReplicationListener _CBLDefaultConflictResolver _kFLNullValue +_kFLUndefinedValue _kFLEmptyArray _kFLEmptyDict _FLSlice_Equal diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index d6baf17e..fdfe65a6 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -150,6 +150,7 @@ CBL_C { CBLReplicator_AddDocumentReplicationListener; CBLDefaultConflictResolver; kFLNullValue; + kFLUndefinedValue; kFLEmptyArray; kFLEmptyDict; FLSlice_Equal; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index 48beb658..1e6ed3d2 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -151,6 +151,7 @@ CBL_C { CBLReplicator_AddDocumentReplicationListener; CBLDefaultConflictResolver; kFLNullValue; + kFLUndefinedValue; kFLEmptyArray; kFLEmptyDict; FLSlice_Equal; diff --git a/test/CBLTest.cc b/test/CBLTest.cc index 99fd75ea..2c8ca836 100644 --- a/test/CBLTest.cc +++ b/test/CBLTest.cc @@ -64,6 +64,7 @@ const CBLDatabaseConfiguration CBLTest::kDatabaseConfiguration = []{ CBLTest::CBLTest() { // Check that these have been correctly exported CHECK(FLValue_GetType(kFLNullValue) == kFLNull); + CHECK(FLValue_GetType(kFLUndefinedValue) == kFLUndefined); CHECK(FLValue_GetType((FLValue)kFLEmptyArray) == kFLArray); CHECK(FLValue_GetType((FLValue)kFLEmptyDict) == kFLDict); diff --git a/test/QueryTest.cc b/test/QueryTest.cc index b8c9cba4..3c1c45a7 100644 --- a/test/QueryTest.cc +++ b/test/QueryTest.cc @@ -285,12 +285,13 @@ TEST_CASE_METHOD(QueryTest, "Query Result As Array", "[Query]") { CBLError error; int errPos; query = CBLDatabase_CreateQuery(db, kCBLN1QLLanguage, - "SELECT name FROM _ WHERE birthday like '1959-%' ORDER BY birthday"_sl, + "SELECT name, foo FROM _ WHERE birthday like '1959-%' ORDER BY birthday"_sl, &errPos, &error); REQUIRE(query); - CHECK(CBLQuery_ColumnCount(query) == 1); + REQUIRE(CBLQuery_ColumnCount(query) == 2); CHECK(CBLQuery_ColumnName(query, 0) == "name"_sl); + CHECK(CBLQuery_ColumnName(query, 1) == "foo"_sl); alloc_slice explanation(CBLQuery_Explain(query)); cerr << string(explanation); @@ -303,7 +304,7 @@ TEST_CASE_METHOD(QueryTest, "Query Result As Array", "[Query]") { REQUIRE(results); while (CBLResultSet_Next(results)) { FLArray result = CBLResultSet_ResultArray(results); - REQUIRE(FLArray_Count(result) == 1); + REQUIRE(FLArray_Count(result) == 2); FLValue name = FLArray_Get(result, 0); FLDict dict = FLValue_AsDict(name); CHECK(dict); @@ -312,8 +313,10 @@ TEST_CASE_METHOD(QueryTest, "Query Result As Array", "[Query]") { REQUIRE(n < 3); CHECK(first == kExpectedFirst[n]); CHECK(last == kExpectedLast[n]); - ++n; cerr << first << " " << last << "\n"; + FLValue foo = FLArray_Get(result, 1); + CHECK(FLValue_GetType(foo) == kFLUndefined); + ++n; } CHECK(n == 3); } From 897c92a9b07882afe9d069ff746b1fb61a17f50b Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 12 Oct 2021 18:48:13 -0700 Subject: [PATCH 25/90] Update LiteCore submodule --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 5e9f2b1e..c597ad4d 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 5e9f2b1e9a0db11ee02965ec3f6929b8b0261874 +Subproject commit c597ad4de7f7c8257490398f2760f3a4e17cbf7d From 75b47126fa2aedb47f3f69a7da8007111cf618c6 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 13 Oct 2021 15:20:25 -0700 Subject: [PATCH 26/90] Update LiteCore (#233) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index c597ad4d..af93ae75 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit c597ad4de7f7c8257490398f2760f3a4e17cbf7d +Subproject commit af93ae7594a2598b36c66a1e70365f268971888c From a1762f20e0ccd1433796acec058b01fb5b6c96eb Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Fri, 29 Oct 2021 00:00:19 +0000 Subject: [PATCH 27/90] Fix the strip script order (#236) Before it was stripping all the static libraries before extracting debug information which means that there was no debug information left to extract --- jenkins/strip.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkins/strip.sh b/jenkins/strip.sh index 4422b206..2eebfadb 100755 --- a/jenkins/strip.sh +++ b/jenkins/strip.sh @@ -8,12 +8,13 @@ if [[ $# > 1 ]]; then fi pushd $WORKING_DIR +COMMAND="${PREFIX}objcopy --only-keep-debug libcblite.so tmp" +eval ${COMMAND} COMMAND="find . -name \"*.a\" | xargs ${PREFIX}strip --strip-unneeded" eval ${COMMAND} rm libcblite.so* +mv tmp libcblite.so.sym make -j8 cblite -COMMAND="${PREFIX}objcopy --only-keep-debug libcblite.so libcblite.so.sym" -eval ${COMMAND} COMMAND="${PREFIX}strip --strip-unneeded libcblite.so" eval ${COMMAND} COMMAND="${PREFIX}objcopy --add-gnu-debuglink=libcblite.so.sym libcblite.so" From 9d2b1a7dd4dbc5d2c82e29fc5be92d15cff63206 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 29 Oct 2021 11:08:24 -0700 Subject: [PATCH 28/90] Update LiteCore (#239) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index af93ae75..1c86dfe5 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit af93ae7594a2598b36c66a1e70365f268971888c +Subproject commit 1c86dfe529ae443e75f085c5ce8e806084cd7418 From d4e23fb570a47fa438d7bab7b47a964133c6627b Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Fri, 29 Oct 2021 22:07:29 +0000 Subject: [PATCH 29/90] Disable Android library stripping (#237) It will happen anyway when building an app, and this way the distributed file can be upload to crash reporting services for proper symbolication --- jenkins/ci_build_android.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/ci_build_android.sh b/jenkins/ci_build_android.sh index d126d377..aca06a66 100644 --- a/jenkins/ci_build_android.sh +++ b/jenkins/ci_build_android.sh @@ -63,7 +63,7 @@ function build_variant { -DEDITION=$EDITION \ .. - ${CMAKE_PATH}/ninja install/strip + ${CMAKE_PATH}/ninja install } ln -sf ${WORKSPACE}/couchbase-lite-c-ee/couchbase-lite-core-EE ${WORKSPACE}/couchbase-lite-c/vendor/couchbase-lite-core-EE From 6eb020e00b2b35ecea406c5033d820fe83aaa706 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 1 Nov 2021 10:11:19 -0700 Subject: [PATCH 30/90] Update LiteCore for Beta3 --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 1c86dfe5..98b4442e 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 1c86dfe529ae443e75f085c5ce8e806084cd7418 +Subproject commit 98b4442e4b914caf3a2d28c71a33d1701b2bfa1d From 5a1a9f7749dd730a1c83dfcf665d945fd4e8cd8b Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 4 Nov 2021 09:53:11 -0700 Subject: [PATCH 31/90] CBL-2537 : Fix iOS and macOS deployment target version (#243) iOS is 10.0 and macOS is 10.14 --- CMakeLists.txt | 2 +- Xcode/xcconfigs/Project.xcconfig | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f21beb5a..e0d811e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(NOT DEFINED CMAKE_OSX_SYSROOT) endif() set(CMAKE_OSX_ARCHITECTURES x86_64 arm64) -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) project ( CouchbaseLite_C diff --git a/Xcode/xcconfigs/Project.xcconfig b/Xcode/xcconfigs/Project.xcconfig index fc909bfd..15edf357 100644 --- a/Xcode/xcconfigs/Project.xcconfig +++ b/Xcode/xcconfigs/Project.xcconfig @@ -14,8 +14,8 @@ FLEECE = $(LITECORE)/vendor/fleece CBL_VERSION_STRING = 3.0.0 CBL_BUILD_NUMBER = 0 -IPHONEOS_DEPLOYMENT_TARGET = 11.0 -MACOSX_DEPLOYMENT_TARGET = 10.13 -TVOS_DEPLOYMENT_TARGET = 11.0 +IPHONEOS_DEPLOYMENT_TARGET = 10.0 +MACOSX_DEPLOYMENT_TARGET = 10.14 +TVOS_DEPLOYMENT_TARGET = 10.0 SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator VALID_ARCHS = arm64 x86_64 From c41138c15a59a2f0499b3d0d08a69a567fca65e0 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Fri, 5 Nov 2021 00:39:45 +0000 Subject: [PATCH 32/90] Generate Windows symbols zip for build job (#246) --- jenkins/ci_build_win_desktop.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jenkins/ci_build_win_desktop.ps1 b/jenkins/ci_build_win_desktop.ps1 index 6957083a..badc5a1f 100644 --- a/jenkins/ci_build_win_desktop.ps1 +++ b/jenkins/ci_build_win_desktop.ps1 @@ -90,3 +90,8 @@ if("${Edition}" -eq "enterprise") { } Make-Package "${env:WORKSPACE}\build_x64" "couchbase-lite-c-$Edition-$Version-$BuildNum-windows-x86_64.zip" + +# Windows symbols into a separate archive since they are not included in the "install" anyway +Push-Location "${env:WORKSPACE}\build_x64\MinSizeRel" +& 7za a -tzip -mx9 "${env:WORKSPACE}\couchbase-lite-c-$Edition-$Version-$BuildNum-windows-x86_64-symbols.zip" cblite.pdb +Pop-Location \ No newline at end of file From b13892b0a2ad16acb0477a46c977b080ac1c4140 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Fri, 5 Nov 2021 09:55:28 +0900 Subject: [PATCH 33/90] Fix incorrect build server path on previous commit --- jenkins/ci_build_win_desktop.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/ci_build_win_desktop.ps1 b/jenkins/ci_build_win_desktop.ps1 index badc5a1f..6a0a8916 100644 --- a/jenkins/ci_build_win_desktop.ps1 +++ b/jenkins/ci_build_win_desktop.ps1 @@ -92,6 +92,6 @@ if("${Edition}" -eq "enterprise") { Make-Package "${env:WORKSPACE}\build_x64" "couchbase-lite-c-$Edition-$Version-$BuildNum-windows-x86_64.zip" # Windows symbols into a separate archive since they are not included in the "install" anyway -Push-Location "${env:WORKSPACE}\build_x64\MinSizeRel" +Push-Location "${env:WORKSPACE}\build_x64\couchbase-lite-c\MinSizeRel" & 7za a -tzip -mx9 "${env:WORKSPACE}\couchbase-lite-c-$Edition-$Version-$BuildNum-windows-x86_64-symbols.zip" cblite.pdb Pop-Location \ No newline at end of file From 0e583b4f2e2c3cde084df29711b4cdf0bc452bc2 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 10 Nov 2021 22:27:38 -0800 Subject: [PATCH 34/90] CBL-2548 : Retain database in ListenerToken of CBLDocumentChangeListener (#249) Retain database in the ListenerToken to allow to remove / release the token after closing and releasing the database (using CBLDatabase_Release). On the binding platform that uses GC, the order of releasing the object is not guaranteed so the database might be released before the token. --- src/CBLDatabase.cc | 2 +- test/DatabaseTest.cc | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/CBLDatabase.cc b/src/CBLDatabase.cc index 73b5af20..48b6acf9 100644 --- a/src/CBLDatabase.cc +++ b/src/CBLDatabase.cc @@ -131,7 +131,7 @@ namespace cbl_internal { _db->notify(this, _db, _docID); } - CBLDatabase* _db; + Retained _db; alloc_slice _docID; unique_ptr _c4obs; }; diff --git a/test/DatabaseTest.cc b/test/DatabaseTest.cc index 9bb4b310..f3b10eb9 100644 --- a/test/DatabaseTest.cc +++ b/test/DatabaseTest.cc @@ -1373,6 +1373,30 @@ TEST_CASE_METHOD(DatabaseTest, "Database notifications") { } +TEST_CASE_METHOD(DatabaseTest, "Remove Database Listener after releasing database") { + // Add a listener: + dbListenerCalls = fooListenerCalls = 0; + auto token = CBLDatabase_AddChangeListener(db, dbListener, this); + auto docToken = CBLDatabase_AddDocumentChangeListener(db, "foo"_sl, fooListener, this); + + // Create a doc, check that the listener was called: + createDocument(db, "foo", "greeting", "Howdy!"); + CHECK(dbListenerCalls == 1); + CHECK(fooListenerCalls == 1); + + // Close and release the database: + CBLError error; + if (!CBLDatabase_Close(db, &error)) + WARN("Failed to close database: " << error.domain << "/" << error.code); + CBLDatabase_Release(db); + db = nullptr; + + // Remove and release the token: + CBLListener_Remove(token); + CBLListener_Remove(docToken); +} + + static int notificationsReadyCalls = 0; static void notificationsReady(void *context, CBLDatabase* db) { From 33b8f90e8a2afc78ddb943521f069f4e46f4ee8b Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Sat, 20 Nov 2021 00:51:27 +0000 Subject: [PATCH 35/90] Update README.md Add note about Xcode 13 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 20b44a27..f29aa674 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ The resulting (debug by default) library is `Debug\cblite.dll`. ### With Xcode on macOS +:warning: Do not use Xcode 13 because of a [downstream issue](https://github.com/ARMmbed/mbedtls/issues/5052) :warning: + 1. Clone the repo 2. Check out submodules (recursively), i.e. `git submodule update --init --recursive` 3. Open the Xcode project in the `Xcode` subfolder From 0aa15fb91d8aedcc41fff74acf4f8596985184a2 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 29 Nov 2021 10:49:36 -0800 Subject: [PATCH 36/90] Update LiteCore --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 98b4442e..cb8f7c9f 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 98b4442e4b914caf3a2d28c71a33d1701b2bfa1d +Subproject commit cb8f7c9fc8eb70b7b509f5043ce55c2f042adf84 From a6c597de72619fd1bc904fbc120728413d86d05f Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 30 Nov 2021 16:18:54 -0800 Subject: [PATCH 37/90] CBL-2609 : Fix setting SQLite temp dir for Android (#254) Set to CBLInitContext.tempDir instead of filesDir. --- src/Internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Internal.cc b/src/Internal.cc index 3e9a4d90..fe2383b2 100644 --- a/src/Internal.cc +++ b/src/Internal.cc @@ -76,7 +76,7 @@ namespace cbl_internal { tempDir.mustExistAsDir(); C4Error c4err; - if (!c4_setTempDir(FLStr(context.filesDir), &c4err)) { + if (!c4_setTempDir(FLStr(context.tempDir), &c4err)) { C4Error::raise(c4err); } From a30b2fa012c27f82a267a150e060a7e8852c74be Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Tue, 30 Nov 2021 16:19:07 -0800 Subject: [PATCH 38/90] API: Added `CBLBlobReader_Seek`, `CBLBlobReader_Position` (#251) This looks like an accidental omission from the API. Other platforms' read streams support seeking. CBL-2573 --- include/cbl/CBLBlob.h | 21 +++++++ src/CBLBlob_CAPI.cc | 14 +++++ src/CBLBlob_Internal.hh | 33 ++++++++-- src/exports/CBL_Exports.txt | 2 + src/exports/generated/CBL.def | 2 + src/exports/generated/CBL.exp | 2 + src/exports/generated/CBL.gnu | 2 + src/exports/generated/CBL_Android.gnu | 2 + src/exports/generated/CBL_EE.def | 2 + src/exports/generated/CBL_EE.exp | 2 + src/exports/generated/CBL_EE.gnu | 2 + src/exports/generated/CBL_EE_Android.gnu | 2 + test/BlobTest.cc | 77 +++++++++++++++++++----- 13 files changed, 145 insertions(+), 18 deletions(-) diff --git a/include/cbl/CBLBlob.h b/include/cbl/CBLBlob.h index af0be2c6..d6a03829 100644 --- a/include/cbl/CBLBlob.h +++ b/include/cbl/CBLBlob.h @@ -125,6 +125,27 @@ CBL_CAPI_BEGIN size_t maxLength, CBLError* _cbl_nullable outError) CBLAPI; + /** Defines the interpretation of `offset` in \ref CBLBlobReader_Seek. */ + typedef CBL_ENUM(uint8_t, CBLSeekBase) { + kCBLSeekModeFromStart, ///< Offset is an absolute position starting from 0 + kCBLSeekModeRelative, ///< Offset is relative to the current stream position + kCBLSeekModeFromEnd ///< Offset is relative to the end of the blob + }; + + /** Sets the position of a CBLBlobReadStream. + @param stream The stream to reposition. + @param offset The byte offset in the stream (relative to the `mode`). + @param base The base position from which the offset is calculated. + @param outError On failure, an error will be stored here if non-NULL. + @return The new absolute position, or -1 on failure. */ + int64_t CBLBlobReader_Seek(CBLBlobReadStream* stream, + int64_t offset, + CBLSeekBase base, + CBLError* _cbl_nullable outError) CBLAPI; + + /** Returns the current position of a CBLBlobReadStream. */ + uint64_t CBLBlobReader_Position(CBLBlobReadStream* stream) CBLAPI; + /** Closes a CBLBlobReadStream. */ void CBLBlobReader_Close(CBLBlobReadStream* _cbl_nullable) CBLAPI; diff --git a/src/CBLBlob_CAPI.cc b/src/CBLBlob_CAPI.cc index 5b3a9e1f..20f6d42e 100644 --- a/src/CBLBlob_CAPI.cc +++ b/src/CBLBlob_CAPI.cc @@ -70,6 +70,20 @@ int CBLBlobReader_Read(CBLBlobReadStream* stream, } catchAndBridgeReturning(outError, -1) } +int64_t CBLBlobReader_Seek(CBLBlobReadStream* stream, + int64_t position, + CBLSeekBase base, + CBLError *outError) noexcept +{ + try { + return stream->seek(position, base); + } catchAndBridgeReturning(outError, -1); +} + +uint64_t CBLBlobReader_Position(CBLBlobReadStream* stream) noexcept { + return stream->position(); +} + void CBLBlobReader_Close(CBLBlobReadStream* stream) noexcept { delete stream; } diff --git a/src/CBLBlob_Internal.hh b/src/CBLBlob_Internal.hh index a6254750..2b133b60 100644 --- a/src/CBLBlob_Internal.hh +++ b/src/CBLBlob_Internal.hh @@ -207,12 +207,37 @@ private: struct CBLBlobReadStream { - CBLBlobReadStream(const CBLBlob &blob) :_c4stream(*blob.blobStore(), blob.key()) { } - size_t read(void *buffer, size_t maxBytes) {return _c4stream.read(buffer, maxBytes);} - int64_t getLength() const {return _c4stream.getLength();} - void seek(int64_t pos) {return _c4stream.seek(pos);} + CBLBlobReadStream(const CBLBlob &blob) + :_c4stream(*blob.blobStore(), blob.key()) + { } + + size_t read(void *buffer, size_t maxBytes) { + size_t n = _c4stream.read(buffer, maxBytes); + _pos += n; + return n; + } + + int64_t seek(int64_t pos, CBLSeekBase base) { + switch (base) { + case kCBLSeekModeFromStart: break; + case kCBLSeekModeRelative: pos += _pos; break; + case kCBLSeekModeFromEnd: pos += _c4stream.getLength(); break; + } + if (pos < 0) + C4Error::raise(LiteCoreDomain, kC4ErrorInvalidParameter, "Seek to negative position"); + pos = std::min(pos, _c4stream.getLength()); + _c4stream.seek(pos); + _pos = pos; + return pos; + } + + uint64_t position() const noexcept {return _pos;} + + int64_t length() const {return _c4stream.getLength();} + private: C4ReadStream _c4stream; + uint64_t _pos = 0; }; diff --git a/src/exports/CBL_Exports.txt b/src/exports/CBL_Exports.txt index 5ccdcd38..0fd29bd7 100644 --- a/src/exports/CBL_Exports.txt +++ b/src/exports/CBL_Exports.txt @@ -44,6 +44,8 @@ CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read +CBLBlobReader_Position +CBLBlobReader_Seek CBLBlobReader_Close CBLBlobWriter_Create CBLBlobWriter_Close diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index 5132c7ab..1c12ec2a 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -30,6 +30,8 @@ CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read +CBLBlobReader_Position +CBLBlobReader_Seek CBLBlobReader_Close CBLBlobWriter_Create CBLBlobWriter_Close diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index b41672f8..62864896 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -28,6 +28,8 @@ _CBLBlob_CreateJSON _CBLBlob_CreateWithData _CBLBlob_CreateWithStream _CBLBlobReader_Read +_CBLBlobReader_Position +_CBLBlobReader_Seek _CBLBlobReader_Close _CBLBlobWriter_Create _CBLBlobWriter_Close diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index 9bd3cb43..05693b96 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -28,6 +28,8 @@ CBL_C { CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; + CBLBlobReader_Position; + CBLBlobReader_Seek; CBLBlobReader_Close; CBLBlobWriter_Create; CBLBlobWriter_Close; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index f33933bf..16a01c7b 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -29,6 +29,8 @@ CBL_C { CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; + CBLBlobReader_Position; + CBLBlobReader_Seek; CBLBlobReader_Close; CBLBlobWriter_Create; CBLBlobWriter_Close; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index d404a4af..0b599fbe 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -50,6 +50,8 @@ CBLBlob_CreateJSON CBLBlob_CreateWithData CBLBlob_CreateWithStream CBLBlobReader_Read +CBLBlobReader_Position +CBLBlobReader_Seek CBLBlobReader_Close CBLBlobWriter_Create CBLBlobWriter_Close diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index 3cc8222e..15646432 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -48,6 +48,8 @@ _CBLBlob_CreateJSON _CBLBlob_CreateWithData _CBLBlob_CreateWithStream _CBLBlobReader_Read +_CBLBlobReader_Position +_CBLBlobReader_Seek _CBLBlobReader_Close _CBLBlobWriter_Create _CBLBlobWriter_Close diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index fdfe65a6..0c5e4fce 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -48,6 +48,8 @@ CBL_C { CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; + CBLBlobReader_Position; + CBLBlobReader_Seek; CBLBlobReader_Close; CBLBlobWriter_Create; CBLBlobWriter_Close; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index 1e6ed3d2..1a42bccc 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -49,6 +49,8 @@ CBL_C { CBLBlob_CreateWithData; CBLBlob_CreateWithStream; CBLBlobReader_Read; + CBLBlobReader_Position; + CBLBlobReader_Seek; CBLBlobReader_Close; CBLBlobWriter_Create; CBLBlobWriter_Close; diff --git a/test/BlobTest.cc b/test/BlobTest.cc index 1f295d0a..f7f1d4fb 100644 --- a/test/BlobTest.cc +++ b/test/BlobTest.cc @@ -67,27 +67,76 @@ TEST_CASE_METHOD(BlobTest, "Create blob stream and close", "[Blob]") { TEST_CASE_METHOD(BlobTest, "Create blob with stream", "[Blob]") { - alloc_slice content("This is the content of the blob 1."); - - // Create and close stream with out creating blob: + static constexpr slice kBlobContent = "This is the content of the blob 1."; CBLError error; - CBLBlobWriteStream* ws = CBLBlobWriter_Create(db, &error); - CBLBlobWriter_Write(ws, content.buf, content.size, &error); - CBLBlob* blob = CBLBlob_CreateWithStream("text/plain"_sl, ws); - + CBLBlob *blob; + { + CBLBlobWriteStream* ws = CBLBlobWriter_Create(db, &error); + REQUIRE(ws); + REQUIRE(CBLBlobWriter_Write(ws, &kBlobContent[0], 10, &error)); + REQUIRE(CBLBlobWriter_Write(ws, &kBlobContent[10], kBlobContent.size - 10, &error)); + blob = CBLBlob_CreateWithStream("text/plain"_sl, ws); + REQUIRE(blob); + // Note: After creating a blob with the stream, the created blob will take + // ownership of the stream so do not close the stream. + } + // Set blob in a document and save: auto doc = CBLDocument_CreateWithID("doc1"_sl); auto props = CBLDocument_MutableProperties(doc); FLMutableDict_SetBlob(props, "blob"_sl, blob); CHECK(CBLDatabase_SaveDocument(db, doc, &error)); - // Check content: - FLSliceResult gotContent = CBLBlob_Content(blob, &error); - CHECK(gotContent == content); - FLSliceResult_Release(gotContent); - - // Note: After creating a blob with the stream, the created blob will take - // the ownership of the stream so do not close the stream. + // Read content as a slice: + { + FLSliceResult gotContent = CBLBlob_Content(blob, &error); + CHECK(gotContent == kBlobContent); + FLSliceResult_Release(gotContent); + } + + // Read content as stream: + { + static_assert(kBlobContent.size == 34, "the checks below assume the blob is 34 bytes long"); + char buf[20]; + CBLBlobReadStream *in = CBLBlob_OpenContentStream(blob, &error); + REQUIRE(in); + CHECK(CBLBlobReader_Position(in) == 0); + CHECK(CBLBlobReader_Read(in, buf, 20, &error) == 20); + CHECK(memcmp(buf, &kBlobContent[0], 20) == 0); + + CHECK(CBLBlobReader_Position(in) == 20); + CHECK(CBLBlobReader_Read(in, buf, 20, &error) == 14); + CHECK(memcmp(buf, &kBlobContent[20], 14) == 0); + + CHECK(CBLBlobReader_Position(in) == 34); + CHECK(CBLBlobReader_Read(in, buf, 20, &error) == 0); + + CHECK(CBLBlobReader_Seek(in, 12, kCBLSeekModeFromStart, &error) == 12); + CHECK(CBLBlobReader_Position(in) == 12); + CHECK(CBLBlobReader_Read(in, buf, 7, &error) == 7); + CHECK(memcmp(buf, &kBlobContent[12], 7) == 0); + CHECK(CBLBlobReader_Position(in) == 12 + 7); + + CHECK(CBLBlobReader_Seek(in, 1, kCBLSeekModeRelative, &error) == 20); + CHECK(CBLBlobReader_Position(in) == 20); + + CHECK(CBLBlobReader_Seek(in, -5, kCBLSeekModeFromEnd, &error) == kBlobContent.size - 5); + CHECK(CBLBlobReader_Position(in) == kBlobContent.size - 5); + + // seek past EOF is not error, but pos is pinned to the EOF + CHECK(CBLBlobReader_Seek(in, 9999, kCBLSeekModeFromStart, &error) == kBlobContent.size); + CHECK(CBLBlobReader_Position(in) == kBlobContent.size); + + // but seek to a negative position is an error + ExpectingExceptions x; + CHECK(CBLBlobReader_Seek(in, -999, kCBLSeekModeFromEnd, &error) < 0); + CHECK(error.domain == kCBLDomain); + CHECK(error.code == kCBLErrorInvalidParameter); + CHECK(CBLBlobReader_Position(in) == kBlobContent.size); + + CBLBlobReader_Close(in); + } + CBLBlob_Release(blob); CBLDocument_Release(doc); } From 329f26b739823eb06dd64332c1774029a81ed751 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 6 Dec 2021 20:13:35 -0800 Subject: [PATCH 39/90] Update LiteCore (#256) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index cb8f7c9f..46fea9da 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit cb8f7c9fc8eb70b7b509f5043ce55c2f042adf84 +Subproject commit 46fea9da79548a9c1488269253bc96b906e50f82 From d51c8c33993bf348d8e20d5f4a7d95a1777c82b0 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 8 Dec 2021 19:42:00 -0800 Subject: [PATCH 40/90] Update LiteCore for using poll instead of select (#257) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 46fea9da..627462d5 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 46fea9da79548a9c1488269253bc96b906e50f82 +Subproject commit 627462d5773e7cdafd32e165e25efa5963c506b5 From 91e1b799451c6a62835b03a78c0bf8141dfdcd84 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 9 Dec 2021 14:27:12 -0800 Subject: [PATCH 41/90] Update saveBlob() and getBlob() support level --- include/cbl/CBLBlob.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/cbl/CBLBlob.h b/include/cbl/CBLBlob.h index d6a03829..2b537350 100644 --- a/include/cbl/CBLBlob.h +++ b/include/cbl/CBLBlob.h @@ -251,7 +251,10 @@ CBL_CAPI_BEGIN #pragma mark - BINDING DEV SUPPORT FOR BLOB: #endif - /** Get a \ref CBLBlob object from the database using the \ref CBLBlob properties. + /** (UNCOMMITTED) Use this API if you are developing Javascript language bindings. + If you are developing a native app, you must use the CBLBlob API. + + Get a \ref CBLBlob object from the database using the \ref CBLBlob properties. The \ref CBLBlob properties is a blob's metadata containing two required fields which are a special marker property `"@type":"blob"`, and property `digest` whose value @@ -268,7 +271,10 @@ CBL_CAPI_BEGIN const CBLBlob* _cbl_nullable CBLDatabase_GetBlob(CBLDatabase* db, FLDict properties, CBLError* _cbl_nullable outError) CBLAPI; - /** Save a new \ref CBLBlob object into the database without associating it with + /** (UNCOMMITTED) Use this API if you are developing Javascript language bindings. + If you are developing a native app, you must use the CBLBlob API. + + Save a new \ref CBLBlob object into the database without associating it with any documents. The properties of the saved \ref CBLBlob object will include information necessary for referencing the \ref CBLBlob object in the properties of the document to be saved into the database. From 39c6660725c8ca6552ce505cb3dd1843dba2de92 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 10 Dec 2021 12:49:08 -0800 Subject: [PATCH 42/90] Update LiteCore (#258) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 627462d5..4e04af8b 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 627462d5773e7cdafd32e165e25efa5963c506b5 +Subproject commit 4e04af8b2fc635851491548f523dedf825e943f3 From 08477ffa36a3edee0e532db91bc2151af9eba2da Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 10 Dec 2021 20:24:07 -0800 Subject: [PATCH 43/90] Update LiteCore (#260) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 4e04af8b..cb121569 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 4e04af8b2fc635851491548f523dedf825e943f3 +Subproject commit cb1215693bf3c2c9de32fa469ffdee1172b48a40 From 3b3aa413961edfa2a1dd6b93f7aae82008f2a977 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 16 Dec 2021 16:47:16 -0800 Subject: [PATCH 44/90] Update LiteCore for CBL-2673 (#261) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index cb121569..1d1ea194 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit cb1215693bf3c2c9de32fa469ffdee1172b48a40 +Subproject commit 1d1ea1941fa7688e55fe8c654aec50153e96c7be From 198ca19a79db13c4f7b41867dd9abfd0f0149f7c Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 10 Jan 2022 20:58:38 -0800 Subject: [PATCH 45/90] Update LiteCore (#263) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 1d1ea194..6265d618 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 1d1ea1941fa7688e55fe8c654aec50153e96c7be +Subproject commit 6265d618c78f3f739ea9801de024bfc8c8216f81 From ca3d19020ac2680ff30f8ea86c6c5d4113814abb Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Tue, 11 Jan 2022 15:49:34 -0800 Subject: [PATCH 46/90] Update LiteCore (#265) Update LiteCore for RC2 --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 6265d618..b018a12d 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 6265d618c78f3f739ea9801de024bfc8c8216f81 +Subproject commit b018a12db01222d451b4f7b95478d4825bc19954 From a4dfa85a99c0102b7651e1df03e01567b827b588 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 23 Feb 2022 16:23:37 -0800 Subject: [PATCH 47/90] CBL-2852 : Fix missing fleece symbols (#279) * Added all missing Fleece symbols. * Fixed generate_exports.sh script that left out Fleece_Apple_Exports.txt. * Fixed CBLReplicator_AddDocumentReplicationListener declaration style in CBLReplication.h. --- include/cbl/CBLReplicator.h | 8 ++++---- src/exports/Fleece_Apple_Exports.txt | 3 +++ src/exports/Fleece_Exports.txt | 17 ++++++++++++++++ src/exports/generate_exports.sh | 9 +++++--- src/exports/generated/CBL.def | 16 +++++++++++++++ src/exports/generated/CBL.exp | 26 ++++++++++++++++++++++++ src/exports/generated/CBL.gnu | 16 +++++++++++++++ src/exports/generated/CBL_Android.gnu | 16 +++++++++++++++ src/exports/generated/CBL_EE.def | 16 +++++++++++++++ src/exports/generated/CBL_EE.exp | 26 ++++++++++++++++++++++++ src/exports/generated/CBL_EE.gnu | 16 +++++++++++++++ src/exports/generated/CBL_EE_Android.gnu | 16 +++++++++++++++ 12 files changed, 178 insertions(+), 7 deletions(-) diff --git a/include/cbl/CBLReplicator.h b/include/cbl/CBLReplicator.h index bf803991..cab8f601 100644 --- a/include/cbl/CBLReplicator.h +++ b/include/cbl/CBLReplicator.h @@ -383,10 +383,10 @@ typedef void (*CBLDocumentReplicationListener)(void *context, const CBLReplicatedDocument* documents); /** Adds a listener that will be called when documents are replicated. */ -_cbl_warn_unused CBLListenerToken* -CBLReplicator_AddDocumentReplicationListener(CBLReplicator*, - CBLDocumentReplicationListener, - void* _cbl_nullable context) CBLAPI; +_cbl_warn_unused +CBLListenerToken* CBLReplicator_AddDocumentReplicationListener(CBLReplicator*, + CBLDocumentReplicationListener, + void* _cbl_nullable context) CBLAPI; /** @} */ /** @} */ diff --git a/src/exports/Fleece_Apple_Exports.txt b/src/exports/Fleece_Apple_Exports.txt index 6acca57f..a4e402d2 100644 --- a/src/exports/Fleece_Apple_Exports.txt +++ b/src/exports/Fleece_Apple_Exports.txt @@ -4,6 +4,7 @@ # # Fleece exports for Apple platforms only (interop with Objective-C and CoreFoundation) +FLEncoder_WriteCFObject FLValue_CopyCFObject FLDict_GetWithCFString FLDictIterator_GetKeyAsNSString @@ -13,3 +14,5 @@ FLErrorDomain FLEncoder_WriteNSObject FLEncoder_FinishWithNSData + +FLCreateSharedStringsTable diff --git a/src/exports/Fleece_Exports.txt b/src/exports/Fleece_Exports.txt index 078d66f3..c614744c 100644 --- a/src/exports/Fleece_Exports.txt +++ b/src/exports/Fleece_Exports.txt @@ -27,6 +27,8 @@ FLDoc_GetAllocedData FLDoc_GetData FLDoc_GetRoot FLDoc_GetSharedKeys +FLDoc_SetAssociated +FLDoc_GetAssociated FLData_Dump FLDump @@ -38,6 +40,7 @@ FLValue_IsInteger FLValue_IsUnsigned FLValue_IsDouble FLValue_IsEqual +FLValue_IsMutable FLValue_AsBool FLValue_AsData FLValue_AsInt @@ -55,6 +58,8 @@ FLValue_ToJSON5 FLValue_FindDoc FLValue_Retain FLValue_Release +FLValue_NewString +FLValue_NewData FLData_ConvertJSON FLJSON5_ToJSON @@ -75,6 +80,7 @@ FLMutableArray_New FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged +FLMutableArray_SetChanged FLMutableArray_Append FLMutableArray_Set FLMutableArray_Insert @@ -106,6 +112,8 @@ FLEncoder_NewWithOptions FLEncoder_NewWritingToFile FLEncoder_Free FLEncoder_SetSharedKeys +FLEncoder_SetExtraInfo +FLEncoder_GetExtraInfo FLEncoder_GetBase FLEncoder_SuppressTrailer FLEncoder_WriteRaw @@ -146,6 +154,7 @@ FLMutableDict_New FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged +FLMutableDict_SetChanged FLMutableDict_Set FLMutableDict_Remove FLMutableDict_RemoveAll @@ -167,10 +176,14 @@ FLSharedKeys_Release FLSharedKeys_New FLSharedKeys_LoadStateData FLSharedKeys_LoadState +FLSharedKeys_Encode +FLSharedKeys_Decode +FLSharedKeys_NewWithRead FLSharedKeys_GetStateData FLSharedKeys_Count FLSharedKeys_RevertToCount FLSharedKeys_WriteState +FLSharedKeyScope_WithRange FLKeyPath_New FLKeyPath_Free @@ -178,10 +191,12 @@ FLKeyPath_Eval FLKeyPath_EvalOnce FLKeyPath_ToString FLKeyPath_Equals +FLKeyPath_GetElement FLDeepIterator_New FLDeepIterator_Free FLDeepIterator_GetValue +FLDeepIterator_GetParent FLDeepIterator_GetKey FLDeepIterator_GetIndex FLDeepIterator_GetDepth @@ -190,3 +205,5 @@ FLDeepIterator_Next FLDeepIterator_GetPath FLDeepIterator_GetPathString FLDeepIterator_GetJSONPointer + +FL_WipeMemory diff --git a/src/exports/generate_exports.sh b/src/exports/generate_exports.sh index eb998107..45ac4026 100755 --- a/src/exports/generate_exports.sh +++ b/src/exports/generate_exports.sh @@ -11,17 +11,20 @@ cd "$SCRIPT_DIR/generated" cat ../CBL_Exports.txt ../Fleece_Exports.txt >exports.txt cat ../CBL_EE_Exports.txt exports.txt >exports_ee.txt +cat ../Fleece_Apple_Exports.txt exports.txt >apple_exports.txt +cat ../Fleece_Apple_Exports.txt exports_ee.txt >apple_exports_ee.txt + cat ../CBL_Android_Exports.txt exports.txt >android_exports.txt cat ../CBL_Android_Exports.txt exports_ee.txt >android_exports_ee.txt -../format_apple.awk CBL.exp +../format_apple.awk CBL.exp ../format_linux.awk CBL.gnu ../format_linux.awk CBL_Android.gnu ../format_windows.awk CBL.def -../format_apple.awk CBL_EE.exp +../format_apple.awk CBL_EE.exp ../format_linux.awk CBL_EE.gnu ../format_linux.awk CBL_EE_Android.gnu ../format_windows.awk CBL_EE.def -rm exports.txt exports_ee.txt android_exports.txt android_exports_ee.txt +rm *exports*.txt diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index 1c12ec2a..5024026d 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -153,6 +153,8 @@ FLDoc_GetAllocedData FLDoc_GetData FLDoc_GetRoot FLDoc_GetSharedKeys +FLDoc_SetAssociated +FLDoc_GetAssociated FLData_Dump FLDump FLDumpData @@ -162,6 +164,7 @@ FLValue_IsInteger FLValue_IsUnsigned FLValue_IsDouble FLValue_IsEqual +FLValue_IsMutable FLValue_AsBool FLValue_AsData FLValue_AsInt @@ -179,6 +182,8 @@ FLValue_ToJSON5 FLValue_FindDoc FLValue_Retain FLValue_Release +FLValue_NewString +FLValue_NewData FLData_ConvertJSON FLJSON5_ToJSON FLArray_Count @@ -195,6 +200,7 @@ FLMutableArray_New FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged +FLMutableArray_SetChanged FLMutableArray_Append FLMutableArray_Set FLMutableArray_Insert @@ -222,6 +228,8 @@ FLEncoder_NewWithOptions FLEncoder_NewWritingToFile FLEncoder_Free FLEncoder_SetSharedKeys +FLEncoder_SetExtraInfo +FLEncoder_GetExtraInfo FLEncoder_GetBase FLEncoder_SuppressTrailer FLEncoder_WriteRaw @@ -260,6 +268,7 @@ FLMutableDict_New FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged +FLMutableDict_SetChanged FLMutableDict_Set FLMutableDict_Remove FLMutableDict_RemoveAll @@ -279,19 +288,25 @@ FLSharedKeys_Release FLSharedKeys_New FLSharedKeys_LoadStateData FLSharedKeys_LoadState +FLSharedKeys_Encode +FLSharedKeys_Decode +FLSharedKeys_NewWithRead FLSharedKeys_GetStateData FLSharedKeys_Count FLSharedKeys_RevertToCount FLSharedKeys_WriteState +FLSharedKeyScope_WithRange FLKeyPath_New FLKeyPath_Free FLKeyPath_Eval FLKeyPath_EvalOnce FLKeyPath_ToString FLKeyPath_Equals +FLKeyPath_GetElement FLDeepIterator_New FLDeepIterator_Free FLDeepIterator_GetValue +FLDeepIterator_GetParent FLDeepIterator_GetKey FLDeepIterator_GetIndex FLDeepIterator_GetDepth @@ -300,3 +315,4 @@ FLDeepIterator_Next FLDeepIterator_GetPath FLDeepIterator_GetPathString FLDeepIterator_GetJSONPointer +FL_WipeMemory diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index 62864896..51da20ed 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -1,5 +1,15 @@ # GENERATED BY generate_exports.sh -- DO NOT EDIT +_FLEncoder_WriteCFObject +_FLValue_CopyCFObject +_FLDict_GetWithCFString +_FLDictIterator_GetKeyAsNSString +_FLValue_GetNSObject +_FLDict_GetWithNSString +_FLErrorDomain +_FLEncoder_WriteNSObject +_FLEncoder_FinishWithNSData +_FLCreateSharedStringsTable _CBL_Retain _CBL_Release _CBL_InstanceCount @@ -151,6 +161,8 @@ _FLDoc_GetAllocedData _FLDoc_GetData _FLDoc_GetRoot _FLDoc_GetSharedKeys +_FLDoc_SetAssociated +_FLDoc_GetAssociated _FLData_Dump _FLDump _FLDumpData @@ -160,6 +172,7 @@ _FLValue_IsInteger _FLValue_IsUnsigned _FLValue_IsDouble _FLValue_IsEqual +_FLValue_IsMutable _FLValue_AsBool _FLValue_AsData _FLValue_AsInt @@ -177,6 +190,8 @@ _FLValue_ToJSON5 _FLValue_FindDoc _FLValue_Retain _FLValue_Release +_FLValue_NewString +_FLValue_NewData _FLData_ConvertJSON _FLJSON5_ToJSON _FLArray_Count @@ -193,6 +208,7 @@ _FLMutableArray_New _FLMutableArray_NewFromJSON _FLMutableArray_GetSource _FLMutableArray_IsChanged +_FLMutableArray_SetChanged _FLMutableArray_Append _FLMutableArray_Set _FLMutableArray_Insert @@ -220,6 +236,8 @@ _FLEncoder_NewWithOptions _FLEncoder_NewWritingToFile _FLEncoder_Free _FLEncoder_SetSharedKeys +_FLEncoder_SetExtraInfo +_FLEncoder_GetExtraInfo _FLEncoder_GetBase _FLEncoder_SuppressTrailer _FLEncoder_WriteRaw @@ -258,6 +276,7 @@ _FLMutableDict_New _FLMutableDict_NewFromJSON _FLMutableDict_GetSource _FLMutableDict_IsChanged +_FLMutableDict_SetChanged _FLMutableDict_Set _FLMutableDict_Remove _FLMutableDict_RemoveAll @@ -277,19 +296,25 @@ _FLSharedKeys_Release _FLSharedKeys_New _FLSharedKeys_LoadStateData _FLSharedKeys_LoadState +_FLSharedKeys_Encode +_FLSharedKeys_Decode +_FLSharedKeys_NewWithRead _FLSharedKeys_GetStateData _FLSharedKeys_Count _FLSharedKeys_RevertToCount _FLSharedKeys_WriteState +_FLSharedKeyScope_WithRange _FLKeyPath_New _FLKeyPath_Free _FLKeyPath_Eval _FLKeyPath_EvalOnce _FLKeyPath_ToString _FLKeyPath_Equals +_FLKeyPath_GetElement _FLDeepIterator_New _FLDeepIterator_Free _FLDeepIterator_GetValue +_FLDeepIterator_GetParent _FLDeepIterator_GetKey _FLDeepIterator_GetIndex _FLDeepIterator_GetDepth @@ -298,3 +323,4 @@ _FLDeepIterator_Next _FLDeepIterator_GetPath _FLDeepIterator_GetPathString _FLDeepIterator_GetJSONPointer +_FL_WipeMemory diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index 05693b96..cf12d158 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -151,6 +151,8 @@ CBL_C { FLDoc_GetData; FLDoc_GetRoot; FLDoc_GetSharedKeys; + FLDoc_SetAssociated; + FLDoc_GetAssociated; FLData_Dump; FLDump; FLDumpData; @@ -160,6 +162,7 @@ CBL_C { FLValue_IsUnsigned; FLValue_IsDouble; FLValue_IsEqual; + FLValue_IsMutable; FLValue_AsBool; FLValue_AsData; FLValue_AsInt; @@ -177,6 +180,8 @@ CBL_C { FLValue_FindDoc; FLValue_Retain; FLValue_Release; + FLValue_NewString; + FLValue_NewData; FLData_ConvertJSON; FLJSON5_ToJSON; FLArray_Count; @@ -193,6 +198,7 @@ CBL_C { FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; + FLMutableArray_SetChanged; FLMutableArray_Append; FLMutableArray_Set; FLMutableArray_Insert; @@ -220,6 +226,8 @@ CBL_C { FLEncoder_NewWritingToFile; FLEncoder_Free; FLEncoder_SetSharedKeys; + FLEncoder_SetExtraInfo; + FLEncoder_GetExtraInfo; FLEncoder_GetBase; FLEncoder_SuppressTrailer; FLEncoder_WriteRaw; @@ -258,6 +266,7 @@ CBL_C { FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; + FLMutableDict_SetChanged; FLMutableDict_Set; FLMutableDict_Remove; FLMutableDict_RemoveAll; @@ -277,19 +286,25 @@ CBL_C { FLSharedKeys_New; FLSharedKeys_LoadStateData; FLSharedKeys_LoadState; + FLSharedKeys_Encode; + FLSharedKeys_Decode; + FLSharedKeys_NewWithRead; FLSharedKeys_GetStateData; FLSharedKeys_Count; FLSharedKeys_RevertToCount; FLSharedKeys_WriteState; + FLSharedKeyScope_WithRange; FLKeyPath_New; FLKeyPath_Free; FLKeyPath_Eval; FLKeyPath_EvalOnce; FLKeyPath_ToString; FLKeyPath_Equals; + FLKeyPath_GetElement; FLDeepIterator_New; FLDeepIterator_Free; FLDeepIterator_GetValue; + FLDeepIterator_GetParent; FLDeepIterator_GetKey; FLDeepIterator_GetIndex; FLDeepIterator_GetDepth; @@ -298,6 +313,7 @@ CBL_C { FLDeepIterator_GetPath; FLDeepIterator_GetPathString; FLDeepIterator_GetJSONPointer; + FL_WipeMemory; local: *; }; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index 16a01c7b..2bd41015 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -152,6 +152,8 @@ CBL_C { FLDoc_GetData; FLDoc_GetRoot; FLDoc_GetSharedKeys; + FLDoc_SetAssociated; + FLDoc_GetAssociated; FLData_Dump; FLDump; FLDumpData; @@ -161,6 +163,7 @@ CBL_C { FLValue_IsUnsigned; FLValue_IsDouble; FLValue_IsEqual; + FLValue_IsMutable; FLValue_AsBool; FLValue_AsData; FLValue_AsInt; @@ -178,6 +181,8 @@ CBL_C { FLValue_FindDoc; FLValue_Retain; FLValue_Release; + FLValue_NewString; + FLValue_NewData; FLData_ConvertJSON; FLJSON5_ToJSON; FLArray_Count; @@ -194,6 +199,7 @@ CBL_C { FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; + FLMutableArray_SetChanged; FLMutableArray_Append; FLMutableArray_Set; FLMutableArray_Insert; @@ -221,6 +227,8 @@ CBL_C { FLEncoder_NewWritingToFile; FLEncoder_Free; FLEncoder_SetSharedKeys; + FLEncoder_SetExtraInfo; + FLEncoder_GetExtraInfo; FLEncoder_GetBase; FLEncoder_SuppressTrailer; FLEncoder_WriteRaw; @@ -259,6 +267,7 @@ CBL_C { FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; + FLMutableDict_SetChanged; FLMutableDict_Set; FLMutableDict_Remove; FLMutableDict_RemoveAll; @@ -278,19 +287,25 @@ CBL_C { FLSharedKeys_New; FLSharedKeys_LoadStateData; FLSharedKeys_LoadState; + FLSharedKeys_Encode; + FLSharedKeys_Decode; + FLSharedKeys_NewWithRead; FLSharedKeys_GetStateData; FLSharedKeys_Count; FLSharedKeys_RevertToCount; FLSharedKeys_WriteState; + FLSharedKeyScope_WithRange; FLKeyPath_New; FLKeyPath_Free; FLKeyPath_Eval; FLKeyPath_EvalOnce; FLKeyPath_ToString; FLKeyPath_Equals; + FLKeyPath_GetElement; FLDeepIterator_New; FLDeepIterator_Free; FLDeepIterator_GetValue; + FLDeepIterator_GetParent; FLDeepIterator_GetKey; FLDeepIterator_GetIndex; FLDeepIterator_GetDepth; @@ -299,6 +314,7 @@ CBL_C { FLDeepIterator_GetPath; FLDeepIterator_GetPathString; FLDeepIterator_GetJSONPointer; + FL_WipeMemory; local: *; }; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index 0b599fbe..5d4fc2fb 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -173,6 +173,8 @@ FLDoc_GetAllocedData FLDoc_GetData FLDoc_GetRoot FLDoc_GetSharedKeys +FLDoc_SetAssociated +FLDoc_GetAssociated FLData_Dump FLDump FLDumpData @@ -182,6 +184,7 @@ FLValue_IsInteger FLValue_IsUnsigned FLValue_IsDouble FLValue_IsEqual +FLValue_IsMutable FLValue_AsBool FLValue_AsData FLValue_AsInt @@ -199,6 +202,8 @@ FLValue_ToJSON5 FLValue_FindDoc FLValue_Retain FLValue_Release +FLValue_NewString +FLValue_NewData FLData_ConvertJSON FLJSON5_ToJSON FLArray_Count @@ -215,6 +220,7 @@ FLMutableArray_New FLMutableArray_NewFromJSON FLMutableArray_GetSource FLMutableArray_IsChanged +FLMutableArray_SetChanged FLMutableArray_Append FLMutableArray_Set FLMutableArray_Insert @@ -242,6 +248,8 @@ FLEncoder_NewWithOptions FLEncoder_NewWritingToFile FLEncoder_Free FLEncoder_SetSharedKeys +FLEncoder_SetExtraInfo +FLEncoder_GetExtraInfo FLEncoder_GetBase FLEncoder_SuppressTrailer FLEncoder_WriteRaw @@ -280,6 +288,7 @@ FLMutableDict_New FLMutableDict_NewFromJSON FLMutableDict_GetSource FLMutableDict_IsChanged +FLMutableDict_SetChanged FLMutableDict_Set FLMutableDict_Remove FLMutableDict_RemoveAll @@ -299,19 +308,25 @@ FLSharedKeys_Release FLSharedKeys_New FLSharedKeys_LoadStateData FLSharedKeys_LoadState +FLSharedKeys_Encode +FLSharedKeys_Decode +FLSharedKeys_NewWithRead FLSharedKeys_GetStateData FLSharedKeys_Count FLSharedKeys_RevertToCount FLSharedKeys_WriteState +FLSharedKeyScope_WithRange FLKeyPath_New FLKeyPath_Free FLKeyPath_Eval FLKeyPath_EvalOnce FLKeyPath_ToString FLKeyPath_Equals +FLKeyPath_GetElement FLDeepIterator_New FLDeepIterator_Free FLDeepIterator_GetValue +FLDeepIterator_GetParent FLDeepIterator_GetKey FLDeepIterator_GetIndex FLDeepIterator_GetDepth @@ -320,3 +335,4 @@ FLDeepIterator_Next FLDeepIterator_GetPath FLDeepIterator_GetPathString FLDeepIterator_GetJSONPointer +FL_WipeMemory diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index 15646432..7fed1b44 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -1,5 +1,15 @@ # GENERATED BY generate_exports.sh -- DO NOT EDIT +_FLEncoder_WriteCFObject +_FLValue_CopyCFObject +_FLDict_GetWithCFString +_FLDictIterator_GetKeyAsNSString +_FLValue_GetNSObject +_FLDict_GetWithNSString +_FLErrorDomain +_FLEncoder_WriteNSObject +_FLEncoder_FinishWithNSData +_FLCreateSharedStringsTable _CBLEncryptionKey_FromPassword _CBLDatabase_ChangeEncryptionKey _CBLEndpoint_CreateWithLocalDB @@ -171,6 +181,8 @@ _FLDoc_GetAllocedData _FLDoc_GetData _FLDoc_GetRoot _FLDoc_GetSharedKeys +_FLDoc_SetAssociated +_FLDoc_GetAssociated _FLData_Dump _FLDump _FLDumpData @@ -180,6 +192,7 @@ _FLValue_IsInteger _FLValue_IsUnsigned _FLValue_IsDouble _FLValue_IsEqual +_FLValue_IsMutable _FLValue_AsBool _FLValue_AsData _FLValue_AsInt @@ -197,6 +210,8 @@ _FLValue_ToJSON5 _FLValue_FindDoc _FLValue_Retain _FLValue_Release +_FLValue_NewString +_FLValue_NewData _FLData_ConvertJSON _FLJSON5_ToJSON _FLArray_Count @@ -213,6 +228,7 @@ _FLMutableArray_New _FLMutableArray_NewFromJSON _FLMutableArray_GetSource _FLMutableArray_IsChanged +_FLMutableArray_SetChanged _FLMutableArray_Append _FLMutableArray_Set _FLMutableArray_Insert @@ -240,6 +256,8 @@ _FLEncoder_NewWithOptions _FLEncoder_NewWritingToFile _FLEncoder_Free _FLEncoder_SetSharedKeys +_FLEncoder_SetExtraInfo +_FLEncoder_GetExtraInfo _FLEncoder_GetBase _FLEncoder_SuppressTrailer _FLEncoder_WriteRaw @@ -278,6 +296,7 @@ _FLMutableDict_New _FLMutableDict_NewFromJSON _FLMutableDict_GetSource _FLMutableDict_IsChanged +_FLMutableDict_SetChanged _FLMutableDict_Set _FLMutableDict_Remove _FLMutableDict_RemoveAll @@ -297,19 +316,25 @@ _FLSharedKeys_Release _FLSharedKeys_New _FLSharedKeys_LoadStateData _FLSharedKeys_LoadState +_FLSharedKeys_Encode +_FLSharedKeys_Decode +_FLSharedKeys_NewWithRead _FLSharedKeys_GetStateData _FLSharedKeys_Count _FLSharedKeys_RevertToCount _FLSharedKeys_WriteState +_FLSharedKeyScope_WithRange _FLKeyPath_New _FLKeyPath_Free _FLKeyPath_Eval _FLKeyPath_EvalOnce _FLKeyPath_ToString _FLKeyPath_Equals +_FLKeyPath_GetElement _FLDeepIterator_New _FLDeepIterator_Free _FLDeepIterator_GetValue +_FLDeepIterator_GetParent _FLDeepIterator_GetKey _FLDeepIterator_GetIndex _FLDeepIterator_GetDepth @@ -318,3 +343,4 @@ _FLDeepIterator_Next _FLDeepIterator_GetPath _FLDeepIterator_GetPathString _FLDeepIterator_GetJSONPointer +_FL_WipeMemory diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index 0c5e4fce..fd98a923 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -171,6 +171,8 @@ CBL_C { FLDoc_GetData; FLDoc_GetRoot; FLDoc_GetSharedKeys; + FLDoc_SetAssociated; + FLDoc_GetAssociated; FLData_Dump; FLDump; FLDumpData; @@ -180,6 +182,7 @@ CBL_C { FLValue_IsUnsigned; FLValue_IsDouble; FLValue_IsEqual; + FLValue_IsMutable; FLValue_AsBool; FLValue_AsData; FLValue_AsInt; @@ -197,6 +200,8 @@ CBL_C { FLValue_FindDoc; FLValue_Retain; FLValue_Release; + FLValue_NewString; + FLValue_NewData; FLData_ConvertJSON; FLJSON5_ToJSON; FLArray_Count; @@ -213,6 +218,7 @@ CBL_C { FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; + FLMutableArray_SetChanged; FLMutableArray_Append; FLMutableArray_Set; FLMutableArray_Insert; @@ -240,6 +246,8 @@ CBL_C { FLEncoder_NewWritingToFile; FLEncoder_Free; FLEncoder_SetSharedKeys; + FLEncoder_SetExtraInfo; + FLEncoder_GetExtraInfo; FLEncoder_GetBase; FLEncoder_SuppressTrailer; FLEncoder_WriteRaw; @@ -278,6 +286,7 @@ CBL_C { FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; + FLMutableDict_SetChanged; FLMutableDict_Set; FLMutableDict_Remove; FLMutableDict_RemoveAll; @@ -297,19 +306,25 @@ CBL_C { FLSharedKeys_New; FLSharedKeys_LoadStateData; FLSharedKeys_LoadState; + FLSharedKeys_Encode; + FLSharedKeys_Decode; + FLSharedKeys_NewWithRead; FLSharedKeys_GetStateData; FLSharedKeys_Count; FLSharedKeys_RevertToCount; FLSharedKeys_WriteState; + FLSharedKeyScope_WithRange; FLKeyPath_New; FLKeyPath_Free; FLKeyPath_Eval; FLKeyPath_EvalOnce; FLKeyPath_ToString; FLKeyPath_Equals; + FLKeyPath_GetElement; FLDeepIterator_New; FLDeepIterator_Free; FLDeepIterator_GetValue; + FLDeepIterator_GetParent; FLDeepIterator_GetKey; FLDeepIterator_GetIndex; FLDeepIterator_GetDepth; @@ -318,6 +333,7 @@ CBL_C { FLDeepIterator_GetPath; FLDeepIterator_GetPathString; FLDeepIterator_GetJSONPointer; + FL_WipeMemory; local: *; }; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index 1a42bccc..b2e88790 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -172,6 +172,8 @@ CBL_C { FLDoc_GetData; FLDoc_GetRoot; FLDoc_GetSharedKeys; + FLDoc_SetAssociated; + FLDoc_GetAssociated; FLData_Dump; FLDump; FLDumpData; @@ -181,6 +183,7 @@ CBL_C { FLValue_IsUnsigned; FLValue_IsDouble; FLValue_IsEqual; + FLValue_IsMutable; FLValue_AsBool; FLValue_AsData; FLValue_AsInt; @@ -198,6 +201,8 @@ CBL_C { FLValue_FindDoc; FLValue_Retain; FLValue_Release; + FLValue_NewString; + FLValue_NewData; FLData_ConvertJSON; FLJSON5_ToJSON; FLArray_Count; @@ -214,6 +219,7 @@ CBL_C { FLMutableArray_NewFromJSON; FLMutableArray_GetSource; FLMutableArray_IsChanged; + FLMutableArray_SetChanged; FLMutableArray_Append; FLMutableArray_Set; FLMutableArray_Insert; @@ -241,6 +247,8 @@ CBL_C { FLEncoder_NewWritingToFile; FLEncoder_Free; FLEncoder_SetSharedKeys; + FLEncoder_SetExtraInfo; + FLEncoder_GetExtraInfo; FLEncoder_GetBase; FLEncoder_SuppressTrailer; FLEncoder_WriteRaw; @@ -279,6 +287,7 @@ CBL_C { FLMutableDict_NewFromJSON; FLMutableDict_GetSource; FLMutableDict_IsChanged; + FLMutableDict_SetChanged; FLMutableDict_Set; FLMutableDict_Remove; FLMutableDict_RemoveAll; @@ -298,19 +307,25 @@ CBL_C { FLSharedKeys_New; FLSharedKeys_LoadStateData; FLSharedKeys_LoadState; + FLSharedKeys_Encode; + FLSharedKeys_Decode; + FLSharedKeys_NewWithRead; FLSharedKeys_GetStateData; FLSharedKeys_Count; FLSharedKeys_RevertToCount; FLSharedKeys_WriteState; + FLSharedKeyScope_WithRange; FLKeyPath_New; FLKeyPath_Free; FLKeyPath_Eval; FLKeyPath_EvalOnce; FLKeyPath_ToString; FLKeyPath_Equals; + FLKeyPath_GetElement; FLDeepIterator_New; FLDeepIterator_Free; FLDeepIterator_GetValue; + FLDeepIterator_GetParent; FLDeepIterator_GetKey; FLDeepIterator_GetIndex; FLDeepIterator_GetDepth; @@ -319,6 +334,7 @@ CBL_C { FLDeepIterator_GetPath; FLDeepIterator_GetPathString; FLDeepIterator_GetJSONPointer; + FL_WipeMemory; local: *; }; From 7dc5672ee68131c39113a78cd8f2c4606ac745ae Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 24 Feb 2022 11:28:51 -0800 Subject: [PATCH 48/90] Update LiteCore for CBL-2808 and CBL-2844 (#281) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index b018a12d..ad378a8d 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit b018a12db01222d451b4f7b95478d4825bc19954 +Subproject commit ad378a8dc0da43acb0168d91b2b1d9d8f7bfb076 From 39648d5753051cef6daf2d2d763721a024a3850c Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 24 Feb 2022 11:32:11 -0800 Subject: [PATCH 49/90] Updated XCode CBL_VERSION_STRING to 3.0.1 --- Xcode/xcconfigs/Project.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/xcconfigs/Project.xcconfig b/Xcode/xcconfigs/Project.xcconfig index 15edf357..071d1e7a 100644 --- a/Xcode/xcconfigs/Project.xcconfig +++ b/Xcode/xcconfigs/Project.xcconfig @@ -11,7 +11,7 @@ LITECORE = vendor/couchbase-lite-core FLEECE = $(LITECORE)/vendor/fleece -CBL_VERSION_STRING = 3.0.0 +CBL_VERSION_STRING = 3.0.1 CBL_BUILD_NUMBER = 0 IPHONEOS_DEPLOYMENT_TARGET = 10.0 From 3da80788242c5e59f27ab488a30dad21bfe5dc8f Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 10 Mar 2022 16:11:14 -0800 Subject: [PATCH 50/90] Use VERSION environment variable for generating CBL_Edition.h --- CMakeLists.txt | 10 +++++++++- cmake/generate_edition.cmake | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d811e4..3e172e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,17 @@ endif() set(CMAKE_OSX_ARCHITECTURES x86_64 arm64) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) +if(DEFINED ENV{VERSION}) + message(VERBOSE "Using VERSION:$ENV{VERSION} from environment variable") + set(CBL_VERSION_STRING $ENV{VERSION}) +else() + message(WARNING "No VERSION set, defaulting to 0.0.0") + set(CBL_VERSION_STRING "0.0.0") +endif() + project ( CouchbaseLite_C - VERSION 3.0.0 + VERSION ${CBL_VERSION_STRING} ) set(CBL_LIB_VERSION ${CouchbaseLite_C_VERSION}) diff --git a/cmake/generate_edition.cmake b/cmake/generate_edition.cmake index 6beea9eb..ce2740e6 100644 --- a/cmake/generate_edition.cmake +++ b/cmake/generate_edition.cmake @@ -46,6 +46,7 @@ macro(generate_edition) endif() if(DEFINED ENV{BLD_NUM}) + message(VERBOSE "Using BLD_NUM:$ENV{BLD_NUM} from environment variable") set(CouchbaseLite_C_BUILD $ENV{BLD_NUM}) else() message(WARNING "No BLD_NUM set, defaulting to 0...") From 45de9d964ffc09912a164ad5d809d9d386e7727e Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 7 Apr 2022 14:33:14 -0700 Subject: [PATCH 51/90] Update LiteCore for CBL-2877 (#290) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index ad378a8d..f15a2a52 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit ad378a8dc0da43acb0168d91b2b1d9d8f7bfb076 +Subproject commit f15a2a528a45345949991319e7ed3607bd235c7d From 6d31478b78ec758058c7369482a5b2537ed7309d Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 13 Apr 2022 12:57:59 -0700 Subject: [PATCH 52/90] Update LiteCore for CBL-2976 (#292) Updated LiteCore for CBL-2976, Enhanced Pinned Server Certificate. --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index f15a2a52..a6401bdc 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit f15a2a528a45345949991319e7ed3607bd235c7d +Subproject commit a6401bdcf3580fd71699e4e71b0c8b5abc309942 From e0ed738815c2e98e0119e24b54140c78bb38e752 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 22 Apr 2022 10:03:05 -0700 Subject: [PATCH 53/90] Update .gitignore Ignored .DS_Store file on macOS. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b7b4072f..510339b7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ python/CouchbaseLite/*.c Cargo.lock bindings/rust/CouchbaseLite/target/ build_apple_out + +# macOS +.DS_Store From 52bb881c241b38da05126979b92f459739493f8f Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 22 Apr 2022 10:04:48 -0700 Subject: [PATCH 54/90] Update XCode CBL_VERSION_STRING to 3.0.2 --- Xcode/xcconfigs/Project.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/xcconfigs/Project.xcconfig b/Xcode/xcconfigs/Project.xcconfig index 071d1e7a..1c43e7e3 100644 --- a/Xcode/xcconfigs/Project.xcconfig +++ b/Xcode/xcconfigs/Project.xcconfig @@ -11,7 +11,7 @@ LITECORE = vendor/couchbase-lite-core FLEECE = $(LITECORE)/vendor/fleece -CBL_VERSION_STRING = 3.0.1 +CBL_VERSION_STRING = 3.0.2 CBL_BUILD_NUMBER = 0 IPHONEOS_DEPLOYMENT_TARGET = 10.0 From 3edb30050dec63f9f4655160f846010faf9002c4 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 22 Apr 2022 16:12:23 -0700 Subject: [PATCH 55/90] Update Jenkins file and LiteCore to 3.0.2-10 (#295) * Update LiteCore to 3.0.2-10 * Update Jenkinsfile --- Jenkinsfile | 2 -- vendor/couchbase-lite-core | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 794fa4dd..ecb41d88 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,8 +28,6 @@ pipeline { agent { label 's61113u16 (litecore)' } environment { BRANCH = "${BRANCH_NAME}" - CC = "gcc-7" - CXX = "g++-7" } steps { sh 'jenkins/jenkins_unix.sh' diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index a6401bdc..b945776f 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit a6401bdcf3580fd71699e4e71b0c8b5abc309942 +Subproject commit b945776faf3bc2b836de9f4618b65c60af63ab4c From bb22109968bf5c2c00edf8fdc747a987898cf95f Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 25 Apr 2022 13:19:40 -0700 Subject: [PATCH 56/90] Update LiteCore to 3.0.2-11 (#296) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index b945776f..737ce1f8 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit b945776faf3bc2b836de9f4618b65c60af63ab4c +Subproject commit 737ce1f81b936e0c4ecb31e835db9f921cb8812b From ec65a1f208a2a2e7216998db052d26144fd4e072 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 6 Jul 2022 17:44:32 -0700 Subject: [PATCH 57/90] Update to use LiteCore 3.0.2-19 (#328) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 737ce1f8..6fb3bfc4 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 737ce1f81b936e0c4ecb31e835db9f921cb8812b +Subproject commit 6fb3bfc417b100fbc65b6c762f4c2d78b9b6ed6c From b3a15649a1c2794314b03e1246e8de06d4cd12bb Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Tue, 13 Sep 2022 10:03:30 +0900 Subject: [PATCH 58/90] Update to use LiteCore 3.0.2-20 (#346) --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 6fb3bfc4..7cb516b9 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 6fb3bfc417b100fbc65b6c762f4c2d78b9b6ed6c +Subproject commit 7cb516b9f7c030ba8851178b71bcae93fafa38f3 From 52f0f0f0b77116672e754786f9419ce4ec9c37b6 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Thu, 15 Sep 2022 10:15:37 +0900 Subject: [PATCH 59/90] Update version number in xcconfig to 3.0.3 --- Xcode/xcconfigs/Project.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xcode/xcconfigs/Project.xcconfig b/Xcode/xcconfigs/Project.xcconfig index 1c43e7e3..6817a37a 100644 --- a/Xcode/xcconfigs/Project.xcconfig +++ b/Xcode/xcconfigs/Project.xcconfig @@ -11,7 +11,7 @@ LITECORE = vendor/couchbase-lite-core FLEECE = $(LITECORE)/vendor/fleece -CBL_VERSION_STRING = 3.0.2 +CBL_VERSION_STRING = 3.0.3 CBL_BUILD_NUMBER = 0 IPHONEOS_DEPLOYMENT_TARGET = 10.0 From 19543fc4a101f6b82ccd5866d704218a08f7aa82 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 27 Oct 2022 18:12:21 -0700 Subject: [PATCH 60/90] CBL-3611 : Fix pending conflicts are not being called to resolve (Port) (#385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Port fix (b8f77dde64b241399fc3fa0f2cc89d4ebf8f3771) from master branch (Original issue CBL-3609) * Changed the conflict detection and conflict revision to be the same as the logic in the other platforms so that the code doesn’t use inaccurate revision flags and revID from the DocumentEnded (CBL-3610). * With the new logic, no needs to pass revID from DocumentEnded to ConflictResolver class so removing _revID from the class. * Fixed a bug in ConflictResolver::runNow() that doesn’t reset inConflict to false when resolving is successful. * Fixed bugs in CBLDocument that doesn’t use revID and sequence from selected revision (e.g. when conflicting revision is selected). * Added Test --- src/CBLDocument_Internal.hh | 6 ++-- src/CBLReplicator_Internal.hh | 2 +- src/ConflictResolver.cc | 23 ++++-------- src/ConflictResolver.hh | 4 +-- test/ReplicatorEETest.cc | 67 +++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 23 deletions(-) diff --git a/src/CBLDocument_Internal.hh b/src/CBLDocument_Internal.hh index a7604e56..e452b973 100644 --- a/src/CBLDocument_Internal.hh +++ b/src/CBLDocument_Internal.hh @@ -88,7 +88,7 @@ public: uint64_t sequence() const { auto c4doc = _c4doc.useLocked(); - return c4doc ? c4doc->sequence() : 0; + return c4doc ? static_cast(c4doc->selectedRev().sequence) : 0; } @@ -233,8 +233,10 @@ public: _properties = nullptr; _fromJSON = nullptr; while (c4doc->selectNextLeafRevision(true, true)) - if (c4doc->selectedRev().flags & kRevIsConflict) + if (c4doc->selectedRev().flags & kRevIsConflict) { + _revID = c4doc->selectedRev().revID; return true; + } return false; } diff --git a/src/CBLReplicator_Internal.hh b/src/CBLReplicator_Internal.hh index 7396dbf0..26bce649 100644 --- a/src/CBLReplicator_Internal.hh +++ b/src/CBLReplicator_Internal.hh @@ -312,7 +312,7 @@ private: for (size_t i = 0; i < numDocs; ++i) { auto src = *c4Docs[i]; - if (!pushing && src.flags & kRevIsConflict) { + if (!pushing && src.error.code == kC4ErrorConflict && src.error.domain == LiteCoreDomain) { // Conflict -- start an async resolver task: auto r = new ConflictResolver(_db, _conf.conflictResolver, _conf.context, src); bumpConflictResolverCount(1); diff --git a/src/ConflictResolver.cc b/src/ConflictResolver.cc index bc9fb284..5ed58a53 100644 --- a/src/ConflictResolver.cc +++ b/src/ConflictResolver.cc @@ -56,13 +56,11 @@ namespace cbl_internal { ConflictResolver::ConflictResolver(CBLDatabase *db, CBLConflictResolver customResolver, void* context, - alloc_slice docID, - alloc_slice revID) + alloc_slice docID) :_db(db) ,_clientResolver(customResolver) ,_clientResolverContext(context) ,_docID(move(docID)) - ,_revID(move(revID)) { //SyncLog(Info, "ConflictResolver %p on %.*s", this, _docID.c_str()); } @@ -72,7 +70,7 @@ namespace cbl_internal { CBLConflictResolver customResolver, void* context, const C4DocumentEnded &docEnded) - :ConflictResolver(db, customResolver, context, docEnded.docID, docEnded.revID) + :ConflictResolver(db, customResolver, context, docEnded.docID) { } @@ -99,15 +97,8 @@ namespace cbl_internal { FMTSLICE(_docID)); return true; } - - if (_revID) { - ok = conflict->selectRevision(_revID) && - (conflict->revisionFlags() & (kRevLeaf|kRevIsConflict)) == - (kRevLeaf|kRevIsConflict); - } else { - ok = conflict->selectNextConflictingRevision(); - _revID = conflict->revisionID(); - } + + ok = conflict->selectNextConflictingRevision(); if (!ok) { // Revision is gone or not a leaf: Conflict must be resolved, so stop SyncLog(Info, "Conflict in doc '%.*s' already resolved, nothing to do", @@ -115,7 +106,6 @@ namespace cbl_internal { if (_completionHandler) { _completionHandler(this); // the handler will most likely delete me } - return true; } @@ -126,8 +116,8 @@ namespace cbl_internal { ok = defaultResolve(conflict); if (ok) { - _revID = conflict->revisionID(); _flags = conflict->revisionFlags(); + inConflict = false; } else { _error = external(C4Error::make(LiteCoreDomain, kC4ErrorConflict)); // If a local revision is saved at the same time we'll fail with a conflict, so retry: @@ -169,8 +159,7 @@ namespace cbl_internal { CBLDocument *remoteDoc = conflict; if (remoteDoc->revisionFlags() & kRevDeleted) remoteDoc = nullptr; - - auto localDoc = _db->getDocument(_docID, true); + auto localDoc = _db->getDocument(_docID, false); if (localDoc && localDoc->revisionFlags() & kRevDeleted) localDoc = nullptr; diff --git a/src/ConflictResolver.hh b/src/ConflictResolver.hh index f161e71a..5d5f5164 100644 --- a/src/ConflictResolver.hh +++ b/src/ConflictResolver.hh @@ -23,8 +23,7 @@ namespace cbl_internal { ConflictResolver(CBLDatabase *db, CBLConflictResolver _cbl_nullable customResolver, void* _cbl_nullable context, - alloc_slice docID, - alloc_slice revID = nullslice); + alloc_slice docID); ConflictResolver(CBLDatabase*, CBLConflictResolver _cbl_nullable, @@ -54,7 +53,6 @@ namespace cbl_internal { CBLConflictResolver _cbl_nullable _clientResolver; void* _cbl_nullable _clientResolverContext; alloc_slice const _docID; - alloc_slice _revID; C4RevisionFlags _flags {}; CompletionHandler _completionHandler; CBLError _error {}; diff --git a/test/ReplicatorEETest.cc b/test/ReplicatorEETest.cc index 516f675e..c5ddae28 100644 --- a/test/ReplicatorEETest.cc +++ b/test/ReplicatorEETest.cc @@ -311,6 +311,73 @@ TEST_CASE_METHOD(ReplicatorLocalTest, "Default Resolver : Higher RevID Wins", "[ CHECK(remoteDoc.revisionID() == doc2.revisionID()); } +TEST_CASE_METHOD(ReplicatorLocalTest, "Resolve Pending Conflicts", "[Replicator][Current]") { + MutableDocument doc("foo1"); + doc["greeting"] = "Howdy!"; + db.saveDocument(doc); + + auto badConflictResolver = [](void *context, + FLString documentID, + const CBLDocument *localDocument, + const CBLDocument *remoteDocument) -> const CBLDocument* + { + throw std::runtime_error("An unexpected error has occurred."); + }; + + auto conflictResolver = [](void *context, + FLString documentID, + const CBLDocument *localDocument, + const CBLDocument *remoteDocument) -> const CBLDocument* + { + return remoteDocument; + }; + + config.replicatorType = kCBLReplicatorTypePush; + replicate(); + + Document foo1 = otherDB.getDocument("foo1"); + REQUIRE(foo1); + CHECK(foo1["greeting"].asString() == "Howdy!"_sl); + + MutableDocument foo1a = db.getMutableDocument("foo1"); + REQUIRE(foo1a); + foo1a["greeting"] = "hey"; + db.saveDocument(foo1a); + + MutableDocument foo1b = otherDB.getMutableDocument("foo1"); + REQUIRE(foo1b); + foo1b["greeting"] = "hola"; + otherDB.saveDocument(foo1b); + + resetReplicator(); + config.conflictResolver = badConflictResolver; + config.replicatorType = kCBLReplicatorTypePull; + { + ExpectingExceptions ex; + replicate(); + } + + foo1 = db.getDocument("foo1"); + REQUIRE(foo1); + CHECK(foo1["greeting"].asString() == "hey"_sl); + + // Purge to ensure that no "foo1" to be pulled again + // and conflict resolver should be still called: + otherDB.purgeDocumentByID("foo1"); + foo1b = otherDB.getMutableDocument("foo1"); + REQUIRE(!foo1b); + + replicatedDocIDs.clear(); + resetReplicator(); + config.conflictResolver = conflictResolver; + config.replicatorType = kCBLReplicatorTypePull; + replicate(); + + foo1 = db.getDocument("foo1"); + REQUIRE(foo1); + CHECK(foo1["greeting"].asString() == "hola"_sl); +} + class ReplicatorConflictTest : public ReplicatorLocalTest { public: enum class ResolverMode { kLocalWins, kRemoteWins, kMerge, kMergeAutoID }; From 2e0bb3ab9998ea78805547df935cf8fa99f82bb4 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Thu, 27 Oct 2022 18:12:37 -0700 Subject: [PATCH 61/90] CBL-3834 : Wait for listener callbacks to finish when removing listener (Port) (#386) * Wait for listener callbacks to finish when removing listener (#372) * Wait for listener callbacks to finish when removing listener * Use `recursive_mutex` * Update CBLDatabase class according to the fix * _callback is now just a pointer. * Locked with the recursive mutex in the call method. Co-authored-by: Gabriel Terwesten --- src/CBLDatabase.cc | 3 ++- src/CBLQuery_Internal.hh | 11 ++++++----- src/Listener.cc | 3 +-- src/Listener.hh | 20 ++++++++++++-------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/CBLDatabase.cc b/src/CBLDatabase.cc index 48b6acf9..153c60fc 100644 --- a/src/CBLDatabase.cc +++ b/src/CBLDatabase.cc @@ -116,11 +116,12 @@ namespace cbl_internal { } CBLDocumentChangeListener callback() const { - return (CBLDocumentChangeListener)_callback.load(); + return (CBLDocumentChangeListener)_callback; } // this is called indirectly by CBLDatabase::sendNotifications void call(const CBLDatabase*, FLString) { + std::lock_guard lock(_mutex); auto cb = callback(); if (cb) cb(_context, _db, _docID); diff --git a/src/CBLQuery_Internal.hh b/src/CBLQuery_Internal.hh index bef8a724..f38e1dcf 100644 --- a/src/CBLQuery_Internal.hh +++ b/src/CBLQuery_Internal.hh @@ -183,7 +183,7 @@ namespace cbl_internal { _c4obs = c4query->observe([this](C4QueryObserver*) { this->queryChanged(); }); }); } - + ~ListenerToken() { // Note: // When calling CBLListener_Remove(CBLListenerToken*), the ListenerToken object @@ -200,10 +200,11 @@ namespace cbl_internal { void setEnabled(bool enabled); CBLQueryChangeListener callback() const { - return (CBLQueryChangeListener)_callback.load(); + return (CBLQueryChangeListener)_callback; } void call() { + std::lock_guard lock(_mutex); CBLQueryChangeListener cb = callback(); if (cb) cb(_context, _query, this); @@ -212,13 +213,13 @@ namespace cbl_internal { Retained resultSet() { return new CBLResultSet(_query, _c4obs->getEnumerator(false)); } - + // CBLStoppable : - + void stop() override { setEnabled(false); } - + private: void queryChanged(); // defn is in CBLDatabase.cc, to prevent circular hdr dependency diff --git a/src/Listener.cc b/src/Listener.cc index c0393bb3..33e86e5d 100644 --- a/src/Listener.cc +++ b/src/Listener.cc @@ -24,8 +24,7 @@ using namespace std; void CBLListenerToken::remove() { auto oldOwner = _owner; if (oldOwner) { - _callback = nullptr; - _owner = nullptr; + removed(); oldOwner->remove(this); } } diff --git a/src/Listener.hh b/src/Listener.hh index aaf7d50e..ea1fb34b 100644 --- a/src/Listener.hh +++ b/src/Listener.hh @@ -21,7 +21,6 @@ #include "Internal.hh" #include "InstanceCounted.hh" #include -#include #include #include #include @@ -35,7 +34,7 @@ namespace cbl_internal { } -/** Abstract base class of listener tokens. (In the public API, as an opaque typeef.) */ +/** Abstract base class of listener tokens. (In the public API, as an opaque typedef.) */ struct CBLListenerToken : public CBLRefCounted { public: CBLListenerToken(const void *callback, void* _cbl_nullable context) @@ -57,11 +56,15 @@ protected: friend class cbl_internal::ListenersBase; void removed() { + std::lock_guard lock(_mutex); _owner = nullptr; _callback = nullptr; } - std::atomic _callback; // Really a C fn pointer + /** Must be held when accessing _callback and while running it. + https://github.com/couchbase/couchbase-lite-C/pull/372 */ + std::recursive_mutex _mutex; + const void* _cbl_nullable _callback; // Really a C fn pointer void* const _cbl_nullable _context; cbl_internal::ListenersBase* _cbl_nullable _owner {nullptr}; }; @@ -77,10 +80,11 @@ namespace cbl_internal { :CBLListenerToken((const void*)callback, context) { } - LISTENER callback() const {return (LISTENER)_callback.load();} + LISTENER callback() const {return (LISTENER)_callback;} - template + template void call(Args... args) { + std::lock_guard lock(_mutex); LISTENER cb = callback(); if (cb) cb(_context, args...); @@ -160,12 +164,12 @@ namespace cbl_internal { void add(ListenerToken* _cbl_nonnull token) {ListenersBase::add(token);} void clear() {ListenersBase::clear();} bool empty() const {return ListenersBase::empty();} - + ListenerToken* _cbl_nullable find(CBLListenerToken *token) const { return contains(token) ? (ListenerToken*) token : nullptr; } - template + template void call(Args... args) const { for (auto &lp : tokens()) ((ListenerToken*)lp.get())->call(args...); @@ -197,7 +201,7 @@ namespace cbl_internal { using Notifications = std::unique_ptr>; void call(const Notifications&); - + struct State { CBLNotificationsReadyCallback _cbl_nullable callback {nullptr}; void* _cbl_nullable context; From 9a558a0ca37dd67e82b202393880e234163101e8 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Wed, 2 Nov 2022 15:42:58 -0700 Subject: [PATCH 62/90] Update LiteCore (#390) For CBL-3831, CBL-3833, CBL3704, CBL-3841 --- vendor/couchbase-lite-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 7cb516b9..73c5a264 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 7cb516b9f7c030ba8851178b71bcae93fafa38f3 +Subproject commit 73c5a2644f76cac01c6a456240543b86d1ab3a0c From c2678b132ac08bd42a797d5171c50bb3955c8b72 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 3 Feb 2023 16:33:05 -0800 Subject: [PATCH 63/90] Fix build and test failures - lithium (#440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix empty identity is not valid error with XCode 14 (#398) - Problem : XCode 14 starts to require code signing for command line app and dynamic lib. - Explicitly set the code sign identity and development team to CBL_Tests and CBL_dylib target. - Moved code signing related configs from CBL_Framework to xcconfig files. * Use snprintf instead of sprintf - Fixed XCode warning on using sprintf. * Update LiteCore to the latest lithium * Fix Query Index Test Fails - Updated QueryTest’s tests that check explain string as the format has been changed by SQLite. * Update xcode codesign identity - No Code Sign for CBL_C Dylib in Debug build - No Code Sign for CBL_Test - Update xcodebuid GH Action to simply run xcode build command --- .github/workflows/xcodebuild.yml | 18 ++---------------- CBL_C.xcodeproj/project.pbxproj | 8 -------- Xcode/xcconfigs/CBL_Dylib_Release.xcconfig | 4 ++++ Xcode/xcconfigs/CBL_Framework.xcconfig | 2 ++ Xcode/xcconfigs/CBL_dylib.xcconfig | 1 + Xcode/xcconfigs/Tests.xcconfig | 6 +++++- test/BlobTest_Cpp.cc | 4 +++- test/CBLTest.cc | 4 +++- test/QueryTest.cc | 10 ++++++---- vendor/couchbase-lite-core | 2 +- 10 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.github/workflows/xcodebuild.yml b/.github/workflows/xcodebuild.yml index 8a61b32d..29f5de15 100644 --- a/.github/workflows/xcodebuild.yml +++ b/.github/workflows/xcodebuild.yml @@ -10,27 +10,13 @@ on: branches: - '**' -env: - # Customize the Xcode configuration here (Release or Debug) - # NOTE: If we decide to archive the build products we should build with RelWithDebInfo instead. - CONFIGURATION: Debug - jobs: build: runs-on: macOS-latest - steps: - uses: actions/checkout@v2 with: submodules: recursive - -#### BUILD - - name: "Build Tests" - uses: sersoft-gmbh/xcodebuild-action@v1 - with: - project: CBL_C.xcodeproj - scheme: CBL_Tests - destination: platform=macOS - configuration: $CONFIGURATION - action: build + run: | + xcodebuild build -project CBL_C.xcodeproj -configuration "Debug" -scheme "CBL_Tests" -destination "platform=macOS" | xcpretty diff --git a/CBL_C.xcodeproj/project.pbxproj b/CBL_C.xcodeproj/project.pbxproj index 9f6364f3..b2f274d3 100644 --- a/CBL_C.xcodeproj/project.pbxproj +++ b/CBL_C.xcodeproj/project.pbxproj @@ -1459,8 +1459,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 27310FD7235F686D0046F8C8 /* CBL_Framework_Debug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; - DEVELOPMENT_TEAM = N2Q372V7W2; ENABLE_HARDENED_RUNTIME = YES; }; name = Debug; @@ -1469,8 +1467,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 27984E492249AF61000FE777 /* CBL_Framework_Release.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "Apple Development"; - DEVELOPMENT_TEAM = N2Q372V7W2; ENABLE_HARDENED_RUNTIME = YES; }; name = Release; @@ -1630,8 +1626,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 27310FD7235F686D0046F8C8 /* CBL_Framework_Debug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "-"; - DEVELOPMENT_TEAM = N2Q372V7W2; ENABLE_HARDENED_RUNTIME = YES; }; name = Debug_EE; @@ -1791,8 +1785,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 27984E492249AF61000FE777 /* CBL_Framework_Release.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "Apple Development"; - DEVELOPMENT_TEAM = N2Q372V7W2; ENABLE_HARDENED_RUNTIME = YES; }; name = Release_EE; diff --git a/Xcode/xcconfigs/CBL_Dylib_Release.xcconfig b/Xcode/xcconfigs/CBL_Dylib_Release.xcconfig index fb8d7a6c..c7d7ea05 100644 --- a/Xcode/xcconfigs/CBL_Dylib_Release.xcconfig +++ b/Xcode/xcconfigs/CBL_Dylib_Release.xcconfig @@ -8,3 +8,7 @@ #include "CBL_dylib.xcconfig" #include "vendor/couchbase-lite-core/Xcode/xcconfigs/dylib_Release.xcconfig" + +CODE_SIGNING_ALLOWED = YES +CODE_SIGN_IDENTITY = Apple Development +DEVELOPMENT_TEAM = N2Q372V7W2 diff --git a/Xcode/xcconfigs/CBL_Framework.xcconfig b/Xcode/xcconfigs/CBL_Framework.xcconfig index bdd9fc9e..bb895a3e 100644 --- a/Xcode/xcconfigs/CBL_Framework.xcconfig +++ b/Xcode/xcconfigs/CBL_Framework.xcconfig @@ -10,7 +10,9 @@ INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/Frameworks +CODE_SIGN_IDENTITY = Apple Development DEFINES_MODULE = YES +DEVELOPMENT_TEAM = N2Q372V7W2 EXECUTABLE_PREFIX = FRAMEWORK_VERSION = A INFOPLIST_FILE = Xcode/Framework-Info.plist diff --git a/Xcode/xcconfigs/CBL_dylib.xcconfig b/Xcode/xcconfigs/CBL_dylib.xcconfig index 415dc52b..ea9f0cf4 100644 --- a/Xcode/xcconfigs/CBL_dylib.xcconfig +++ b/Xcode/xcconfigs/CBL_dylib.xcconfig @@ -10,3 +10,4 @@ PRODUCT_NAME = cblite EXPORTED_SYMBOLS_FILE = $(DERIVED_FILE_DIR)/CBL.exp // output of src/exports/generate_exports.sh +CODE_SIGNING_ALLOWED = NO diff --git a/Xcode/xcconfigs/Tests.xcconfig b/Xcode/xcconfigs/Tests.xcconfig index 679281c1..7f7ff637 100644 --- a/Xcode/xcconfigs/Tests.xcconfig +++ b/Xcode/xcconfigs/Tests.xcconfig @@ -8,5 +8,9 @@ HEADER_SEARCH_PATHS = include Xcode/generated_headers/public/cbl $(FLEECE)/API $(FLEECE)/Fleece/Support $(FLEECE)/vendor/catch PRODUCT_NAME = cbl_tests +CODE_SIGNING_ALLOWED = NO +LLVM_LTO = NO // LTO makes tests very slow to link and confuses Instruments -LLVM_LTO = NO // LTO makes tests very slow to link and confuses Instruments +CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO +GCC_WARN_UNKNOWN_PRAGMAS = NO +CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = NO diff --git a/test/BlobTest_Cpp.cc b/test/BlobTest_Cpp.cc index a3b0e424..dd093a35 100644 --- a/test/BlobTest_Cpp.cc +++ b/test/BlobTest_Cpp.cc @@ -28,6 +28,8 @@ using namespace fleece; using namespace cbl; +static constexpr size_t kDocIDBufferSize = 20; + static const slice kBlobContents = "This is the content of the blob."; static const string kBlobContentType = "text/plain"; static const string kBlobDigest = "sha1-gtf8MtnkloBRj0Od1CHA9LG69FM="; @@ -174,7 +176,7 @@ TEST_CASE_METHOD(CBLTest_Cpp, "C++ Blobs in arrays/dicts", "[Blob]") { TEST_CASE_METHOD(CBLTest_Cpp, "C++ Blobs in ResultSet", "[Blob]") { for (int i = 0; i < 10; ++i) { char docID[20]; - sprintf(docID, "doc-%d", i); + snprintf(docID, kDocIDBufferSize, "doc-%d", i); MutableDocument doc(docID); Blob blob(kBlobContentType, kBlobContents); doc["picture"] = blob.properties(); diff --git a/test/CBLTest.cc b/test/CBLTest.cc index 2c8ca836..64e0e624 100644 --- a/test/CBLTest.cc +++ b/test/CBLTest.cc @@ -50,6 +50,8 @@ static string databaseDir() { } +static constexpr size_t kDocIDBufferSize = 20; + alloc_slice const CBLTest::kDatabaseDir(databaseDir()); slice const CBLTest::kDatabaseName = "CBLtest"; @@ -181,7 +183,7 @@ unsigned ImportJSONLines(string&& path, CBLDatabase* database) { cbl::Transaction t(database); ReadFileByLines(path, [&](FLSlice line) { char docID[20]; - sprintf(docID, "%07u", numDocs+1); + snprintf(docID, kDocIDBufferSize, "%07u", numDocs+1); auto doc = CBLDocument_CreateWithID(slice(docID)); REQUIRE(CBLDocument_SetJSON(doc, line, &error)); CHECK(CBLDatabase_SaveDocumentWithConcurrencyControl(database, doc, kCBLConcurrencyControlFailOnConflict, &error)); diff --git a/test/QueryTest.cc b/test/QueryTest.cc index 3c1c45a7..51d71207 100644 --- a/test/QueryTest.cc +++ b/test/QueryTest.cc @@ -176,7 +176,7 @@ TEST_CASE_METHOD(QueryTest, "Create and Delete Value Index", "[Query]") { &errPos, &error); alloc_slice explanation1(CBLQuery_Explain(query)); - CHECK(explanation1.find("SCAN TABLE kv_default AS _ USING INDEX index1"_sl)); + CHECK(explanation1.find("USING INDEX index1"_sl)); CBLQuery_Release(query); query = CBLDatabase_CreateQuery(db, kCBLN1QLLanguage, @@ -184,7 +184,7 @@ TEST_CASE_METHOD(QueryTest, "Create and Delete Value Index", "[Query]") { &errPos, &error); alloc_slice explanation2(CBLQuery_Explain(query)); - CHECK(explanation2.find("SCAN TABLE kv_default AS _ USING INDEX index2"_sl)); + CHECK(explanation2.find("USING INDEX index2"_sl)); CBLQuery_Release(query); query = nullptr; @@ -223,7 +223,8 @@ TEST_CASE_METHOD(QueryTest, "Create and Delete Full-Text Index", "[Query]") { &errPos, &error); alloc_slice explanation1(CBLQuery_Explain(query)); - CHECK(explanation1.find("SCAN TABLE kv_default::index1 AS fts1"_sl)); + CHECK(explanation1.find("JOIN \"kv_default::index1\" AS fts1")); + CHECK(explanation1.find("SCAN fts1 VIRTUAL TABLE INDEX"_sl)); CBLQuery_Release(query); query = CBLDatabase_CreateQuery(db, kCBLN1QLLanguage, @@ -231,7 +232,8 @@ TEST_CASE_METHOD(QueryTest, "Create and Delete Full-Text Index", "[Query]") { &errPos, &error); alloc_slice explanation2(CBLQuery_Explain(query)); - CHECK(explanation2.find("SCAN TABLE kv_default::index2 AS fts1"_sl)); + CHECK(explanation2.find("JOIN \"kv_default::index2\" AS fts1")); + CHECK(explanation2.find("SCAN fts1 VIRTUAL TABLE INDEX"_sl)); CBLQuery_Release(query); query = nullptr; diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 73c5a264..50ce87bd 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 73c5a2644f76cac01c6a456240543b86d1ab3a0c +Subproject commit 50ce87bd3e04394159f2a615abf4a9b3e7fa16be From 4afed8a84d269c4c7e254ce597077320825eb895 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Mon, 6 Feb 2023 10:58:17 -0800 Subject: [PATCH 64/90] CBL-3923 : Add User-Agent to Replicator Header (#438) * 3a32adb5c5c606b9c7531c4939c06814bc6ea0e4 * a8bbe081025d65c88afc8cbd739fbe83fad9cdef * c55d30df97bb4aea3b5b8edd603236ae7fda7a60 * 1084bf9dec720bd73bcf6ab5d090f98b7e69ff23 * 1f25fa54adead109fa3e0db43cc876a956c1c70b * e09f1393b6ab3f979a089e0636e30f02a93006a4 * 38c04fc21f89feff39f42a51f4e172fb72b387a9 --- CBL_C.xcodeproj/project.pbxproj | 8 ++ cmake/generate_edition.cmake | 6 +- cmake/platform_apple.cmake | 1 + include/cbl/CBL_Edition.h.in | 3 +- src/CBLPrivate.h | 2 + src/CBLReplicatorConfig.hh | 18 ++- src/CBLReplicator_CAPI.cc | 6 + src/CBLReplicator_Internal.hh | 4 + src/CBLUserAgent.hh | 163 +++++++++++++++++++++++ src/CBLUserAgent.mm | 28 ++++ src/exports/CBL_Exports.txt | 1 + src/exports/generated/CBL.def | 1 + src/exports/generated/CBL.exp | 1 + src/exports/generated/CBL.gnu | 1 + src/exports/generated/CBL_Android.gnu | 1 + src/exports/generated/CBL_EE.def | 1 + src/exports/generated/CBL_EE.exp | 1 + src/exports/generated/CBL_EE.gnu | 1 + src/exports/generated/CBL_EE_Android.gnu | 1 + test/ReplicatorTest.cc | 15 +++ 20 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 src/CBLUserAgent.hh create mode 100644 src/CBLUserAgent.mm diff --git a/CBL_C.xcodeproj/project.pbxproj b/CBL_C.xcodeproj/project.pbxproj index b2f274d3..4394ff56 100644 --- a/CBL_C.xcodeproj/project.pbxproj +++ b/CBL_C.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ 27DBD098246C9DE7002FD7A7 /* CBLDatabase+Apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 27DBD097246C9DE7002FD7A7 /* CBLDatabase+Apple.mm */; }; 27DBD09C246CA60E002FD7A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 271A98AF243FDF55008C032D /* SystemConfiguration.framework */; }; 27DBD0A9246CA667002FD7A7 /* CBLLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 277B77C6245B44BE00B222D3 /* CBLLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 40EBC24F298D89CE00182F16 /* CBLUserAgent.hh in Headers */ = {isa = PBXBuildFile; fileRef = 40EBC23E298D896D00182F16 /* CBLUserAgent.hh */; }; + 40EBC260298D8A9900182F16 /* CBLUserAgent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 40EBC252298D8A9900182F16 /* CBLUserAgent.mm */; }; 6938073022DE96C200727053 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 277CC9B122BC4E2E00B245CB /* Security.framework */; }; 932062DB26BC6B43006917A5 /* CBLQuery.cc in Sources */ = {isa = PBXBuildFile; fileRef = 932062DA26BC6B43006917A5 /* CBLQuery.cc */; }; 9320630F26BDB408006917A5 /* CBLPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 9320630126BDB340006917A5 /* CBLPlatform.h */; }; @@ -369,6 +371,8 @@ 27DBCF41246B81EE002FD7A7 /* LibC++Debug.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "LibC++Debug.cc"; sourceTree = ""; }; 27DBD096246C99AF002FD7A7 /* mergeIntoStaticLib.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = mergeIntoStaticLib.sh; sourceTree = ""; }; 27DBD097246C9DE7002FD7A7 /* CBLDatabase+Apple.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "CBLDatabase+Apple.mm"; sourceTree = ""; }; + 40EBC23E298D896D00182F16 /* CBLUserAgent.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CBLUserAgent.hh; sourceTree = ""; }; + 40EBC252298D8A9900182F16 /* CBLUserAgent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CBLUserAgent.mm; sourceTree = ""; }; 932062DA26BC6B43006917A5 /* CBLQuery.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CBLQuery.cc; sourceTree = ""; }; 9320630126BDB340006917A5 /* CBLPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLPlatform.h; sourceTree = ""; }; 9320631126BDB5CA006917A5 /* CBLPlatform_CAPI+Android.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "CBLPlatform_CAPI+Android.cc"; sourceTree = ""; }; @@ -503,6 +507,8 @@ 27DBCF2E246B4352002FD7A7 /* CBLQuery_Internal.hh */, 27D11BFF235140E300C58A70 /* CBLReplicator_Internal.hh */, 277FEE7621ED62AA00B60E3C /* CBLReplicatorConfig.hh */, + 40EBC23E298D896D00182F16 /* CBLUserAgent.hh */, + 40EBC252298D8A9900182F16 /* CBLUserAgent.mm */, 27D11BEE2351043B00C58A70 /* ConflictResolver.cc */, 27D11BED2351043B00C58A70 /* ConflictResolver.hh */, 271C2A7421CC4BD60045856E /* Internal.cc */, @@ -667,6 +673,7 @@ 271C2A3421CAC98F0045856E /* CBLDatabase.h in Headers */, 271C2A3121CAC98F0045856E /* CBLReplicator.h in Headers */, 271C2A3221CAC98F0045856E /* CBLBase.h in Headers */, + 40EBC24F298D89CE00182F16 /* CBLUserAgent.hh in Headers */, 27886C8D21F64C1400069BEA /* Listener.hh in Headers */, 93EC366226C49AF700182B02 /* CBLEncryptable_Internal.hh in Headers */, ); @@ -1171,6 +1178,7 @@ 277B77D5245B44E900B222D3 /* CBLLog.cc in Sources */, 271C2A7221CADB170045856E /* CBLDatabase.cc in Sources */, 276633A62602815000B9BD36 /* CBLDatabase_CAPI.cc in Sources */, + 40EBC260298D8A9900182F16 /* CBLUserAgent.mm in Sources */, 27DBD098246C9DE7002FD7A7 /* CBLDatabase+Apple.mm in Sources */, 275BC4DE2201323700DBE7D2 /* CBLBlob_CAPI.cc in Sources */, 271C2A7821CC750E0045856E /* CBLDocument.cc in Sources */, diff --git a/cmake/generate_edition.cmake b/cmake/generate_edition.cmake index ce2740e6..1483292f 100644 --- a/cmake/generate_edition.cmake +++ b/cmake/generate_edition.cmake @@ -55,7 +55,7 @@ macro(generate_edition) endif() math(EXPR CouchbaseLite_C_VERNUM "${CouchbaseLite_C_VERSION_MAJOR} * 1000000 + ${CouchbaseLite_C_VERSION_MINOR} * 1000 + ${CouchbaseLite_C_VERSION_PATCH}") - string(TIMESTAMP CouchbaseLite_C_SOURCE_ID) + string(TIMESTAMP CouchbaseLite_C_BUILD_TIMESTAMP UTC) find_package(Git) if(Git_FOUND) @@ -90,9 +90,9 @@ macro(generate_edition) string(PREPEND HASH "${EE_HASH}+") endif() - string(APPEND CouchbaseLite_C_SOURCE_ID " ${HASH}") + set(CouchbaseLite_C_SOURCE_ID "${HASH}") else() - string(APPEND CouchbaseLite_C_SOURCE_ID " ") + set(CouchbaseLite_C_SOURCE_ID "") endif() configure_file( diff --git a/cmake/platform_apple.cmake b/cmake/platform_apple.cmake index 98d3eab2..47fdb4d5 100644 --- a/cmake/platform_apple.cmake +++ b/cmake/platform_apple.cmake @@ -8,6 +8,7 @@ function(set_platform_source_files) set( ${PLATFORM_RESULT} src/CBLDatabase+Apple.mm + src/CBLUserAgent.mm PARENT_SCOPE ) endfunction() diff --git a/include/cbl/CBL_Edition.h.in b/include/cbl/CBL_Edition.h.in index a9292bf2..cd60321a 100644 --- a/include/cbl/CBL_Edition.h.in +++ b/include/cbl/CBL_Edition.h.in @@ -23,4 +23,5 @@ #define CBLITE_VERSION "@CouchbaseLite_C_VERSION@" #define CBLITE_VERSION_NUMBER @CouchbaseLite_C_VERNUM@ #define CBLITE_BUILD_NUMBER @CouchbaseLite_C_BUILD@ -#define CBLITE_SOURCE_ID "@CouchbaseLite_C_SOURCE_ID@" \ No newline at end of file +#define CBLITE_SOURCE_ID "@CouchbaseLite_C_SOURCE_ID@" +#define CBLITE_BUILD_TIMESTAMP "@CouchbaseLite_C_BUILD_TIMESTAMP@" \ No newline at end of file diff --git a/src/CBLPrivate.h b/src/CBLPrivate.h index 2f839838..424150bc 100644 --- a/src/CBLPrivate.h +++ b/src/CBLPrivate.h @@ -82,5 +82,7 @@ CBL_CAPI_BEGIN FLSliceResult CBLDocument_CanonicalRevisionID(const CBLDocument* doc) CBLAPI; unsigned CBLDocument_Generation(const CBLDocument* doc) CBLAPI; + + FLSlice CBLReplicator_UserAgent(const CBLReplicator* repl) CBLAPI; CBL_CAPI_END diff --git a/src/CBLReplicatorConfig.hh b/src/CBLReplicatorConfig.hh index 37c2e0b6..1b9f6fcd 100644 --- a/src/CBLReplicatorConfig.hh +++ b/src/CBLReplicatorConfig.hh @@ -20,6 +20,7 @@ #include "CBLReplicator.h" #include "CBLDatabase_Internal.hh" +#include "CBLUserAgent.hh" #include "Internal.hh" #include "c4ReplicatorTypes.h" #include "c4Private.h" @@ -162,6 +163,7 @@ namespace cbl_internal { #pragma mark - CONFIGURATION: +#define kCBLReplicatorUserAgent "kCBLReplicatorUserAgent" namespace cbl_internal { // Managed config object that retains/releases its properties. @@ -190,8 +192,11 @@ namespace cbl_internal { _proxy.username = copyString(_proxy.username, _proxyUsername); _proxy.password = copyString(_proxy.password, _proxyPassword); } - } + Dict headersDict = Dict(headers); + fleece::Value userAgent = headersDict[kCBLReplicatorUserAgent]; + _userAgent = userAgent ? userAgent.asstring() : createUserAgentHeader(); + } ~ReplicatorConfiguration() { release(database); @@ -220,7 +225,11 @@ namespace cbl_internal { // Writes a LiteCore replicator optionsDict void writeOptions(Encoder &enc) const { - writeOptionalKey(enc, kC4ReplicatorOptionExtraHeaders, Dict(headers)); + fleece::MutableDict mHeaders = headers ? FLDict_AsMutable(headers) : FLMutableDict_New(); + if (!mHeaders[kCBLReplicatorUserAgent]) { + mHeaders[kCBLReplicatorUserAgent] = _userAgent; + } + writeOptionalKey(enc, kC4ReplicatorOptionExtraHeaders, mHeaders); writeOptionalKey(enc, kC4ReplicatorOptionDocIDs, Array(documentIDs)); writeOptionalKey(enc, kC4ReplicatorOptionChannels, Array(channels)); if (pinnedServerCertificate.buf) { @@ -272,6 +281,10 @@ namespace cbl_internal { } } + slice getUserAgent() const { + return slice(_userAgent); + } + ReplicatorConfiguration(const ReplicatorConfiguration&) =delete; ReplicatorConfiguration& operator=(const ReplicatorConfiguration&) =delete; @@ -287,6 +300,7 @@ namespace cbl_internal { alloc_slice _pinnedServerCert, _trustedRootCerts; CBLProxySettings _proxy; alloc_slice _proxyHostname, _proxyUsername, _proxyPassword; + string _userAgent; }; } diff --git a/src/CBLReplicator_CAPI.cc b/src/CBLReplicator_CAPI.cc index dcdd29a4..8ff9140e 100644 --- a/src/CBLReplicator_CAPI.cc +++ b/src/CBLReplicator_CAPI.cc @@ -16,6 +16,7 @@ // limitations under the License. // +#include "CBLPrivate.h" #include "CBLReplicator.h" #include "CBLReplicator_Internal.hh" @@ -57,6 +58,11 @@ void CBLAuth_Free(CBLAuthenticator *auth) noexcept { delete auth; } +/** Private API*/ +FLSlice CBLReplicator_UserAgent(const CBLReplicator* repl) noexcept { + return repl->getUserAgent(); +} + CBLReplicator* CBLReplicator_Create(const CBLReplicatorConfiguration* conf, CBLError *outError) noexcept { try { return retain(new CBLReplicator(*conf)); diff --git a/src/CBLReplicator_Internal.hh b/src/CBLReplicator_Internal.hh index 26bce649..dc5b2dc6 100644 --- a/src/CBLReplicator_Internal.hh +++ b/src/CBLReplicator_Internal.hh @@ -237,6 +237,10 @@ public: return _docListeners.add(listener, context); } + slice getUserAgent() const { + return _conf.getUserAgent(); + } + private: alloc_slice encodeOptions() { diff --git a/src/CBLUserAgent.hh b/src/CBLUserAgent.hh new file mode 100644 index 00000000..a6ab6390 --- /dev/null +++ b/src/CBLUserAgent.hh @@ -0,0 +1,163 @@ +// +// CBLuserAgent.hh +// +// Copyright (c) 2022 Couchbase, Inc 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. +// + + +#pragma once +#include "CBL_Edition.h" +#include + +using string = std::string; + +#ifdef _MSC_VER +#define NOMINMAX +#include +#pragma comment(lib, "ntdll") + +// It's a pain to get the actual header, so just add the function def here +extern "C" NTSYSAPI NTSTATUS NTAPI RtlGetVersion( + _Out_ PRTL_OSVERSIONINFOW lpVersionInformation +); +#endif + +#if __APPLE__ +#include +#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR +static string getDeviceModel(const char* fallback) { + utsname uts; + if(uname(&uts) != 0) { + return fallback; + } + return uts.machine; +} + +#endif +string getAppleVersion(); +#endif + +#if defined(__linux__) && !defined(__ANDROID__) +#include +#include +#include +#include +#include + +static std::optional tryKey(const char* filename, string&& key) { + static const std::regex r("(.*)=(.*)"); + std::ifstream fin(filename); + if(!fin) { + return {}; + } + + fin.exceptions(std::ios_base::badbit); + string line; + std::smatch match; + while(std::getline(fin, line)) { + if(std::regex_match(line, match, r)) { + if(match[1] == key) { + return match[2]; + } + } + } + + return {}; +} + +static string getDistroInfo() { + // os-release is apparently the standard these days + if(auto os = tryKey("/etc/os-release", "PRETTY_NAME")) { + return *os; + } + + if(auto os = tryKey("/usr/lib/os-release", "PRETTY_NAME")) { + return *os; + } + + // Fall back to the non-standard lsb-release + if(auto lsb = tryKey("/etc/lsb-release", "DISTRIB_DESCRIPTION")) { + return *lsb; + } + + if(auto lsb = tryKey("/etc/lsb-release", "DISTRIB_ID")) { + return *lsb; + } + + // Last resort, use uname + utsname uts; + if(uname(&uts) != 0) { + return "Unknown Linux"; + } + + return string(uts.sysname) + ' ' + uts.release; +} +#endif + +using stringstream = std::stringstream; +using alloc_slice = fleece::alloc_slice; + +// TEMPLATE - “CouchbaseLite”/ “-” ” (Java; ” “;” “) ” “, Commit/” (“unofficial@” | ) ” Core/” +// OUTPUT - CouchbaseLite/3.1.0-SNAPSHOT (Java; Android 11; Pixel 4a) EE/debug, Commit/unofficial@HQ-Rename0337 Core/3.1.0 + +static string createUserAgentHeader(){ + stringstream header; + string os; + alloc_slice coreVersion = c4_getVersion(); + alloc_slice coreBuild = c4_getBuildInfo(); +#if defined (__APPLE__) && defined (__MACH__) +#if TARGET_IPHONE_SIMULATOR + os = "iOS Simulator " + getAppleVersion(); +#elif TARGET_OS_IPHONE + os = getDeviceModel("iOS Device") + ' ' + getAppleVersion(); +#elif TARGET_OS_MAC + os = "macOS " + getAppleVersion(); +#endif +#elif __ANDROID__ + char rel_ver_str[3]; + char sdk_ver_str[3]; + __system_property_get("ro.build.version.sdk", sdk_ver_str); + __system_property_get("ro.build.version.release", rel_ver_str); + os = "Android " + std::string(rel_ver_str) + " - API " + std::string(sdk_ver_str); +#elif _MSC_VER + RTL_OSVERSIONINFOW version{}; + version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW); + auto result = RtlGetVersion(&version); + stringstream osStream; + if (result < 0) { + os = "Microsoft Windows (Version Fetch Failed)"; + } else { + osStream << "Microsoft Windows " << version.dwMajorVersion << "." << version.dwMinorVersion << "." << version.dwBuildNumber; + os = osStream.str(); + } +#elif __linux__ + os = getDistroInfo(); +#else + os = "Unknown OS"; +#endif + header << "CouchbaseLite/" + << CBLITE_VERSION + << "-" + << CBLITE_BUILD_NUMBER + << " (" + << os + << ") " + << "Commit/" + << CBLITE_SOURCE_ID + << " ---> Core/" + << coreVersion.asString(); + + return header.str(); +} diff --git a/src/CBLUserAgent.mm b/src/CBLUserAgent.mm new file mode 100644 index 00000000..6182651b --- /dev/null +++ b/src/CBLUserAgent.mm @@ -0,0 +1,28 @@ +// +// CBLuserAgent.mm +// +// Copyright (c) 2023 Couchbase, Inc 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. +// + +#import +#include +using namespace std; + +// Silence clang! Including the CBLUserAgent header here just causes headaches +string getAppleVersion(); + +string getAppleVersion() { + return [[[NSProcessInfo processInfo] operatingSystemVersionString] cStringUsingEncoding:NSASCIIStringEncoding]; +} \ No newline at end of file diff --git a/src/exports/CBL_Exports.txt b/src/exports/CBL_Exports.txt index 0fd29bd7..13c28d60 100644 --- a/src/exports/CBL_Exports.txt +++ b/src/exports/CBL_Exports.txt @@ -173,5 +173,6 @@ CBLReplicator_PendingDocumentIDs CBLReplicator_IsDocumentPending CBLReplicator_AddChangeListener CBLReplicator_AddDocumentReplicationListener +CBLReplicator_UserAgent CBLDefaultConflictResolver diff --git a/src/exports/generated/CBL.def b/src/exports/generated/CBL.def index 5024026d..2fb3c10e 100644 --- a/src/exports/generated/CBL.def +++ b/src/exports/generated/CBL.def @@ -132,6 +132,7 @@ CBLReplicator_PendingDocumentIDs CBLReplicator_IsDocumentPending CBLReplicator_AddChangeListener CBLReplicator_AddDocumentReplicationListener +CBLReplicator_UserAgent CBLDefaultConflictResolver kFLNullValue kFLUndefinedValue diff --git a/src/exports/generated/CBL.exp b/src/exports/generated/CBL.exp index 51da20ed..1ffc51db 100644 --- a/src/exports/generated/CBL.exp +++ b/src/exports/generated/CBL.exp @@ -140,6 +140,7 @@ _CBLReplicator_PendingDocumentIDs _CBLReplicator_IsDocumentPending _CBLReplicator_AddChangeListener _CBLReplicator_AddDocumentReplicationListener +_CBLReplicator_UserAgent _CBLDefaultConflictResolver _kFLNullValue _kFLUndefinedValue diff --git a/src/exports/generated/CBL.gnu b/src/exports/generated/CBL.gnu index cf12d158..91ca9b10 100644 --- a/src/exports/generated/CBL.gnu +++ b/src/exports/generated/CBL.gnu @@ -130,6 +130,7 @@ CBL_C { CBLReplicator_IsDocumentPending; CBLReplicator_AddChangeListener; CBLReplicator_AddDocumentReplicationListener; + CBLReplicator_UserAgent; CBLDefaultConflictResolver; kFLNullValue; kFLUndefinedValue; diff --git a/src/exports/generated/CBL_Android.gnu b/src/exports/generated/CBL_Android.gnu index 2bd41015..53f0aca5 100644 --- a/src/exports/generated/CBL_Android.gnu +++ b/src/exports/generated/CBL_Android.gnu @@ -131,6 +131,7 @@ CBL_C { CBLReplicator_IsDocumentPending; CBLReplicator_AddChangeListener; CBLReplicator_AddDocumentReplicationListener; + CBLReplicator_UserAgent; CBLDefaultConflictResolver; kFLNullValue; kFLUndefinedValue; diff --git a/src/exports/generated/CBL_EE.def b/src/exports/generated/CBL_EE.def index 5d4fc2fb..9e19f065 100644 --- a/src/exports/generated/CBL_EE.def +++ b/src/exports/generated/CBL_EE.def @@ -152,6 +152,7 @@ CBLReplicator_PendingDocumentIDs CBLReplicator_IsDocumentPending CBLReplicator_AddChangeListener CBLReplicator_AddDocumentReplicationListener +CBLReplicator_UserAgent CBLDefaultConflictResolver kFLNullValue kFLUndefinedValue diff --git a/src/exports/generated/CBL_EE.exp b/src/exports/generated/CBL_EE.exp index 7fed1b44..82246079 100644 --- a/src/exports/generated/CBL_EE.exp +++ b/src/exports/generated/CBL_EE.exp @@ -160,6 +160,7 @@ _CBLReplicator_PendingDocumentIDs _CBLReplicator_IsDocumentPending _CBLReplicator_AddChangeListener _CBLReplicator_AddDocumentReplicationListener +_CBLReplicator_UserAgent _CBLDefaultConflictResolver _kFLNullValue _kFLUndefinedValue diff --git a/src/exports/generated/CBL_EE.gnu b/src/exports/generated/CBL_EE.gnu index fd98a923..d86aff2d 100644 --- a/src/exports/generated/CBL_EE.gnu +++ b/src/exports/generated/CBL_EE.gnu @@ -150,6 +150,7 @@ CBL_C { CBLReplicator_IsDocumentPending; CBLReplicator_AddChangeListener; CBLReplicator_AddDocumentReplicationListener; + CBLReplicator_UserAgent; CBLDefaultConflictResolver; kFLNullValue; kFLUndefinedValue; diff --git a/src/exports/generated/CBL_EE_Android.gnu b/src/exports/generated/CBL_EE_Android.gnu index b2e88790..c5bc34ff 100644 --- a/src/exports/generated/CBL_EE_Android.gnu +++ b/src/exports/generated/CBL_EE_Android.gnu @@ -151,6 +151,7 @@ CBL_C { CBLReplicator_IsDocumentPending; CBLReplicator_AddChangeListener; CBLReplicator_AddDocumentReplicationListener; + CBLReplicator_UserAgent; CBLDefaultConflictResolver; kFLNullValue; kFLUndefinedValue; diff --git a/test/ReplicatorTest.cc b/test/ReplicatorTest.cc index 174c49fe..d1e73bc8 100644 --- a/test/ReplicatorTest.cc +++ b/test/ReplicatorTest.cc @@ -216,6 +216,21 @@ TEST_CASE_METHOD(ReplicatorTest, "Copy pointer configs with nullptr value", "[Re CBLReplicator_Release(repl2); } +TEST_CASE_METHOD(ReplicatorTest, "Check userAgent header", "[Replicator]") { + CBLReplicatorConfiguration config = {}; + config.database = db.ref(); + + CBLError error; + CBLEndpoint* endpoint = CBLEndpoint_CreateWithURL("ws://fsdfds.vzcsg/foobar"_sl, &error); + config.endpoint = endpoint; + + auto repl1 = CBLReplicator_Create(&config, &error); + REQUIRE(repl1); + + auto userAgent = slice(CBLReplicator_UserAgent(repl1)).asString(); + CHECK_THAT(userAgent, Catch::StartsWith("CouchbaseLite/")); + CBLReplicator_Release(repl1); +} #pragma mark - ACTUAL-NETWORK TESTS: From 54be5e98f19cd95c7fc562d764434992444644ec Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 10 Feb 2023 13:34:11 -0800 Subject: [PATCH 65/90] CBL-4111 : Add more info about returning error in prop encryption callbacks (#443) * Updated LiteCore to 3.0.9-2 to uptake the propery encryption fix. * Added more info about returning error in prop encryption / decryption callbacks. * From the change in LiteCore, we now support 503 error returned from the prop encryption / decryption callback, and when the 503 error returned, the replicator will be offline and trigger the retry logic. When the Crypto or the other error returned, the document will be failed to replicate permanently unless there is an update or the replicate is reset during start. * Updated `Encryption error` and `Decryption error` to test with different error types (503, Crypto, and Other). * Remove `status.progress.complete < 1.0` check when there is a replication error as there is no gaurantee that the complete will be less than 1.0. --- include/cbl/CBLReplicator.h | 50 +++++++++++-- test/ReplicatorPropEncTest.cc | 136 +++++++++++++++++++++++++++------- test/ReplicatorTest.hh | 1 - vendor/couchbase-lite-core | 2 +- 4 files changed, 154 insertions(+), 35 deletions(-) diff --git a/include/cbl/CBLReplicator.h b/include/cbl/CBLReplicator.h index cab8f601..3ed04841 100644 --- a/include/cbl/CBLReplicator.h +++ b/include/cbl/CBLReplicator.h @@ -151,10 +151,27 @@ typedef struct { #ifdef COUCHBASE_ENTERPRISE -/** Callback that encrypts \ref CBLEncryptable properties in documents pushed by the replicator. - \note If a null \ref FLSliceResult or an error is returned, the document will be failed to - replicate with the \ref kCBLErrorCrypto error when. For security reason, the encryption - cannot be skipped. */ +/** Callback that encrypts \ref CBLEncryptable properties in the documents pushed by the replicator. + The callback returns encrypted data as a FLSliceResult object, and the replicator will responsible + for releasing the returned FLSliceResult object. + + If an error occurred during encryption, return a null \ref FLSliceResult with an error set to the + out error parameter of the callback. There are two errors that are supported by the callback : + + 1. kCBLDomain / kCBLErrorCrypto : Permanent Crypto Error. When this error is set, the document + will fail to replicate, and the document will not be synced again unless the document is updated, + or the replicator is reset. + + 2. kCBLWebSocketDomain / 503 : Service Unavailable Error. This error is for mostly for a case + such as when a crypto service is temporarily unavailable during encryption. When this error + is set, the replicator will go into the offline state and will retry again according to the replicator + retry logic. As a result, the document will be retried to replicate again, and the encryption callback + will be called again to encrypt the properties of the document. + + @note If an error besides the two errors above is set to the out error parameter of the callback, + or only a null \ref FLSliceResult object is returned without setting an error, the document + will be failed to replicate as the kCBLDomain / kCBLErrorCrypto error is sepecified. + @note A null \ref FLSliceResult can be created by calling FLSliceResult_CreateWith(nullptr, 0). */ typedef FLSliceResult (*CBLPropertyEncryptor) ( void* context, ///< Replicator’s context FLString documentID, ///< Document ID @@ -167,9 +184,28 @@ typedef FLSliceResult (*CBLPropertyEncryptor) ( ); /** Callback that decrypts encrypted \ref CBLEncryptable properties in documents pulled by the replicator. - \note The decryption will be skipped (the encrypted data will be kept) when a null \ref FLSliceResult - without an error is returned. If an error is returned, the document will be failed to replicate - with the \ref kCBLErrorCrypto error. */ + The callback returns decrypted data as a FLSliceResult object, and the replicator will responsible for + releasing the returned FLSliceResult object. + + If an error occurred during decryption, return a null \ref FLSliceResult with an error set to the + out error parameter of the callback. There are two errors that are supported by the callback : + + 1. kCBLDomain / kCBLErrorCrypto : Permanent Crypto Error. When this error is set, the document + will fail to replicate, and the document will not be synced again unless the document is updated, + or the replicator is reset. + + 2. kCBLWebSocketDomain / 503 : Service Unavailable Error. This error is for mostly for a case + such as when a crypto service is temporarily unavailable during decryption. When this error + is set, the replicator will go into the offline state and will retry again according to the replicator + retry logic. As a result, the document will be retried to replicate again, and the decryption callback + will be called again to decrypt the properties of the document. + + If the decryption should be skipped to retain the encrypted data as-is, return a null \ref FLSliceResult + object without setting an error set to the out error parameter. + + @note If an error besides the two errors above is set to the out error parameter of the callback, + the document will be failed to replicate as getting the kCBLDomain / kCBLErrorCrypto error. + @note A null \ref FLSliceResult can be created by calling FLSliceResult_CreateWith(nullptr, 0). */ typedef FLSliceResult (*CBLPropertyDecryptor) ( void* context, ///< Replicator’s context FLString documentID, ///< Document ID diff --git a/test/ReplicatorPropEncTest.cc b/test/ReplicatorPropEncTest.cc index 45edbf06..175deb5e 100644 --- a/test/ReplicatorPropEncTest.cc +++ b/test/ReplicatorPropEncTest.cc @@ -35,8 +35,8 @@ class ReplicatorPropertyEncryptionTest : public ReplicatorTest { bool skipEncryption = false; bool skipDecryption = false; - bool encryptionError = false; - bool decryptionError = false; + CBLError encryptionError = { }; + CBLError decryptionError = { }; ReplicatorPropertyEncryptionTest() :otherDB(openEmptyDatabaseNamed("otherDB")) @@ -94,13 +94,12 @@ class ReplicatorPropertyEncryptionTest : public ReplicatorTest { encryptCount++; if (skipEncryption) { // Not allow and will result to an crypto error - return FLSliceResult(alloc_slice(kFLSliceNull)); + return FLSliceResult_CreateWith(nullptr, 0); } - if (encryptionError) { - CBLError err = {kCBLDomain, kCBLErrorCrypto}; - *error = err; - return FLSliceResult(alloc_slice(kFLSliceNull)); + if (encryptionError.code > 0) { + *error = encryptionError; + return FLSliceResult_CreateWith(nullptr, 0); } alloc_slice encrypted(input); @@ -123,13 +122,12 @@ class ReplicatorPropertyEncryptionTest : public ReplicatorTest { decryptCount++; if (skipDecryption) { // Not allow and will result to an crypto error - return FLSliceResult(alloc_slice(kFLSliceNull)); + return FLSliceResult_CreateWith(nullptr, 0); } - if (decryptionError) { - CBLError err = {kCBLDomain, kCBLErrorCrypto}; - *error = err; - return FLSliceResult(alloc_slice(kFLSliceNull)); + if (decryptionError.code > 0) { + *error = decryptionError; + return FLSliceResult_CreateWith(nullptr, 0); } alloc_slice decrypted(input); @@ -626,6 +624,8 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Skip decryption : ok", "[Rep TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encryption error", "[Replicator][Encryptable]") { + CBLLog_SetConsoleLevel(kCBLLogVerbose); + auto doc = CBLDocument_CreateWithID("doc1"_sl); auto props = CBLDocument_MutableProperties(doc); @@ -638,18 +638,60 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Encryption error", "[Replica CBLDocument_Release(doc); CBLEncryptable_Release(secret1); - config.replicatorType = kCBLReplicatorTypePushAndPull; + config.replicatorType = kCBLReplicatorTypePush; + setupEncryptionCallback(true, false); - { - ExpectingExceptions x; - encryptionError = true; - replicate(); + CBLError expectedError = { }; + CBLError expectedDocReplError = { }; + bool willRetryToSyncAgain = false; + + SECTION("503 Error") { + encryptionError = {kCBLWebSocketDomain, 503}; + expectedDocReplError = encryptionError; + expectedError = encryptionError; + willRetryToSyncAgain = true; // The doc should be retried to sync again + } + + SECTION("Crypto Error") { + encryptionError = {kCBLDomain, kCBLErrorCrypto}; + expectedDocReplError = encryptionError; + expectedError = { }; + } + + SECTION("Other Error") { + encryptionError = {kCBLDomain, kCBLErrorUnexpectedError}; + expectedDocReplError = encryptionError; + expectedError = { }; } + ExpectingExceptions x; + replicate(expectedError); + CHECK(replicatedDocs.size() == 1); - CHECK(replicatedDocs[0].error.code == kCBLErrorCrypto); - CHECK(replicatedDocs[0].error.domain == kCBLDomain); + CHECK(replicatedDocs[0] .error.domain == expectedDocReplError.domain); + CHECK(replicatedDocs[0].error.code == expectedDocReplError.code); CHECK(!CBLDatabase_GetDocument(otherDB.ref(), "doc1"_sl, &error)); + + // Now try to replicate again with no error: + + replicatedDocs.clear(); + encryptionError = { }; + + expectedError = { }; + replicate(); + + if (willRetryToSyncAgain) { + CHECK(replicatedDocs.size() == 1); + CHECK(replicatedDocs[0].error.domain == 0); + CHECK(replicatedDocs[0].error.code == 0); + + const CBLDocument* doc1 = CBLDatabase_GetDocument(otherDB.ref(), "doc1"_sl, &error); + CHECK(doc1); + CBLDocument_Release(doc1); + } else { + CHECK(replicatedDocs.size() == 0); + CHECK(!CBLDatabase_GetDocument(otherDB.ref(), "doc1"_sl, &error)); + } } TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Decryption error", "[Replicator][Encryptable]") { @@ -679,18 +721,60 @@ TEST_CASE_METHOD(ReplicatorPropertyEncryptionTest, "Decryption error", "[Replica replicatedDocs.clear(); resetDBAndReplicator(); - { - ExpectingExceptions x; - decryptionError = true; - replicate(); + CBLError expectedError = { }; + CBLError expectedDocReplError = { }; + bool willRetryToSyncAgain = false; + + SECTION("503 Error") { + decryptionError = {kCBLWebSocketDomain, 503}; + expectedDocReplError = decryptionError; + expectedError = decryptionError; + willRetryToSyncAgain = true; // The doc should be retried to sync again } - + + SECTION("Crypto Error") { + decryptionError = {kCBLDomain, kCBLErrorCrypto}; + expectedDocReplError = decryptionError; + expectedError = { }; + } + + SECTION("Other Error") { + decryptionError = {kCBLDomain, kCBLErrorUnexpectedError}; + expectedDocReplError = decryptionError; + expectedError = { }; + } + + CHECK(replicatedDocs.size() == 0); + ExpectingExceptions x; + replicate(expectedError); + CHECK(replicatedDocs.size() == 1); - CHECK(replicatedDocs[0].error.code == kCBLErrorCrypto); - CHECK(replicatedDocs[0].error.domain == kCBLDomain); + CHECK(replicatedDocs[0].error.domain == expectedDocReplError.domain); + CHECK(replicatedDocs[0].error.code == expectedDocReplError.code); CBLError error; CHECK(!CBLDatabase_GetDocument(db.ref(), "doc1"_sl, &error)); + + // Now try to replicate again with no error: + + replicatedDocs.clear(); + decryptionError = { }; + + expectedError = { }; + replicate(); + + if (willRetryToSyncAgain) { + CHECK(replicatedDocs.size() == 1); + CHECK(replicatedDocs[0].error.domain == 0); + CHECK(replicatedDocs[0].error.code == 0); + + const CBLDocument* doc = CBLDatabase_GetDocument(db.ref(), "doc1"_sl, &error); + CHECK(doc); + CBLDocument_Release(doc); + } else { + CHECK(replicatedDocs.size() == 0); + CHECK(!CBLDatabase_GetDocument(db.ref(), "doc1"_sl, &error)); + } } } diff --git a/test/ReplicatorTest.hh b/test/ReplicatorTest.hh index 35780534..80eb5534 100644 --- a/test/ReplicatorTest.hh +++ b/test/ReplicatorTest.hh @@ -105,7 +105,6 @@ public: if (expectedError.code > 0) { CHECK(status.error.code == expectedError.code); - CHECK(status.progress.complete < 1.0); } else { CHECK(status.error.code == 0); CHECK(status.progress.complete == 1.0); diff --git a/vendor/couchbase-lite-core b/vendor/couchbase-lite-core index 50ce87bd..77212825 160000 --- a/vendor/couchbase-lite-core +++ b/vendor/couchbase-lite-core @@ -1 +1 @@ -Subproject commit 50ce87bd3e04394159f2a615abf4a9b3e7fa16be +Subproject commit 7721282531cec0c0c3106b26337afe9a6b803237 From cc067e15930b6e51648e1299e8a794e3d2091ce5 Mon Sep 17 00:00:00 2001 From: Pasin Suriyentrakorn Date: Fri, 10 Feb 2023 15:21:40 -0800 Subject: [PATCH 66/90] Regenerate API docs (#444) --- docs/C/html/_base_8h.html | 65 +- docs/C/html/_base_8h_source.html | 431 ++--- docs/C/html/_c_b_l___compat_8h.html | 59 +- docs/C/html/_c_b_l___compat_8h_source.html | 27 +- docs/C/html/_c_b_l_base_8h.html | 62 +- docs/C/html/_c_b_l_base_8h_source.html | 35 +- docs/C/html/_c_b_l_blob_8h.html | 114 +- docs/C/html/_c_b_l_blob_8h_source.html | 196 +- docs/C/html/_c_b_l_database_8h.html | 96 +- docs/C/html/_c_b_l_database_8h_source.html | 39 +- docs/C/html/_c_b_l_document_8h.html | 102 +- docs/C/html/_c_b_l_document_8h_source.html | 107 +- docs/C/html/_c_b_l_encryptable_8h.html | 76 +- docs/C/html/_c_b_l_encryptable_8h_source.html | 54 +- docs/C/html/_c_b_l_log_8h.html | 51 +- docs/C/html/_c_b_l_log_8h_source.html | 33 +- docs/C/html/_c_b_l_platform_8h.html | 27 +- docs/C/html/_c_b_l_platform_8h_source.html | 27 +- docs/C/html/_c_b_l_query_8h.html | 110 +- docs/C/html/_c_b_l_query_8h_source.html | 43 +- docs/C/html/_c_b_l_replicator_8h.html | 93 +- docs/C/html/_c_b_l_replicator_8h_source.html | 397 ++-- docs/C/html/_couchbase_lite_8h.html | 27 +- docs/C/html/_couchbase_lite_8h_source.html | 27 +- docs/C/html/_f_l_slice_8h.html | 67 +- docs/C/html/_f_l_slice_8h_source.html | 347 ++-- .../C/html/_fleece_09_core_foundation_8h.html | 33 +- .../_fleece_09_core_foundation_8h_source.html | 159 +- docs/C/html/_fleece_8h.html | 492 ++--- docs/C/html/_fleece_8h_source.html | 1630 +++++++++-------- docs/C/html/annotated.html | 43 +- docs/C/html/bc_sd.png | Bin 0 -> 635 bytes docs/C/html/classes.html | 27 +- .../dir_17ad6c03ac95e637f87755575f40449e.html | 27 +- .../dir_2ecb5472ec723897fff4bd7d3317a27a.html | 27 +- .../dir_42eeca32d5bbc87802b2b9475842edbd.html | 27 +- .../dir_644f78e2d6809b3b77fed6ee8030c9f9.html | 27 +- .../dir_b346636a750f54d78818ae1d73f9fdd0.html | 27 +- .../dir_c5da75fdc1d6c57999112ed830c87a3c.html | 27 +- .../dir_d44c64559bbebec7f509842c48db8b23.html | 27 +- .../dir_f77815f292c27e5d3b6029f59ba49998.html | 27 +- docs/C/html/docd.png | Bin 0 -> 756 bytes docs/C/html/doxygen.css | 994 ++++++---- docs/C/html/dynsections.js | 2 + docs/C/html/files.html | 49 +- docs/C/html/functions.html | 27 +- docs/C/html/functions_vars.html | 27 +- docs/C/html/globals.html | 27 +- docs/C/html/globals_c.html | 60 +- docs/C/html/globals_defs.html | 27 +- docs/C/html/globals_enum.html | 28 +- docs/C/html/globals_eval.html | 30 +- docs/C/html/globals_f.html | 35 +- docs/C/html/globals_func.html | 27 +- docs/C/html/globals_func_c.html | 59 +- docs/C/html/globals_func_f.html | 35 +- docs/C/html/globals_h.html | 27 +- docs/C/html/globals_k.html | 31 +- docs/C/html/globals_m.html | 27 +- docs/C/html/globals_n.html | 27 +- docs/C/html/globals_r.html | 27 +- docs/C/html/globals_s.html | 27 +- docs/C/html/globals_type.html | 27 +- docs/C/html/globals_vars.html | 28 +- docs/C/html/globals_w.html | 27 +- docs/C/html/group___c_f.html | 43 +- docs/C/html/group___f_l_array.html | 264 +-- docs/C/html/group___f_l_deep_iterator.html | 85 +- docs/C/html/group___f_l_dict.html | 238 ++- docs/C/html/group___f_l_encoder.html | 241 +-- docs/C/html/group___f_l_key_path.html | 73 +- docs/C/html/group___f_l_shared_keys.html | 91 +- docs/C/html/group___f_l_slice.html | 199 +- docs/C/html/group___f_l_value.html | 210 ++- docs/C/html/group___slots.html | 91 +- docs/C/html/group__blobs.html | 470 ++++- docs/C/html/group__database.html | 184 +- docs/C/html/group__delta.html | 53 +- docs/C/html/group__documents.html | 222 +-- docs/C/html/group__encryptables.html | 206 ++- docs/C/html/group__errors.html | 148 +- docs/C/html/group__json.html | 63 +- docs/C/html/group__listeners.html | 65 +- docs/C/html/group__logging.html | 106 +- docs/C/html/group__other__types.html | 35 +- docs/C/html/group__queries.html | 222 +-- docs/C/html/group__reading.html | 119 +- docs/C/html/group__refcounting.html | 65 +- docs/C/html/group__replication.html | 282 +-- docs/C/html/group__types.html | 57 +- docs/C/html/index.html | 27 +- docs/C/html/jquery.js | 7 +- docs/C/html/menu.js | 43 +- docs/C/html/modules.html | 51 +- docs/C/html/nav_fd.png | Bin 0 -> 169 bytes docs/C/html/nav_hd.png | Bin 0 -> 114 bytes docs/C/html/search/all_3.js | 365 ++-- docs/C/html/search/all_6.js | 298 +-- docs/C/html/search/all_9.js | 78 +- docs/C/html/search/enums_0.js | 3 +- docs/C/html/search/enumvalues_0.js | 65 +- docs/C/html/search/functions_1.js | 230 +-- docs/C/html/search/functions_2.js | 260 +-- docs/C/html/search/mag.svg | 37 + docs/C/html/search/mag_d.svg | 37 + docs/C/html/search/mag_seld.svg | 74 + docs/C/html/search/search.css | 110 +- docs/C/html/search/search.js | 124 +- docs/C/html/search/variables_8.js | 3 +- docs/C/html/splitbard.png | Bin 0 -> 282 bytes .../struct_c_b_l_database_configuration.html | 37 +- docs/C/html/struct_c_b_l_encryption_key.html | 37 +- docs/C/html/struct_c_b_l_error.html | 41 +- ...t_c_b_l_full_text_index_configuration.html | 55 +- .../struct_c_b_l_log_file_configuration.html | 49 +- docs/C/html/struct_c_b_l_proxy_settings.html | 49 +- .../struct_c_b_l_replicated_document.html | 41 +- ...struct_c_b_l_replicator_configuration.html | 119 +- .../struct_c_b_l_replicator_progress.html | 39 +- .../html/struct_c_b_l_replicator_status.html | 41 +- ...truct_c_b_l_value_index_configuration.html | 39 +- docs/C/html/struct_f_l_array_iterator.html | 33 +- docs/C/html/struct_f_l_dict_iterator.html | 33 +- docs/C/html/struct_f_l_dict_key.html | 33 +- docs/C/html/struct_f_l_path_component.html | 37 +- docs/C/html/struct_f_l_slice.html | 37 +- docs/C/html/struct_f_l_slice_result.html | 37 +- docs/C/html/tab_ad.png | Bin 0 -> 135 bytes docs/C/html/tab_bd.png | Bin 0 -> 173 bytes docs/C/html/tab_hd.png | Bin 0 -> 180 bytes docs/C/html/tab_sd.png | Bin 0 -> 188 bytes docs/C/html/tabs.css | 2 +- 132 files changed, 7575 insertions(+), 5815 deletions(-) create mode 100644 docs/C/html/bc_sd.png create mode 100644 docs/C/html/docd.png create mode 100644 docs/C/html/nav_fd.png create mode 100644 docs/C/html/nav_hd.png create mode 100644 docs/C/html/search/mag.svg create mode 100644 docs/C/html/search/mag_d.svg create mode 100644 docs/C/html/search/mag_seld.svg create mode 100644 docs/C/html/splitbard.png create mode 100644 docs/C/html/tab_ad.png create mode 100644 docs/C/html/tab_bd.png create mode 100644 docs/C/html/tab_hd.png create mode 100644 docs/C/html/tab_sd.png diff --git a/docs/C/html/_base_8h.html b/docs/C/html/_base_8h.html index 786fbe36..7b5f4668 100644 --- a/docs/C/html/_base_8h.html +++ b/docs/C/html/_base_8h.html @@ -1,9 +1,9 @@ - + - + Couchbase Lite C: vendor/couchbase-lite-core/vendor/fleece/API/fleece/Base.h File Reference @@ -19,8 +19,8 @@
- - +
+
Couchbase Lite C
Couchbase Lite C API
@@ -30,10 +30,10 @@
- + @@ -56,9 +56,16 @@
- +
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+