summaryrefslogtreecommitdiffstats
path: root/include/plist/plist.h
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-03-22 19:16:51 +0100
committerGravatar Nikias Bassen2026-03-22 19:16:51 +0100
commitc8b36a80bad4a1fe488927af4da0ecbcf10079bb (patch)
tree657066f92a85dc43bd51af7698e76d00c29c0b4a /include/plist/plist.h
parent3edac28498d883f1f768699ee15ce85a82bb2a7b (diff)
downloadlibplist-c8b36a80bad4a1fe488927af4da0ecbcf10079bb.tar.gz
libplist-c8b36a80bad4a1fe488927af4da0ecbcf10079bb.tar.bz2
Add OpenStep coercion support for non-OpenStep plist typesHEADmaster
- Use PLIST_OPT_COERCE option to coerce PLIST_BOOLEAN, PLIST_DATE, PLIST_UID, and PLIST_NULL to OpenStep-compatible types (1 or 0, ISO 8601 strings, integers, and 'NULL' string) - Add plist_to_openstep_with_options() function to allow passing coercion option (and others) - Update plist_write_to_string() and plist_write_to_stream() accordingly
Diffstat (limited to 'include/plist/plist.h')
-rw-r--r--include/plist/plist.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index bd35c53..94930b8 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -978,6 +978,30 @@ extern "C"
*/
PLIST_API plist_err_t plist_to_openstep(plist_t plist, char **plist_openstep, uint32_t* length, int prettify);
+ /**
+ * Export the #plist_t structure to OpenStep format with extended options.
+ *
+ * When \a PLIST_OPT_COMPACT is set in \a options, the resulting OpenStep output
+ * will be non-prettified.
+ *
+ * When \a PLIST_OPT_COERCE is set in \a options, plist types that have
+ * no native OpenStep representation are converted to OpenStep-compatible types
+ * instead of returning #PLIST_ERR_FORMAT:
+ * - #PLIST_BOOLEAN is serialized as a 1 or 0
+ * - #PLIST_DATE is serialized as an ISO 8601 date string
+ * - #PLIST_NULL is serialized as string 'NULL'
+ * - #PLIST_UID is serialized as an integer
+ *
+ * @param plist the root node to export
+ * @param plist_openstep a pointer to a char* buffer. This function allocates the memory,
+ * caller is responsible for freeing it.
+ * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
+ * @param options One or more bitwise ORed values of #plist_write_options_t.
+ * @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure
+ * @note Use plist_mem_free() to free the allocated memory.
+ */
+ PLIST_API plist_err_t plist_to_openstep_with_options(plist_t plist, char **plist_openstep, uint32_t* length, plist_write_options_t options);
+
/**
* Import the #plist_t structure from XML format.