Couchbase Lite C
Couchbase Lite C API
Loading...
Searching...
No Matches
FLEncoder.h
Go to the documentation of this file.
1//
2// FLEncoder.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 _FLENCODER_H
15#define _FLENCODER_H
16
17#include "FLBase.h"
18#include <stdio.h>
19
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26 // This is the C API! For the C++ API, see Fleece.hh.
27
28
37
38
41
48
49
52
61 size_t reserveSize,
62 bool uniqueStrings) FLAPI;
63
66
69
72
75
78
79
83
86
88
89
97
101
107
110
115
120
127
133
138
147
152
155
156
163
166
167
177
180
184
187
188
194
196
197
200
206
211
213
214
217
220
223
226
227#ifdef __cplusplus
228}
229#endif
230
232
233#endif // _FLENCODER_H
#define FL_NULLABLE
Definition CompilerSupport.h:87
#define FLEECE_PUBLIC
Definition CompilerSupport.h:254
#define FL_ASSUME_NONNULL_BEGIN
Definition CompilerSupport.h:85
#define NODISCARD
Definition CompilerSupport.h:59
#define FL_ASSUME_NONNULL_END
Definition CompilerSupport.h:86
#define FLAPI
Definition CompilerSupport.h:260
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_New(void)
Creates a new encoder, for generating Fleece data.
FLEECE_PUBLIC bool FLEncoder_WriteInt(FLEncoder, int64_t)
Writes an integer to an encoder.
FLEECE_PUBLIC bool FLEncoder_EndDict(FLEncoder)
Ends writing a dictionary value; pops back the previous encoding state.
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_NewWithOptions(FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
Creates a new encoder, allowing some options to be customized.
FLEECE_PUBLIC const char *FL_NULLABLE FLEncoder_GetErrorMessage(FLEncoder)
Returns the error message of an encoder, or NULL if there's no error.
FLEECE_PUBLIC bool FLEncoder_BeginArray(FLEncoder, size_t reserveCount)
Begins writing an array value to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteKeyValue(FLEncoder, FLValue)
Specifies the key for the next value to be written to the current dictionary.
FLEECE_PUBLIC bool FLEncoder_WriteFloat(FLEncoder, float)
Writes a 32-bit floating point number to an encoder.
FLEECE_PUBLIC FLError FLEncoder_GetError(FLEncoder)
Returns the error code of an encoder, or NoError (0) if there's no error.
FLEECE_PUBLIC bool FLEncoder_WriteDateString(FLEncoder encoder, FLTimestamp ts, bool asUTC)
Writes a timestamp to an encoder, as an ISO-8601 date string.
FLEECE_PUBLIC void FLEncoder_SetSharedKeys(FLEncoder, FLSharedKeys FL_NULLABLE)
Tells the encoder to use a shared-keys mapping when encoding dictionary keys.
FLEECE_PUBLIC void * FLEncoder_GetExtraInfo(FLEncoder)
Returns the user-defined value associated with the encoder; NULL by default.
FLEECE_PUBLIC bool FLEncoder_WriteBool(FLEncoder, bool)
Writes a boolean value (true or false) to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteString(FLEncoder, FLString)
Writes a string to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteKey(FLEncoder, FLString)
Specifies the key for the next value to be written to the current dictionary.
FLEECE_PUBLIC bool FLEncoder_WriteUndefined(FLEncoder)
Writes an undefined value to an encoder.
FLEECE_PUBLIC size_t FLEncoder_BytesWritten(FLEncoder)
Returns the number of bytes encoded so far.
FLEECE_PUBLIC void FLEncoder_Free(FLEncoder FL_NULLABLE)
Frees the space used by an encoder.
FLEECE_PUBLIC void FLEncoder_Reset(FLEncoder)
Resets the state of an encoder without freeing it.
FLEncoderFormat
Output formats a FLEncoder can generate.
Definition FLEncoder.h:43
FLEECE_PUBLIC bool FLEncoder_EndArray(FLEncoder)
Ends writing an array value; pops back the previous encoding state.
FLEECE_PUBLIC bool FLEncoder_WriteData(FLEncoder, FLSlice)
Writes a binary data value (a blob) to an encoder.
FLEECE_PUBLIC void FLEncoder_SetExtraInfo(FLEncoder, void *FL_NULLABLE info)
Associates an arbitrary user-defined value with the encoder.
NODISCARD FLEECE_PUBLIC FLSliceResult FLEncoder_Finish(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded data, else null.
FLEECE_PUBLIC bool FLEncoder_WriteNull(FLEncoder)
Writes a null value to an encoder.
NODISCARD FLEECE_PUBLIC FLDoc FL_NULLABLE FLEncoder_FinishDoc(FLEncoder, FLError *FL_NULLABLE outError)
Ends encoding; if there has been no error, it returns the encoded Fleece data packaged in an FLDoc.
FLEECE_PUBLIC bool FLEncoder_BeginDict(FLEncoder, size_t reserveCount)
Begins writing a dictionary value to an encoder.
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_NewWritingToFile(FILE *, bool uniqueStrings)
Creates a new Fleece encoder that writes to a file, not to memory.
FLEECE_PUBLIC bool FLEncoder_WriteUInt(FLEncoder, uint64_t)
Writes an unsigned integer to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteValue(FLEncoder, FLValue)
Writes a Fleece Value to an Encoder.
FLEECE_PUBLIC bool FLEncoder_WriteRaw(FLEncoder, FLSlice)
Writes raw data directly to the encoded output.
FLEECE_PUBLIC bool FLEncoder_WriteDouble(FLEncoder, double)
Writes a 64-bit floating point number to an encoder.
@ kFLEncodeFleece
Fleece encoding.
Definition FLEncoder.h:44
@ kFLEncodeJSON5
JSON5, an extension of JSON with a more readable syntax
Definition FLEncoder.h:46
@ kFLEncodeJSON
JSON encoding.
Definition FLEncoder.h:45
FLSlice FLString
Definition FLSlice.h:92
int64_t FLTimestamp
A point in time, expressed as milliseconds since the Unix epoch (1-1-1970 midnight UTC....
Definition FLBase.h:92
FLError
Error codes returned from some API calls.
Definition FLBase.h:48
struct _FLDoc * FLDoc
A reference to a document.
Definition FLBase.h:42
struct _FLEncoder * FLEncoder
A reference to an encoder.
Definition FLBase.h:41
struct _FLSharedKeys * FLSharedKeys
A reference to a shared-keys mapping.
Definition FLBase.h:43
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