IBusSerializable

## IBusSerializable IBusSerializable — A serializable object. |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #define             ibus_serializable_set_attachment    (o,
                                                             k,
                                                             v)
    #define             ibus_serializable_get_attachment    (o,
                                                             k,
                                                             v)
    #define             ibus_serializable_remove_attachment (o,
                                                             k)
                        IBusSerializable;
                        IBusSerializableClass;
    gboolean            (*IBusSerializableSerializeFunc)    (IBusSerializable *object,
                                                             IBusMessageIter *iter);
    gboolean            (*IBusSerializableDeserializeFunc)  (IBusSerializable *object,
                                                             IBusMessageIter *iter);
    gboolean            (*IBusSerializableCopyFunc)         (IBusSerializable *dest,
                                                             const IBusSerializable *src);
    IBusSerializable *  ibus_serializable_new               (void);
    gboolean            ibus_serializable_set_qattachment   (IBusSerializable *object,
                                                             GQuark key,
                                                             const GValue *value);
    const GValue *      ibus_serializable_get_qattachment   (IBusSerializable *object,
                                                             GQuark key);
    void                ibus_serializable_remove_qattachment
                                                            (IBusSerializable *object,
                                                             GQuark key);
    IBusSerializable *  ibus_serializable_copy              (IBusSerializable *object);
    gboolean            ibus_serializable_serialize         (IBusSerializable *object,
                                                             IBusMessageIter *iter);
    IBusSerializable *  ibus_serializable_deserialize       (IBusMessageIter *iter);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----IBusObject
                   +----IBusSerializable
                         +----IBusHotkeyProfile
                         +----IBusText
                         +----IBusAttribute
                         +----IBusAttrList
                         +----IBusEngineDesc
                         +----IBusLookupTable
                         +----IBusComponent
                         +----IBusProperty
                         +----IBusPropList
                         +----IBusObservedPath

## Description

An IBusSerializable is an IBus object which can be serialized, that is, to be to and from an IBusMessage.

This class is to be extended by other class that requires serialization. An extended class should overrides following methods:

- `serialize(object,iter)`: for serialize.

- `deserialize(object,iter)`: for deserialize.

- `copy(desc,src)`: for copy between IBusSerializable.

See `IBusSerializableSerializeFunc()`, `IBusSerializableDeserializeFunc()`, `IBusSerializableCopyFunc()` for function prototype.

## Details

### ibus_serializable_set_attachment()

    #define             ibus_serializable_set_attachment(o, k, v)

Attach a value to an IBusSerializable. This macro is an convenient wrapper of `ibus_serializable_set_qattachment()`.

`o` : | An IBusSerializable.
`k` : | String formatted key for indexing value.
`v` : | Value to be attached. Should be also serializable.

### ibus_serializable_get_attachment()

    #define             ibus_serializable_get_attachment(o, k, v)

Get a value from attachment of an IBusSerializable. This macro is an convenient wrapper of `ibus_serializable_get_qattachment()`.

`o` : | An IBusSerializable.
`k` : | String formatted key for indexing value.
`v` : | Value to be attached. Should be also serializable.

### ibus_serializable_remove_attachment()

    #define             ibus_serializable_remove_attachment(o, k)

Remove a value from attachment of an IBusSerializable. This macro is an convenient wrapper of `ibus_serializable_remove_qattachment()`.

`o` : | An IBusSerializable.
`k` : | String formatted key for indexing value.

### IBusSerializable

    typedef struct _IBusSerializable IBusSerializable;

All the fields in the IBusSerializable structure are private to the IBusSerializable and should never be accessed directly.

### IBusSerializableClass

    typedef struct {
        IBusObjectClass parent;

        /* signature */
        GString *signature;

        /* virtual table */
        gboolean    (* serialize)   (IBusSerializable       *object,
                                     IBusMessageIter        *iter);
        gboolean    (* deserialize) (IBusSerializable       *object,
                                     IBusMessageIter        *iter);
        gboolean    (* copy)        (IBusSerializable       *dest,
                                     const IBusSerializable *src);
    } IBusSerializableClass;

