diff options
Diffstat (limited to 'include/plist')
| -rw-r--r-- | include/plist/plist.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index b46b9a9..bd35c53 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h | |||
| @@ -175,6 +175,11 @@ extern "C" | |||
| 175 | PLIST_OPT_PARTIAL_DATA = 1 << 1, /**< Print 24 bytes maximum of #PLIST_DATA values. If the data is longer than 24 bytes, the first 16 and last 8 bytes will be written. Only valid for #PLIST_FORMAT_PRINT. */ | 175 | PLIST_OPT_PARTIAL_DATA = 1 << 1, /**< Print 24 bytes maximum of #PLIST_DATA values. If the data is longer than 24 bytes, the first 16 and last 8 bytes will be written. Only valid for #PLIST_FORMAT_PRINT. */ |
| 176 | PLIST_OPT_NO_NEWLINE = 1 << 2, /**< Do not print a final newline character. Only valid for #PLIST_FORMAT_PRINT, #PLIST_FORMAT_LIMD, and #PLIST_FORMAT_PLUTIL. */ | 176 | PLIST_OPT_NO_NEWLINE = 1 << 2, /**< Do not print a final newline character. Only valid for #PLIST_FORMAT_PRINT, #PLIST_FORMAT_LIMD, and #PLIST_FORMAT_PLUTIL. */ |
| 177 | PLIST_OPT_INDENT = 1 << 3, /**< Indent each line of output. Currently only #PLIST_FORMAT_PRINT and #PLIST_FORMAT_LIMD are supported. Use #PLIST_OPT_INDENT_BY() macro to specify the level of indentation. */ | 177 | PLIST_OPT_INDENT = 1 << 3, /**< Indent each line of output. Currently only #PLIST_FORMAT_PRINT and #PLIST_FORMAT_LIMD are supported. Use #PLIST_OPT_INDENT_BY() macro to specify the level of indentation. */ |
| 178 | PLIST_OPT_COERCE = 1 << 4, /**< Coerce plist types that have no native JSON representation into JSON-compatible types. | ||
| 179 | #PLIST_DATE is converted to an ISO 8601 date string, | ||
| 180 | #PLIST_DATA is converted to a Base64-encoded string, and | ||
| 181 | #PLIST_UID is converted to an integer. | ||
| 182 | Only valid for #PLIST_FORMAT_JSON. Without this option, these types cause #PLIST_ERR_FORMAT. */ | ||
| 178 | } plist_write_options_t; | 183 | } plist_write_options_t; |
| 179 | 184 | ||
| 180 | /** To be used with #PLIST_OPT_INDENT - encodes the level of indentation for OR'ing it into the #plist_write_options_t bitfield. */ | 185 | /** To be used with #PLIST_OPT_INDENT - encodes the level of indentation for OR'ing it into the #plist_write_options_t bitfield. */ |
| @@ -938,6 +943,29 @@ extern "C" | |||
| 938 | PLIST_API plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify); | 943 | PLIST_API plist_err_t plist_to_json(plist_t plist, char **plist_json, uint32_t* length, int prettify); |
| 939 | 944 | ||
| 940 | /** | 945 | /** |
| 946 | * Export the #plist_t structure to JSON format with extended options. | ||
| 947 | * | ||
| 948 | * When \a PLIST_OPT_COMPACT is set in \a options, the resulting JSON | ||
| 949 | * will be non-prettified. | ||
| 950 | * | ||
| 951 | * When \a PLIST_OPT_COERCE is set in \a options, plist types that have | ||
| 952 | * no native JSON representation are converted to JSON-compatible types | ||
| 953 | * instead of returning #PLIST_ERR_FORMAT: | ||
| 954 | * - #PLIST_DATE is serialized as an ISO 8601 date string | ||
| 955 | * - #PLIST_DATA is serialized as a Base64-encoded string | ||
| 956 | * - #PLIST_UID is serialized as an integer | ||
| 957 | * | ||
| 958 | * @param plist the root node to export | ||
| 959 | * @param plist_json a pointer to a char* buffer. This function allocates the memory, | ||
| 960 | * caller is responsible for freeing it. | ||
| 961 | * @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer. | ||
| 962 | * @param options One or more bitwise ORed values of #plist_write_options_t. | ||
| 963 | * @return PLIST_ERR_SUCCESS on success or a #plist_err_t on failure | ||
| 964 | * @note Use plist_mem_free() to free the allocated memory. | ||
| 965 | */ | ||
| 966 | PLIST_API plist_err_t plist_to_json_with_options(plist_t plist, char **plist_json, uint32_t* length, plist_write_options_t options); | ||
| 967 | |||
| 968 | /** | ||
| 941 | * Export the #plist_t structure to OpenStep format. | 969 | * Export the #plist_t structure to OpenStep format. |
| 942 | * | 970 | * |
| 943 | * @param plist the root node to export | 971 | * @param plist the root node to export |
