| Catalina Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Prerequisites | Known Implementations | ||||
#define CATALINA_FORMATTER_GET_INTERFACE (obj) CatalinaFormatter; CatalinaFormatterIface; gboolean catalina_formatter_serialize (CatalinaFormatter *formatter, const GValue *value, gchar **buffer, gsize *buffer_length, GError **error); gboolean catalina_formatter_deserialize (CatalinaFormatter *formatter, GValue *value, gchar *buffer, gsize buffer_length, GError **error);
CatalinaFormatter provides a serialization format for converting data-types from glib and gobject into data-streams. This is particularly useful for converting objects, integers, and strings into content to be stored within CatalinaStorage.
You can add a formatter to a CatalinaStorage for transparent serialization and deserializtion to and from storage.
CatalinaFormatter implementations must be thread safe for the interface methods.
CatalinaStorage *storage = catalina_storage_new (); g_object_set (storage, "formatter", catalina_binary_formatter_new (), NULL);
#define CATALINA_FORMATTER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CATALINA_TYPE_FORMATTER, CatalinaFormatterIface))
|
typedef struct {
GTypeInterface parent;
gboolean (*serialize) (CatalinaFormatter *formatter,
const GValue *value,
gchar **buffer,
gsize *buffer_length,
GError **error);
gboolean (*deserialize) (CatalinaFormatter *formatter,
GValue *value,
gchar *buffer,
gsize buffer_length,
GError **error);
} CatalinaFormatterIface;
gboolean catalina_formatter_serialize (CatalinaFormatter *formatter, const GValue *value, gchar **buffer, gsize *buffer_length, GError **error);
Attempts to serialize the contents of value to a new stream. If successful, the stream
will be stored to buffer and buffer_length will be set to the length of the resulting
buffer.
Upon failure, FALSE is returned and error is set.
|
A CatalinaFormatter |
|
the GValue to serialize |
|
A location to store the buffer |
|
A location to store the buffer length |
|
A location for a GError or NULL
|
Returns : |
TRUE on success
|
gboolean catalina_formatter_deserialize (CatalinaFormatter *formatter, GValue *value, gchar *buffer, gsize buffer_length, GError **error);
Attempts to deserialize the contents of buffer to value.
Upon failure, FALSE is returned and error is set.
|
A CatalinaFormatter |
|
A GValue |
|
A buffer to deserialize |
|
The length of buffer in bytes
|
|
A location for a GError or NULL
|
Returns : |
TRUE on success
|