[glom] SQLite: Avoid a warning about int types for summary fields.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] SQLite: Avoid a warning about int types for summary fields.
- Date: Mon, 28 Nov 2011 13:00:53 +0000 (UTC)
commit c1e48aeb37f4519473ce72266cd1c3c369857686
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Nov 28 14:00:37 2011 +0100
SQLite: Avoid a warning about int types for summary fields.
* glom/libglom/data_structure/glomconversions.cc:
get_text_for_gda_value(): An int is normal for aggregate fields for
SQLite.
convert_value(): Make sure that we do a locale-independent conversion,
otherwise the above fix will cause us to, for instance, have a
comma in large numbers.
ChangeLog | 11 +++++++++++
glom/libglom/data_structure/glomconversions.cc | 9 +++++++--
glom/libglom/data_structure/glomconversions.h | 4 ++++
3 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a7e4289..946fbf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-11-28 Murray Cumming <murrayc murrayc com>
+
+ SQLite: Avoid a warning about int types for summary fields.
+
+ * glom/libglom/data_structure/glomconversions.cc:
+ get_text_for_gda_value(): An int is normal for aggregate fields for
+ SQLite.
+ convert_value(): Make sure that we do a locale-independent conversion,
+ otherwise the above fix will cause us to, for instance, have a
+ comma in large numbers.
+
2011-11-25 Murray Cumming <murrayc murrayc com>
gcov: Add a legend key to the lcov html.
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 62dcd26..e426dc5 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -420,7 +420,10 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
}
else if(glom_type == Field::TYPE_NUMERIC)
{
- if(value.get_value_type() != GDA_TYPE_NUMERIC && value.get_value_type() != G_TYPE_DOUBLE)
+ const GType value_type = value.get_value_type();
+ if(value_type != GDA_TYPE_NUMERIC
+ && value_type != G_TYPE_DOUBLE
+ && value_type != G_TYPE_INT) //SQLite uses int for summary field results.
{
std::cerr << G_STRFUNC << ": glom field type is NUMERIC but GdaValue type is: " << g_type_name(value.get_value_type()) << std::endl;
return value.to_string();
@@ -432,6 +435,8 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
std::stringstream another_stream;
another_stream.imbue(locale); //Tell it to parse stuff as per this locale.
+ std::cout << "debug: iso_format = " << iso_format << std::endl;
+
//Numeric formatting:
if(!iso_format)
{
@@ -1030,7 +1035,7 @@ Gnome::Gda::Value Conversions::convert_value(const Gnome::Gda::Value& value, Fie
}
//Fallback for other conversions:
- const Glib::ustring text = get_text_for_gda_value(source_glom_type, value);
+ const Glib::ustring text = get_text_for_gda_value(source_glom_type, value, std::locale::classic(), NumericFormat(), true /* iso_format */);
bool test = false;
return parse_value(target_glom_type, text, test, true /* iso_format */);
}
diff --git a/glom/libglom/data_structure/glomconversions.h b/glom/libglom/data_structure/glomconversions.h
index 868de48..a2a4ed0 100644
--- a/glom/libglom/data_structure/glomconversions.h
+++ b/glom/libglom/data_structure/glomconversions.h
@@ -79,6 +79,10 @@ namespace Conversions
Gnome::Gda::Value get_example_value(Field::glom_field_type field_type);
+ /** Convert the value to a different type, if necessary.
+ * Any text-to-number or number-to-text conversions will be in the ISO format,
+ * ignoring the current locale.
+ */
Gnome::Gda::Value convert_value(const Gnome::Gda::Value& value, Field::glom_field_type target_glom_type);
} //namespace Conversions
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]