diff options
| author | 2009-10-10 19:55:51 +0200 | |
|---|---|---|
| committer | 2009-10-10 19:55:51 +0200 | |
| commit | 009274f4dfb7829f2ee98d46afd5e54892806990 (patch) | |
| tree | 01b9944d34bf5f640ff278116ea19f22d698fe5d | |
| parent | 77b02c9404dbfef325b7a19228045a817cafe064 (diff) | |
| download | libplist-009274f4dfb7829f2ee98d46afd5e54892806990.tar.gz libplist-009274f4dfb7829f2ee98d46afd5e54892806990.tar.bz2 | |
Reverse argument for dicts to make it clearer.
| -rw-r--r-- | include/plist/plist.h | 5 | ||||
| -rw-r--r-- | src/plist.c | 13 |
2 files changed, 9 insertions, 9 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index f8c5c53..beb467a 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h | |||
| @@ -262,7 +262,7 @@ extern "C" { | |||
| 262 | * @param item the new item associated to key | 262 | * @param item the new item associated to key |
| 263 | * @param key the identifier of the item to get. Assert if identifier is not present. | 263 | * @param key the identifier of the item to get. Assert if identifier is not present. |
| 264 | */ | 264 | */ |
| 265 | PLIST_API void plist_dict_set_item(plist_t node, plist_t item, const char* key); | 265 | PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item); |
| 266 | 266 | ||
| 267 | /** | 267 | /** |
| 268 | * Insert a new item at position n in a #PLIST_DICT node. | 268 | * Insert a new item at position n in a #PLIST_DICT node. |
| @@ -271,7 +271,7 @@ extern "C" { | |||
| 271 | * @param item the new item to insert | 271 | * @param item the new item to insert |
| 272 | * @param key The identifier of the item to insert. Assert if identifier already present. | 272 | * @param key The identifier of the item to insert. Assert if identifier already present. |
| 273 | */ | 273 | */ |
| 274 | PLIST_API void plist_dict_insert_item(plist_t node, plist_t item, const char* key); | 274 | PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item); |
| 275 | 275 | ||
| 276 | /** | 276 | /** |
| 277 | * Remove an existing position in a #PLIST_DICT node. | 277 | * Remove an existing position in a #PLIST_DICT node. |
| @@ -658,7 +658,6 @@ extern "C" { | |||
| 658 | */ | 658 | */ |
| 659 | PLIST_API void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); | 659 | PLIST_API void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); |
| 660 | 660 | ||
| 661 | |||
| 662 | /*@}*/ | 661 | /*@}*/ |
| 663 | 662 | ||
| 664 | 663 | ||
diff --git a/src/plist.c b/src/plist.c index 8368d6e..95bc43c 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -268,15 +268,15 @@ plist_t plist_dict_get_item(plist_t node, const char* key) | |||
| 268 | if (node && PLIST_DICT == plist_get_node_type(node)) { | 268 | if (node && PLIST_DICT == plist_get_node_type(node)) { |
| 269 | 269 | ||
| 270 | plist_t current = NULL; | 270 | plist_t current = NULL; |
| 271 | for (current = plist_get_first_child(node); | 271 | for (current = (plist_t)g_node_first_child(node); |
| 272 | current; | 272 | current; |
| 273 | current = plist_get_next_sibling(plist_get_next_sibling(current))) { | 273 | current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) { |
| 274 | 274 | ||
| 275 | assert( PLIST_KEY == plist_get_node_type(current) ); | 275 | assert( PLIST_KEY == plist_get_node_type(current) ); |
| 276 | plist_data_t data = plist_get_data(current); | 276 | plist_data_t data = plist_get_data(current); |
| 277 | 277 | ||
| 278 | if (data && !strcmp(key, data->strval)) { | 278 | if (data && !strcmp(key, data->strval)) { |
| 279 | ret = plist_get_next_sibling(current); | 279 | ret = (plist_t)g_node_next_sibling(current); |
| 280 | break; | 280 | break; |
| 281 | } | 281 | } |
| 282 | } | 282 | } |
| @@ -284,7 +284,7 @@ plist_t plist_dict_get_item(plist_t node, const char* key) | |||
| 284 | return ret; | 284 | return ret; |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | void plist_dict_set_item(plist_t node, plist_t item, const char* key) | 287 | void plist_dict_set_item(plist_t node, const char* key, plist_t item) |
| 288 | { | 288 | { |
| 289 | if (node && PLIST_DICT == plist_get_node_type(node)) { | 289 | if (node && PLIST_DICT == plist_get_node_type(node)) { |
| 290 | plist_t old_item = plist_dict_get_item(node, key); | 290 | plist_t old_item = plist_dict_get_item(node, key); |
| @@ -297,7 +297,7 @@ void plist_dict_set_item(plist_t node, plist_t item, const char* key) | |||
| 297 | return; | 297 | return; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | void plist_dict_insert_item(plist_t node, plist_t item, const char* key) | 300 | void plist_dict_insert_item(plist_t node, const char* key, plist_t item) |
| 301 | { | 301 | { |
| 302 | if (node && PLIST_DICT == plist_get_node_type(node)) { | 302 | if (node && PLIST_DICT == plist_get_node_type(node)) { |
| 303 | g_node_append(node, plist_new_key(key)); | 303 | g_node_append(node, plist_new_key(key)); |
| @@ -357,7 +357,7 @@ static plist_t plist_find_node(plist_t plist, plist_type type, const void *value | |||
| 357 | if (!plist) | 357 | if (!plist) |
| 358 | return NULL; | 358 | return NULL; |
| 359 | 359 | ||
| 360 | for (current = plist_get_first_child(plist); current; current = plist_get_next_sibling(current)) { | 360 | for (current = (plist_t)g_node_first_child(plist); current; current = (plist_t)g_node_next_sibling(current)) { |
| 361 | 361 | ||
| 362 | plist_data_t data = plist_get_data(current); | 362 | plist_data_t data = plist_get_data(current); |
| 363 | 363 | ||
| @@ -658,6 +658,7 @@ void plist_set_date_val(plist_t node, int32_t sec, int32_t usec) | |||
| 658 | 658 | ||
| 659 | //DEPRECATED API BELOW | 659 | //DEPRECATED API BELOW |
| 660 | 660 | ||
| 661 | |||
| 661 | static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *value, uint64_t length) | 662 | static plist_t plist_add_sub_element(plist_t node, plist_type type, const void *value, uint64_t length) |
| 662 | { | 663 | { |
| 663 | //only structured types can have children | 664 | //only structured types can have children |
