Couchbase Lite C
Couchbase Lite C API
FLExpert.h
Go to the documentation of this file.
1//
2// FLExpert.h
3//
4// Copyright 2016-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14#ifndef _FLOBSCURE_H
15#define _FLOBSCURE_H
16
17#include "FLValue.h"
18
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25 // VOLATILE API: FLExpert methods are meant for internal use, and will be removed
26 // in a future release
27
28 // This is the C API! For the C++ API, see Fleece.hh.
29
30
39 #define kFLTrustedDontParse FLTrust(-1)
40
59
69 FLEncoder jsonEncoder) FLAPI;
70
71
81 FLSlice jsonDelta,
82 FLError* FL_NULLABLE outError) FLAPI;
83
94 FLSlice jsonDelta,
95 FLEncoder encoder) FLAPI;
120
121 typedef bool (*FLSharedKeysReadCallback)(void* FL_NULLABLE context, FLSharedKeys);
122
124 void* FL_NULLABLE context) FLAPI;
125
128
132
136
140
147
150
154
157
160
163
166
167
168 typedef struct _FLSharedKeyScope* FLSharedKeyScope;
169
173
176
195
217 FLStringResult* FL_NULLABLE outErrorMessage,
218 size_t* FL_NULLABLE outErrorPos,
219 FLError* FL_NULLABLE outError) FLAPI;
220
224
246 bool reuseStrings, bool externPointers) FLAPI;
247
250
254
258
259 #define kFLNoWrittenValue INTPTR_MIN
260
266
272
278
281
286
287
297
301
305
311#ifdef __cplusplus
312}
313#endif
314
316
317#endif // _FLOBSCURE_H
#define FL_NULLABLE
Definition: CompilerSupport.h:87
#define FLEECE_PUBLIC
Definition: CompilerSupport.h:254
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:85
#define FLPURE
Definition: CompilerSupport.h:123
#define NODISCARD
Definition: CompilerSupport.h:59
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:86
#define FLAPI
Definition: CompilerSupport.h:260
NODISCARD FLEECE_PUBLIC FLSliceResult FLCreateJSONDelta(FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu)
Returns JSON that encodes the changes to turn the value old into nuu.
struct _FLSharedKeyScope * FLSharedKeyScope
Definition: FLExpert.h:168
FLEECE_PUBLIC size_t FLEncoder_GetNextWritePos(FLEncoder)
Returns the byte offset in the encoded data where the next value will be written.
NODISCARD FLEECE_PUBLIC FLSharedKeys FLSharedKeys_NewWithRead(FLSharedKeysReadCallback, void *FL_NULLABLE context)
NODISCARD FLEECE_PUBLIC FLSliceResult FLEncoder_Snip(FLEncoder)
Returns the data written so far as a standalone Fleece document, whose root is the last value written...
FLEECE_PUBLIC void FLSharedKeys_Release(FLSharedKeys FL_NULLABLE)
Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero.
FLEECE_PUBLIC FLSlice FLEncoder_GetBase(FLEncoder)
Returns the base value passed to FLEncoder_Amend.
NODISCARD FLEECE_PUBLIC FLSharedKeys FLSharedKeys_New(void)
Creates a new empty FLSharedKeys object, which must eventually be released.
FLEECE_PUBLIC void FLJSONEncoder_NextDocument(FLEncoder)
In a JSON encoder, adds a newline (' ') and prepares to start encoding another top-level object.
FLEECE_PUBLIC const char *FL_NULLABLE FLDump(FLValue FL_NULLABLE)
Debugging function that returns a C string of JSON.
FLEECE_PUBLIC FLValue FL_NULLABLE FLValue_FromData(FLSlice data, FLTrust trust) FLPURE
Returns a pointer to the root value in the encoded data, or NULL if validation failed.
NODISCARD FLEECE_PUBLIC FLSliceResult FLData_ConvertJSON(FLSlice json, FLError *FL_NULLABLE outError)
Directly converts JSON data to Fleece-encoded data.
FLEECE_PUBLIC void FLEncoder_SuppressTrailer(FLEncoder)
Tells the encoder not to write the two-byte Fleece trailer at the end of the data.
FLEECE_PUBLIC FLStringResult FLData_Dump(FLSlice data)
Produces a human-readable dump of Fleece-encoded data.
FLEECE_PUBLIC void FLSharedKeys_WriteState(FLSharedKeys, FLEncoder)
Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed...
FLEECE_PUBLIC bool FLEncodeApplyingJSONDelta(FLValue FL_NULLABLE old, FLSlice jsonDelta, FLEncoder encoder)
Applies the (parsed) JSON data created by CreateJSONDelta to the value old, which must be equal to th...
NODISCARD FLEECE_PUBLIC FLSharedKeyScope FLSharedKeyScope_WithRange(FLSlice range, FLSharedKeys)
Registers a range of memory containing Fleece data that uses the given shared keys.
FLEECE_PUBLIC FLString FLSharedKeys_Decode(FLSharedKeys, int key)
Returns the key string that maps to the given integer key, else NULL.
NODISCARD FLEECE_PUBLIC size_t FLEncoder_FinishItem(FLEncoder)
Finishes encoding the current item, and returns its offset in the output data.
FLEECE_PUBLIC unsigned FLSharedKeys_Count(FLSharedKeys)
Returns the number of keys in the mapping.
FLEECE_PUBLIC void FLSharedKeyScope_Free(FLSharedKeyScope FL_NULLABLE)
Unregisters a scope created by FLSharedKeyScope_WithRange.
FLEECE_PUBLIC void FLSharedKeys_DisableCaching(FLSharedKeys)
Disable caching of the SharedKeys.
FLEECE_PUBLIC 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...
NODISCARD FLEECE_PUBLIC FLSharedKeys FL_NULLABLE FLSharedKeys_Retain(FLSharedKeys FL_NULLABLE)
Increments the reference count of an FLSharedKeys.
FLEECE_PUBLIC void FLSharedKeys_RevertToCount(FLSharedKeys, unsigned oldCount)
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount.
FLEECE_PUBLIC 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.
NODISCARD FLEECE_PUBLIC FLSliceResult FLSharedKeys_GetStateData(FLSharedKeys)
Returns a data blob containing the current state (all the keys and their integers....
NODISCARD FLEECE_PUBLIC bool FLSharedKeys_LoadState(FLSharedKeys, FLValue)
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_Wr...
FLEECE_PUBLIC const char *FL_NULLABLE FLDumpData(FLSlice data)
Debugging function that parses Fleece data and returns a C string of JSON.
NODISCARD FLEECE_PUBLIC FLSliceResult FLApplyJSONDelta(FLValue FL_NULLABLE old, FLSlice jsonDelta, FLError *FL_NULLABLE outError)
Applies the JSON data created by CreateJSONDelta to the value old, which must be equal to the old val...
FLEECE_PUBLIC bool FLSharedKeys_LoadStateData(FLSharedKeys, FLSlice)
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData.
bool(* FLSharedKeysReadCallback)(void *FL_NULLABLE context, FLSharedKeys)
Definition: FLExpert.h:121
NODISCARD FLEECE_PUBLIC FLStringResult FLJSON5_ToJSON(FLString json5, FLStringResult *FL_NULLABLE outErrorMessage, size_t *FL_NULLABLE outErrorPos, FLError *FL_NULLABLE outError)
Converts valid JSON5 https://json5.org to JSON.
FLEECE_PUBLIC intptr_t FLEncoder_LastValueWritten(FLEncoder)
Returns an opaque reference to the last complete value written to the encoder, if possible.
FLEECE_PUBLIC bool FLEncoder_WriteValueAgain(FLEncoder, intptr_t preWrittenValue)
Writes another reference (a "pointer") to an already-written value, given a reference previously retu...
NODISCARD FLEECE_PUBLIC bool FLEncodeJSONDelta(FLValue FL_NULLABLE old, FLValue FL_NULLABLE nuu, FLEncoder jsonEncoder)
Writes JSON that describes the changes to turn the value old into nuu.
FLError
Error codes returned from some API calls.
Definition: FLBase.h:48
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition: FLBase.h:41
FLTrust
Specifies whether not input data is trusted to be 100% valid Fleece.
Definition: FLBase.h:65
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition: FLBase.h:43
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:35
A simple reference to a block of memory.
Definition: FLSlice.h:45
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:63