xref: /qemu/include/qobject/qlit.h (revision e2346a19521c6cce417250c75adb0b3a7cd5535a)
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 QLitDictEntry QLitDictEntry;
21 typedef struct QLitObject QLitObject;
22 
23 struct QLitObject {
24     int type;
25     union {
26         int64_t qnum;
27         const char *qstr;
28         QLitDictEntry *qdict;
29         QLitObject *qlist;
30     } value;
31 };
32 
33 struct QLitDictEntry {
34     const char *key;
35     QLitObject value;
36 };
37 
38 #define QLIT_QNUM(val) \
39     { .type = QTYPE_QNUM, .value.qnum = (val) }
40 #define QLIT_QSTR(val) \
41     { .type = QTYPE_QSTRING, .value.qstr = (val) }
42 #define QLIT_QDICT(val) \
43     { .type = QTYPE_QDICT, .value.qdict = (val) }
44 #define QLIT_QLIST(val) \
45     { .type = QTYPE_QLIST, .value.qlist = (val) }
46 
47 bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
48 
49 #endif /* QLIT_H */
50