From e492ef675c404cc6c0d1cfa26e47a1c16c850d5f Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Tue, 13 Oct 2009 20:03:38 +0200 Subject: Add path accessor util function. --- include/plist/plist.h | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/plist/plist.h b/include/plist/plist.h index e12d6fa..699a0d6 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -48,6 +48,7 @@ extern "C" { #endif #include +#include /** * \mainpage libplist : A library to handle Apple Property Lists @@ -544,22 +545,25 @@ extern "C" { ********************************************/ /** - * Find the first encountered #PLIST_KEY node mathing that key. + * Get a node from its path. Each path element depends on the associated father node type. + * For Dictionaries, var args are casted to const char*, for arrays, var args are caster to uint32_t * Search is breath first order. * - * @param plist the root node of the plist structure. - * @param value the ASCII Key to match. + * @param plist the node to access result from. + * @param length length of the path to access + * @return the value to access. */ - PLIST_API plist_t plist_find_node_by_key(plist_t plist, const char *value); + PLIST_API plist_t plist_access_path(plist_t plist, uint32_t length, ...); /** - * Find the first encountered #PLIST_STRING node mathing that string. - * Search is breath first order. + * Variadic version of #plist_access_path. * - * @param plist the root node of the plist structure. - * @param value the ASCII String to match. + * @param plist the node to access result from. + * @param length length of the path to access + * @param v list of array's index and dic'st key + * @return the value to access. */ - PLIST_API plist_t plist_find_node_by_string(plist_t plist, const char *value); + PLIST_API plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v); /** * Compare two node values @@ -706,6 +710,31 @@ extern "C" { */ PLIST_API void plist_add_sub_date_el(plist_t node, int32_t sec, int32_t usec); + +/******************************************** + * * + * Utils * + * * + ********************************************/ + +/** + * Find the first encountered #PLIST_KEY node mathing that key. + * Search is breath first order. + * + * @param plist the root node of the plist structure. + * @param value the ASCII Key to match. + */ + PLIST_API plist_t plist_find_node_by_key(plist_t plist, const char *value); + +/** + * Find the first encountered #PLIST_STRING node mathing that string. + * Search is breath first order. + * + * @param plist the root node of the plist structure. + * @param value the ASCII String to match. + */ + PLIST_API plist_t plist_find_node_by_string(plist_t plist, const char *value); + /*@}*/ -- cgit v1.1-32-gdbae