Re: [gnome-db] database xml - database version property
- From: Philippe CHARLIER <p charlier chello be>
- To: gnome-db-list gnome org
- Subject: Re: [gnome-db] database xml - database version property
- Date: Fri, 22 Aug 2003 02:12:39 +0200
Is it OK like this ?
Phil
Le ven 22/08/2003 à 01:27, Rodrigo Moya a écrit :
> On Thu, 2003-08-21 at 21:11 +0200, Philippe CHARLIER wrote:
> > Hi Rodrigo,
> >
> > I made the modification so that "gda-xml-database" creates a new
> > database property named "user_version".
> > I preferred to keep the previous property (version) as it was (libgda
> > version number) to avoid potential problems with existing applications
> > testing this value.
> > Now, the user application may define a "user_version" of the database
> > using the couple of functions :
> >
> > "gda-xml-database-set-user-version()" and
> > "gda-xml-database-get-user-version()".
> >
> > The function "gda-xml-database-set-version()" is removed and
> > "gda-xml-database-get-version()" gives the libgda version used to create
> > the database.
> >
> > Patches for "gda-xml-database.h" and "gda-xml-database.c" attached to
> > the mail.
> >
> the patch looks great! But its format is wrong :-) Please re-create the
> patch running:
>
> cvs -z3 diff -up > out.diff
>
> That is in unified format, which is the one used by the patch command.
>
> As soon as you resend it, I'll commit to CVS.
>
> Thanks a lot
>
> _______________________________________________
> gnome-db-list mailing list
> gnome-db-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-db-list
? out.diff
Index: gda-xml-database.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-xml-database.c,v
retrieving revision 1.24
diff -u -p -r1.24 gda-xml-database.c
--- gda-xml-database.c 30 Jul 2003 10:55:35 -0000 1.24
+++ gda-xml-database.c 22 Aug 2003 00:04:44 -0000
@@ -29,6 +29,7 @@
struct _GdaXmlDatabasePrivate {
gchar *uri;
gchar *name;
+ gchar *user_version;
gchar *version;
GHashTable *tables;
GHashTable *views;
@@ -45,18 +46,19 @@ struct _GdaXmlDatabasePrivate {
#define OBJECT_VIEW "view"
#define OBJECT_VIEWS_NODE "views"
-#define PROPERTY_ALLOW_NULL "isnull"
-#define PROPERTY_AUTO "auto_increment"
-#define PROPERTY_CAPTION "caption"
-#define PROPERTY_GDATYPE "gdatype"
-#define PROPERTY_NAME "name"
-#define PROPERTY_OWNER "owner"
-#define PROPERTY_PRIMARY_KEY "pkey"
-#define PROPERTY_REFERENCES "references"
-#define PROPERTY_SCALE "scale"
-#define PROPERTY_SIZE "size"
-#define PROPERTY_UNIQUE_KEY "unique"
-#define PROPERTY_VERSION "version"
+#define PROPERTY_ALLOW_NULL "isnull"
+#define PROPERTY_AUTO "auto_increment"
+#define PROPERTY_CAPTION "caption"
+#define PROPERTY_GDATYPE "gdatype"
+#define PROPERTY_NAME "name"
+#define PROPERTY_OWNER "owner"
+#define PROPERTY_PRIMARY_KEY "pkey"
+#define PROPERTY_REFERENCES "references"
+#define PROPERTY_SCALE "scale"
+#define PROPERTY_SIZE "size"
+#define PROPERTY_UNIQUE_KEY "unique"
+#define PROPERTY_VERSION "version"
+#define PROPERTY_USER_VERSION "user_version"
static void gda_xml_database_class_init (GdaXmlDatabaseClass *klass);
static void gda_xml_database_init (GdaXmlDatabase *xmldb, GdaXmlDatabaseClass *klass);
@@ -148,6 +150,7 @@ gda_xml_database_init (GdaXmlDatabase *x
xmldb->priv = g_new0 (GdaXmlDatabasePrivate, 1);
xmldb->priv->uri = NULL;
xmldb->priv->name = NULL;
+ xmldb->priv->user_version = NULL;
xmldb->priv->version = NULL;
xmldb->priv->tables = g_hash_table_new (g_str_hash, g_str_equal);
xmldb->priv->views = g_hash_table_new (g_str_hash, g_str_equal);
@@ -181,6 +184,11 @@ gda_xml_database_finalize (GObject *obje
xmldb->priv->name = NULL;
}
+ if (xmldb->priv->user_version) {
+ g_free (xmldb->priv->user_version);
+ xmldb->priv->user_version = NULL;
+ }
+
if (xmldb->priv->version) {
g_free (xmldb->priv->version);
xmldb->priv->version = NULL;
@@ -285,6 +293,7 @@ gda_xml_database_new_from_uri (const gch
}
xmldb->priv->name = g_strdup (xmlGetProp (root, PROPERTY_NAME));
+ xmldb->priv->user_version = g_strdup (xmlGetProp (root, PROPERTY_USER_VERSION));
xmldb->priv->version = g_strdup (xmlGetProp (root, PROPERTY_VERSION));
node = root->xmlChildrenNode;
while (node) {
@@ -348,42 +357,61 @@ gda_xml_database_set_name (GdaXmlDatabas
}
/**
- * gda_xml_database_get_version
+ * gda_xml_database_get_user_version
* @xmldb: XML database.
*
- * Get the version of the given #GdaXmlDatabase object. This version is the
- * one that was used for saving the XML file last time it was saved.
+ * Get the user defined version of the given #GdaXmlDatabase object.
*
- * Returns: the database version.
+ * Returns: the database version defined by the user.
*/
const gchar *
-gda_xml_database_get_version (GdaXmlDatabase *xmldb)
+gda_xml_database_get_user_version (GdaXmlDatabase *xmldb)
{
g_return_val_if_fail (GDA_IS_XML_DATABASE (xmldb), NULL);
- return (const gchar *) xmldb->priv->version;
+ return (const gchar *) xmldb->priv->user_version;
}
/**
- * gda_xml_database_set_version
+ * gda_xml_database_set_user_version
* @xmldb: XML database.
- * @version: Version string.
+ * @user_version: User defined Version string.
*
- * Set the version of the given XML database.
+ * Set the user defined version of the given XML database.
*/
void
-gda_xml_database_set_version (GdaXmlDatabase *xmldb, const gchar *version)
+gda_xml_database_set_user_version (GdaXmlDatabase *xmldb, const gchar *user_version)
{
g_return_if_fail (GDA_IS_XML_DATABASE (xmldb));
- g_return_if_fail (version != NULL);
+ g_return_if_fail (user_version != NULL);
- if (xmldb->priv->version)
- g_free (xmldb->priv->version);
- xmldb->priv->version = g_strdup (version);
+ if (xmldb->priv->user_version)
+ g_free (xmldb->priv->user_version);
+ xmldb->priv->user_version = g_strdup (user_version);
gda_xml_database_changed (xmldb);
}
/**
+ * gda_xml_database_get_version
+ * @xmldb: XML database.
+ *
+ * Get the version of libgda used to create the #GdaXmlDatabase object.
+ * This version is the one that was used for saving the XML file last
+ * time it was saved. This value can only be "get" as it is an internal
+ * information related to the creation of the #GdaXmlDatabase object.
+ * To get the user defined database version, use the function
+ * gda_xml_database_get_user_version instead.
+ *
+ * Returns: the libgda version used to create the database.
+ */
+const gchar *
+gda_xml_database_get_version (GdaXmlDatabase *xmldb)
+{
+ g_return_val_if_fail (GDA_IS_XML_DATABASE (xmldb), NULL);
+ return (const gchar *) xmldb->priv->version;
+}
+
+/**
* gda_xml_database_get_uri
* @xmldb: XML database.
*
@@ -457,7 +485,6 @@ gda_xml_database_save (GdaXmlDatabase *x
g_return_val_if_fail (GDA_IS_XML_DATABASE (xmldb), FALSE);
- gda_xml_database_set_version (xmldb, VERSION);
xml = gda_xml_database_to_string (xmldb);
if (xml) {
result = gda_file_save (uri, xml, strlen (xml));
@@ -495,6 +522,7 @@ gda_xml_database_to_string (GdaXmlDataba
doc = xmlNewDoc ("1.0");
root = xmlNewDocNode (doc, NULL, OBJECT_DATABASE, NULL);
xmlSetProp (root, PROPERTY_NAME, xmldb->priv->name);
+ xmlSetProp (root, PROPERTY_USER_VERSION, xmldb->priv->user_version);
xmlSetProp (root, PROPERTY_VERSION, VERSION);
xmlDocSetRootElement (doc, root);
Index: gda-xml-database.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-xml-database.h,v
retrieving revision 1.10
diff -u -p -r1.10 gda-xml-database.h
--- gda-xml-database.h 5 Jul 2003 22:22:06 -0000 1.10
+++ gda-xml-database.h 22 Aug 2003 00:04:44 -0000
@@ -58,8 +58,9 @@ GdaXmlDatabase *gda_xml_database_new_fro
const gchar *gda_xml_database_get_name (GdaXmlDatabase *xmldb);
void gda_xml_database_set_name (GdaXmlDatabase *xmldb, const gchar *name);
+const gchar *gda_xml_database_get_user_version (GdaXmlDatabase *xmldb);
+void gda_xml_database_set_user_version (GdaXmlDatabase *xmldb, const gchar *user_version);
const gchar *gda_xml_database_get_version (GdaXmlDatabase *xmldb);
-void gda_xml_database_set_version (GdaXmlDatabase *xmldb, const gchar *version);
const gchar *gda_xml_database_get_uri (GdaXmlDatabase *xmldb);
void gda_xml_database_set_uri (GdaXmlDatabase *xmldb, const gchar *uri);
void gda_xml_database_changed (GdaXmlDatabase *xmldb);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]