diff options
| author | 2019-01-21 02:09:44 +0100 | |
|---|---|---|
| committer | 2019-01-21 02:22:28 +0100 | |
| commit | 84d6af8f82b30b6519bb401d467febe4ea981dad (patch) | |
| tree | cfd1f1f34e60cfb87696a8cb480e5af00b8c89a3 /include/plist | |
| parent | 5f8ca6e30334b81bd39a67f87a011cee8f282c3c (diff) | |
| download | libplist-84d6af8f82b30b6519bb401d467febe4ea981dad.tar.gz libplist-84d6af8f82b30b6519bb401d467febe4ea981dad.tar.bz2 | |
plist: Add iterator for #PLIST_ARRAY nodes
Similar to #PLIST_DICT, an iterator can now be used for #PLIST_ARRAY
nodes. Get an iterator with plist_array_new_iter() and use
plist_array_next_item() to iterate over the elements.
Diffstat (limited to 'include/plist')
| -rw-r--r-- | include/plist/plist.h | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index e817b4b..707460e 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h | |||
| @@ -3,7 +3,8 @@ | |||
| 3 | * @brief Main include of libplist | 3 | * @brief Main include of libplist |
| 4 | * \internal | 4 | * \internal |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. | 6 | * Copyright (c) 2012-2019 Nikias Bassen, All Rights Reserved. |
| 7 | * Copyright (c) 2008-2009 Jonathan Beck, All Rights Reserved. | ||
| 7 | * | 8 | * |
| 8 | * This library is free software; you can redistribute it and/or | 9 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public | 10 | * modify it under the terms of the GNU Lesser General Public |
| @@ -90,7 +91,12 @@ extern "C" | |||
| 90 | /** | 91 | /** |
| 91 | * The plist dictionary iterator. | 92 | * The plist dictionary iterator. |
| 92 | */ | 93 | */ |
| 93 | typedef void *plist_dict_iter; | 94 | typedef void* plist_dict_iter; |
| 95 | |||
| 96 | /** | ||
| 97 | * The plist array iterator. | ||
| 98 | */ | ||
| 99 | typedef void* plist_array_iter; | ||
| 94 | 100 | ||
| 95 | /** | 101 | /** |
| 96 | * The enumeration of plist node types. | 102 | * The enumeration of plist node types. |
| @@ -281,6 +287,27 @@ extern "C" | |||
| 281 | */ | 287 | */ |
| 282 | void plist_array_remove_item(plist_t node, uint32_t n); | 288 | void plist_array_remove_item(plist_t node, uint32_t n); |
| 283 | 289 | ||
| 290 | /** | ||
| 291 | * Create an iterator of a #PLIST_ARRAY node. | ||
| 292 | * The allocated iterator should be freed with the standard free function. | ||
| 293 | * | ||
| 294 | * @param node The node of type #PLIST_ARRAY | ||
| 295 | * @param iter Location to store the iterator for the array. | ||
| 296 | */ | ||
| 297 | void plist_array_new_iter(plist_t node, plist_array_iter *iter); | ||
| 298 | |||
| 299 | /** | ||
| 300 | * Increment iterator of a #PLIST_ARRAY node. | ||
| 301 | * | ||
| 302 | * @param node The node of type #PLIST_ARRAY. | ||
| 303 | * @param iter Iterator of the array | ||
| 304 | * @param item Location to store the item. The caller must *not* free the | ||
| 305 | * returned item. Will be set to NULL when no more items are left | ||
| 306 | * to iterate. | ||
| 307 | */ | ||
| 308 | void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item); | ||
| 309 | |||
| 310 | |||
| 284 | /******************************************** | 311 | /******************************************** |
| 285 | * * | 312 | * * |
| 286 | * Dictionary functions * | 313 | * Dictionary functions * |
| @@ -299,20 +326,21 @@ extern "C" | |||
| 299 | * Create an iterator of a #PLIST_DICT node. | 326 | * Create an iterator of a #PLIST_DICT node. |
| 300 | * The allocated iterator should be freed with the standard free function. | 327 | * The allocated iterator should be freed with the standard free function. |
| 301 | * | 328 | * |
| 302 | * @param node the node of type #PLIST_DICT | 329 | * @param node The node of type #PLIST_DICT. |
| 303 | * @param iter iterator of the #PLIST_DICT node | 330 | * @param iter Location to store the iterator for the dictionary. |
| 304 | */ | 331 | */ |
| 305 | void plist_dict_new_iter(plist_t node, plist_dict_iter *iter); | 332 | void plist_dict_new_iter(plist_t node, plist_dict_iter *iter); |
| 306 | 333 | ||
| 307 | /** | 334 | /** |
| 308 | * Increment iterator of a #PLIST_DICT node. | 335 | * Increment iterator of a #PLIST_DICT node. |
| 309 | * | 336 | * |
| 310 | * @param node the node of type #PLIST_DICT | 337 | * @param node The node of type #PLIST_DICT |
| 311 | * @param iter iterator of the dictionary | 338 | * @param iter Iterator of the dictionary |
| 312 | * @param key a location to store the key, or NULL. The caller is responsible | 339 | * @param key Location to store the key, or NULL. The caller is responsible |
| 313 | * for freeing the the returned string. | 340 | * for freeing the the returned string. |
| 314 | * @param val a location to store the value, or NULL. The caller should *not* | 341 | * @param val Location to store the value, or NULL. The caller must *not* |
| 315 | * free the returned value. | 342 | * free the returned value. Will be set to NULL when no more |
| 343 | * key/value pairs are left to iterate. | ||
| 316 | */ | 344 | */ |
| 317 | void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val); | 345 | void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val); |
| 318 | 346 | ||
