XMMS2
xmmsv_build.h
Go to the documentation of this file.
1/* XMMS2 - X Music Multiplexer System
2 * Copyright (C) 2003-2011 XMMS2 Team
3 *
4 * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 */
16
17
18#ifndef __XMMSV_BUILD_H__
19#define __XMMSV_BUILD_H__
20
21#include "xmmsc/xmmsv_general.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/**
28 * @defgroup BuildValueType Easier building of lists and dictionaries
29 * @ingroup ValueType
30 * @{
31 */
32/* These helps us doing compiletime typechecking */
33static inline const char *__xmmsv_identity_const_charp (const char *v) {return v;}
34static inline xmmsv_t *__xmmsv_identity_xmmsv (xmmsv_t *v) {return v;}
35static inline xmmsv_t *__xmmsv_null_to_none (xmmsv_t *v) { return v ? v : xmmsv_new_none (); }
36
37#define XMMSV_DICT_ENTRY(k, v) __xmmsv_identity_const_charp (k), __xmmsv_identity_xmmsv (v)
38#define XMMSV_DICT_ENTRY_STR(k, v) XMMSV_DICT_ENTRY (k, __xmmsv_null_to_none (xmmsv_new_string (v)))
39#define XMMSV_DICT_ENTRY_INT(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_int (v))
40#define XMMSV_DICT_END NULL
41xmmsv_t *xmmsv_build_dict (const char *firstkey, ...);
42
43#define XMMSV_LIST_ENTRY(v) __xmmsv_identity_xmmsv (v)
44#define XMMSV_LIST_ENTRY_STR(v) XMMSV_LIST_ENTRY (__xmmsv_null_to_none (xmmsv_new_string (v)))
45#define XMMSV_LIST_ENTRY_INT(v) XMMSV_LIST_ENTRY (xmmsv_new_int (v))
46#define XMMSV_LIST_ENTRY_COLL(v) XMMSV_LIST_ENTRY (__xmmsv_null_to_none (xmmsv_new_coll (v)))
47#define XMMSV_LIST_END NULL
48
49xmmsv_t *xmmsv_build_list (xmmsv_t *first_entry, ...);
50xmmsv_t *xmmsv_build_list_va (xmmsv_t *first_entry, va_list ap);
51/** @} */
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif
xmmsv_t * xmmsv_build_list(xmmsv_t *first_entry,...)
Definition value.c:2278
xmmsv_t * xmmsv_build_list_va(xmmsv_t *first_entry, va_list ap)
Definition value.c:2252
xmmsv_t * xmmsv_build_dict(const char *firstkey,...)
Definition value.c:2221
xmmsv_t * xmmsv_new_none(void)
Allocates a new empty xmmsv_t.
Definition value.c:129
struct xmmsv_St xmmsv_t