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



commit ca96da34bd45c2e471ba2d277c18298dabcd3d40
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Oct 29 22:56:36 2017 +0100

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

 libgda/libgdamm/value.cc |    5 ++-
 libgda/libgdamm/value.h  |    3 +-
 libgda/src/filelist.am   |    1 +
 libgda/src/time.ccg      |   34 +++++++++++++++++++++++++++
 libgda/src/time.hg       |   57 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 96 insertions(+), 4 deletions(-)
---
diff --git a/libgda/libgdamm/value.cc b/libgda/libgdamm/value.cc
index a49efef..e89ae86 100644
--- a/libgda/libgdamm/value.cc
+++ b/libgda/libgdamm/value.cc
@@ -488,12 +488,13 @@ void Value::set(const char* val)
 
 Time Value::get_time() const
 {
-  return *(gda_value_get_time(const_cast<GValue*>(gobj())));
+  const GdaTime* cobj = gda_value_get_time(const_cast<GValue*>(gobj()));
+  return Glib::wrap(const_cast<GdaTime*>(cobj), true /* take_copy */);
 }
 
 void Value::set(const Time& val)
 {
-  gda_value_set_time(gobj(), &(val));
+  gda_value_set_time(gobj(), val.gobj());
 }
 
 Timestamp Value::get_timestamp() const
diff --git a/libgda/libgdamm/value.h b/libgda/libgdamm/value.h
index d974d1d..3be8d17 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/time.h>
 #include <libgdamm/timestamp.h>
 #include <glibmm/value.h>
 #include <glibmm/date.h>
@@ -39,8 +40,6 @@ namespace Gnome
 namespace Gda
 {
 
-typedef GdaTime Time;
-
 /**
  *
  * Use value_type() to identify the value type at runtime.
diff --git a/libgda/src/filelist.am b/libgda/src/filelist.am
index f6d1544..d074220 100644
--- a/libgda/src/filelist.am
+++ b/libgda/src/filelist.am
@@ -47,6 +47,7 @@ files_hg =                    \
        sqlbuilder.hg   \
        sqlstatement.hg   \
        statement.hg            \
+        time.hg \
         timestamp.hg \
        transactionstatus.hg    \
        xatransaction.hg
diff --git a/libgda/src/time.ccg b/libgda/src/time.ccg
new file mode 100644
index 0000000..10b7b4e
--- /dev/null
+++ b/libgda/src/time.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
+{
+
+Time::Time(gushort hour, gushort minute, gushort second, gulong fraction, long timezone)
+: gobject_(gda_time_new_from_values(hour, minute, second, fraction, timezone))
+{
+}
+
+} /* namespace Gda */
+
+} /* namespace Gnome */
diff --git a/libgda/src/time.hg b/libgda/src/time.hg
new file mode 100644
index 0000000..fb3a05d
--- /dev/null
+++ b/libgda/src/time.hg
@@ -0,0 +1,57 @@
+/* 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 Time
+{
+  _CLASS_BOXEDTYPE(Time, GdaTime, gda_time_new, gda_time_copy, gda_time_free)
+  _IGNORE(gda_time_new, gda_time_copy, gda_time_free)
+public:
+   Time(gushort hour, gushort minute, gushort second, gulong fraction, long timezone);
+
+  _WRAP_METHOD(gushort get_hour() const, gda_time_get_hour)
+  _WRAP_METHOD(void set_hour(gushort hour), gda_time_set_hour)
+  _WRAP_METHOD(gushort get_minute() const, gda_time_get_minute)
+  _WRAP_METHOD(void set_minute(gushort minute), gda_time_set_minute)
+  _WRAP_METHOD(gushort get_second() const, gda_time_get_second)
+  _WRAP_METHOD(void set_second(gushort second), gda_time_set_second)
+  _WRAP_METHOD(gulong get_fraction () const, gda_time_get_fraction)
+  _WRAP_METHOD(void set_fraction(gulong fraction), gda_time_set_fraction)
+  _WRAP_METHOD(long get_timezone () const, gda_time_get_timezone)
+  _WRAP_METHOD(void set_timezone(long timezone), gda_time_set_timezone)
+
+  _WRAP_METHOD(bool valid() const, gda_time_valid)
+
+  _WRAP_METHOD(void change_timezone(long ntz), gda_time_change_timezone)
+};
+
+} // namespace Gda
+} // namespace Gnome
+


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