[glom] Make the default precision used for stringstreams available for libglom users
- From: Michael Hasselmann <mikhas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Make the default precision used for stringstreams available for libglom users
- Date: Thu, 14 Jan 2010 11:45:08 +0000 (UTC)
commit c31f7199017df64559d468665a055149c100ff5c
Author: Michael Hasselmann <michaelh openismus com>
Date: Thu Jan 14 12:14:53 2010 +0100
Make the default precision used for stringstreams available for libglom users
* glom/libglom/data_structure/glomconversions.[h|cc]
(get_stringstream_precision_default): Wrap the constant used into a function
and export it in the headers. Users of libglom need it to show the same
precision for Glom's numeric type.
ChangeLog | 10 ++++++++++
glom/libglom/data_structure/glomconversions.cc | 14 +++++++++-----
glom/libglom/data_structure/glomconversions.h | 2 ++
3 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d56ef3..2c767a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-01-14 Michael Hasselmann <michaelh openismus com>
+
+ Make the default precision used for stringstreams available for libglom users
+
+ * glom/libglom/data_structure/glomconversions.[h|cc]
+ (get_stringstream_precision_default): Wrap the constant used into a function
+ and export it in the headers. Users of libglom need it to show the same
+ precision for Glom's numeric type.
+
+
2010-01-12 Murray Cumming <murrayc murrayc com>
Music Collection Example: Changed a layout.
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 95a0fe5..480ca9b 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -55,9 +55,11 @@ namespace
namespace Glom
{
-// 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
-static const int STRINGSTREAM_PRECISION_DEFAULT = 15;
+int Conversions::get_stringstream_precision_default()
+{
+ static const int stringstream_precision_default = 15;
+ return stringstream_precision_default;
+}
Glib::ustring Conversions::format_time(const tm& tm_data)
{
@@ -431,7 +433,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(STRINGSTREAM_PRECISION_DEFAULT);
+ another_stream << std::setprecision(get_stringstream_precision_default());
}
if(!(numeric_format.m_currency_symbol.empty()))
@@ -602,7 +604,9 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
std::stringstream clocale_stream;
clocale_stream.imbue( std::locale::classic() ); //The C locale.
- clocale_stream << std::setprecision(STRINGSTREAM_PRECISION_DEFAULT); //Avoid the e syntax. Normally this happens afer 7 digits, with loss of precision. TODO: Handle more.
+
+ //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 << 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 868de48..dc79071 100644
--- a/glom/libglom/data_structure/glomconversions.h
+++ b/glom/libglom/data_structure/glomconversions.h
@@ -32,6 +32,8 @@ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]