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_list)(Visitor *v, const char *name, Error **errp); 26 GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp); 27 void (*end_list)(Visitor *v, Error **errp); 28 29 void (*type_enum)(Visitor *v, int *obj, const char *strings[], 30 const char *kind, const char *name, Error **errp); 31 32 void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp); 33 void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp); 34 void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); 35 void (*type_number)(Visitor *v, double *obj, const char *name, 36 Error **errp); 37 38 /* May be NULL */ 39 void (*start_optional)(Visitor *v, bool *present, const char *name, 40 Error **errp); 41 void (*end_optional)(Visitor *v, Error **errp); 42 43 void (*start_handle)(Visitor *v, void **obj, const char *kind, 44 const char *name, Error **errp); 45 void (*end_handle)(Visitor *v, Error **errp); 46 void (*type_uint8)(Visitor *v, uint8_t *obj, const char *name, Error **errp); 47 void (*type_uint16)(Visitor *v, uint16_t *obj, const char *name, Error **errp); 48 void (*type_uint32)(Visitor *v, uint32_t *obj, const char *name, Error **errp); 49 void (*type_uint64)(Visitor *v, uint64_t *obj, const char *name, Error **errp); 50 void (*type_int8)(Visitor *v, int8_t *obj, const char *name, Error **errp); 51 void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp); 52 void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp); 53 void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp); 54 /* visit_type_size() falls back to (*type_uint64)() if type_size is unset */ 55 void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error **errp); 56 }; 57 58 void input_type_enum(Visitor *v, int *obj, const char *strings[], 59 const char *kind, const char *name, Error **errp); 60 void output_type_enum(Visitor *v, int *obj, const char *strings[], 61 const char *kind, const char *name, Error **errp); 62 63 #endif 64