Couchbase Lite C
Couchbase Lite C API
Typedefs | Enumerations
Basic Fleece Data Types

Typedefs

typedef const struct _FLValue * FLValue
 A reference to a value of any type. More...
 
typedef const struct _FLArray * FLArray
 A reference to an array value. More...
 
typedef const struct _FLDict * FLDict
 A reference to a dictionary (map) value. More...
 
typedef struct _FLSlot * FLSlot
 A reference to a mutable array/dict item. More...
 
typedef struct _FLArray * FLMutableArray
 A reference to a mutable array. More...
 
typedef struct _FLDict * FLMutableDict
 A reference to a mutable dictionary. More...
 
typedef struct _FLEncoder * FLEncoder
 A reference to an encoder. More...
 
typedef struct _FLDoc * FLDoc
 A reference to a document. More...
 
typedef struct _FLSharedKeys * FLSharedKeys
 A reference to a shared-keys mapping. More...
 

Enumerations

enum  FLError {
  kFLNoError = 0 , kFLMemoryError , kFLOutOfRange , kFLInvalidData ,
  kFLEncodeError , kFLJSONError , kFLUnknownValue , kFLInternalError ,
  kFLNotFound , kFLSharedKeysStateError , kFLPOSIXError , kFLUnsupported
}
 Error codes returned from some API calls. More...
 
enum  FLTrust { kFLUntrusted , kFLTrusted }
 Specifies whether not input data is trusted to be 100% valid Fleece. More...
 

Timestamps

Fleece does not have a native type for dates or times; like JSON, they are represented as strings in ISO-8601 format, which look like "2008-08-07T05:18:51.589Z".

They can also be represented more compactly as numbers, interpreted as milliseconds since the Unix epoch (midnight at January 1 1970, UTC.)

typedef int64_t FLTimestamp
 A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.) More...
 
FLEECE_PUBLIC FLTimestamp FLTimestamp_Now (void)
 Returns an FLTimestamp corresponding to the current time. More...
 
FLEECE_PUBLIC FLStringResult FLTimestamp_ToString (FLTimestamp timestamp, bool asUTC)
 Formats a timestamp as a date-time string in ISO-8601 format. More...
 
FLEECE_PUBLIC FLTimestamp FLTimestamp_FromString (FLString str)
 Parses an ISO-8601 date-time string to a timestamp. More...
 
#define FLTimestampNone   INT64_MIN
 A value representing a missing timestamp; returned when a date cannot be parsed. More...
 

Detailed Description

Macro Definition Documentation

◆ FLTimestampNone

#define FLTimestampNone   INT64_MIN

A value representing a missing timestamp; returned when a date cannot be parsed.

Typedef Documentation

◆ FLArray

typedef const struct _FLArray* FLArray

A reference to an array value.

◆ FLDict

typedef const struct _FLDict* FLDict

A reference to a dictionary (map) value.

◆ FLDoc

typedef struct _FLDoc* FLDoc

A reference to a document.

◆ FLEncoder

typedef struct _FLEncoder* FLEncoder

A reference to an encoder.

◆ FLMutableArray

typedef struct _FLArray* FLMutableArray

A reference to a mutable array.

◆ FLMutableDict

typedef struct _FLDict* FLMutableDict

A reference to a mutable dictionary.

◆ FLSharedKeys

typedef struct _FLSharedKeys* FLSharedKeys

A reference to a shared-keys mapping.

◆ FLSlot

typedef struct _FLSlot* FLSlot

A reference to a mutable array/dict item.

◆ FLTimestamp

typedef int64_t FLTimestamp

A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC.)

◆ FLValue

typedef const struct _FLValue* FLValue

A reference to a value of any type.

Enumeration Type Documentation

◆ FLError

enum FLError

Error codes returned from some API calls.

Enumerator
kFLNoError 
kFLMemoryError 
kFLOutOfRange 
kFLInvalidData 
kFLEncodeError 
kFLJSONError 
kFLUnknownValue 
kFLInternalError 
kFLNotFound 
kFLSharedKeysStateError 
kFLPOSIXError 
kFLUnsupported 

◆ FLTrust

enum FLTrust

Specifies whether not input data is trusted to be 100% valid Fleece.

Enumerator
kFLUntrusted 

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

Function Documentation

◆ FLTimestamp_FromString()

FLEECE_PUBLIC FLTimestamp FLTimestamp_FromString ( FLString  str)

Parses an ISO-8601 date-time string to a timestamp.

On failure returns FLTimestampNone.

Note
See also FLValue_AsTimestamp, which takes an FLValue and interprets numeric representations as well as strings.

◆ FLTimestamp_Now()

FLEECE_PUBLIC FLTimestamp FLTimestamp_Now ( void  )

Returns an FLTimestamp corresponding to the current time.

◆ FLTimestamp_ToString()

FLEECE_PUBLIC FLStringResult FLTimestamp_ToString ( FLTimestamp  timestamp,
bool  asUTC 
)

Formats a timestamp as a date-time string in ISO-8601 format.

Note
See also FLEncoder_WriteDateString, which writes a timestamp to an FLEncoder.
Parameters
timestampA time, given as milliseconds since the Unix epoch (1/1/1970 00:00 UTC.)
asUTCIf true, the timestamp will be given in universal time; if false, in the local timezone.
Returns
A heap-allocated string, which you are responsible for releasing.