File indexing completed on 2025-03-13 09:14:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef __JSON_GOBJECT_H__
0025 #define __JSON_GOBJECT_H__
0026
0027 #include <json-glib/json-types.h>
0028
0029 G_BEGIN_DECLS
0030
0031 #define JSON_TYPE_SERIALIZABLE (json_serializable_get_type ())
0032 #define JSON_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_SERIALIZABLE, JsonSerializable))
0033 #define JSON_IS_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_SERIALIZABLE))
0034 #define JSON_SERIALIZABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), JSON_TYPE_SERIALIZABLE, JsonSerializableIface))
0035
0036 typedef struct _JsonSerializable JsonSerializable;
0037 typedef struct _JsonSerializableIface JsonSerializableIface;
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 struct _JsonSerializableIface
0061 {
0062
0063 GTypeInterface g_iface;
0064
0065
0066 JsonNode *(* serialize_property) (JsonSerializable *serializable,
0067 const gchar *property_name,
0068 const GValue *value,
0069 GParamSpec *pspec);
0070 gboolean (* deserialize_property) (JsonSerializable *serializable,
0071 const gchar *property_name,
0072 GValue *value,
0073 GParamSpec *pspec,
0074 JsonNode *property_node);
0075
0076 GParamSpec * (* find_property) (JsonSerializable *serializable,
0077 const char *name);
0078 GParamSpec **(* list_properties) (JsonSerializable *serializable,
0079 guint *n_pspecs);
0080 void (* set_property) (JsonSerializable *serializable,
0081 GParamSpec *pspec,
0082 const GValue *value);
0083 void (* get_property) (JsonSerializable *serializable,
0084 GParamSpec *pspec,
0085 GValue *value);
0086 };
0087
0088 JSON_AVAILABLE_IN_1_0
0089 GType json_serializable_get_type (void) G_GNUC_CONST;
0090
0091 JSON_AVAILABLE_IN_1_0
0092 JsonNode *json_serializable_serialize_property (JsonSerializable *serializable,
0093 const gchar *property_name,
0094 const GValue *value,
0095 GParamSpec *pspec);
0096 JSON_AVAILABLE_IN_1_0
0097 gboolean json_serializable_deserialize_property (JsonSerializable *serializable,
0098 const gchar *property_name,
0099 GValue *value,
0100 GParamSpec *pspec,
0101 JsonNode *property_node);
0102
0103 JSON_AVAILABLE_IN_1_0
0104 GParamSpec * json_serializable_find_property (JsonSerializable *serializable,
0105 const char *name);
0106 JSON_AVAILABLE_IN_1_0
0107 GParamSpec ** json_serializable_list_properties (JsonSerializable *serializable,
0108 guint *n_pspecs);
0109 JSON_AVAILABLE_IN_1_0
0110 void json_serializable_set_property (JsonSerializable *serializable,
0111 GParamSpec *pspec,
0112 const GValue *value);
0113 JSON_AVAILABLE_IN_1_0
0114 void json_serializable_get_property (JsonSerializable *serializable,
0115 GParamSpec *pspec,
0116 GValue *value);
0117
0118 JSON_AVAILABLE_IN_1_0
0119 JsonNode *json_serializable_default_serialize_property (JsonSerializable *serializable,
0120 const gchar *property_name,
0121 const GValue *value,
0122 GParamSpec *pspec);
0123 JSON_AVAILABLE_IN_1_0
0124 gboolean json_serializable_default_deserialize_property (JsonSerializable *serializable,
0125 const gchar *property_name,
0126 GValue *value,
0127 GParamSpec *pspec,
0128 JsonNode *property_node);
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159 typedef JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed);
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 typedef gpointer (* JsonBoxedDeserializeFunc) (JsonNode *node);
0201
0202 JSON_AVAILABLE_IN_1_0
0203 void json_boxed_register_serialize_func (GType gboxed_type,
0204 JsonNodeType node_type,
0205 JsonBoxedSerializeFunc serialize_func);
0206 JSON_AVAILABLE_IN_1_0
0207 void json_boxed_register_deserialize_func (GType gboxed_type,
0208 JsonNodeType node_type,
0209 JsonBoxedDeserializeFunc deserialize_func);
0210 JSON_AVAILABLE_IN_1_0
0211 gboolean json_boxed_can_serialize (GType gboxed_type,
0212 JsonNodeType *node_type);
0213 JSON_AVAILABLE_IN_1_0
0214 gboolean json_boxed_can_deserialize (GType gboxed_type,
0215 JsonNodeType node_type);
0216 JSON_AVAILABLE_IN_1_0
0217 JsonNode *json_boxed_serialize (GType gboxed_type,
0218 gconstpointer boxed);
0219 JSON_AVAILABLE_IN_1_0
0220 gpointer json_boxed_deserialize (GType gboxed_type,
0221 JsonNode *node);
0222
0223 JSON_AVAILABLE_IN_1_0
0224 JsonNode *json_gobject_serialize (GObject *gobject);
0225 JSON_AVAILABLE_IN_1_0
0226 GObject * json_gobject_deserialize (GType gtype,
0227 JsonNode *node);
0228
0229 JSON_AVAILABLE_IN_1_0
0230 GObject * json_gobject_from_data (GType gtype,
0231 const gchar *data,
0232 gssize length,
0233 GError **error);
0234 JSON_AVAILABLE_IN_1_0
0235 gchar * json_gobject_to_data (GObject *gobject,
0236 gsize *length);
0237
0238 JSON_DEPRECATED_IN_1_0_FOR(json_gobject_from_data)
0239 GObject * json_construct_gobject (GType gtype,
0240 const gchar *data,
0241 gsize length,
0242 GError **error);
0243 JSON_DEPRECATED_IN_1_0_FOR(json_gobject_to_data)
0244 gchar * json_serialize_gobject (GObject *gobject,
0245 gsize *length) G_GNUC_MALLOC;
0246
0247 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
0248 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonSerializable, g_object_unref)
0249 #endif
0250
0251 G_END_DECLS
0252
0253 #endif