xref: /openbmc/qemu/include/qapi/qmp/qlit.h (revision d1fd31f8)
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 "qobject.h"
18 
19 typedef struct QLitDictEntry QLitDictEntry;
20 typedef struct QLitObject QLitObject;
21 
22 struct QLitObject {
23     QType type;
24     union {
25         bool qbool;
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_QNULL \
39     { .type = QTYPE_QNULL }
40 #define QLIT_QBOOL(val) \
41     { .type = QTYPE_QBOOL, .value.qbool = (val) }
42 #define QLIT_QNUM(val) \
43     { .type = QTYPE_QNUM, .value.qnum = (val) }
44 #define QLIT_QSTR(val) \
45     { .type = QTYPE_QSTRING, .value.qstr = (val) }
46 #define QLIT_QDICT(val) \
47     { .type = QTYPE_QDICT, .value.qdict = (val) }
48 #define QLIT_QLIST(val) \
49     { .type = QTYPE_QLIST, .value.qlist = (val) }
50 
51 bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
52 
53 QObject *qobject_from_qlit(const QLitObject *qlit);
54 
55 #endif /* QLIT_H */
56