qobject-output-visitor.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef QOBJECT_OUTPUT_VISITOR_H
  14. #define QOBJECT_OUTPUT_VISITOR_H
  15. #include "qapi/visitor.h"
  16. typedef struct QObjectOutputVisitor QObjectOutputVisitor;
  17. /**
  18. * Create a QObject output visitor for @obj
  19. *
  20. * A QObject output visitor visit builds a QObject from QAPI Object.
  21. * This simultaneously walks the QAPI object and the QObject being
  22. * built. The latter walk starts at @obj.
  23. *
  24. * visit_type_FOO() creates a QObject for QAPI type FOO. It creates a
  25. * QDict for struct/union types, a QList for list types, QString for
  26. * type 'str' and enumeration types, QNum for integer and float
  27. * types, QBool for type 'bool'. For type 'any', it increments the
  28. * QObject's reference count. For QAPI alternate types, it creates
  29. * the QObject for the member that is in use.
  30. *
  31. * visit_start_struct() ... visit_end_struct() visits a QAPI
  32. * struct/union and creates a QDict. Visits in between visit the
  33. * members. visit_optional() is true when the struct/union has this
  34. * member. visit_check_struct() does nothing.
  35. *
  36. * visit_start_list() ... visit_end_list() visits a QAPI list and
  37. * creates a QList. Visits in between visit list members, one after
  38. * the other. visit_next_list() returns NULL when all QAPI list
  39. * members have been visited. visit_check_list() does nothing.
  40. *
  41. * visit_start_alternate() ... visit_end_alternate() visits a QAPI
  42. * alternate. The visit in between creates the QObject for the
  43. * alternate member that is in use.
  44. *
  45. * Errors are not expected to happen.
  46. *
  47. * The caller is responsible for freeing the visitor with
  48. * visit_free().
  49. */
  50. Visitor *qobject_output_visitor_new(QObject **result);
  51. #endif