Initial Import
[profile/ivi/json-glib.git] / json-glib / json-generator.h
1 /* json-generator.h - JSON streams generator
2  * 
3  * This file is part of JSON-GLib
4  * Copyright (C) 2007  OpenedHand Ltd.
5  * Copyright (C) 2009  Intel Corp.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Author:
21  *   Emmanuele Bassi  <ebassi@linux.intel.com>
22  */
23
24 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
25 #error "Only <json-glib/json-glib.h> can be included directly."
26 #endif
27
28 #ifndef __JSON_GENERATOR_H__
29 #define __JSON_GENERATOR_H__
30
31 #include <json-glib/json-types.h>
32 #include <gio/gio.h>
33
34 G_BEGIN_DECLS
35
36 #define JSON_TYPE_GENERATOR             (json_generator_get_type ())
37 #define JSON_GENERATOR(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_GENERATOR, JsonGenerator))
38 #define JSON_IS_GENERATOR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_GENERATOR))
39 #define JSON_GENERATOR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), JSON_TYPE_GENERATOR, JsonGeneratorClass))
40 #define JSON_IS_GENERATOR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), JSON_TYPE_GENERATOR))
41 #define JSON_GENERATOR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), JSON_TYPE_GENERATOR, JsonGeneratorClass))
42
43 typedef struct _JsonGenerator           JsonGenerator;
44 typedef struct _JsonGeneratorPrivate    JsonGeneratorPrivate;
45 typedef struct _JsonGeneratorClass      JsonGeneratorClass;
46
47 /**
48  * JsonGenerator:
49  *
50  * JSON data streams generator. The contents of the #JsonGenerator structure
51  * are private and should only be accessed via the provided API.
52  */
53 struct _JsonGenerator
54 {
55   /*< private >*/
56   GObject parent_instance;
57
58   JsonGeneratorPrivate *priv;
59 };
60
61 /**
62  * JsonGeneratorClass:
63  *
64  * #JsonGenerator class
65  */
66 struct _JsonGeneratorClass
67 {
68   /*< private >*/
69   GObjectClass parent_class;
70
71   /* padding, for future expansion */
72   void (* _json_reserved1) (void);
73   void (* _json_reserved2) (void);
74   void (* _json_reserved3) (void);
75   void (* _json_reserved4) (void);
76 };
77
78 GType json_generator_get_type (void) G_GNUC_CONST;
79
80 JsonGenerator * json_generator_new              (void);
81
82 void            json_generator_set_pretty       (JsonGenerator  *generator,
83                                                  gboolean        is_pretty);
84 gboolean        json_generator_get_pretty       (JsonGenerator  *generator);
85 void            json_generator_set_indent       (JsonGenerator  *generator,
86                                                  guint           indent_level);
87 guint           json_generator_get_indent       (JsonGenerator  *generator);
88 void            json_generator_set_indent_char  (JsonGenerator  *generator,
89                                                  gunichar        indent_char);
90 gunichar        json_generator_get_indent_char  (JsonGenerator  *generator);
91 void            json_generator_set_root         (JsonGenerator  *generator,
92                                                  JsonNode       *node);
93 JsonNode *      json_generator_get_root         (JsonGenerator  *generator);
94
95 gchar *         json_generator_to_data          (JsonGenerator  *generator,
96                                                  gsize          *length);
97 gboolean        json_generator_to_file          (JsonGenerator  *generator,
98                                                  const gchar    *filename,
99                                                  GError        **error);
100 gboolean        json_generator_to_stream        (JsonGenerator  *generator,
101                                                  GOutputStream  *stream,
102                                                  GCancellable   *cancellable,
103                                                  GError        **error);
104
105 G_END_DECLS
106
107 #endif /* __JSON_GENERATOR_H__ */