]>
Commit | Line | Data |
---|---|---|
0f71a1e0 PB |
1 | /* |
2 | * Core Definitions for QAPI Visitor implementations | |
3 | * | |
04e070d2 | 4 | * Copyright (C) 2012-2016 Red Hat, Inc. |
0f71a1e0 PB |
5 | * |
6 | * Author: Paolo Bonizni <pbonzini@redhat.com> | |
7 | * | |
8 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
9 | * See the COPYING.LIB file in the top-level directory. | |
10 | * | |
11 | */ | |
12 | #ifndef QAPI_VISITOR_IMPL_H | |
13 | #define QAPI_VISITOR_IMPL_H | |
14 | ||
7b1b5d19 PB |
15 | #include "qapi/error.h" |
16 | #include "qapi/visitor.h" | |
0f71a1e0 | 17 | |
7edd63f1 PB |
18 | struct Visitor |
19 | { | |
20 | /* Must be set */ | |
0b2a0d6b | 21 | void (*start_struct)(Visitor *v, const char *name, void **obj, |
337283df | 22 | size_t size, Error **errp); |
7edd63f1 PB |
23 | void (*end_struct)(Visitor *v, Error **errp); |
24 | ||
761d524d KW |
25 | void (*start_implicit_struct)(Visitor *v, void **obj, size_t size, |
26 | Error **errp); | |
27 | void (*end_implicit_struct)(Visitor *v, Error **errp); | |
28 | ||
7edd63f1 PB |
29 | void (*start_list)(Visitor *v, const char *name, Error **errp); |
30 | GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp); | |
31 | void (*end_list)(Visitor *v, Error **errp); | |
32 | ||
0b2a0d6b | 33 | void (*type_enum)(Visitor *v, const char *name, int *obj, |
337283df | 34 | const char *const strings[], Error **errp); |
0426d53c | 35 | /* May be NULL; only needed for input visitors. */ |
0b2a0d6b EB |
36 | void (*get_next_type)(Visitor *v, const char *name, QType *type, |
37 | bool promote_int, Error **errp); | |
7edd63f1 | 38 | |
4c40314a | 39 | /* Must be set. */ |
0b2a0d6b | 40 | void (*type_int64)(Visitor *v, const char *name, int64_t *obj, |
4c40314a EB |
41 | Error **errp); |
42 | /* Must be set. */ | |
0b2a0d6b | 43 | void (*type_uint64)(Visitor *v, const char *name, uint64_t *obj, |
f755dea7 EB |
44 | Error **errp); |
45 | /* Optional; fallback is type_uint64(). */ | |
0b2a0d6b | 46 | void (*type_size)(Visitor *v, const char *name, uint64_t *obj, |
f755dea7 EB |
47 | Error **errp); |
48 | /* Must be set. */ | |
0b2a0d6b EB |
49 | void (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp); |
50 | void (*type_str)(Visitor *v, const char *name, char **obj, Error **errp); | |
51 | void (*type_number)(Visitor *v, const char *name, double *obj, | |
7edd63f1 | 52 | Error **errp); |
0b2a0d6b | 53 | void (*type_any)(Visitor *v, const char *name, QObject **obj, |
28770e05 | 54 | Error **errp); |
7edd63f1 | 55 | |
5cdc8831 | 56 | /* May be NULL; most useful for input visitors. */ |
0b2a0d6b | 57 | void (*optional)(Visitor *v, const char *name, bool *present); |
7edd63f1 | 58 | |
cee2dedb | 59 | bool (*start_union)(Visitor *v, bool data_present, Error **errp); |
7edd63f1 PB |
60 | }; |
61 | ||
0b2a0d6b | 62 | void input_type_enum(Visitor *v, const char *name, int *obj, |
337283df | 63 | const char *const strings[], Error **errp); |
0b2a0d6b | 64 | void output_type_enum(Visitor *v, const char *name, int *obj, |
337283df | 65 | const char *const strings[], Error **errp); |
0f71a1e0 PB |
66 | |
67 | #endif |