xref: /qemu/include/qobject/qlit.h (revision 28035bcdf4647245743cf87cea3788331bf67a5f)
1 /*
2  * Copyright IBM, Corp. 2009
3  * Copyright (c) 2013, 2015, 2017 Red Hat Inc.
4  *
5  * Authors:
6  *  Anthony Liguori   <aliguori@us.ibm.com>
7  *  Markus Armbruster <armbru@redhat.com>
8  *  Marc-André Lureau <marcandre.lureau@redhat.com>
9  *
10  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
11  * See the COPYING.LIB file in the top-level directory.
12  *
13  */
14 #ifndef QLIT_H
15 #define QLIT_H
16 
17 #include "qapi-types.h"
18 #include "qobject.h"
19 
20 typedef struct LiteralQDictEntry LiteralQDictEntry;
21 typedef struct LiteralQObject LiteralQObject;
22 
23 struct LiteralQObject {
24     int type;
25     union {
26         int64_t qnum;
27         const char *qstr;
28         LiteralQDictEntry *qdict;
29         LiteralQObject *qlist;
30     } value;
31 };
32 
33 struct LiteralQDictEntry {
34     const char *key;
35     LiteralQObject value;
36 };
37 
38 #define QLIT_QNUM(val) \
39     (LiteralQObject){.type = QTYPE_QNUM, .value.qnum = (val)}
40 #define QLIT_QSTR(val) \
41     (LiteralQObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
42 #define QLIT_QDICT(val) \
43     (LiteralQObject){.type = QTYPE_QDICT, .value.qdict = (val)}
44 #define QLIT_QLIST(val) \
45     (LiteralQObject){.type = QTYPE_QLIST, .value.qlist = (val)}
46 
47 int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs);
48 
49 #endif /* QLIT_H */
50