summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2016-11-10 02:14:59 +0100
committerGravatar Nikias Bassen2016-11-10 02:14:59 +0100
commitad1a95e96218e411b4dbde38c002fc5f4b530a65 (patch)
tree9172c150414993c8790ce1d68d0c4369f27198a3
parent35f13502ddd7c5682671b315f0865fa4ba6b646d (diff)
downloadlibplist-ad1a95e96218e411b4dbde38c002fc5f4b530a65.tar.gz
libplist-ad1a95e96218e411b4dbde38c002fc5f4b530a65.tar.bz2
Add new PLIST_IS_* helper macros for the different plist node types
Instead of e.g.: if (plist_get_node_type(plist) == PLIST_STRING) you can now write: if (PLIST_IS_STRING(plist))
-rw-r--r--include/plist/plist.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index ace86f8..e817b4b 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -664,6 +664,20 @@ extern "C"
*/
char plist_compare_node_value(plist_t node_l, plist_t node_r);
+ #define _PLIST_IS_TYPE(__plist, __plist_type) (__plist && (plist_get_node_type(__plist) == PLIST_##__plist_type))
+
+ /* Helper macros for the different plist types */
+ #define PLIST_IS_BOOLEAN(__plist) _PLIST_IS_TYPE(__plist, BOOLEAN)
+ #define PLIST_IS_UINT(__plist) _PLIST_IS_TYPE(__plist, UINT)
+ #define PLIST_IS_REAL(__plist) _PLIST_IS_TYPE(__plist, REAL)
+ #define PLIST_IS_STRING(__plist) _PLIST_IS_TYPE(__plist, STRING)
+ #define PLIST_IS_ARRAY(__plist) _PLIST_IS_TYPE(__plist, ARRAY)
+ #define PLIST_IS_DICT(__plist) _PLIST_IS_TYPE(__plist, DICT)
+ #define PLIST_IS_DATE(__plist) _PLIST_IS_TYPE(__plist, DATE)
+ #define PLIST_IS_DATA(__plist) _PLIST_IS_TYPE(__plist, DATA)
+ #define PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY)
+ #define PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID)
+
/*@}*/
#ifdef __cplusplus