### IBusSerializableSerializeFunc ()

    gboolean            (*IBusSerializableSerializeFunc)    (IBusSerializable *object,
                                                             IBusMessageIter *iter);

Prototype of serialize function. Serialize function convert an IBusSerializable to IBusMessageIter. Returns a gboolean value which indicates whether the conversion is success. Return TRUE if succeed.

`object` : | An IBusSerializable.
`iter` : | An IBusMessageIter.
Returns : | TRUE if succeed; FALSE otherwise.

### IBusSerializableDeserializeFunc ()

    gboolean            (*IBusSerializableDeserializeFunc)  (IBusSerializable *object,
                                                             IBusMessageIter *iter);

Prototype of deserialize function. Deserialize function convert an IBusMessageIter to IBusSerializable. Returns a gboolean value which indicates whether the conversion is success.

`object` : | An IBusSerializable.
`iter` : | An IBusMessageIter.
Returns : | TRUE if succeed; FALSE otherwise.

### IBusSerializableCopyFunc ()

    gboolean            (*IBusSerializableCopyFunc)         (IBusSerializable *dest,
                                                             const IBusSerializable *src);

Prototype of copy function. Copy function copy from source IBusSerializable to the destination one. Returns a gboolean value which indicates whether the copying is success.

`dest` : | The destination IBusSerializable.
`src` : | A source IBusMessageIter.
Returns : | TRUE if succeed; FALSE otherwise.

### ibus_serializable_new ()

    IBusSerializable *  ibus_serializable_new               (void);

Creates a new instance of an IBusSerializable.

Returns : | a new instance of IBusSerializable.

### ibus_serializable_set_qattachment ()

    gboolean            ibus_serializable_set_qattachment   (IBusSerializable *object,
                                                             GQuark key,
                                                             const GValue *value);

Attach a value to an IBusSerializable. The value should be serializable as well. Basic type such as integer, string are deemed to be serializable.

`see_also`: `ibus_serializable_set_attachment()`.

`object` : | An IBusSerializable.
`key` : | String formatted key for indexing value.
`value` : | Value to be attached. Should be also serializable.
Returns : | TRUE if succeed; FALSE otherwise.

### ibus_serializable_get_qattachment ()

    const GValue *      ibus_serializable_get_qattachment   (IBusSerializable *object,
                                                             GQuark key);

Get a value from attachment of an IBusSerializable. `see_also`: `ibus_serializable_set_attachment()`.

`object` : | An IBusSerializable.
`key` : | String formatted key for indexing value.
Returns : | The attached value; or NULL if fail to retrieve the value.

### ibus_serializable_remove_qattachment ()

    void                ibus_serializable_remove_qattachment
                                                            (IBusSerializable *object,
                                                             GQuark key);

Remove a value from attachment of an IBusSerializable. `see_also`: `ibus_serializable_remove_attachment()`.

`object` : | An IBusSerializable.
`key` : | String formatted key for indexing value.

### ibus_serializable_copy ()

    IBusSerializable *  ibus_serializable_copy              (IBusSerializable *object);

Clone an IBusSerializable. The copy method should be implemented in extended class.

`see_also`: `IBusSerializableCopyFunc()`.

`object` : | An IBusSerializable.
Returns : | A newly allocated clone object; or NULL if `object` is not serializable.

### ibus_serializable_serialize ()

    gboolean            ibus_serializable_serialize         (IBusSerializable *object,
                                                             IBusMessageIter *iter);

Serialize an IBusSerializable to an IBusMessageIter. The serialize method should be implemented in extended class.

`see_also`: `IBusSerializableCopyFunc()`.

`object` : | An IBusSerializable.
`iter` : | An IBusMessageIter.
Returns : | TRUE if succeed; FALSE otherwise.

### ibus_serializable_deserialize ()

    IBusSerializable *  ibus_serializable_deserialize       (IBusMessageIter *iter);

Deserialize an IBusMessageIter to an IBusSerializable/ The deserialize method should be implemented in extended class.

`see_also`: `IBusSerializableCopyFunc()`.

`iter` : | An IBusMessageIter.
Returns : | The deserialized IBusSerializable.