Serializable
Object Hierarchy:
Description:
public interface Serializable : Object
GObject that encodes and decodes on a Stream.
Implement this on every wire type. Scalars, enums, flags, nested Serializable objects, and string[] encode by default. Override
bin_write_prop /
bin_read_prop for Gee.ArrayList
, uint8[], or other non-scalars — call
bin_default_write_prop /
bin_default_read_prop for the rest. Use
bin_pre /
bin_post for work around inbound decode.
Example
public class Pair : GLib.Object, OLLMrpc.Bin.Serializable {
public string name { get; set; default = ""; }
public int count { get; set; default = 0; }
}
OLLMrpc.Bin.register("Pair", typeof(Pair));
write_bin.write(new Pair() { name = "alpha", count = 42 });
var parsed = read_bin.parse() as Pair;
List property
public override void bin_write_prop(
OLLMrpc.Bin.Stream ctx, GLib.ParamSpec prop
) throws GLib.Error {
switch (prop.name) {
case "items":
this.bin_write_prop_array(ctx, "items", typeof(Pair));
return;
default:
this.bin_default_write_prop(ctx, prop);
return;
}
}
See also:
Stream, Json
All known implementing classes:
Content:
Methods:
- public virtual void bin_default_read_prop (Stream ctx, ParamSpec prop, uint8 type_byte) throws Error
Stock scalar/object decode for one property.
- public virtual void bin_default_write_prop (Stream ctx, ParamSpec prop) throws Error
Stock scalar/object encode for one property.
- public virtual void bin_post (Stream ctx) throws Error
Run after all inbound properties are decoded.
- public virtual void bin_pre (Stream ctx) throws Error
Run before inbound properties are decoded into this object.
- public virtual void bin_read (Stream ctx) throws Error
- public virtual void bin_read_prop (Stream ctx, ParamSpec prop, uint8 type_byte) throws Error
- public virtual void bin_write (Stream ctx) throws Error
- public virtual void bin_write_prop (Stream ctx, ParamSpec prop) throws Error
- public virtual void bin_write_prop_array (Stream ctx, string prop_name, Type element_type) throws Error
Encode a homogeneous Gee.ArrayList property
as a typed object array on the wire.
- public virtual ArrayList<Object> read_anon_array (Stream ctx, string prop_name, uint8 type_byte, Type element_type) throws Error
Decode a homogeneous object-array body whose wire header is anonymous
(e.g. AUTO JSON GLib.Object) but whose elements decode as
element_type.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref