json-builder.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* json-builder.h: JSON tree builder
  2. *
  3. * This file is part of JSON-GLib
  4. * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Author:
  20. * Luca Bruno <lethalman88@gmail.com>
  21. */
  22. #ifndef __JSON_BUILDER_H__
  23. #define __JSON_BUILDER_H__
  24. #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
  25. #error "Only <json-glib/json-glib.h> can be included directly."
  26. #endif
  27. #include <json-glib/json-types.h>
  28. G_BEGIN_DECLS
  29. #define JSON_TYPE_BUILDER (json_builder_get_type ())
  30. #define JSON_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_BUILDER, JsonBuilder))
  31. #define JSON_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_BUILDER))
  32. #define JSON_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), JSON_TYPE_BUILDER, JsonBuilderClass))
  33. #define JSON_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), JSON_TYPE_BUILDER))
  34. #define JSON_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JSON_TYPE_BUILDER, JsonBuilderClass))
  35. typedef struct _JsonBuilder JsonBuilder;
  36. typedef struct _JsonBuilderPrivate JsonBuilderPrivate;
  37. typedef struct _JsonBuilderClass JsonBuilderClass;
  38. /**
  39. * JsonBuilder:
  40. *
  41. * The `JsonBuilder` structure contains only private data and should be
  42. * accessed using the provided API
  43. *
  44. * Since: 0.12
  45. */
  46. struct _JsonBuilder
  47. {
  48. /*< private >*/
  49. GObject parent_instance;
  50. JsonBuilderPrivate *priv;
  51. };
  52. /**
  53. * JsonBuilderClass:
  54. *
  55. * The `JsonBuilderClass` structure contains only private data
  56. *
  57. * Since: 0.12
  58. */
  59. struct _JsonBuilderClass
  60. {
  61. /*< private >*/
  62. GObjectClass parent_class;
  63. /* padding, for future expansion */
  64. void (* _json_reserved1) (void);
  65. void (* _json_reserved2) (void);
  66. };
  67. JSON_AVAILABLE_IN_1_0
  68. GType json_builder_get_type (void) G_GNUC_CONST;
  69. JSON_AVAILABLE_IN_1_0
  70. JsonBuilder *json_builder_new (void);
  71. JSON_AVAILABLE_IN_1_2
  72. JsonBuilder *json_builder_new_immutable (void);
  73. JSON_AVAILABLE_IN_1_0
  74. JsonNode *json_builder_get_root (JsonBuilder *builder);
  75. JSON_AVAILABLE_IN_1_0
  76. void json_builder_reset (JsonBuilder *builder);
  77. JSON_AVAILABLE_IN_1_0
  78. JsonBuilder *json_builder_begin_array (JsonBuilder *builder);
  79. JSON_AVAILABLE_IN_1_0
  80. JsonBuilder *json_builder_end_array (JsonBuilder *builder);
  81. JSON_AVAILABLE_IN_1_0
  82. JsonBuilder *json_builder_begin_object (JsonBuilder *builder);
  83. JSON_AVAILABLE_IN_1_0
  84. JsonBuilder *json_builder_end_object (JsonBuilder *builder);
  85. JSON_AVAILABLE_IN_1_0
  86. JsonBuilder *json_builder_set_member_name (JsonBuilder *builder,
  87. const gchar *member_name);
  88. JSON_AVAILABLE_IN_1_0
  89. JsonBuilder *json_builder_add_value (JsonBuilder *builder,
  90. JsonNode *node);
  91. JSON_AVAILABLE_IN_1_0
  92. JsonBuilder *json_builder_add_int_value (JsonBuilder *builder,
  93. gint64 value);
  94. JSON_AVAILABLE_IN_1_0
  95. JsonBuilder *json_builder_add_double_value (JsonBuilder *builder,
  96. gdouble value);
  97. JSON_AVAILABLE_IN_1_0
  98. JsonBuilder *json_builder_add_boolean_value (JsonBuilder *builder,
  99. gboolean value);
  100. JSON_AVAILABLE_IN_1_0
  101. JsonBuilder *json_builder_add_string_value (JsonBuilder *builder,
  102. const gchar *value);
  103. JSON_AVAILABLE_IN_1_0
  104. JsonBuilder *json_builder_add_null_value (JsonBuilder *builder);
  105. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  106. G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonBuilder, g_object_unref)
  107. #endif
  108. G_END_DECLS
  109. #endif /* __JSON_BUILDER_H__ */