[libgda] Honor the GDA_DATA_MODEL_DUMP_ATTRIBUTES env. variable in gda_data_model_dump_as_string()



commit 5d887397e8965866dec4689c458d921b9f0b2400
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Sep 8 22:40:49 2011 +0200

    Honor the GDA_DATA_MODEL_DUMP_ATTRIBUTES env. variable in gda_data_model_dump_as_string()

 libgda/gda-data-model.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 994a61a..94f6fac 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -2218,6 +2218,7 @@ gda_data_model_dump (GdaDataModel *model, FILE *to_stream)
 gchar *
 gda_data_model_dump_as_string (GdaDataModel *model)
 {
+	gboolean dump_attrs = FALSE;
 	gboolean dump_rows = FALSE;
 	gboolean dump_title = FALSE;
 	gboolean null_as_empty = FALSE;
@@ -2226,6 +2227,8 @@ gda_data_model_dump_as_string (GdaDataModel *model)
 
 	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), NULL);
 
+	if (getenv ("GDA_DATA_MODEL_DUMP_ATTRIBUTES")) /* Flawfinder: ignore */
+		dump_attrs = TRUE;
 	if (getenv ("GDA_DATA_MODEL_DUMP_ROW_NUMBERS")) /* Flawfinder: ignore */
 		dump_rows = TRUE;
 	if (getenv ("GDA_DATA_MODEL_DUMP_TITLE")) /* Flawfinder: ignore */
@@ -2245,7 +2248,20 @@ gda_data_model_dump_as_string (GdaDataModel *model)
 		if (max_width < 0)
 			max_width = 0;
 	}
-	return real_gda_data_model_dump_as_string (model, FALSE, dump_rows, dump_title, null_as_empty, max_width, NULL);
+	if (dump_attrs) {
+		GString *string;
+		gchar *tmp;
+		tmp = real_gda_data_model_dump_as_string (model, FALSE, dump_rows, dump_title, null_as_empty, max_width, NULL);
+		string = g_string_new (tmp);
+		g_free (tmp);
+		tmp = real_gda_data_model_dump_as_string (model, TRUE, dump_rows, dump_title, null_as_empty, max_width, NULL);
+		g_string_append_c (string, '\n');
+		g_string_append (string, tmp);
+		g_free (tmp);
+		return g_string_free (string, FALSE);
+	}
+	else
+		return real_gda_data_model_dump_as_string (model, FALSE, dump_rows, dump_title, null_as_empty, max_width, NULL);
 }
 
 static void



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