Couchbase Lite C
Couchbase Lite C API
Loading...
Searching...
No Matches
FLEncoder.h File Reference
#include "FLBase.h"
#include <stdio.h>

Go to the source code of this file.

Macros

#define _FLENCODER_H

Functions

Writing to the encoder
Note
The functions that write to the encoder do not return error codes, just a 'false' result on error. The actual error is attached to the encoder and can be accessed by calling FLEncoder_GetError or FLEncoder_End.

After an error occurs, the encoder will ignore all subsequent writes.

FLEECE_PUBLIC bool FLEncoder_WriteNull (FLEncoder)
 Writes a null value to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteUndefined (FLEncoder)
 Writes an undefined value to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteBool (FLEncoder, bool)
 Writes a boolean value (true or false) to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteInt (FLEncoder, int64_t)
 Writes an integer to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteUInt (FLEncoder, uint64_t)
 Writes an unsigned integer to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteFloat (FLEncoder, float)
 Writes a 32-bit floating point number to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteDouble (FLEncoder, double)
 Writes a 64-bit floating point number to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteString (FLEncoder, FLString)
 Writes a string to an encoder.
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 bool FLEncoder_WriteData (FLEncoder, FLSlice)
 Writes a binary data value (a blob) to an encoder.
FLEECE_PUBLIC bool FLEncoder_WriteValue (FLEncoder, FLValue)
 Writes a Fleece Value to an Encoder.
FLEECE_PUBLIC bool FLEncoder_WriteFormatted (FLEncoder, const char *format,...) __printflike(2
 Writes an Array or Dict to the encoder, as per the format string and printf-style arguments.
FLEECE_PUBLIC bool FLEECE_PUBLIC bool FLEncoder_WriteFormattedArgs (FLEncoder, const char *format, va_list args)
 Writes an Array or Dict to the encoder, as per the format string and va_list.
FLEECE_PUBLIC bool FLEncoder_BeginArray (FLEncoder, size_t reserveCount)
 Begins writing an array value to an encoder.
FLEECE_PUBLIC bool FLEncoder_EndArray (FLEncoder)
 Ends writing an array value; pops back the previous encoding state.
FLEECE_PUBLIC bool FLEncoder_BeginDict (FLEncoder, size_t reserveCount)
 Begins writing a dictionary value 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_WriteKeyValue (FLEncoder, FLValue)
 Specifies the key for the next value to be written to the current dictionary.
FLEECE_PUBLIC bool FLEncoder_EndDict (FLEncoder)
 Ends writing a dictionary value; pops back the previous encoding state.
FLEECE_PUBLIC bool FLEncoder_WriteRaw (FLEncoder, FLSlice)
 Writes raw data directly to the encoded output.
Finishing up
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 FLSliceResult FLEncoder_Finish (FLEncoder, FLError *FL_NULLABLE outError)
 Ends encoding; if there has been no error, it returns the encoded data, else null.
Error handling
FLEECE_PUBLIC FLError FLEncoder_GetError (FLEncoder)
 Returns the error code of an encoder, or NoError (0) if there's no error.
FLEECE_PUBLIC const char *FL_NULLABLE FLEncoder_GetErrorMessage (FLEncoder e LIFETIMEBOUND)
 Returns the error message of an encoder, or NULL if there's no error.

Setup and configuration

enum  FLEncoderFormat { kFLEncodeFleece , kFLEncodeJSON , kFLEncodeJSON5 }
 Output formats a FLEncoder can generate. More...
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_New (void)
 Creates a new encoder, for generating Fleece data.
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_NewWithOptions (FLEncoderFormat format, size_t reserveSize, bool uniqueStrings)
 Creates a new encoder, allowing some options to be customized.
NODISCARD FLEECE_PUBLIC FLEncoder FLEncoder_NewWritingToFile (FILE *, bool uniqueStrings)
 Creates a new Fleece encoder that writes to a file, not to memory.
FLEECE_PUBLIC void FLEncoder_Free (FLEncoder FL_NULLABLE)
 Frees the space used by an encoder.
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_SetExtraInfo (FLEncoder, void *FL_NULLABLE info)
 Associates an arbitrary user-defined value with the encoder.
FLEECE_PUBLIC void * FLEncoder_GetExtraInfo (FLEncoder)
 Returns the user-defined value associated with the encoder; NULL by default.
FLEECE_PUBLIC void FLEncoder_Reset (FLEncoder)
 Resets the state of an encoder without freeing it.
FLEECE_PUBLIC size_t FLEncoder_BytesWritten (FLEncoder)
 Returns the number of bytes encoded so far.

Macro Definition Documentation

◆ _FLENCODER_H

#define _FLENCODER_H