[libgdamm] Timestamp: Wrap as an opaque boxed type.



commit 45831d96ae4864622e2e9115938746f96f1ed4a0
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Oct 29 22:52:12 2017 +0100

    Timestamp: Wrap as an opaque boxed type.
    
    Now that the C type is an opaque type.

 libgda/libgdamm/value.cc     |    5 ++-
 libgda/libgdamm/value.h      |    2 +-
 libgda/src/filelist.am       |    1 +
 libgda/src/geometricpoint.hg |    2 +-
 libgda/src/timestamp.ccg     |   34 ++++++++++++++++++++
 libgda/src/timestamp.hg      |   72 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 112 insertions(+), 4 deletions(-)
---
diff --git a/libgda/libgdamm/value.cc b/libgda/libgdamm/value.cc
index 8022cf3..a49efef 100644
--- a/libgda/libgdamm/value.cc
+++ b/libgda/libgdamm/value.cc
@@ -498,12 +498,13 @@ void Value::set(const Time& val)
 
 Timestamp Value::get_timestamp() const
 {
-  return *(gda_value_get_timestamp(const_cast<GValue*>(gobj())));
+  const GdaTimestamp* cobj = gda_value_get_timestamp(const_cast<GValue*>(gobj()));
+  return Glib::wrap(const_cast<GdaTimestamp*>(cobj), true /* take_copy */);
 }
 
 void Value::set(const Timestamp& val)
 {
-  gda_value_set_timestamp(gobj(), &(val));
+  gda_value_set_timestamp(gobj(), val.gobj());
 }
 
 guint Value::get_uint() const
diff --git a/libgda/libgdamm/value.h b/libgda/libgdamm/value.h
index 074bad1..d974d1d 100644
--- a/libgda/libgdamm/value.h
+++ b/libgda/libgdamm/value.h
@@ -27,6 +27,7 @@
 
 #include <libgdamm/numeric.h>
 #include <libgdamm/geometricpoint.h>
+#include <libgdamm/timestamp.h>
 #include <glibmm/value.h>
 #include <glibmm/date.h>
 #include <libgda/gda-value.h> //TODO: Patch libgda to use the struct _ technique.
@@ -39,7 +40,6 @@ namespace Gda
 {
 
 typedef GdaTime Time;
-typedef GdaTimestamp Timestamp;
 
 /**
  *
diff --git a/libgda/src/filelist.am b/libgda/src/filelist.am
index c8af655..f6d1544 100644
--- a/libgda/src/filelist.am
+++ b/libgda/src/filelist.am
@@ -47,5 +47,6 @@ files_hg =                    \
        sqlbuilder.hg   \
        sqlstatement.hg   \
        statement.hg            \
+        timestamp.hg \
        transactionstatus.hg    \
        xatransaction.hg
diff --git a/libgda/src/geometricpoint.hg b/libgda/src/geometricpoint.hg
index 4dc1aa6..141a039 100644
--- a/libgda/src/geometricpoint.hg
+++ b/libgda/src/geometricpoint.hg
@@ -37,7 +37,7 @@ public:
 
   _WRAP_METHOD(double get_x() const, gda_geometric_point_get_x)
   _WRAP_METHOD(void set_x(double x), gda_geometric_point_set_x)
-  _WRAP_METHOD(int get_y() const, gda_geometric_point_get_y)
+  _WRAP_METHOD(double get_y() const, gda_geometric_point_get_y)
   _WRAP_METHOD(void set_y(double y), gda_geometric_point_set_y)
 };
 
diff --git a/libgda/src/timestamp.ccg b/libgda/src/timestamp.ccg
new file mode 100644
index 0000000..18287be
--- /dev/null
+++ b/libgda/src/timestamp.ccg
@@ -0,0 +1,34 @@
+/* Copyright 2011 libgdamm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <libgda/gda-value.h>
+
+
+namespace Gnome
+{
+
+namespace Gda
+{
+
+Timestamp::Timestamp(gushort year, gushort month, gushort day, gushort hour, gushort minute, gushort second, 
gulong fraction, long timezone)
+: gobject_(gda_timestamp_new_from_values(year, month, day, hour, minute, second, fraction, timezone))
+{
+}
+
+} /* namespace Gda */
+
+} /* namespace Gnome */
diff --git a/libgda/src/timestamp.hg b/libgda/src/timestamp.hg
new file mode 100644
index 0000000..aa730fa
--- /dev/null
+++ b/libgda/src/timestamp.hg
@@ -0,0 +1,72 @@
+/* Copyright 2011 libgdamm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or(at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/ustring.h>
+#include <glibmm/value.h>
+
+_DEFS(libgdamm,libgda)
+
+namespace Gnome
+{
+
+namespace Gda
+{
+
+
+/** TODO
+ */
+class Timestamp
+{
+  _CLASS_BOXEDTYPE(Timestamp, GdaTimestamp, gda_timestamp_new, gda_timestamp_copy, gda_timestamp_free)
+  _IGNORE(gda_timestamp_new, gda_timestamp_copy, gda_timestamp_free)
+public:
+
+  Timestamp(gushort year, gushort month, gushort day, gushort hour, gushort minute, gushort second, gulong 
fraction, long timezone);
+
+  _WRAP_METHOD(gshort get_year() const, gda_timestamp_get_year)
+  _WRAP_METHOD(void set_year(gshort year), gda_timestamp_set_year)
+
+  _WRAP_METHOD(gushort get_month() const, gda_timestamp_get_month)
+  _WRAP_METHOD(void set_month(gushort month), gda_timestamp_set_month)
+
+  _WRAP_METHOD(gushort get_day() const, gda_timestamp_get_day)
+  _WRAP_METHOD(void set_day(gushort day), gda_timestamp_set_day)
+
+  _WRAP_METHOD(gushort get_hour() const, gda_timestamp_get_hour)
+  _WRAP_METHOD(void set_hour(gushort hour), gda_timestamp_set_hour)
+
+  _WRAP_METHOD(gushort get_minute() const, gda_timestamp_get_minute)
+  _WRAP_METHOD(void set_minute(gushort minute), gda_timestamp_set_minute)
+
+  _WRAP_METHOD(gushort get_second() const, gda_timestamp_get_second)
+  _WRAP_METHOD(void set_second(gushort second), gda_timestamp_set_second)
+
+  _WRAP_METHOD(gulong get_fraction() const, gda_timestamp_get_fraction)
+  _WRAP_METHOD(void set_fraction(gulong fraction), gda_timestamp_set_fraction)
+
+  _WRAP_METHOD(long get_timezone() const, gda_timestamp_get_timezone)
+  _WRAP_METHOD(void set_timezone(long month), gda_timestamp_set_timezone)
+
+  _WRAP_METHOD(bool valid() const, gda_timestamp_valid)
+
+  _WRAP_METHOD(void change_timezone(long ntz), gda_timestamp_change_timezone)
+};
+
+
+} // namespace Gda
+} // namespace Gnome
+


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