File indexing completed on 2026-01-06 10:13: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
0025
0026 #pragma once
0027
0028 #include <json-glib/json-types.h>
0029
0030 G_BEGIN_DECLS
0031
0032 #define JSON_TYPE_SERIALIZABLE (json_serializable_get_type ())
0033 #define JSON_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), JSON_TYPE_SERIALIZABLE, JsonSerializable))
0034 #define JSON_IS_SERIALIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JSON_TYPE_SERIALIZABLE))
0035 #define JSON_SERIALIZABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), JSON_TYPE_SERIALIZABLE, JsonSerializableIface))
0036
0037 typedef struct _JsonSerializable JsonSerializable;
0038 typedef struct _JsonSerializableIface JsonSerializableIface;
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 struct _JsonSerializableIface
0062 {
0063
0064 GTypeInterface g_iface;
0065
0066
0067 JsonNode *(* serialize_property) (JsonSerializable *serializable,
0068 const gchar *property_name,
0069 const GValue *value,
0070 GParamSpec *pspec);
0071 gboolean (* deserialize_property) (JsonSerializable *serializable,
0072 const gchar *property_name,
0073 GValue *value,
0074 GParamSpec *pspec,
0075 JsonNode *property_node);
0076
0077 GParamSpec * (* find_property) (JsonSerializable *serializable,
0078 const char *name);
0079 GParamSpec **(* list_properties) (JsonSerializable *serializable,
0080 guint *n_pspecs);
0081 void (* set_property) (JsonSerializable *serializable,
0082 GParamSpec *pspec,
0083 const GValue *value);
0084 void (* get_property) (JsonSerializable *serializable,
0085 GParamSpec *pspec,
0086 GValue *value);
0087 };
0088
0089 JSON_AVAILABLE_IN_1_0
0090 GType json_serializable_get_type (void) G_GNUC_CONST;
0091
0092 JSON_AVAILABLE_IN_1_0
0093 JsonNode *json_serializable_serialize_property (JsonSerializable *serializable,
0094 const gchar *property_name,
0095 const GValue *value,
0096 GParamSpec *pspec);
0097 JSON_AVAILABLE_IN_1_0
0098 gboolean json_serializable_deserialize_property (JsonSerializable *serializable,
0099 const gchar *property_name,
0100 GValue *value,
0101 GParamSpec *pspec,
0102 JsonNode *property_node);
0103
0104 JSON_AVAILABLE_IN_1_0
0105 GParamSpec * json_serializable_find_property (JsonSerializable *serializable,
0106 const char *name);
0107 JSON_AVAILABLE_IN_1_0
0108 GParamSpec ** json_serializable_list_properties (JsonSerializable *serializable,
0109 guint *n_pspecs);
0110 JSON_AVAILABLE_IN_1_0
0111 void json_serializable_set_property (JsonSerializable *serializable,
0112 GParamSpec *pspec,
0113 const GValue *value);
0114 JSON_AVAILABLE_IN_1_0
0115 void json_serializable_get_property (JsonSerializable *serializable,
0116 GParamSpec *pspec,
0117 GValue *value);
0118
0119 JSON_AVAILABLE_IN_1_0
0120 JsonNode *json_serializable_default_serialize_property (JsonSerializable *serializable,
0121 const gchar *property_name,
0122 const GValue *value,
0123 GParamSpec *pspec);
0124 JSON_AVAILABLE_IN_1_0
0125 gboolean json_serializable_default_deserialize_property (JsonSerializable *serializable,
0126 const gchar *property_name,
0127 GValue *value,
0128 GParamSpec *pspec,
0129 JsonNode *property_node);
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
0160 typedef JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed);
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
0201 typedef gpointer (* JsonBoxedDeserializeFunc) (JsonNode *node);
0202
0203 JSON_AVAILABLE_IN_1_0
0204 void json_boxed_register_serialize_func (GType gboxed_type,
0205 JsonNodeType node_type,
0206 JsonBoxedSerializeFunc serialize_func);
0207 JSON_AVAILABLE_IN_1_0
0208 void json_boxed_register_deserialize_func (GType gboxed_type,
0209 JsonNodeType node_type,
0210 JsonBoxedDeserializeFunc deserialize_func);
0211 JSON_AVAILABLE_IN_1_0
0212 gboolean json_boxed_can_serialize (GType gboxed_type,
0213 JsonNodeType *node_type);
0214 JSON_AVAILABLE_IN_1_0
0215 gboolean json_boxed_can_deserialize (GType gboxed_type,
0216 JsonNodeType node_type);
0217 JSON_AVAILABLE_IN_1_0
0218 JsonNode *json_boxed_serialize (GType gboxed_type,
0219 gconstpointer boxed);
0220 JSON_AVAILABLE_IN_1_0
0221 gpointer json_boxed_deserialize (GType gboxed_type,
0222 JsonNode *node);
0223
0224 JSON_AVAILABLE_IN_1_0
0225 JsonNode *json_gobject_serialize (GObject *gobject);
0226 JSON_AVAILABLE_IN_1_0
0227 GObject * json_gobject_deserialize (GType gtype,
0228 JsonNode *node);
0229
0230 JSON_AVAILABLE_IN_1_0
0231 GObject * json_gobject_from_data (GType gtype,
0232 const gchar *data,
0233 gssize length,
0234 GError **error);
0235 JSON_AVAILABLE_IN_1_0
0236 gchar * json_gobject_to_data (GObject *gobject,
0237 gsize *length);
0238
0239 JSON_DEPRECATED_IN_1_0_FOR(json_gobject_from_data)
0240 GObject * json_construct_gobject (GType gtype,
0241 const gchar *data,
0242 gsize length,
0243 GError **error);
0244 JSON_DEPRECATED_IN_1_0_FOR(json_gobject_to_data)
0245 gchar * json_serialize_gobject (GObject *gobject,
0246 gsize *length) G_GNUC_MALLOC;
0247
0248 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
0249 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonSerializable, g_object_unref)
0250 #endif
0251
0252 G_END_DECLS