xref: /openbmc/qemu/include/qapi/qmp/qlit.h (revision 406d2aa2)
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         bool qbool;
27         int64_t qnum;
28         const char *qstr;
29         QLitDictEntry *qdict;
30         QLitObject *qlist;
31     } value;
32 };
33 
34 struct QLitDictEntry {
35     const char *key;
36     QLitObject value;
37 };
38 
39 #define QLIT_QNULL \
40     { .type = QTYPE_QNULL }
41 #define QLIT_QBOOL(val) \
42     { .type = QTYPE_QBOOL, .value.qbool = (val) }
43 #define QLIT_QNUM(val) \
44     { .type = QTYPE_QNUM, .value.qnum = (val) }
45 #define QLIT_QSTR(val) \
46     { .type = QTYPE_QSTRING, .value.qstr = (val) }
47 #define QLIT_QDICT(val) \
48     { .type = QTYPE_QDICT, .value.qdict = (val) }
49 #define QLIT_QLIST(val) \
50     { .type = QTYPE_QLIST, .value.qlist = (val) }
51 
52 bool qlit_equal_qobject(const QLitObject *lhs, const QObject *rhs);
53 
54 #endif /* QLIT_H */
55