qapi-visit-core.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Core Definitions for QAPI Visitor Classes
  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 QAPI_VISITOR_CORE_H
  14. #define QAPI_VISITOR_CORE_H
  15. #include "qapi/qapi-types-core.h"
  16. #include <stdlib.h>
  17. typedef struct GenericList
  18. {
  19. void *value;
  20. struct GenericList *next;
  21. } GenericList;
  22. typedef struct Visitor Visitor;
  23. struct Visitor
  24. {
  25. /* Must be set */
  26. void (*start_struct)(Visitor *v, void **obj, const char *kind,
  27. const char *name, size_t size, Error **errp);
  28. void (*end_struct)(Visitor *v, Error **errp);
  29. void (*start_list)(Visitor *v, const char *name, Error **errp);
  30. GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
  31. void (*end_list)(Visitor *v, Error **errp);
  32. void (*type_enum)(Visitor *v, int *obj, const char *strings[],
  33. const char *kind, const char *name, Error **errp);
  34. void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp);
  35. void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
  36. void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
  37. void (*type_number)(Visitor *v, double *obj, const char *name,
  38. Error **errp);
  39. /* May be NULL */
  40. void (*start_optional)(Visitor *v, bool *present, const char *name,
  41. Error **errp);
  42. void (*end_optional)(Visitor *v, Error **errp);
  43. void (*start_handle)(Visitor *v, void **obj, const char *kind,
  44. const char *name, Error **errp);
  45. void (*end_handle)(Visitor *v, Error **errp);
  46. };
  47. void visit_start_handle(Visitor *v, void **obj, const char *kind,
  48. const char *name, Error **errp);
  49. void visit_end_handle(Visitor *v, Error **errp);
  50. void visit_start_struct(Visitor *v, void **obj, const char *kind,
  51. const char *name, size_t size, Error **errp);
  52. void visit_end_struct(Visitor *v, Error **errp);
  53. void visit_start_list(Visitor *v, const char *name, Error **errp);
  54. GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp);
  55. void visit_end_list(Visitor *v, Error **errp);
  56. void visit_start_optional(Visitor *v, bool *present, const char *name,
  57. Error **errp);
  58. void visit_end_optional(Visitor *v, Error **errp);
  59. void visit_type_enum(Visitor *v, int *obj, const char *strings[],
  60. const char *kind, const char *name, Error **errp);
  61. void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
  62. void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
  63. void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
  64. void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
  65. #endif