Top | ![]() |
![]() |
![]() |
![]() |
Implementors of this interface, could define or override the way you want to represent your class in a XML file.
gboolean
gxml_serializable_get_enable_unknown_serializable_property
(GXmlSerializable *self
);
Return false if you want to ignore unknown properties and GXmlNode's not in your class definition.
Take care, disabling this feature you can lost data on serialization, because any unknown property or element will be discarted.
gboolean gxml_serializable_set_default_namespace (GXmlSerializable *self
,GXmlNode *node
);
Used to set specific namespace for an GXmlElement.
By default no namspace prefix is added to GXmlElement on serialized. Implementors must consider override this methodk if this node should have a namespace.
gboolean
gxml_serializable_serialize_use_xml_node_value
(GXmlSerializable *self
);
Used to check GXmlElement's contents must be deseralized.
By default GXml's implementations doesn't deseriaze/serialize XML node contents. In order to enable it, you must override gxml_serializable_serialize_use_xml_node_value()
method to return true and store XML node's content to "serialized-xml-node-value" property.
Implementors could set up methods to provide a clean easy to use API to set nodes contents. In most cases, users would like to set a value through a getter or setter or through a property in the class. If you use a property, you should add it to ignored_serializable_properties in order to see its value in a XML node property.
gchar *
gxml_serializable_node_name (GXmlSerializable *self
);
Defines the way to set Node name.
gboolean
gxml_serializable_property_use_nick (GXmlSerializable *self
);
Defines the way to set Node's property name, by using it's nick instead of default name.
When serialize a class property, by default it uses its name given on class declaration, but is less common to see XML node properties with names like "your_property", but more common is to use "YourProperty". In order to use this kind of names, your implementation should use properties' nick name and override gxml_serializable_property_use_nick()
method to return true. This should instruct your code to use this method to use property's nick name. This is the default in GXml default implementations.
GXmlNode * gxml_serializable_serialize (GXmlSerializable *self
,GXmlNode *node
,GError **error
);
Serialize this object.
This method must call serialize_property()
recursivally on all properties to serialize.
self |
the GXmlSerializable instance |
|
node |
. an GXmlNode object to serialize to. . |
[in] |
error |
location to store the error occuring, or |
GXmlNode * gxml_serializable_serialize_property (GXmlSerializable *self
,GXmlNode *element
,GParamSpec *prop
,GError **error
);
Serialize a property prop
on a GXmlElement.
This method is called recursivally by gxml_serializable_serialize()
method over all properties to be serialized.
self |
the GXmlSerializable instance |
|
element |
|
|
prop |
|
|
error |
location to store the error occuring, or |
gboolean gxml_serializable_deserialize (GXmlSerializable *self
,GXmlNode *node
,GError **error
);
Deserialize this object.
self |
the GXmlSerializable instance |
|
node |
. GXmlNode used to deserialize from. . |
[in] |
error |
location to store the error occuring, or |
gboolean gxml_serializable_deserialize_property (GXmlSerializable *self
,GXmlNode *property_node
,GError **error
);
Handles deserializing individual properties.
Interface method to handle deserialization of an individual property. The implementing class receives a description of the property and the GXmlNode that contains the content. The implementing GXmlSerializable object can extract the data from the GXmlNode and store it in its property itself. Note that the GXmlNode may be as simple as a GXmlText that stores the data as a string.
Implementors: Use Serializable.get_property_value in order to allow derived classes to override the properties to serialize.
self |
the GXmlSerializable instance |
|
property_node |
. the GXmlNode encapsulating data to deserialize . |
[in] |
error |
location to store the error occuring, or |
GParamSpec * gxml_serializable_find_property_spec (GXmlSerializable *self
,const gchar *property_name
);
Handles finding the GParamSpec for a given property.
GXml.Serialization uses
(as well as g_object_class_find_property()
, g_object_class_list_properties()
, and g_object_get_property()
) to manage serialization of properties. GXmlSerializable gives the implementing class an opportunity to override g_object_set_property()
to control what properties exist for GXml.Serialization's purposes.g_object_class_find_property()
For instance, if an object has private data fields that are not installed public properties, but that should be serialized,
can be defined to return a GParamSpec for non-installed properties. Other GXmlSerializable functions should be consistent with it.g_object_class_find_property()
An implementing class might wish to maintain such GParamSpec s separately, rather than creating new ones for each call.
self |
the GXmlSerializable instance |
|
property_name |
. the name of a property to obtain a GParamSpec for . |
[in] |
GParamSpec * gxml_serializable_default_find_property_spec (GXmlSerializable *self
,const gchar *property_name
);
Default implementation for gxml_serializable_find_property_spec()
GParamSpec ** gxml_serializable_list_serializable_properties (GXmlSerializable *self
,int *result_length1
);
List the known properties for an object's class
Class GXml.Serialization uses
(as well as g_object_class_list_properties()
, g_object_class_find_property()
, and g_object_get_property()
) to manage serialization of an object's properties. GXmlSerializable gives an implementing class an opportunity to override g_object_set_property()
to control which properties exist for GXml.Serialization's purposes.g_object_class_list_properties()
For instance, if an object has private data fields that are not installed public properties, but that should be serialized, list_properties can be defined to return a list of GParamSpec s covering all the "properties" to serialize. Other GXmlSerializable functions should be consistent with it.
An implementing class might wish to maintain such GParamSpec s separately, rather than creating new ones for each call.
GParamSpec ** gxml_serializable_default_list_serializable_properties (GXmlSerializable *self
,int *result_length1
);
Default implementation for gxml_serializable_list_serializable_properties()
GeeMap *
gxml_serializable_get_unknown_serializable_properties
(GXmlSerializable *self
);
Get and return the current value of the "unknown-serializable-properties" property.
On deserialization stores any GXmlAttribute not used on this object, but exists in current XML file.
Node's name is used as key to find stored GXmlAttribute, key is case sensitive.
XML allows great flexibility, providing different ways to represent the same information. This is a problem when you try to deserialize them.
In order to deserialize correctly, you must create your XML, both by serializing a GXmlSerializable object or by hand writing. By using the former, you can add extra information, like attributes, but most of them could be ignored or lost on deserialization/serialization process. To avoid data lost, you can override gxml_serializable_get_enable_unknown_serializable_property()
method in order to return true, your implementation or the ones in GXml, will store all unknown attributes on deserialization and must serialize again back to the XML file. Even you are allowed to get this unknown objects by iterating on "unknown-serializable-properties" collection, if you know attribute's name, use it to retrieve it.
This property is ignored on serialisation.
GeeCollection *
gxml_serializable_get_unknown_serializable_nodes
(GXmlSerializable *self
);
Get and return the current value of the "unknown-serializable-nodes" property.
On deserialization stores any GXmlNode not used on this object, but exists in current XML file.
XML allows great flexibility, providing different ways to represent the same information. This is a problem when you try to deserialize them.
In order to deserialize correctly, you must create your XML, both by serializing a GXmlSerializable object or by hand writing. By using the former, you can add extra information, like nodes or contents in known nodes, but most of them could be ignored or lost on deserialization/serialization process. To avoid data lost, you can override gxml_serializable_get_enable_unknown_serializable_property()
method in order to return true, your implementation or the ones in GXml, will store all unknown properties and nodes on deserialization and must serialize again back to the XML file. Even you are allowed to get this unknown objects by iterating on "unknown-serializable-nodes" hash table.
This property is ignored on serialisation.
gchar *
gxml_serializable_get_serialized_xml_node_value
(GXmlSerializable *self
);
Get and return the current value of the "serialized-xml-node-value" property.
Used to add content in an GXmlElement.
By default no contents is serialized/deseralized. Implementors must implement gxml_serializable_serialize_use_xml_node_value()
function returning true in order to use this property.
This property is ignored by default. Implementors must implement gxml_serializable_serialize_use_xml_node_value()
to return true and add a set and get function to get/set this value, in order to use your own API.
This property is ignored on serialisation.
void gxml_serializable_set_serialized_xml_node_value (GXmlSerializable *self
,const gchar *value
);
Set the value of the "serialized-xml-node-value" property to value
.
Used to add content in an GXmlElement.
By default no contents is serialized/deseralized. Implementors must implement gxml_serializable_serialize_use_xml_node_value()
function returning true in order to use this property.
This property is ignored by default. Implementors must implement gxml_serializable_serialize_use_xml_node_value()
to return true and add a set and get function to get/set this value, in order to use your own API.
This property is ignored on serialisation.
self |
the GXmlSerializable instance to modify |
|
value |
the new value of the "serialized-xml-node-value" property |
gboolean gxml_serializable_string_to_gvalue (const gchar *str
,GValue *dest
,GError **error
);
Transforms a string into another type hosted by GValue.
A utility function that handles converting a string representation of a value into the type specified by the supplied GValue dest. A GXmlSerializableError will be set if the string cannot be parsed into the desired type.
GXmlSerializable interface support a number of data types to convert from its string representation. These are supported types:
a. integers: int8, int64, uint, long, ulong, char, uchar a. boolean a. floats: float, double a. enumerations
typedef struct _GXmlSerializable GXmlSerializable;
Serialization framework. Base interface.
Implementors of this interface, could define or override the way you want to represent your class in a XML file.
struct GXmlSerializableIface { GTypeInterface parent_iface; gboolean (*get_enable_unknown_serializable_property) (GXmlSerializable* self); gboolean (*set_default_namespace) (GXmlSerializable* self, GXmlNode* node); gboolean (*serialize_use_xml_node_value) (GXmlSerializable* self); gchar* (*node_name) (GXmlSerializable* self); gboolean (*property_use_nick) (GXmlSerializable* self); GXmlNode* (*serialize) (GXmlSerializable* self, GXmlNode* node, GError** error); GXmlNode* (*serialize_property) (GXmlSerializable* self, GXmlNode* element, GParamSpec* prop, GError** error); gboolean (*deserialize) (GXmlSerializable* self, GXmlNode* node, GError** error); gboolean (*deserialize_property) (GXmlSerializable* self, GXmlNode* property_node, GError** error); GParamSpec* (*find_property_spec) (GXmlSerializable* self, const gchar* property_name); GParamSpec* (*default_find_property_spec) (GXmlSerializable* self, const gchar* property_name); GParamSpec** (*list_serializable_properties) (GXmlSerializable* self, int* result_length1); GParamSpec** (*default_list_serializable_properties) (GXmlSerializable* self, int* result_length1); GeeMap* (*get_unknown_serializable_properties) (GXmlSerializable* self); GeeCollection* (*get_unknown_serializable_nodes) (GXmlSerializable* self); gchar* (*get_serialized_xml_node_value) (GXmlSerializable* self); void (*set_serialized_xml_node_value) (GXmlSerializable* self, const gchar* value); };
Interface for creating GXmlSerializable implementations.
the parent interface structure |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
virtual method called by |
||
getter method for the abstract property "unknown-serializable-properties" |
||
getter method for the abstract property "unknown-serializable-nodes" |
||
getter method for the abstract property "serialized-xml-node-value" |
||
setter method for the abstract property "serialized-xml-node-value" |