xref: /openbmc/qemu/include/qapi/visitor-impl.h (revision 953ea14d)
1 /*
2  * Core Definitions for QAPI Visitor implementations
3  *
4  * Copyright (C) 2012 Red Hat, Inc.
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 
15 #include "qapi/error.h"
16 #include "qapi/visitor.h"
17 
18 struct Visitor
19 {
20     /* Must be set */
21     void (*start_struct)(Visitor *v, void **obj, const char *kind,
22                          const char *name, size_t size, Error **errp);
23     void (*end_struct)(Visitor *v, Error **errp);
24 
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 
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 
33     void (*type_enum)(Visitor *v, int *obj, const char *strings[],
34                       const char *kind, const char *name, Error **errp);
35     void (*get_next_type)(Visitor *v, int *kind, const int *qobjects,
36                           const char *name, Error **errp);
37 
38     void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp);
39     void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
40     void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
41     void (*type_number)(Visitor *v, double *obj, const char *name,
42                         Error **errp);
43 
44     /* May be NULL */
45     void (*optional)(Visitor *v, bool *present, const char *name,
46                      Error **errp);
47 
48     void (*type_uint8)(Visitor *v, uint8_t *obj, const char *name, Error **errp);
49     void (*type_uint16)(Visitor *v, uint16_t *obj, const char *name, Error **errp);
50     void (*type_uint32)(Visitor *v, uint32_t *obj, const char *name, Error **errp);
51     void (*type_uint64)(Visitor *v, uint64_t *obj, const char *name, Error **errp);
52     void (*type_int8)(Visitor *v, int8_t *obj, const char *name, Error **errp);
53     void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp);
54     void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp);
55     void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp);
56     /* visit_type_size() falls back to (*type_uint64)() if type_size is unset */
57     void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error **errp);
58     bool (*start_union)(Visitor *v, bool data_present, Error **errp);
59     void (*end_union)(Visitor *v, bool data_present, Error **errp);
60 };
61 
62 void input_type_enum(Visitor *v, int *obj, const char *strings[],
63                      const char *kind, const char *name, Error **errp);
64 void output_type_enum(Visitor *v, int *obj, const char *strings[],
65                       const char *kind, const char *name, Error **errp);
66 
67 #endif
68