* Provides interface methods that a class can implement to
* directly handle serialisation of various properties or
* treat other data as properties.
*
* A class that implements this interface will still be passed
* to {@link GXml.Serialization.serialize_object} for
* serialization. That function will check whether the object
* implements {@link GXml.Serializable} and will then prefer
* overridden methods instead of standard ones. Most of the
* methods for this interface can indicate (via return value)
* that, for a given property, the standard serialization
* approach should be used instead. Indeed, not all methods
* need to be implemented, but some accompany one another and
* should be implemented carefully, corresponding to one
* another.
*
* For an example, look in tests/XmlSerializableTest
*/
publicinterfaceSerializable:GLib.Object{
/** Return true if your implementation will have handled the given property,
and false elsewise (in which case, XmlSerializable will try to deserialize
it). */
/** OBSOLETENOTE: Return the deserialized value in GLib.Value (even if it's a GLib.Boxed type) because Serializer is going to set the property after calling this, and if you just set it yourself within, it will be overwritten */
/**
* Handles deserializing individual properties.
*
* Interface method to handle deserialization of an
* individual property. The implementing class
* receives a description of the property and the
* {@link GXml.DomNode} that contains the content. The
* implementing {@link GXml.Serializable} object can extract
* the data from the {@link GXml.DomNode} and store it in its
* property itself. Note that the {@link GXml.DomNode} may be
* as simple as a {@link GXml.Text} that stores the data as a
* string.
*
* If the implementation has handled deserialization,
* return true. Return false if you want
* {@link GXml.Serialization} to try to automatically
* deserialize it. If {@link GXml.Serialization} tries to
* handle it, it will want either {@link GXml.Serializable}'s
* set_property (or at least {@link GLib.Object.set_property})
* to know about the property.
*
* @param property_name the name of the property as a string
* @param spec the {@link GLib.ParamSpec} describing the property.
* @param property_node the {@link GXml.DomNode} encapsulating data to deserialize
* @return `true` if the property was handled, `false` if {@link GXml.Serialization} should handle it.
*/
/*
* @todo: consider not giving property_name, but
* letting them get name from spec
* @todo: consider returning {@link GLib.Value} as out param
*/
publicvirtualbooldeserialize_property(stringproperty_name,/* out GLib.Value value,*/GLib.ParamSpecspec,GXml.DomNodeproperty_node){
returnfalse;// default deserialize_property gets used
}
// TODO: just added ? to these, do we really want to allow nulls for them?
// TODO: value and property_name are kind of redundant: eliminate? property_name from spec.property_name and value from the object itself :)
/** Serialized properties should have the XML structure <Property pname="PropertyName">...</Property> */
// TODO: perhaps we should provide that base structure
/**
* Handles serializing individual properties.
*
* Interface method to handle serialization of an
* individual property. The implementing class
* receives a description of it, and should create a
* {@link GXml.DomNode} that encapsulates the property.
* {@link GXml.Serialization} will embed the {@link GXml.DomNode} into
* a "Property" {@link GXml.Element}, so the {@link GXml.DomNode}
* returned can often be something as simple as
* {@link GXml.Text}.
*
* To let {@link GXml.Serialization} attempt to automatically
* serialize the property itself, do not implement
* this method. If the method returns %NULL,
* {@link GXml.Serialization} will attempt handle it itsel.
*
* @param property_name string name of a property to serialize.
* @param spec the {@link GLib.ParamSpec} describing the property.
* @param doc the {@link GXml.Document} the returned {@link GXml.DomNode} should belong to
* @return a new {@link GXml.DomNode}, or `null`
*/
/*
* @todo: consider not giving property_name, let them get name from spec?