Couchbase Lite C
Couchbase Lite C API
|
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 |
Functions | |
FLSharedKeys | FLSharedKeys_New (void) |
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... | |
bool | FLSharedKeys_LoadStateData (FLSharedKeys, FLSlice) |
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData. More... | |
void | FLSharedKeys_WriteState (FLSharedKeys, FLEncoder) |
Writes the current state to a Fleece encoder as a single value, which can later be decoded and passed to FLSharedKeys_LoadState. More... | |
bool | FLSharedKeys_LoadState (FLSharedKeys, FLValue) |
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_WriteState. More... | |
int | FLSharedKeys_Encode (FLSharedKeys, FLString, bool add) |
Maps a key string to a number in the range [0...2047], or returns -1 if it isn't mapped. More... | |
FLString | FLSharedKeys_Decode (FLSharedKeys, int key) |
Returns the key string that maps to the given integer key , else NULL. More... | |
unsigned | FLSharedKeys_Count (FLSharedKeys) |
Returns the number of keys in the mapping. More... | |
void | FLSharedKeys_RevertToCount (FLSharedKeys, unsigned oldCount) |
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount . More... | |
FLSharedKeys | FLSharedKeys_Retain (FLSharedKeys) |
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... | |
FLSharedKeyScope | FLSharedKeyScope_WithRange (FLSlice range, FLSharedKeys) |
void | FLSharedKeyScope_Free (FLSharedKeyScope) |
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 struct _FLSharedKeyScope* FLSharedKeyScope |
typedef bool(* FLSharedKeysReadCallback) (void *context, FLSharedKeys) |
unsigned FLSharedKeys_Count | ( | FLSharedKeys | ) |
Returns the number of keys in the mapping.
This number increases whenever the mapping is changed, and never decreases.
FLString FLSharedKeys_Decode | ( | FLSharedKeys | , |
int | key | ||
) |
Returns the key string that maps to the given integer key
, else NULL.
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.
If the key doesn't already have a mapping, and the add
flag is true, a new mapping is assigned and returned. However, the add
flag has no effect if the key is unmappable (is longer than 16 bytes or contains non-identifier characters), or if all available integers have been assigned.
FLSliceResult FLSharedKeys_GetStateData | ( | FLSharedKeys | ) |
Returns a data blob containing the current state (all the keys and their integers.)
bool FLSharedKeys_LoadState | ( | FLSharedKeys | , |
FLValue | |||
) |
Updates an FLSharedKeys object with saved state, a Fleece value previously written by FLSharedKeys_WriteState.
bool FLSharedKeys_LoadStateData | ( | FLSharedKeys | , |
FLSlice | |||
) |
Updates an FLSharedKeys with saved state data created by FLSharedKeys_GetStateData.
FLSharedKeys FLSharedKeys_New | ( | void | ) |
Creates a new empty FLSharedKeys object, which must eventually be released.
FLSharedKeys FLSharedKeys_NewWithRead | ( | FLSharedKeysReadCallback | , |
void * | context | ||
) |
void FLSharedKeys_Release | ( | FLSharedKeys | ) |
Decrements the reference count of an FLSharedKeys, freeing it when it reaches zero.
FLSharedKeys FLSharedKeys_Retain | ( | FLSharedKeys | ) |
Increments the reference count of an FLSharedKeys.
void FLSharedKeys_RevertToCount | ( | FLSharedKeys | , |
unsigned | oldCount | ||
) |
Reverts an FLSharedKeys by "forgetting" any keys added since it had the count oldCount
.
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.
void FLSharedKeyScope_Free | ( | FLSharedKeyScope | ) |
FLSharedKeyScope FLSharedKeyScope_WithRange | ( | FLSlice | range, |
FLSharedKeys | |||
) |