[libgda] GdaDataModel import & export: better option names



commit cffb411bda6553a2b681a6657835e29e1bce6407
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Mar 1 20:48:53 2012 +0100

    GdaDataModel import & export: better option names
    
    the old option names are still supported

 libgda/gda-data-model-import.c |    7 ++++---
 libgda/gda-data-model.c        |   10 ++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index c157393..7ca50dd 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -779,8 +779,8 @@ gda_data_model_import_get_property (GObject *object,
  *      <itemizedlist>
  *         <listitem><para>ENCODING (string): specifies the encoding of the data in the file</para></listitem>
  *         <listitem><para>SEPARATOR (string): specifies the CSV separator (comma as default)</para></listitem>
- *         <listitem><para>QUOTE (string): specifies the character used to as quote park (double quote as default)</para></listitem>
- *         <listitem><para>TITLE_AS_FIRST_LINE (boolean): consider that the first line of the file contains columns' titles</para></listitem>
+ *         <listitem><para>QUOTE (string): specifies the character used as quote (double quote as default)</para></listitem>
+ *         <listitem><para>NAMES_ON_FIRST_LINE (boolean): consider that the first line of the file contains columns' titles (note that the TITLE_AS_FIRST_LINE option is also accepted as a synonym)</para></listitem>
  *         <listitem><para>G_TYPE_&lt;column number&gt; (GType): specifies the type of value expected in column &lt;column number&gt;</para></listitem>
  *      </itemizedlist>
  *   </para></listitem>
@@ -869,7 +869,8 @@ init_csv_import (GdaDataModelImport *model)
 	gint nbcols;
 
 	if (model->priv->options)
-		title_first_line = find_option_as_boolean (model, "TITLE_AS_FIRST_LINE", FALSE);
+		title_first_line = find_option_as_boolean (model, "NAMES_ON_FIRST_LINE", FALSE) ||
+			find_option_as_boolean (model, "TITLE_AS_FIRST_LINE", FALSE);
 
 	g_assert (model->priv->format == FORMAT_CSV);
 
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 7917b30..843a983 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1419,7 +1419,9 @@ gda_data_model_export_to_string (GdaDataModel *model, GdaDataModelIOFormat forma
 					g_warning (_("The '%s' parameter must hold a boolean value, ignored."), "INVALID_AS_NULL");
 			}
 
-			holder = gda_set_get_holder (options, "FIELDS_NAME");
+			holder = gda_set_get_holder (options, "NAMES_ON_FIRST_LINE");
+			if (!holder)
+				holder = gda_set_get_holder (options, "FIELDS_NAME");
 			if (holder) {
 				const GValue *value;
 				value = gda_holder_get_value (holder);
@@ -1508,12 +1510,12 @@ gda_data_model_export_to_string (GdaDataModel *model, GdaDataModelIOFormat forma
  * <itemizedlist>
  *   <listitem><para>"SEPARATOR": a string value of which the first character is used as a separator in case of CSV export
  *             </para></listitem>
- *   <listitem><para>"QUOTE": a string value of which the first character is used as a quote character in case of CSV export
- *             </para></listitem>
+ *   <listitem><para>"QUOTE": a string value of which the first character is used as a quote character in case of CSV export. The
+ *             default if not specified is the double quote character</para></listitem>
  *   <listitem><para>"FIELD_QUOTE": a boolean value which can be set to FALSE if no quote around the individual fields 
  *             is requeted, in case of CSV export</para></listitem>
+ *   <listitem><para>"NAMES_ON_FIRST_LINE": a boolean value which, if set to %TRUE and in case of a CSV export, will add a first line with the name each exported field (note that "FIELDS_NAME" is also accepted as a synonym)</para></listitem>
  *   <listitem><para>"NAME": a string value used to name the exported data if the export format is XML</para></listitem>
- *   <listitem><para>"FIELDS_NAME": a boolean value which, if set to %TRUE and in case of a CSV export, will add a first line with the name each exported field</para></listitem>
  *   <listitem><para>"OVERWRITE": a boolean value which tells if the file must be over-written if it already exists.</para></listitem>
  *   <listitem><para>"NULL_AS_EMPTY": a boolean value which, if set to %TRUE and in case of a CSV export, will render and NULL value as the empty string (instead of the 'NULL' string)</para></listitem>
  *   <listitem><para>"INVALID_AS_NULL": a boolean value which, if set to %TRUE, considers any invalid data (for example for the date related values) as NULL</para></listitem>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]