visitor-impl.h 2.5 KB
Newer Older
1 2 3
/*
 * Core Definitions for QAPI Visitor implementations
 *
4
 * Copyright (C) 2012-2016 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14
 *
 * Author: Paolo Bonizni <pbonzini@redhat.com>
 *
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
 * See the COPYING.LIB file in the top-level directory.
 *
 */
#ifndef QAPI_VISITOR_IMPL_H
#define QAPI_VISITOR_IMPL_H

15 16
#include "qapi/error.h"
#include "qapi/visitor.h"
17

P
Paolo Bonzini 已提交
18 19 20
struct Visitor
{
    /* Must be set */
21
    void (*start_struct)(Visitor *v, const char *name, void **obj,
22
                         size_t size, Error **errp);
P
Paolo Bonzini 已提交
23 24
    void (*end_struct)(Visitor *v, Error **errp);

25 26 27 28
    void (*start_implicit_struct)(Visitor *v, void **obj, size_t size,
                                  Error **errp);
    void (*end_implicit_struct)(Visitor *v, Error **errp);

P
Paolo Bonzini 已提交
29 30 31 32
    void (*start_list)(Visitor *v, const char *name, Error **errp);
    GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
    void (*end_list)(Visitor *v, Error **errp);

33
    void (*type_enum)(Visitor *v, const char *name, int *obj,
34
                      const char *const strings[], Error **errp);
35
    /* May be NULL; only needed for input visitors. */
36 37
    void (*get_next_type)(Visitor *v, const char *name, QType *type,
                          bool promote_int, Error **errp);
P
Paolo Bonzini 已提交
38

39
    /* Must be set. */
40
    void (*type_int64)(Visitor *v, const char *name, int64_t *obj,
41 42
                       Error **errp);
    /* Must be set. */
43
    void (*type_uint64)(Visitor *v, const char *name, uint64_t *obj,
44 45
                        Error **errp);
    /* Optional; fallback is type_uint64().  */
46
    void (*type_size)(Visitor *v, const char *name, uint64_t *obj,
47 48
                      Error **errp);
    /* Must be set. */
49 50 51
    void (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp);
    void (*type_str)(Visitor *v, const char *name, char **obj, Error **errp);
    void (*type_number)(Visitor *v, const char *name, double *obj,
P
Paolo Bonzini 已提交
52
                        Error **errp);
53
    void (*type_any)(Visitor *v, const char *name, QObject **obj,
54
                     Error **errp);
P
Paolo Bonzini 已提交
55

56
    /* May be NULL; most useful for input visitors. */
57
    void (*optional)(Visitor *v, const char *name, bool *present);
P
Paolo Bonzini 已提交
58

59
    bool (*start_union)(Visitor *v, bool data_present, Error **errp);
P
Paolo Bonzini 已提交
60 61
};

62
void input_type_enum(Visitor *v, const char *name, int *obj,
63
                     const char *const strings[], Error **errp);
64
void output_type_enum(Visitor *v, const char *name, int *obj,
65
                      const char *const strings[], Error **errp);
66 67

#endif