From 621bc135b9825fc9f18ada204f67d3800c5f6fda Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 31 Mar 2011 15:36:02 +0200 Subject: Complete qt/basic and qt/date-time implementations --- odb/qt/mysql/default-mapping.hxx | 30 ---------- odb/qt/mysql/qbytearray-traits.hxx | 71 ------------------------ odb/qt/mysql/qdate-traits.hxx | 55 ------------------- odb/qt/mysql/qdatetime-traits.hxx | 109 ------------------------------------- odb/qt/mysql/qstring-traits.hxx | 95 -------------------------------- odb/qt/mysql/qtime-traits.hxx | 55 ------------------- 6 files changed, 415 deletions(-) delete mode 100644 odb/qt/mysql/default-mapping.hxx delete mode 100644 odb/qt/mysql/qbytearray-traits.hxx delete mode 100644 odb/qt/mysql/qdate-traits.hxx delete mode 100644 odb/qt/mysql/qdatetime-traits.hxx delete mode 100644 odb/qt/mysql/qstring-traits.hxx delete mode 100644 odb/qt/mysql/qtime-traits.hxx (limited to 'odb/qt/mysql') diff --git a/odb/qt/mysql/default-mapping.hxx b/odb/qt/mysql/default-mapping.hxx deleted file mode 100644 index 6a948c4..0000000 --- a/odb/qt/mysql/default-mapping.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// file : qt/mysql/default-mapping.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_DEFAULT_MAPPING_HXX -#define ODB_QT_MYSQL_DEFAULT_MAPPING_HXX - -#include -#include -#include -#include - -// Map QString to MySQL TEXT by default. -// -#pragma db value(QString) type("VARCHAR(56) NOT NULL") - -// Map QDate to MySQL DATE by default. -// -#pragma db value(QDate) type("DATE") - -// Map QTime to MySQL TIME by default. -// -#pragma db value(QTime) type("TIME") - -// Map QTime to MySQL DATETIME by default. -// -#pragma db value(QDateTime) type("DATETIME") - -#endif // ODB_QT_MYSQL_DEFAULT_MAPPING_HXX diff --git a/odb/qt/mysql/qbytearray-traits.hxx b/odb/qt/mysql/qbytearray-traits.hxx deleted file mode 100644 index d94bf44..0000000 --- a/odb/qt/mysql/qbytearray-traits.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// file : odb/qt/mysql/qbytearray-traits.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_QBYTEARRAY_TRAITS_HXX -#define ODB_QT_MYSQL_QBYTEARRAY_TRAITS_HXX - -#include - -#include // std::memcpy -#include // std::size_t - -#include - -#include -#include - -namespace odb -{ - namespace mysql - { - template <> - class default_value_traits - { - public: - typedef QByteArray value_type; - typedef QByteArray query_type; - typedef details::buffer image_type; - - static void - set_value (QByteArray& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (is_null) - v = QByteArray (); - else - { - if (v.capacity () < n + 1) - v.reserve (n + 1); - - std::memcpy (v.data (), b.data (), n); - v.resize (n); - } - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const QByteArray& v) - { - if (v.is_null) - is_null = true; - else - { - n = v.size (); - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - std::memcpy (v.data (), b.data (), n); - } - } - }; - } -} - -#endif // ODB_QT_MYSQL_QBYTEARRAY_TRAITS_HXX diff --git a/odb/qt/mysql/qdate-traits.hxx b/odb/qt/mysql/qdate-traits.hxx deleted file mode 100644 index 168e6f9..0000000 --- a/odb/qt/mysql/qdate-traits.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// file : odb/qt/mysql/qdate-traits.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_QDATE_TRAITS_HXX -#define ODB_QT_MYSQL_QDATE_TRAITS_HXX - -#include - -#include - -#include - -namespace odb -{ - namespace mysql - { - template <> - class default_value_traits - { - public: - typedef QDate value_type; - typedef QDate query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (QDate& v, const MYSQL_TIME& i, bool is_null) - { - if (is_null) - // Set the date to be invalid. - // - v.setDate (0, 0, 0); - else - v.setDate (i.year, i.month, i.day); - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const QDate& v) - { - if (v.isNull ()) - is_null = true; - else - { - is_null = false; - i.year = v.year (); - i.month = v.month (); - i.day = v.day (); - } - } - }; - } -} - -#endif // ODB_QT_MYSQL_QDATE_TRAITS_HXX diff --git a/odb/qt/mysql/qdatetime-traits.hxx b/odb/qt/mysql/qdatetime-traits.hxx deleted file mode 100644 index 75cb05e..0000000 --- a/odb/qt/mysql/qdatetime-traits.hxx +++ /dev/null @@ -1,109 +0,0 @@ -// file : odb/qt/mysql/qdatetime-traits.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_QDATETIME_TRAITS_HXX -#define ODB_QT_MYSQL_QDATETIME_TRAITS_HXX - -#include - -#include - -#include - -namespace odb -{ - namespace mysql - { - template <> - class default_value_traits - { - public: - typedef QDateTime value_type; - typedef QDateTime query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (QDateTime& v, const MYSQL_TIME& i, bool is_null) - { - if (is_null) - // Set the date part to be invalid. - // - v.setDate (QDate (0, 0, 0)); - else - { - v.setDate (QDate (i.year, i.month, i.day)); - v.setTime (QTime (i.hour, i.minute, i.second)); - } - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const QDateTime& v) - { - if (v.isNull ()) - is_null = true; - else - { - is_null = false; - - const QDate& d (v.date ()); - i.year = d.year (); - i.month = d.month (); - i.day = d.day (); - - const QTime& t (v.time ()); - i.hour = t.hour (); - i.minute = t.minute (); - i.second = t.second (); - } - } - }; - - template <> - class default_value_traits - { - public: - typedef QDateTime value_type; - typedef QDateTime query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (QDateTime& v, const MYSQL_TIME& i, bool is_null) - { - if (is_null) - // Set the date part to be invalid. - // - v.setDate (QDate (0, 0, 0)); - else - { - v.setDate (QDate (i.year, i.month, i.day)); - v.setTime (QTime (i.hour, i.minute, i.second)); - } - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const QDateTime& v) - { - if (v.isNull ()) - is_null = true; - else - { - is_null = false; - - const QDate& d (v.date ()); - i.year = d.year (); - i.month = d.month (); - i.day = d.day (); - - const QTime& t (v.time ()); - i.hour = t.hour (); - i.minute = t.minute (); - i.second = t.second (); - } - } - }; - } -} - -#endif // ODB_QT_MYSQL_QDATETIME_TRAITS_HXX diff --git a/odb/qt/mysql/qstring-traits.hxx b/odb/qt/mysql/qstring-traits.hxx deleted file mode 100644 index facb569..0000000 --- a/odb/qt/mysql/qstring-traits.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// file : odb/qt/mysql/qstring-traits.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_QSTRING_TRAITS_HXX -#define ODB_QT_MYSQL_QSTRING_TRAITS_HXX - -#include - -#include // std::memcpy -#include // std::size_t - -#include - -#include -#include - -namespace odb -{ - namespace mysql - { - class qstring_value_traits - { - public: - typedef QString value_type; - typedef QString query_type; - typedef details::buffer image_type; - - static void - set_value (QString& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - v = QString::fromUtf8 (b.data (), n); - else - v.clear (); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const QString& v) - { - is_null = false; - - const QByteArray& a (v.toUtf8 ()); - n = a.size (); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - std::memcpy (b.data (), a.data (), n); - } - }; - - template <> - struct default_value_traits< - QString, details::buffer, id_string>: qstring_value_traits - { - }; - - template <> - struct default_value_traits< - QString, details::buffer, id_decimal>: qstring_value_traits - { - }; - - template <> - struct default_value_traits< - QString, details::buffer, id_enum>: qstring_value_traits - { - }; - - template <> - struct default_value_traits< - QString, details::buffer, id_set>: qstring_value_traits - { - }; - - template <> - struct default_type_traits - { - static const database_type_id db_type_id = id_string; - }; - } -} - -#include - -#endif // ODB_QT_MYSQL_QSTRING_TRAITS_HXX diff --git a/odb/qt/mysql/qtime-traits.hxx b/odb/qt/mysql/qtime-traits.hxx deleted file mode 100644 index 9789114..0000000 --- a/odb/qt/mysql/qtime-traits.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// file : odb/qt/mysql/qtime-traits.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ODB_QT_MYSQL_QTIME_TRAITS_HXX -#define ODB_QT_MYSQL_QTIME_TRAITS_HXX - -#include - -#include - -#include - -namespace odb -{ - namespace mysql - { - template <> - class default_value_traits - { - public: - typedef QTime value_type; - typedef QTime query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (QTime& v, const MYSQL_TIME& i, bool is_null) - { - if (is_null) - // Set the time to be invalid. - // - v.setHMS (24, 0, 0); - else - v.setHMS (i.hour, i.minute, i.second); - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const QTime& v) - { - if (v.isNull ()) - is_null = true; - else - { - is_null = false; - i.hour = v.hour (); - i.minute = v.minute (); - i.second = v.second (); - } - } - }; - } -} - -#endif // ODB_QT_MYSQL_QTIME_TRAITS_HXX -- cgit v1.1