Initial Import
[profile/ivi/json-glib.git] / json-glib / json-builder.h
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
23 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
24 #error "Only <json-glib/json-glib.h> can be included directly."
25 #endif
26
27 #ifndef __JSON_BUILDER_H__
28 #define __JSON_BUILDER_H__
29
30 #include <json-glib/json-types.h>
31
32 G_BEGIN_DECLS
33
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))
40
41 typedef struct _JsonBuilder           JsonBuilder;
42 typedef struct _JsonBuilderPrivate    JsonBuilderPrivate;
43 typedef struct _JsonBuilderClass      JsonBuilderClass;
44
45 /**
46  * JsonBuilder:
47  *
48  * The <structname>JsonBuilder</structname> structure contains only
49  * private data and shouls be accessed using the provided API
50  *
51  * Since: 0.12
52  */
53 struct _JsonBuilder
54 {
55   /*< private >*/
56   GObject parent_instance;
57
58   JsonBuilderPrivate *priv;
59 };
60
61 /**
62  * JsonBuilderClass:
63  *
64  * The <structname>JsonBuilder</structname> structure contains only
65  * private data
66  *
67  * Since: 0.12
68  */
69 struct _JsonBuilderClass
70 {
71   /*< private >*/
72   GObjectClass parent_class;
73
74   /* padding, for future expansion */
75   void (* _json_reserved1) (void);
76   void (* _json_reserved2) (void);
77 };
78
79 GType json_builder_get_type (void) G_GNUC_CONST;
80
81 JsonBuilder *json_builder_new                (void);
82 JsonNode    *json_builder_get_root           (JsonBuilder  *builder);
83 void         json_builder_reset              (JsonBuilder  *builder);
84
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);
89
90 JsonBuilder *json_builder_set_member_name    (JsonBuilder  *builder,
91                                               const gchar  *member_name);
92 JsonBuilder *json_builder_add_value          (JsonBuilder  *builder,
93                                               JsonNode     *node);
94 JsonBuilder *json_builder_add_int_value      (JsonBuilder  *builder,
95                                               gint64        value);
96 JsonBuilder *json_builder_add_double_value   (JsonBuilder  *builder,
97                                               gdouble       value);
98 JsonBuilder *json_builder_add_boolean_value  (JsonBuilder  *builder,
99                                               gboolean      value);
100 JsonBuilder *json_builder_add_string_value   (JsonBuilder  *builder,
101                                               const gchar  *value);
102 JsonBuilder *json_builder_add_null_value     (JsonBuilder  *builder);
103
104 G_END_DECLS
105
106 #endif /* __JSON_BUILDER_H__ */