aboutsummaryrefslogtreecommitdiff
path: root/odb/qt/mysql
diff options
context:
space:
mode:
Diffstat (limited to 'odb/qt/mysql')
-rw-r--r--odb/qt/mysql/default-mapping.hxx30
-rw-r--r--odb/qt/mysql/qbytearray-traits.hxx71
-rw-r--r--odb/qt/mysql/qdate-traits.hxx55
-rw-r--r--odb/qt/mysql/qdatetime-traits.hxx109
-rw-r--r--odb/qt/mysql/qstring-traits.hxx95
-rw-r--r--odb/qt/mysql/qtime-traits.hxx55
6 files changed, 0 insertions, 415 deletions
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 <constantin@codesynthesis.com>
-// 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 <QString>
-#include <QDate>
-#include <QTime>
-#include <QDateTime>
-
-// 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 <constantin@codesynthesis.com>
-// 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 <odb/pre.hxx>
-
-#include <cstring> // std::memcpy
-#include <cstddef> // std::size_t
-
-#include <QByteArray>
-
-#include <odb/details/buffer.hxx>
-#include <odb/mysql/traits.hxx>
-
-namespace odb
-{
- namespace mysql
- {
- template <>
- class default_value_traits<QByteArray, details::buffer, id_blob>
- {
- 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 <constantin@codesynthesis.com>
-// 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 <odb/pre.hxx>
-
-#include <QDate>
-
-#include <odb/mysql/traits.hxx>
-
-namespace odb
-{
- namespace mysql
- {
- template <>
- class default_value_traits<QDate, MYSQL_TIME, id_date>
- {
- 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 <constantin@codesynthesis.com>
-// 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 <odb/pre.hxx>
-
-#include <QDateTime>
-
-#include <odb/mysql/traits.hxx>
-
-namespace odb
-{
- namespace mysql
- {
- template <>
- class default_value_traits<QDateTime, MYSQL_TIME, id_datetime>
- {
- 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<QDateTime, MYSQL_TIME, id_timestamp>
- {
- 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 <constantin@codesynthesis.com>
-// 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 <odb/pre.hxx>
-
-#include <cstring> // std::memcpy
-#include <cstddef> // std::size_t
-
-#include <QString>
-
-#include <odb/details/buffer.hxx>
-#include <odb/mysql/traits.hxx>
-
-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<QString>
- {
- static const database_type_id db_type_id = id_string;
- };
- }
-}
-
-#include <odb/post.hxx>
-
-#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 <constantin@codesynthesis.com>
-// 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 <odb/pre.hxx>
-
-#include <QTime>
-
-#include <odb/mysql/traits.hxx>
-
-namespace odb
-{
- namespace mysql
- {
- template <>
- class default_value_traits<QTime, MYSQL_TIME, id_time>
- {
- 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