Couchbase Lite C
Couchbase Lite C API
FLValue.h
Go to the documentation of this file.
1//
2// FLValue.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 _FLVALUE_H
15#define _FLVALUE_H
16
17#include "FLBase.h"
18
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25 // This is the C API! For the C++ API, see Fleece.hh.
26
27
49 typedef enum {
50 kFLUndefined = -1,
53 kFLNull = 0,
59 kFLDict
61
62
65
70
71
78
81
87
90
94
100
105
112
119
122
127
130
133
136
140
143
146
164
169
174
179#ifdef __cplusplus
180}
181#endif
182
184
185#endif // _FLVALUE_H
#define FL_NULLABLE
Definition: CompilerSupport.h:74
#define FLEECE_PUBLIC
Definition: CompilerSupport.h:241
#define FL_ASSUME_NONNULL_BEGIN
Definition: CompilerSupport.h:72
#define FLPURE
Definition: CompilerSupport.h:110
#define FL_ASSUME_NONNULL_END
Definition: CompilerSupport.h:73
#define FLAPI
Definition: CompilerSupport.h:247
FLValueType
Types of Fleece values.
Definition: FLValue.h:49
FLEECE_PUBLIC FLDict FL_NULLABLE FLValue_AsDict(FLValue FL_NULLABLE) FLPURE
If a FLValue represents a dictionary, returns it as an FLDict, else NULL.
FLEECE_PUBLIC void FLValue_Release(FLValue FL_NULLABLE)
Decrements the ref-count of a mutable value, or of an immutable value's FLDoc.
FLEECE_PUBLIC bool FLValue_AsBool(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to boolean.
static void FLDict_Release(FLDict FL_NULLABLE v)
Definition: FLValue.h:173
static void FLArray_Release(FLArray FL_NULLABLE v)
Definition: FLValue.h:171
static FLArray FL_NULLABLE FLArray_Retain(FLArray FL_NULLABLE v)
Definition: FLValue.h:170
FLEECE_PUBLIC FLSlice FLValue_AsData(FLValue FL_NULLABLE) FLPURE
Returns the exact contents of a data value, or null for all other types.
FLEECE_PUBLIC bool FLValue_IsInteger(FLValue FL_NULLABLE) FLPURE
Returns true if the value is non-NULL and represents an integer.
FLEECE_PUBLIC const FLValue kFLNullValue
A constant null value (like a JSON null, not a NULL pointer!)
static FLDict FL_NULLABLE FLDict_Retain(FLDict FL_NULLABLE v)
Definition: FLValue.h:172
FLEECE_PUBLIC float FLValue_AsFloat(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to a 32-bit floating point number.
FLEECE_PUBLIC bool FLValue_IsDouble(FLValue FL_NULLABLE)
Returns true if the value is non-NULL and represents a 64-bit floating-point number.
FLEECE_PUBLIC FLValueType FLValue_GetType(FLValue FL_NULLABLE) FLPURE
Returns the data type of an arbitrary value.
FLEECE_PUBLIC bool FLValue_IsMutable(FLValue FL_NULLABLE) FLPURE
Returns true if the value is mutable.
FLEECE_PUBLIC bool FLValue_IsEqual(FLValue FL_NULLABLE v1, FLValue FL_NULLABLE v2) FLPURE
Compares two values for equality.
FLEECE_PUBLIC const FLValue kFLUndefinedValue
A constant undefined value.
FLEECE_PUBLIC bool FLValue_IsUnsigned(FLValue FL_NULLABLE) FLPURE
Returns true if the value is non-NULL and represents an integer >= 2^63.
FLEECE_PUBLIC FLTimestamp FLValue_AsTimestamp(FLValue FL_NULLABLE) FLPURE
Converts a value to a timestamp, in milliseconds since Unix epoch, or INT64_MIN on failure.
FLEECE_PUBLIC FLValue FL_NULLABLE FLValue_Retain(FLValue FL_NULLABLE)
Increments the ref-count of a mutable value, or of an immutable value's FLDoc.
FLEECE_PUBLIC int64_t FLValue_AsInt(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to an integer.
FLEECE_PUBLIC FLStringResult FLValue_ToString(FLValue FL_NULLABLE)
Returns a string representation of any scalar value.
FLEECE_PUBLIC FLArray FL_NULLABLE FLValue_AsArray(FLValue FL_NULLABLE) FLPURE
If a FLValue represents an array, returns it cast to FLArray, else NULL.
FLEECE_PUBLIC uint64_t FLValue_AsUnsigned(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to an unsigned integer.
FLEECE_PUBLIC FLString FLValue_AsString(FLValue FL_NULLABLE) FLPURE
Returns the exact contents of a string value, or null for all other types.
FLEECE_PUBLIC double FLValue_AsDouble(FLValue FL_NULLABLE) FLPURE
Returns a value coerced to a 32-bit floating point number.
@ kFLArray
An array of values.
Definition: FLValue.h:58
@ kFLNumber
A numeric value, either integer or floating-point.
Definition: FLValue.h:55
@ kFLBoolean
A true or false value.
Definition: FLValue.h:54
@ kFLString
A string.
Definition: FLValue.h:56
@ kFLNull
Equivalent to a JSON 'null'.
Definition: FLValue.h:53
@ kFLUndefined
Type of a NULL pointer, i.e.
Definition: FLValue.h:50
@ kFLDict
A mapping of strings to values (AKA "object" in JSON.)
Definition: FLValue.h:59
@ kFLData
Binary data (no JSON equivalent)
Definition: FLValue.h:57
int64_t FLTimestamp
A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC....
Definition: FLBase.h:92
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:37
const struct _FLArray * FLArray
A reference to an array value.
Definition: FLBase.h:36
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