Merge remote-tracking branch 'sstabellini/tags/xen-20161102-tag' into staging
[qemu/ar7.git] / include / qapi / clone-visitor.h
blobb16177e1ee258a321a4c24fe95dc59a34338efd7
1 /*
2 * Clone Visitor
4 * Copyright (C) 2016 Red Hat, Inc.
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
9 */
11 #ifndef QAPI_CLONE_VISITOR_H
12 #define QAPI_CLONE_VISITOR_H
14 #include "qemu/typedefs.h"
15 #include "qapi/visitor.h"
16 #include "qapi-visit.h"
19 * The clone visitor is for direct use only by the QAPI_CLONE() macro;
20 * it requires that the root visit occur on an object, list, or
21 * alternate, and is not usable directly on built-in QAPI types.
23 typedef struct QapiCloneVisitor QapiCloneVisitor;
25 void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
26 void **, Error **));
29 * Deep-clone QAPI object @src of the given @type, and return the result.
31 * Not usable on QAPI scalars (integers, strings, enums), nor on a
32 * QAPI object that references the 'any' type. Safe when @src is NULL.
34 #define QAPI_CLONE(type, src) \
35 ((type *)qapi_clone(src, \
36 (void (*)(Visitor *, const char *, void**, \
37 Error **))visit_type_ ## type))
39 #endif