Couchbase Lite C
Couchbase Lite C API
Typedefs | Functions
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...
 

Functions

FLKeyPath FLKeyPath_New (FLSlice specifier, FLError *error)
 Creates a new FLKeyPath object by compiling a path specifier string. More...
 
void FLKeyPath_Free (FLKeyPath)
 Frees a compiled FLKeyPath object. More...
 
FLValue FLKeyPath_Eval (FLKeyPath, FLValue root)
 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...
 
FLStringResult FLKeyPath_ToString (FLKeyPath path)
 Returns a path in string form. More...
 
bool FLKeyPath_Equals (FLKeyPath path1, FLKeyPath path2)
 Equality test. More...
 
bool FLKeyPath_GetElement (FLKeyPath, size_t i, FLSlice *outDictKey, int32_t *outArrayIndex)
 Returns an element of a path, either a key or an array index. More...
 

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

Typedef Documentation

◆ FLKeyPath

typedef struct _FLKeyPath* FLKeyPath

A reference to a key path.

Function Documentation

◆ FLKeyPath_Equals()

bool FLKeyPath_Equals ( FLKeyPath  path1,
FLKeyPath  path2 
)

Equality test.

◆ FLKeyPath_Eval()

FLValue FLKeyPath_Eval ( FLKeyPath  ,
FLValue  root 
)

Evaluates a compiled key-path for a given Fleece root object.

◆ FLKeyPath_EvalOnce()

FLValue FLKeyPath_EvalOnce ( FLSlice  specifier,
FLValue  root,
FLError error 
)

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.

◆ FLKeyPath_Free()

void FLKeyPath_Free ( FLKeyPath  )

Frees a compiled FLKeyPath object.

(It's ok to pass NULL.)

◆ FLKeyPath_GetElement()

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.

◆ FLKeyPath_New()

FLKeyPath FLKeyPath_New ( FLSlice  specifier,
FLError error 
)

Creates a new FLKeyPath object by compiling a path specifier string.

◆ FLKeyPath_ToString()

FLStringResult FLKeyPath_ToString ( FLKeyPath  path)

Returns a path in string form.