Midgard2 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <midgard/midgard.h> MidgardReplicatorPrivate; struct MidgardReplicator; typedef MidgardReplicatorClass; gchar * midgard_replicator_serialize (GObject *object
); gboolean midgard_replicator_export (MidgardDBObject *object
); gchar * midgard_replicator_export_purged (MidgardConnection *mgd
,const gchar *classname
,const gchar *startdate
,const gchar *enddate
); gchar * midgard_replicator_serialize_blob (MidgardObject *object
); gchar * midgard_replicator_export_blob (MidgardObject *object
); gboolean midgard_replicator_export_by_guid (MidgardConnection *mgd
,const gchar *guid
); gchar * midgard_replicator_export_media (MidgardObject *object
); GObject ** midgard_replicator_unserialize (MidgardConnection *mgd
,const gchar *xml
,gboolean force
); gboolean midgard_replicator_import_object (MidgardDBObject *object
,gboolean force
); void midgard_replicator_import_from_xml (MidgardConnection *mgd
,const gchar *xml
,gboolean force
);
MidgardReplicator lets you serialize and unserialize objects. Once transformed to string, can be sent as custom message through D_Bus services, imported to different database, stored in files, etc.
http://www.midgard-project.org/development/mrfc/view/0030.html
http://www.midgard-project.org/development/mrfc/view/0033.html
gchar * midgard_replicator_serialize (GObject *object
);
|
GObject (or derived class) instance |
Returns : |
serialized objects as xml content or NULL on failure. |
gboolean midgard_replicator_export (MidgardDBObject *object
);
Given object is not serialized. Its storage record is marked as exported.
see
midgard_object_update()
to find out possible error codes returned in case of MidgardObject failure.
|
MidgardDBObject instance |
Returns : |
TRUE on success, FALSE otherwise. |
gchar * midgard_replicator_export_purged (MidgardConnection *mgd
,const gchar *classname
,const gchar *startdate
,const gchar *enddate
);
Exports all purged objects of given class. If startdate
or enddate
are not NULL,
all objects which were purged between dates will be exported.
|
MidgardConnection instance |
|
name of MidgardObjectClass derived one |
|
optional start date |
|
optional end date |
Returns : |
xml buffer with serialized objects or NULL if there are no objects matching given criteria. |
gchar * midgard_replicator_serialize_blob (MidgardObject *object
);
Serialize midgard_blob binary data.
|
MidgardObject of MIDGARD_TYPE_ATTACHMENT type |
Returns : |
Newly allocated xml buffer, which holds blob data base64 encoded, or NULL . |
gchar * midgard_replicator_export_blob (MidgardObject *object
);
Alias for midgard_replicator_serialize_blob()
.
|
MidgardObject of MIDGARD_TYPE_ATTACHMENT type |
Returns : |
serialized object as xml data |
gboolean midgard_replicator_export_by_guid (MidgardConnection *mgd
,const gchar *guid
);
Marks object's storage record as exported.
Cases to return FALSE
:
Given guid is NULL or empty string (MGD_ERR_INVALID_PROPERTY_VALUE)
Object identified by given guid doesn't exist (MGD_ERR_NOT_EXISTS)
Object identified by given guid is purged (MGD_ERR_OBJECT_PURGED)
Internal storage error (MGD_ERR_INTERNAL)
|
MidgardConnection instance |
|
guid which identifies object to be exported |
Returns : |
TRUE on success, FALSE otherwise |
GObject ** midgard_replicator_unserialize (MidgardConnection *mgd
,const gchar *xml
,gboolean force
);
|
MidgardConnection instance |
|
xml buffer which holds serialized object |
|
toggle to force unserialization |
Returns : |
Newly allocated array of GObjects. [transfer full] |
gboolean midgard_replicator_import_object (MidgardDBObject *object
,gboolean force
);
Imports given object to underlying storage
Cases to return FALSE
:
Given guid is NULL or empty string (MGD_ERR_INVALID_PROPERTY_VALUE)
Object is already imported (MGD_ERR_OBJECT_IMPORTED)
Object identified is deleted (MGD_ERR_OBJECT_DELETED)
Object doesn't provide metadata one (MGD_ERR_NO_METADATA)
Set force
toggle if you want to import object even if it's already imported or deleted.
|
MidgardDBObject instance |
|
toggle to force import |
Returns : |
TRUE on success, FALSE otherwise |
void midgard_replicator_import_from_xml (MidgardConnection *mgd
,const gchar *xml
,gboolean force
);
This method tries to import all objects which could be unserialized from gievn xml.
It's not atomic. Check error code returned from midgard_connection_get_error()
.
|
MidgardConnection instance |
|
data buffer which holds serialized object |
|
toggle to force import |