Commit ea37ed01 authored by Nikias Bassen's avatar Nikias Bassen

Add plist_dict_item_get_key() to allow retrieving the key node for a given item of a #PLIST_DICT

parent 9555e71d
......@@ -353,9 +353,9 @@ extern "C"
void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val);
/**
* Get key associated to an item. Item must be member of a dictionary
* Get key associated key to an item. Item must be member of a dictionary.
*
* @param node the node
* @param node the item
* @param key a location to store the key. The caller is responsible for freeing the returned string.
*/
void plist_dict_get_item_key(plist_t node, char **key);
......@@ -370,6 +370,14 @@ extern "C"
*/
plist_t plist_dict_get_item(plist_t node, const char* key);
/**
* Get key node associated to an item. Item must be member of a dictionary.
*
* @param node the item
* @return the key node of the given item, or NULL.
*/
plist_t plist_dict_item_get_key(plist_t node);
/**
* Set item identified by key in a #PLIST_DICT node.
* The previous item identified by key will be freed using #plist_free.
......
......@@ -618,6 +618,17 @@ PLIST_API void plist_dict_get_item_key(plist_t node, char **key)
}
}
PLIST_API plist_t plist_dict_item_get_key(plist_t node)
{
plist_t ret = NULL;
plist_t father = plist_get_parent(node);
if (PLIST_DICT == plist_get_node_type(father))
{
ret = (plist_t)node_prev_sibling(node);
}
return ret;
}
PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key)
{
plist_t ret = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment