MgXmlStorage

Name

MgXmlStorage -- Interface which provides saving and loading using XML structures

Synopsis



#define     MG_XML_STORAGE_TYPE
#define     MG_XML_STORAGE                  (obj)
#define     IS_MG_XML_STORAGE               (obj)
#define     MG_XML_STORAGE_GET_IFACE        (obj)
struct      MgXmlStorage;
struct      MgXmlStorageIface;
GType       mg_xml_storage_get_type         (void);
gchar*      mg_xml_storage_get_xml_id       (MgXmlStorage *iface);
xmlNodePtr  mg_xml_storage_save_to_xml      (MgXmlStorage *iface,
                                             GError **error);
gboolean    mg_xml_storage_load_from_xml    (MgXmlStorage *iface,
                                             xmlNodePtr node,
                                             GError **error);

Object Hierarchy


  GInterface
   +----MgXmlStorage

Implementations

MgXmlStorage is implemented by MgQfValue, MgServer, MgDatabase, MgQfField, MgTarget, MgDbConstraint, MgServerFunction, MgServerAggregate, MgQfAll, MgCondition, MgDbTable, MgDbField, MgQuery, MgJoin, MgQfFunc and MgServerDataType.

Prerequisites

MgXmlStorage requires GObject.

Description

Any object which implements this interface can be streamed and restored to and from an XML file.

Details

MG_XML_STORAGE_TYPE

#define MG_XML_STORAGE_TYPE          (mg_xml_storage_get_type())


MG_XML_STORAGE()

#define MG_XML_STORAGE(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, mg_xml_storage_get_type(), MgXmlStorage)

obj :


IS_MG_XML_STORAGE()

#define IS_MG_XML_STORAGE(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, mg_xml_storage_get_type ())

obj :


MG_XML_STORAGE_GET_IFACE()

#define MG_XML_STORAGE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MG_XML_STORAGE_TYPE, MgXmlStorageIface))

obj :


struct MgXmlStorage

struct MgXmlStorage;


struct MgXmlStorageIface

struct MgXmlStorageIface {

	GTypeInterface           g_iface;

	/* virtual table */
	gchar      *(* get_xml_id)      (MgXmlStorage *iface);
	xmlNodePtr  (* save_to_xml)     (MgXmlStorage *iface, GError **error);
	gboolean    (* load_from_xml)   (MgXmlStorage *iface, xmlNodePtr node, GError **error);
};


mg_xml_storage_get_type ()

GType       mg_xml_storage_get_type         (void);

Returns :


mg_xml_storage_get_xml_id ()

gchar*      mg_xml_storage_get_xml_id       (MgXmlStorage *iface);

Fetch the xml id string of the object, it's up to the caller to free the string.

iface :

an object which implements the MgXmlStorage interface

Returns :

the xml id.


mg_xml_storage_save_to_xml ()

xmlNodePtr  mg_xml_storage_save_to_xml      (MgXmlStorage *iface,
                                             GError **error);

Creates a new xmlNodePtr structure and fills it with data representing the object given as argument.

iface :

an object which implements the MgXmlStorage interface

error :

location to store error, or NULL

Returns :

the new XML node, or NULL if an error occured.


mg_xml_storage_load_from_xml ()

gboolean    mg_xml_storage_load_from_xml    (MgXmlStorage *iface,
                                             xmlNodePtr node,
                                             GError **error);

Updates the object with data stored in the XML node. The object MUST already exist and be of the correct type before calling this function. This is a virtual function.

iface :

an object which implements the MgXmlStorage interface

node :

an XML node from an XML structure

error :

location to store error, or NULL

Returns :

TRUE if no error occured.