Couchbase Lite C
Couchbase Lite C API
Functions
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...
 
bool FLEncodeJSONDelta (FLValue old, FLValue nuu, FLEncoder jsonEncoder)
 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...
 
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...
 

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.

Function Documentation

◆ FLApplyJSONDelta()

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.

Parameters
oldA value that's typically the old/original state of some data. This must be equal to the old value used when creating the jsonDelta.
jsonDeltaA JSON-encoded delta created by FLCreateJSONDelta or FLEncodeJSONDelta.
errorOn failure, error information will be stored where this points, if non-null.
Returns
The corresponding nuu value, encoded as Fleece, or null if an error occurred.

◆ FLCreateJSONDelta()

FLSliceResult FLCreateJSONDelta ( FLValue  old,
FLValue  nuu 
)

Returns JSON that encodes the changes to turn the value old into nuu.

(The format is documented in Fleece.md, but you should treat it as a black box.)

Parameters
oldA value that's typically the old/original state of some data.
nuuA value that's typically the new/changed state of the old data.
Returns
JSON data representing the changes from old to nuu, or NULL on (extremely unlikely) failure.

◆ FLEncodeApplyingJSONDelta()

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.

Parameters
oldA value that's typically the old/original state of some data. This must be equal to the old value used when creating the jsonDelta.
jsonDeltaA JSON-encoded delta created by FLCreateJSONDelta or FLEncodeJSONDelta.
encoderA Fleece encoder to write the decoded nuu value to. (JSON encoding is not supported.)
Returns
True on success, false on error; call FLEncoder_GetError for details.

◆ FLEncodeJSONDelta()

bool FLEncodeJSONDelta ( FLValue  old,
FLValue  nuu,
FLEncoder  jsonEncoder 
)

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

Parameters
oldA value that's typically the old/original state of some data.
nuuA value that's typically the new/changed state of the old data.
jsonEncoderAn encoder to write the JSON to. Must have been created using FLEncoder_NewWithOptions, with JSON or JSON5 format.
Returns
True on success, false on (extremely unlikely) failure.