[libgdamm] Value: Add create_as_float/double() and set_float/double().



commit e6614f73d6a8bef2205858392ade2ca6266ac7d8
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Apr 25 11:45:31 2014 +0200

    Value: Add create_as_float/double() and set_float/double().
    
    Deprecating the ambiguous constructors and set() methods.

 libgda/libgdamm/value.cc |   32 ++++++++++++++++++++++++++++++++
 libgda/libgdamm/value.h  |   36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/libgda/libgdamm/value.cc b/libgda/libgdamm/value.cc
index 826fedc..1f4be1a 100644
--- a/libgda/libgdamm/value.cc
+++ b/libgda/libgdamm/value.cc
@@ -83,10 +83,19 @@ Value::Value(const Glib::Date& val)
   set(val);
 }
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
 Value::Value(double val)
 {
   set(val);
 }
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+Value Value::create_as_double(double val)
+{
+  Value result;
+  result.set_double(val);
+  return result;
+}
 
 Value::Value(const GeometricPoint& val)
 {
@@ -103,10 +112,19 @@ Value::Value(const Numeric& val)
   set(val);
 }
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
 Value::Value(float val)
 {
   set(val);
 }
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+Value Value::create_as_float(float val)
+{
+  Value result;
+  result.set_float(val);
+  return result;
+}
 
 Value::Value(gshort val)
 {
@@ -351,8 +369,15 @@ double Value::get_double() const
   return g_value_get_double(const_cast<GValue*>(gobj()));
 }
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
 void Value::set(double val)
 {
+  set_double(val);
+}
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+void Value::set_double(double val)
+{
   value_reinit(gobj(), Glib::Value<double>::value_type());
   g_value_set_double(gobj(), val);
 }
@@ -394,8 +419,15 @@ float Value::get_float() const
   return g_value_get_float(const_cast<GValue*>(gobj()));
 }
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
 void Value::set(float val)
 {
+  set_float(val);
+}
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+void Value::set_float(float val)
+{
   value_reinit(gobj(), Glib::Value<float>::value_type());
   g_value_set_float(gobj(), val);
 }
diff --git a/libgda/libgdamm/value.h b/libgda/libgdamm/value.h
index e912bf5..da76ac6 100644
--- a/libgda/libgdamm/value.h
+++ b/libgda/libgdamm/value.h
@@ -75,15 +75,31 @@ public:
 
   explicit Value(const Glib::Date& val);
 
-  explicit Value(double val);
-
   explicit Value(const GeometricPoint& val);
 
   explicit Value(int val);
 
   explicit Value(const Numeric& val);
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
+  //We shouldn't have this constructor because the double and float constructors are ambiguous.
+  /**
+   * @deprecated Use create_as_double() instead.
+   */
+  explicit Value(double val);
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+  static Value create_as_double(double val);
+
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
+  //We shouldn't have this constructor because the double and float constructors are ambiguous.
+  /**
+   * @deprecated Use create_as_double() instead.
+   */
   explicit Value(float val);
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+  static Value create_as_float(float val);
 
   explicit Value(gshort val);
 
@@ -164,7 +180,15 @@ public:
 
   double get_double() const;
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
+  //set(double) and set(float) are ambiguous.
+  /**
+   * @deprecate Use set_double().
+   */
   void set(double val);
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+  void set_double(double val);
 
   GeometricPoint get_geometric_point() const;
 
@@ -184,7 +208,15 @@ public:
 
   float get_float() const;
 
+#ifndef LIBGDAMM_DISABLE_DEPRECATED
+  //set(double) and set(float) are ambiguous.
+  /**
+   * @deprecate Use set_float().
+   */
   void set(float val);
+#endif //LIBGDAMM_DISABLE_DEPRECATED
+
+  void set_float(float val);
 
   gshort get_short() const;
 


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