From 5f1cd97b9727fe10df79e1eb316ff493d9dfc2a9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 1 Feb 2024 20:50:43 +0300 Subject: Turn libodb-qt repository into package for muti-package repository --- .../odb/qt/date-time/oracle/qdate-time-traits.hxx | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 libodb-qt/odb/qt/date-time/oracle/qdate-time-traits.hxx (limited to 'libodb-qt/odb/qt/date-time/oracle/qdate-time-traits.hxx') diff --git a/libodb-qt/odb/qt/date-time/oracle/qdate-time-traits.hxx b/libodb-qt/odb/qt/date-time/oracle/qdate-time-traits.hxx new file mode 100644 index 0000000..ba90075 --- /dev/null +++ b/libodb-qt/odb/qt/date-time/oracle/qdate-time-traits.hxx @@ -0,0 +1,136 @@ +// file : odb/qt/date-time/oracle/qdate-time-traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_QT_DATE_TIME_ORACLE_QDATETIME_TRAITS_HXX +#define ODB_QT_DATE_TIME_ORACLE_QDATETIME_TRAITS_HXX + +#include + +#include + +#include +#include + +namespace odb +{ + namespace oracle + { + template <> + struct default_value_traits + { + typedef QDateTime value_type; + typedef QDateTime query_type; + typedef datetime image_type; + + static void + set_value (QDateTime& v, const datetime& i, bool is_null) + { + if (is_null) + // Default constructor creates a null QDateTime. + // + v = QDateTime (); + else + { + sb2 y (0); + ub1 m (0), d (0), h (0), minute (0), s (0); + ub4 ns (0); + i.get (y, m, d, h, minute, s, ns); + + v = QDateTime (QDate (static_cast (y), + static_cast (m), + static_cast (d)), + QTime (static_cast (h), + static_cast (minute), + static_cast (s), + static_cast (ns / 1000000))); + } + } + + static void + set_image (datetime& i, bool& is_null, const QDateTime& v) + { + if (v.isNull ()) + is_null = true; + else + { + is_null = false; + + const QDate& d (v.date ()); + const QTime& t (v.time ()); + + i.set (static_cast (d.year ()), + static_cast (d.month ()), + static_cast (d.day ()), + static_cast (t.hour ()), + static_cast (t.minute ()), + static_cast (t.second ()), + static_cast (t.msec () * 1000000)); + } + } + }; + + template <> + struct default_value_traits + { + typedef QDateTime value_type; + typedef QDateTime query_type; + typedef char* image_type; + + static void + set_value (QDateTime& v, const char* b, bool is_null) + { + if (is_null) + // Default constructor creates a null QDateTime. + // + v = QDateTime (); + else + { + short y; + unsigned char m, d, h, minute, s; + + details::get_date (b, y, m, d, h, minute, s); + + v = QDateTime (QDate (static_cast (y), + static_cast (m), + static_cast (d)), + QTime (static_cast (h), + static_cast (minute), + static_cast (s), + 0)); + } + } + + static void + set_image (char* b, bool& is_null, const QDateTime& v) + { + if (v.isNull ()) + is_null = true; + else + { + is_null = false; + + const QDate& d (v.date ()); + const QTime& t (v.time ()); + + details::set_date (b, + static_cast (d.year ()), + static_cast (d.month ()), + static_cast (d.day ()), + static_cast (t.hour ()), + static_cast (t.minute ()), + static_cast (t.second ())); + } + } + }; + + template <> + struct default_type_traits + { + static const database_type_id db_type_od = id_timestamp; + }; + } +} + +#include + +#endif // ODB_QT_DATE_TIME_ORACLE_QDATETIME_TRAITS_HXX -- cgit v1.1