LiteCore
Couchbase Lite cross-platform core implementation
|
These functions use the printf
idiom to make it convenient to create structured Fleece values in memory with one call.
More...
Functions | |
NODISCARD FLEECE_PUBLIC FLValue | FLValue_NewWithFormat (const char *format,...) __printflike(1 |
Translates the JSON-style format string into a tree of mutable Fleece objects, adding values from the following arguments wherever a printf-style % specifier appears. | |
NODISCARD FLEECE_PUBLIC FLValue NODISCARD FLEECE_PUBLIC FLValue | FLValue_NewWithFormatV (const char *format, va_list args) |
Variant of FLValue_NewWithFormat that takes a pre-existing va_list . | |
FLEECE_PUBLIC void | FLMutableArray_UpdateWithFormat (FLMutableArray, const char *format,...) __printflike(2 |
Like FLValue_NewWithFormat, except it operates on an existing mutable array. | |
FLEECE_PUBLIC void FLEECE_PUBLIC void | FLMutableDict_UpdateWithFormat (FLMutableDict, const char *format,...) __printflike(2 |
Like FLValue_NewWithFormat, except it operates on an existing mutable dict. | |
FLEECE_PUBLIC void FLEECE_PUBLIC void FLEECE_PUBLIC void | FLValue_UpdateWithFormatV (FLValue, const char *format, va_list args) |
Like FLMutableArray_UpdateWithFormat / FLMutableDict_UpdateWithFormat but takes a pre-existing va_list . | |
These functions use the printf
idiom to make it convenient to create structured Fleece values in memory with one call.
They create or modify a FLMutableArray
or `FLMutableDict by reading the given format string and the following arguments.
The format string is basically JSON5, except that any value in it may be a printf-style '' specifier instead of a literal, in which case that value will be read from the next argument. The supported format specifiers are:
c
(cast the arg to char
to avoid a compiler warning)i
or d
(use size specifiers l
, ll
, or z
)u
(use size specifiers l
, ll
, or z
)f
(arg can be float
or double
; no size spec needed)s
%.*s
(takes two args, a const char*
and an int
. See FMTSLICE
.)p
(arg must be a FLValue
)%@
(Apple platforms only: arg must be a NSString
, NSNumber
, NSArray
, NSDictionary
, NSNull
, or equivalent CFTypeRef
)A -
can appear after the %
, indicating that the argument should be ignored if it has a default value, namely false
, 0, or an empty string. This means the corresponding item won't be written (a Dict item will be erased if it previously existed.)
If an argument is a NULL pointer nothing is written, and any pre-existing Dict item will be removed.
FLEECE_PUBLIC void FLMutableArray_UpdateWithFormat | ( | FLMutableArray | , |
const char * | format, | ||
... ) |
Like FLValue_NewWithFormat, except it operates on an existing mutable array.
The values parsed from the format string and arguments will be appended to it.
FLEECE_PUBLIC void FLEECE_PUBLIC void FLMutableDict_UpdateWithFormat | ( | FLMutableDict | , |
const char * | format, | ||
... ) |
Like FLValue_NewWithFormat, except it operates on an existing mutable dict.
(Pre-existing properties not appearing in the format string are preserved.)
NODISCARD FLEECE_PUBLIC FLValue FLValue_NewWithFormat | ( | const char * | format, |
... ) |
Translates the JSON-style format string into a tree of mutable Fleece objects, adding values from the following arguments wherever a printf-style %
specifier appears.
FLMutableArray
or FLMutableString
depending on the syntax of the format string. NODISCARD FLEECE_PUBLIC FLValue NODISCARD FLEECE_PUBLIC FLValue FLValue_NewWithFormatV | ( | const char * | format, |
va_list | args ) |
Variant of FLValue_NewWithFormat that takes a pre-existing va_list
.
FLEECE_PUBLIC void FLEECE_PUBLIC void FLEECE_PUBLIC void FLValue_UpdateWithFormatV | ( | FLValue | , |
const char * | format, | ||
va_list | args ) |
Like FLMutableArray_UpdateWithFormat / FLMutableDict_UpdateWithFormat but takes a pre-existing va_list
.