XMMS2
|
00001 /* XMMS2 - X Music Multiplexer System 00002 * Copyright (C) 2003-2011 XMMS2 Team 00003 * 00004 * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!! 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 */ 00016 00017 00018 #ifndef __XMMSV_BUILD_H__ 00019 #define __XMMSV_BUILD_H__ 00020 00021 #include "xmmsc/xmmsv_general.h" 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /** 00028 * @defgroup BuildValueType Easier building of lists and dictionaries 00029 * @ingroup ValueType 00030 * @{ 00031 */ 00032 /* These helps us doing compiletime typechecking */ 00033 static inline const char *__xmmsv_identity_const_charp (const char *v) {return v;} 00034 static inline xmmsv_t *__xmmsv_identity_xmmsv (xmmsv_t *v) {return v;} 00035 static inline xmmsv_t *__xmmsv_null_to_none (xmmsv_t *v) { return v ? v : xmmsv_new_none (); } 00036 00037 #define XMMSV_DICT_ENTRY(k, v) __xmmsv_identity_const_charp (k), __xmmsv_identity_xmmsv (v) 00038 #define XMMSV_DICT_ENTRY_STR(k, v) XMMSV_DICT_ENTRY (k, __xmmsv_null_to_none (xmmsv_new_string (v))) 00039 #define XMMSV_DICT_ENTRY_INT(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_int (v)) 00040 #define XMMSV_DICT_END NULL 00041 xmmsv_t *xmmsv_build_dict (const char *firstkey, ...); 00042 00043 #define XMMSV_LIST_ENTRY(v) __xmmsv_identity_xmmsv (v) 00044 #define XMMSV_LIST_ENTRY_STR(v) XMMSV_LIST_ENTRY (__xmmsv_null_to_none (xmmsv_new_string (v))) 00045 #define XMMSV_LIST_ENTRY_INT(v) XMMSV_LIST_ENTRY (xmmsv_new_int (v)) 00046 #define XMMSV_LIST_ENTRY_COLL(v) XMMSV_LIST_ENTRY (__xmmsv_null_to_none (xmmsv_new_coll (v))) 00047 #define XMMSV_LIST_END NULL 00048 00049 xmmsv_t *xmmsv_build_list (xmmsv_t *first_entry, ...); 00050 xmmsv_t *xmmsv_build_list_va (xmmsv_t *first_entry, va_list ap); 00051 /** @} */ 00052 00053 #ifdef __cplusplus 00054 } 00055 #endif 00056 00057 #endif