CatalinaFormatter

CatalinaFormatter — serialization for glib types

Synopsis

#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);

Object Hierarchy

  GInterface
   +----CatalinaFormatter

Prerequisites

CatalinaFormatter requires GObject.

Known Implementations

CatalinaFormatter is implemented by CatalinaBinaryFormatter.

Description

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);

Details

CATALINA_FORMATTER_GET_INTERFACE()

#define CATALINA_FORMATTER_GET_INTERFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj),  CATALINA_TYPE_FORMATTER, CatalinaFormatterIface))

obj :


CatalinaFormatter

typedef struct _CatalinaFormatter CatalinaFormatter;


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;


catalina_formatter_serialize ()

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.

formatter :

A CatalinaFormatter

value :

the GValue to serialize

buffer :

A location to store the buffer

buffer_length :

A location to store the buffer length

error :

A location for a GError or NULL

Returns :

TRUE on success

catalina_formatter_deserialize ()

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.

formatter :

A CatalinaFormatter

value :

A GValue

buffer :

A buffer to deserialize

buffer_length :

The length of buffer in bytes

error :

A location for a GError or NULL

Returns :

TRUE on success