1 /* json-builder.h: JSON tree builder
3 * This file is part of JSON-GLib
4 * Copyright (C) 2010 Luca Bruno <lethalman88@gmail.com>
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.
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.
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/>.
20 * Luca Bruno <lethalman88@gmail.com>
23 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
24 #error "Only <json-glib/json-glib.h> can be included directly."
27 #ifndef __JSON_BUILDER_H__
28 #define __JSON_BUILDER_H__
30 #include <json-glib/json-types.h>
34 #define JSON_TYPE_BUILDER (json_builder_get_type ())
35 #define JSON_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_BUILDER, JsonBuilder))
36 #define JSON_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_BUILDER))
37 #define JSON_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), JSON_TYPE_BUILDER, JsonBuilderClass))
38 #define JSON_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), JSON_TYPE_BUILDER))
39 #define JSON_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JSON_TYPE_BUILDER, JsonBuilderClass))
41 typedef struct _JsonBuilder JsonBuilder;
42 typedef struct _JsonBuilderPrivate JsonBuilderPrivate;
43 typedef struct _JsonBuilderClass JsonBuilderClass;
48 * The <structname>JsonBuilder</structname> structure contains only
49 * private data and shouls be accessed using the provided API
56 GObject parent_instance;
58 JsonBuilderPrivate *priv;
64 * The <structname>JsonBuilder</structname> structure contains only
69 struct _JsonBuilderClass
72 GObjectClass parent_class;
74 /* padding, for future expansion */
75 void (* _json_reserved1) (void);
76 void (* _json_reserved2) (void);
79 GType json_builder_get_type (void) G_GNUC_CONST;
81 JsonBuilder *json_builder_new (void);
82 JsonNode *json_builder_get_root (JsonBuilder *builder);
83 void json_builder_reset (JsonBuilder *builder);
85 JsonBuilder *json_builder_begin_array (JsonBuilder *builder);
86 JsonBuilder *json_builder_end_array (JsonBuilder *builder);
87 JsonBuilder *json_builder_begin_object (JsonBuilder *builder);
88 JsonBuilder *json_builder_end_object (JsonBuilder *builder);
90 JsonBuilder *json_builder_set_member_name (JsonBuilder *builder,
91 const gchar *member_name);
92 JsonBuilder *json_builder_add_value (JsonBuilder *builder,
94 JsonBuilder *json_builder_add_int_value (JsonBuilder *builder,
96 JsonBuilder *json_builder_add_double_value (JsonBuilder *builder,
98 JsonBuilder *json_builder_add_boolean_value (JsonBuilder *builder,
100 JsonBuilder *json_builder_add_string_value (JsonBuilder *builder,
102 JsonBuilder *json_builder_add_null_value (JsonBuilder *builder);
106 #endif /* __JSON_BUILDER_H__ */