| 20 */ |
20 */ |
| 21 |
21 |
| 22 #ifndef _FACEBOOK_JSON_H_ |
22 #ifndef _FACEBOOK_JSON_H_ |
| 23 #define _FACEBOOK_JSON_H_ |
23 #define _FACEBOOK_JSON_H_ |
| 24 |
24 |
| |
25 #define FB_TYPE_JSON_VALUES (fb_json_values_get_type()) |
| |
26 #define FB_JSON_VALUES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FB_TYPE_JSON_VALUES, FbJsonValues)) |
| |
27 #define FB_JSON_VALUES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), FB_TYPE_JSON_VALUES, FbJsonValuesClass)) |
| |
28 #define FB_IS_JSON_VALUES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), FB_TYPE_JSON_VALUES)) |
| |
29 #define FB_IS_JSON_VALUES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), FB_TYPE_JSON_VALUES)) |
| |
30 #define FB_JSON_VALUES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FB_TYPE_JSON_VALUES, FbJsonValuesClass)) |
| |
31 |
| 25 /** |
32 /** |
| 26 * SECTION:json |
33 * SECTION:json |
| 27 * @section_id: facebook-json |
34 * @section_id: facebook-json |
| 28 * @short_description: <filename>json.h</filename> |
35 * @short_description: <filename>json.h</filename> |
| 29 * @title: JSON Utilities |
36 * @title: JSON Utilities |
| 39 * |
46 * |
| 40 * The #GQuark of the domain of JSON errors. |
47 * The #GQuark of the domain of JSON errors. |
| 41 */ |
48 */ |
| 42 #define FB_JSON_ERROR fb_json_error_quark() |
49 #define FB_JSON_ERROR fb_json_error_quark() |
| 43 |
50 |
| 44 typedef struct _FbJsonValue FbJsonValue; |
|
| 45 typedef struct _FbJsonValues FbJsonValues; |
51 typedef struct _FbJsonValues FbJsonValues; |
| |
52 typedef struct _FbJsonValuesClass FbJsonValuesClass; |
| |
53 typedef struct _FbJsonValuesPrivate FbJsonValuesPrivate; |
| 46 |
54 |
| 47 /** |
55 /** |
| 48 * FbJsonError: |
56 * FbJsonError: |
| 49 * @FB_JSON_ERROR_SUCCESS: There is no error. |
57 * @FB_JSON_ERROR_SUCCESS: There is no error. |
| 50 * @FB_JSON_ERROR_AMBIGUOUS: The node has ambiguous matches. |
58 * @FB_JSON_ERROR_AMBIGUOUS: The node has ambiguous matches. |
| 83 FB_JSON_TYPE_INT = G_TYPE_INT64, |
91 FB_JSON_TYPE_INT = G_TYPE_INT64, |
| 84 FB_JSON_TYPE_STR = G_TYPE_STRING |
92 FB_JSON_TYPE_STR = G_TYPE_STRING |
| 85 } FbJsonType; |
93 } FbJsonType; |
| 86 |
94 |
| 87 /** |
95 /** |
| 88 * FbJsonValue: |
|
| 89 * @expr: The #JsonPath expression. |
|
| 90 * @type: The #FbJsonType. |
|
| 91 * @required: TRUE if the node is required, otherwise FALSE. |
|
| 92 * @value: The #GValue. |
|
| 93 * |
|
| 94 * Represents a JSON node value. |
|
| 95 */ |
|
| 96 struct _FbJsonValue |
|
| 97 { |
|
| 98 const gchar *expr; |
|
| 99 FbJsonType type; |
|
| 100 gboolean required; |
|
| 101 GValue value; |
|
| 102 }; |
|
| 103 |
|
| 104 /** |
|
| 105 * FbJsonValues: |
96 * FbJsonValues: |
| 106 * @root: The root #JsonNode. |
|
| 107 * @queue: The queue of #FbJsonValue's. |
|
| 108 * @next: The next #FbJsonValue. |
|
| 109 * @isarray: #TRUE if an array is present, otherwise #FALSE. |
|
| 110 * @array: The #JsonArray or #NULL. |
|
| 111 * @index: The advancing array index. |
|
| 112 * @error: The #GError. |
|
| 113 * |
97 * |
| 114 * Represents a JSON value handler. |
98 * Represents a JSON value handler. |
| 115 */ |
99 */ |
| 116 struct _FbJsonValues |
100 struct _FbJsonValues |
| 117 { |
101 { |
| 118 JsonNode *root; |
102 /*< private >*/ |
| 119 GQueue *queue; |
103 GObject parent; |
| 120 GList *next; |
104 FbJsonValuesPrivate *priv; |
| 121 |
|
| 122 gboolean isarray; |
|
| 123 JsonArray *array; |
|
| 124 guint index; |
|
| 125 |
|
| 126 GError *error; |
|
| 127 }; |
105 }; |
| |
106 |
| |
107 /** |
| |
108 * FbJsonValuesClass: |
| |
109 * |
| |
110 * The base class for all #FbJsonValues's. |
| |
111 */ |
| |
112 struct _FbJsonValuesClass |
| |
113 { |
| |
114 /*< private >*/ |
| |
115 GObjectClass parent_class; |
| |
116 }; |
| |
117 |
| |
118 /** |
| |
119 * fb_json_values_get_type: |
| |
120 * |
| |
121 * Returns: The #GType for an #FbJsonValues. |
| |
122 */ |
| |
123 GType |
| |
124 fb_json_values_get_type(void); |
| 128 |
125 |
| 129 /** |
126 /** |
| 130 * fb_json_error_quark: |
127 * fb_json_error_quark: |
| 131 * |
128 * |
| 132 * Gets the #GQuark of the domain of JSON errors. |
129 * Gets the #GQuark of the domain of JSON errors. |
| 380 /** |
377 /** |
| 381 * fb_json_values_new: |
378 * fb_json_values_new: |
| 382 * @root: The root #JsonNode. |
379 * @root: The root #JsonNode. |
| 383 * |
380 * |
| 384 * Creates a new #FbJsonValues. The returned #FbJsonValues should be |
381 * Creates a new #FbJsonValues. The returned #FbJsonValues should be |
| 385 * freed with #fb_json_values_free() when no longer needed. |
382 * freed with #g_object_unref when no longer needed. |
| 386 * |
383 * |
| 387 * Returns: The new #FbJsonValues. |
384 * Returns: The new #FbJsonValues. |
| 388 */ |
385 */ |
| 389 FbJsonValues * |
386 FbJsonValues * |
| 390 fb_json_values_new(JsonNode *root); |
387 fb_json_values_new(JsonNode *root); |
| 391 |
|
| 392 /** |
|
| 393 * fb_json_values_free: |
|
| 394 * @values: The #FbJsonValues. |
|
| 395 * |
|
| 396 * Frees all memory used by the #FbJsonValues. |
|
| 397 */ |
|
| 398 void |
|
| 399 fb_json_values_free(FbJsonValues *values); |
|
| 400 |
388 |
| 401 /** |
389 /** |
| 402 * fb_json_values_add: |
390 * fb_json_values_add: |
| 403 * @values: The #FbJsonValues. |
391 * @values: The #FbJsonValues. |
| 404 * @type: The #FbJsonType. |
392 * @type: The #FbJsonType. |