]> git.proxmox.com Git - mirror_qemu.git/blob - include/qapi/clone-visitor.h
sockets: Use new QAPI cloning
[mirror_qemu.git] / include / qapi / clone-visitor.h
1 /*
2 * Clone Visitor
3 *
4 * Copyright (C) 2016 Red Hat, Inc.
5 *
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.
8 *
9 */
10
11 #ifndef QAPI_CLONE_VISITOR_H
12 #define QAPI_CLONE_VISITOR_H
13
14 #include "qemu/typedefs.h"
15 #include "qapi/visitor.h"
16 #include "qapi-visit.h"
17
18 /*
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.
22 */
23 typedef struct QapiCloneVisitor QapiCloneVisitor;
24
25 void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
26 void **, Error **));
27
28 /*
29 * Deep-clone QAPI object @src of the given @type, and return the result.
30 *
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.
33 */
34 #define QAPI_CLONE(type, src) \
35 ((type *)qapi_clone(src, \
36 (void (*)(Visitor *, const char *, void**, \
37 Error **))visit_type_ ## type))
38
39 #endif