libpurple/protocols/facebook/json.h

branch
facebook
changeset 37250
3f5570a17b15
child 37251
8d6136db4399
equal deleted inserted replaced
37249:dfa58c08a4fd 37250:3f5570a17b15
1 /* purple
2 *
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 */
21
22 #ifndef _FACEBOOK_JSON_H_
23 #define _FACEBOOK_JSON_H_
24
25 #include <glib.h>
26 #include <json-glib/json-glib.h>
27
28 #define FB_JSON_ERROR fb_json_error_quark()
29
30 typedef enum _FbJsonError FbJsonError;
31
32 enum _FbJsonError
33 {
34 FB_JSON_ERROR_SUCCESS = 0,
35 FB_JSON_ERROR_AMBIGUOUS,
36 FB_JSON_ERROR_NOMATCH
37 };
38
39 GQuark
40 fb_json_error_quark(void);
41
42 JsonBuilder *
43 fb_json_bldr_new(JsonNodeType type);
44
45 gchar *
46 fb_json_bldr_close(JsonBuilder *bldr, JsonNodeType type, gsize *size);
47
48 void
49 fb_json_bldr_arr_begin(JsonBuilder *bldr, const gchar *name);
50
51 void
52 fb_json_bldr_arr_end(JsonBuilder *bldr);
53
54 void
55 fb_json_bldr_obj_begin(JsonBuilder *bldr, const gchar *name);
56
57 void
58 fb_json_bldr_obj_end(JsonBuilder *bldr);
59
60 void
61 fb_json_bldr_add_bool(JsonBuilder *bldr, const gchar *name, gboolean value);
62
63 void
64 fb_json_bldr_add_dbl(JsonBuilder *bldr, const gchar *name, gdouble value);
65
66 void
67 fb_json_bldr_add_int(JsonBuilder *bldr, const gchar *name, gint64 value);
68
69 void
70 fb_json_bldr_add_null(JsonBuilder *bldr, const gchar *name);
71
72 void
73 fb_json_bldr_add_str(JsonBuilder *bldr, const gchar *name, const gchar *value);
74
75 void
76 fb_json_bldr_add_strf(JsonBuilder *bldr, const gchar *name,
77 const gchar *format, ...)
78 G_GNUC_PRINTF(3, 4);
79
80 JsonNode *
81 fb_json_node_new(const gchar *data, gssize size, GError **error);
82
83 JsonNode *
84 fb_json_node_get(JsonNode *root, const gchar *expr, GError **error);
85
86 JsonArray *
87 fb_json_node_get_arr(JsonNode *root, const gchar *expr, GError **error);
88
89 gboolean
90 fb_json_node_get_bool(JsonNode *root, const gchar *expr, GError **error);
91
92 gdouble
93 fb_json_node_get_dbl(JsonNode *root, const gchar *expr, GError **error);
94
95 gint64
96 fb_json_node_get_int(JsonNode *root, const gchar *expr, GError **error);
97
98 const gchar *
99 fb_json_node_get_str(JsonNode *root, const gchar *expr, GError **error);
100
101 gboolean
102 fb_json_node_chk(JsonNode *root, const gchar *expr, JsonNode **value);
103
104 gboolean
105 fb_json_node_chk_arr(JsonNode *root, const gchar *expr, JsonArray **value);
106
107 gboolean
108 fb_json_node_chk_bool(JsonNode *root, const gchar *expr, gboolean *value);
109
110 gboolean
111 fb_json_node_chk_dbl(JsonNode *root, const gchar *expr, gdouble *value);
112
113 gboolean
114 fb_json_node_chk_int(JsonNode *root, const gchar *expr, gint64 *value);
115
116 gboolean
117 fb_json_node_chk_str(JsonNode *root, const gchar *expr, const gchar **value);
118
119 #endif /* _FACEBOOK_JSON_H_ */

mercurial