[glom] Rename get_stringstream_precision_default().



commit 1adb40faab84141de49e82de35ebae39336e60ee
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jan 14 16:47:22 2010 +0100

    Rename get_stringstream_precision_default().
    
    * glom/libglom/data_structure/glomconversions.[h|cc]:
    get_stringstream_precision_default(): Rename this to the slighly-better
    named (because it's not mentioning implementation)
    NumericFormat::get_default_precision() in
    * glom/libglom/data_structure/numeric_format.[h|cc]: and document it
    vaguely.

 ChangeLog                                      |   11 +++++++++++
 glom/libglom/data_structure/glomconversions.cc |    9 ++-------
 glom/libglom/data_structure/glomconversions.h  |    2 --
 glom/libglom/data_structure/numeric_format.cc  |    5 +++++
 glom/libglom/data_structure/numeric_format.h   |    6 ++++++
 5 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f87251f..7fc9943 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-01-14  Murray Cumming  <murrayc murrayc com>
 
+	Rename get_stringstream_precision_default().
+
+	* glom/libglom/data_structure/glomconversions.[h|cc]:
+	get_stringstream_precision_default(): Rename this to the slighly-better 
+	named (because it's not mentioning implementation) 
+	NumericFormat::get_default_precision() in
+	* glom/libglom/data_structure/numeric_format.[h|cc]: and document it 
+	vaguely.
+
+2010-01-14  Murray Cumming  <murrayc murrayc com>
+
 	Minor simplification.
 
 	* glom/libglom/data_structure/glomconversions.cc:
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 76ffa15..1fdb10e 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -55,11 +55,6 @@ namespace
 namespace Glom
 {
 
-int Conversions::get_stringstream_precision_default()
-{
-    return 15;
-}
-
 Glib::ustring Conversions::format_time(const tm& tm_data)
 {
   return format_time( tm_data, std::locale("") /* the user's current locale */ ); //Get the current locale.
@@ -432,7 +427,7 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
       {
         //Increase the number of digits (even before the decimal point) we can 
         //have until it uses the awkward e syntax. The default seems to be 7.
-        another_stream << std::setprecision(get_stringstream_precision_default());
+        another_stream << std::setprecision( NumericFormat::get_default_precision() );
       }
 
       if(!(numeric_format.m_currency_symbol.empty()))
@@ -605,7 +600,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
     clocale_stream.imbue( std::locale::classic() ); //The C locale.
 
     //Avoid the e syntax. Normally this happens afer 7 digits, with loss of precision. TODO: Handle more.
-    clocale_stream << std::setprecision(get_stringstream_precision_default());
+    clocale_stream << std::setprecision( NumericFormat::get_default_precision() );
     clocale_stream << the_number;
     const Glib::ustring number_canonical_text = clocale_stream.str(); //Avoid << because it does implicit character conversion (though that might not be a problem here. Not sure). murrayc
     //std::cout << "  DEBUG: number_canonical_text=" << number_canonical_text << std::endl;  
diff --git a/glom/libglom/data_structure/glomconversions.h b/glom/libglom/data_structure/glomconversions.h
index dc79071..868de48 100644
--- a/glom/libglom/data_structure/glomconversions.h
+++ b/glom/libglom/data_structure/glomconversions.h
@@ -32,8 +32,6 @@ namespace Glom
 
 namespace Conversions
 {
-  int get_stringstream_precision_default();
-
   ///Get text for display to the user.
   Glib::ustring get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const NumericFormat& numeric_format = NumericFormat());
   Glib::ustring get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const std::locale& locale, const NumericFormat& numeric_format = NumericFormat(), bool iso_format = false);
diff --git a/glom/libglom/data_structure/numeric_format.cc b/glom/libglom/data_structure/numeric_format.cc
index 98a90e1..09f246f 100644
--- a/glom/libglom/data_structure/numeric_format.cc
+++ b/glom/libglom/data_structure/numeric_format.cc
@@ -62,4 +62,9 @@ bool NumericFormat::operator!=(const NumericFormat& src) const
   return !(operator==(src));
 }
 
+guint NumericFormat::get_default_precision()
+{
+  return 15;
+}
+
 } //namespace Glom
diff --git a/glom/libglom/data_structure/numeric_format.h b/glom/libglom/data_structure/numeric_format.h
index bf6b98e..f11b7f9 100644
--- a/glom/libglom/data_structure/numeric_format.h
+++ b/glom/libglom/data_structure/numeric_format.h
@@ -40,6 +40,12 @@ public:
   bool operator==(const NumericFormat& src) const;
   bool operator!=(const NumericFormat& src) const;
 
+  /** Get the number of digits (even before the decimal point) we should allow
+   * to be shown until we show the awkward e syntax.
+   * This should not be used if m_decimal_places_restricted is true.
+   */
+  static guint get_default_precision();
+
   Glib::ustring m_currency_symbol;
   bool m_use_thousands_separator; //Setting this to false would override the locale, if it used a 1000s separator.
   bool m_decimal_places_restricted;



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