]>
Commit | Line | Data |
---|---|---|
2345c77c MR |
1 | /* |
2 | * Core Definitions for QAPI Visitor Classes | |
3 | * | |
4 | * Copyright IBM, Corp. 2011 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
10 | * See the COPYING.LIB file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
14 | #include "qapi/qapi-visit-core.h" | |
15 | ||
16 | void visit_start_handle(Visitor *v, void **obj, const char *kind, | |
17 | const char *name, Error **errp) | |
18 | { | |
19 | if (!error_is_set(errp) && v->start_handle) { | |
20 | v->start_handle(v, obj, kind, name, errp); | |
21 | } | |
22 | } | |
23 | ||
24 | void visit_end_handle(Visitor *v, Error **errp) | |
25 | { | |
26 | if (!error_is_set(errp) && v->end_handle) { | |
27 | v->end_handle(v, errp); | |
28 | } | |
29 | } | |
30 | ||
31 | void visit_start_struct(Visitor *v, void **obj, const char *kind, | |
32 | const char *name, size_t size, Error **errp) | |
33 | { | |
34 | if (!error_is_set(errp)) { | |
35 | v->start_struct(v, obj, kind, name, size, errp); | |
36 | } | |
37 | } | |
38 | ||
39 | void visit_end_struct(Visitor *v, Error **errp) | |
40 | { | |
41 | if (!error_is_set(errp)) { | |
42 | v->end_struct(v, errp); | |
43 | } | |
44 | } | |
45 | ||
46 | void visit_start_list(Visitor *v, const char *name, Error **errp) | |
47 | { | |
48 | if (!error_is_set(errp)) { | |
49 | v->start_list(v, name, errp); | |
50 | } | |
51 | } | |
52 | ||
53 | GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp) | |
54 | { | |
55 | if (!error_is_set(errp)) { | |
56 | return v->next_list(v, list, errp); | |
57 | } | |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
62 | void visit_end_list(Visitor *v, Error **errp) | |
63 | { | |
64 | if (!error_is_set(errp)) { | |
65 | v->end_list(v, errp); | |
66 | } | |
67 | } | |
68 | ||
69 | void visit_start_optional(Visitor *v, bool *present, const char *name, | |
70 | Error **errp) | |
71 | { | |
72 | if (!error_is_set(errp) && v->start_optional) { | |
73 | v->start_optional(v, present, name, errp); | |
74 | } | |
75 | } | |
76 | ||
77 | void visit_end_optional(Visitor *v, Error **errp) | |
78 | { | |
79 | if (!error_is_set(errp) && v->end_optional) { | |
80 | v->end_optional(v, errp); | |
81 | } | |
82 | } | |
83 | ||
84 | void visit_type_enum(Visitor *v, int *obj, const char *strings[], | |
85 | const char *kind, const char *name, Error **errp) | |
86 | { | |
87 | if (!error_is_set(errp)) { | |
88 | v->type_enum(v, obj, strings, kind, name, errp); | |
89 | } | |
90 | } | |
91 | ||
92 | void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) | |
93 | { | |
94 | if (!error_is_set(errp)) { | |
95 | v->type_int(v, obj, name, errp); | |
96 | } | |
97 | } | |
98 | ||
99 | void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) | |
100 | { | |
101 | if (!error_is_set(errp)) { | |
102 | v->type_bool(v, obj, name, errp); | |
103 | } | |
104 | } | |
105 | ||
106 | void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp) | |
107 | { | |
108 | if (!error_is_set(errp)) { | |
109 | v->type_str(v, obj, name, errp); | |
110 | } | |
111 | } | |
112 | ||
113 | void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp) | |
114 | { | |
115 | if (!error_is_set(errp)) { | |
116 | v->type_number(v, obj, name, errp); | |
117 | } | |
118 | } |