Michael Roth | e4e6aa1 | 2011-07-19 14:50:34 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Output Visitor |
| 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 | |
Daniel P. Berrange | b3db211 | 2016-09-30 15:45:27 +0100 | [diff] [blame] | 14 | #ifndef QOBJECT_OUTPUT_VISITOR_H |
| 15 | #define QOBJECT_OUTPUT_VISITOR_H |
Michael Roth | e4e6aa1 | 2011-07-19 14:50:34 -0500 | [diff] [blame] | 16 | |
Paolo Bonzini | 7b1b5d1 | 2012-12-17 18:19:43 +0100 | [diff] [blame] | 17 | #include "qapi/visitor.h" |
| 18 | #include "qapi/qmp/qobject.h" |
Michael Roth | e4e6aa1 | 2011-07-19 14:50:34 -0500 | [diff] [blame] | 19 | |
Daniel P. Berrange | 7d5e199 | 2016-09-30 15:45:28 +0100 | [diff] [blame] | 20 | typedef struct QObjectOutputVisitor QObjectOutputVisitor; |
Michael Roth | e4e6aa1 | 2011-07-19 14:50:34 -0500 | [diff] [blame] | 21 | |
Markus Armbruster | aa3a982 | 2017-03-03 13:32:48 +0100 | [diff] [blame] | 22 | /** |
| 23 | * Create a QObject output visitor for @obj |
Eric Blake | 3b098d5 | 2016-06-09 10:48:43 -0600 | [diff] [blame] | 24 | * |
Markus Armbruster | aa3a982 | 2017-03-03 13:32:48 +0100 | [diff] [blame] | 25 | * A QObject output visitor visit builds a QObject from QAPI Object. |
| 26 | * This simultaneously walks the QAPI object and the QObject being |
| 27 | * built. The latter walk starts at @obj. |
| 28 | * |
| 29 | * visit_type_FOO() creates a QObject for QAPI type FOO. It creates a |
| 30 | * QDict for struct/union types, a QList for list types, QString for |
Marc-André Lureau | 01b2ffc | 2017-06-07 20:35:58 +0400 | [diff] [blame] | 31 | * type 'str' and enumeration types, QNum for integer and float |
| 32 | * types, QBool for type 'bool'. For type 'any', it increments the |
| 33 | * QObject's reference count. For QAPI alternate types, it creates |
| 34 | * the QObject for the member that is in use. |
Markus Armbruster | aa3a982 | 2017-03-03 13:32:48 +0100 | [diff] [blame] | 35 | * |
| 36 | * visit_start_struct() ... visit_end_struct() visits a QAPI |
| 37 | * struct/union and creates a QDict. Visits in between visit the |
| 38 | * members. visit_optional() is true when the struct/union has this |
| 39 | * member. visit_check_struct() does nothing. |
| 40 | * |
| 41 | * visit_start_list() ... visit_end_list() visits a QAPI list and |
| 42 | * creates a QList. Visits in between visit list members, one after |
| 43 | * the other. visit_next_list() returns NULL when all QAPI list |
| 44 | * members have been visited. visit_check_list() does nothing. |
| 45 | * |
| 46 | * visit_start_alternate() ... visit_end_alternate() visits a QAPI |
| 47 | * alternate. The visit in between creates the QObject for the |
| 48 | * alternate member that is in use. |
| 49 | * |
| 50 | * Errors are not expected to happen. |
| 51 | * |
| 52 | * The caller is responsible for freeing the visitor with |
| 53 | * visit_free(). |
Eric Blake | 3b098d5 | 2016-06-09 10:48:43 -0600 | [diff] [blame] | 54 | */ |
Daniel P. Berrange | 7d5e199 | 2016-09-30 15:45:28 +0100 | [diff] [blame] | 55 | Visitor *qobject_output_visitor_new(QObject **result); |
Michael Roth | e4e6aa1 | 2011-07-19 14:50:34 -0500 | [diff] [blame] | 56 | |
| 57 | #endif |