summaryrefslogtreecommitdiff
path: root/libodb-qt/odb/qt/basic
diff options
context:
space:
mode:
Diffstat (limited to 'libodb-qt/odb/qt/basic')
-rw-r--r--libodb-qt/odb/qt/basic/basic-common.options4
-rw-r--r--libodb-qt/odb/qt/basic/basic-mssql.options13
-rw-r--r--libodb-qt/odb/qt/basic/basic-mysql.options13
-rw-r--r--libodb-qt/odb/qt/basic/basic-oracle.options13
-rw-r--r--libodb-qt/odb/qt/basic/basic-pgsql.options13
-rw-r--r--libodb-qt/odb/qt/basic/basic-sqlite.options13
-rw-r--r--libodb-qt/odb/qt/basic/mssql/default-mapping.hxx29
-rw-r--r--libodb-qt/odb/qt/basic/mssql/qbyte-array-traits.hxx177
-rw-r--r--libodb-qt/odb/qt/basic/mssql/qstring-traits.hxx372
-rw-r--r--libodb-qt/odb/qt/basic/mssql/quuid-traits.hxx58
-rw-r--r--libodb-qt/odb/qt/basic/mysql/default-mapping.hxx28
-rw-r--r--libodb-qt/odb/qt/basic/mysql/qbyte-array-traits.hxx78
-rw-r--r--libodb-qt/odb/qt/basic/mysql/qstring-traits.hxx93
-rw-r--r--libodb-qt/odb/qt/basic/mysql/quuid-traits.hxx74
-rw-r--r--libodb-qt/odb/qt/basic/oracle/default-mapping.hxx27
-rw-r--r--libodb-qt/odb/qt/basic/oracle/qbyte-array-traits.hxx167
-rw-r--r--libodb-qt/odb/qt/basic/oracle/qstring-traits.hxx206
-rw-r--r--libodb-qt/odb/qt/basic/oracle/quuid-traits.hxx70
-rw-r--r--libodb-qt/odb/qt/basic/pgsql/default-mapping.hxx27
-rw-r--r--libodb-qt/odb/qt/basic/pgsql/qbyte-array-traits.hxx77
-rw-r--r--libodb-qt/odb/qt/basic/pgsql/qstring-traits.hxx74
-rw-r--r--libodb-qt/odb/qt/basic/pgsql/quuid-traits.hxx65
-rw-r--r--libodb-qt/odb/qt/basic/sqlite/default-mapping.hxx27
-rw-r--r--libodb-qt/odb/qt/basic/sqlite/qbyte-array-traits.hxx77
-rw-r--r--libodb-qt/odb/qt/basic/sqlite/qstring-traits.hxx83
-rw-r--r--libodb-qt/odb/qt/basic/sqlite/quuid-traits.hxx74
26 files changed, 1952 insertions, 0 deletions
diff --git a/libodb-qt/odb/qt/basic/basic-common.options b/libodb-qt/odb/qt/basic/basic-common.options
new file mode 100644
index 0000000..f704314
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-common.options
@@ -0,0 +1,4 @@
+# file : odb/qt/basic/basic-common.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
diff --git a/libodb-qt/odb/qt/basic/basic-mssql.options b/libodb-qt/odb/qt/basic/basic-mssql.options
new file mode 100644
index 0000000..2234df5
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-mssql.options
@@ -0,0 +1,13 @@
+# file : odb/qt/basic/basic-mssql.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+# Include the default mapping in prologue instead of epilogue to
+# allow the user to override the default mapping.
+#
+--odb-prologue '#include <odb/qt/basic/mssql/default-mapping.hxx>'
+
+--hxx-prologue '#include <odb/qt/basic/mssql/qstring-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/mssql/qbyte-array-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/mssql/quuid-traits.hxx>'
diff --git a/libodb-qt/odb/qt/basic/basic-mysql.options b/libodb-qt/odb/qt/basic/basic-mysql.options
new file mode 100644
index 0000000..d049f4e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-mysql.options
@@ -0,0 +1,13 @@
+# file : odb/qt/basic/basic-mysql.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+# Include the default mapping in prologue instead of epilogue to
+# allow the user to override the default mapping.
+#
+--odb-prologue '#include <odb/qt/basic/mysql/default-mapping.hxx>'
+
+--hxx-prologue '#include <odb/qt/basic/mysql/qstring-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/mysql/qbyte-array-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/mysql/quuid-traits.hxx>'
diff --git a/libodb-qt/odb/qt/basic/basic-oracle.options b/libodb-qt/odb/qt/basic/basic-oracle.options
new file mode 100644
index 0000000..60ef9d0
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-oracle.options
@@ -0,0 +1,13 @@
+# file : odb/qt/basic/basic-oracle.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+# Include the default mapping in prologue instead of epilogue to
+# allow the user to override the default mapping.
+#
+--odb-prologue '#include <odb/qt/basic/oracle/default-mapping.hxx>'
+
+--hxx-prologue '#include <odb/qt/basic/oracle/qstring-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/oracle/qbyte-array-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/oracle/quuid-traits.hxx>'
diff --git a/libodb-qt/odb/qt/basic/basic-pgsql.options b/libodb-qt/odb/qt/basic/basic-pgsql.options
new file mode 100644
index 0000000..6f0dc6e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-pgsql.options
@@ -0,0 +1,13 @@
+# file : odb/qt/basic/basic-pgsql.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+# Include the default mapping in prologue instead of epilogue to
+# allow the user to override the default mapping.
+#
+--odb-prologue '#include <odb/qt/basic/pgsql/default-mapping.hxx>'
+
+--hxx-prologue '#include <odb/qt/basic/pgsql/qstring-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/pgsql/qbyte-array-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/pgsql/quuid-traits.hxx>'
diff --git a/libodb-qt/odb/qt/basic/basic-sqlite.options b/libodb-qt/odb/qt/basic/basic-sqlite.options
new file mode 100644
index 0000000..c64e37c
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/basic-sqlite.options
@@ -0,0 +1,13 @@
+# file : odb/qt/basic/basic-sqlite.options
+# license : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+# Include the default mapping in prologue instead of epilogue to
+# allow the user to override the default mapping.
+#
+--odb-prologue '#include <odb/qt/basic/sqlite/default-mapping.hxx>'
+
+--hxx-prologue '#include <odb/qt/basic/sqlite/qstring-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/sqlite/qbyte-array-traits.hxx>'
+--hxx-prologue '#include <odb/qt/basic/sqlite/quuid-traits.hxx>'
diff --git a/libodb-qt/odb/qt/basic/mssql/default-mapping.hxx b/libodb-qt/odb/qt/basic/mssql/default-mapping.hxx
new file mode 100644
index 0000000..19fd43b
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mssql/default-mapping.hxx
@@ -0,0 +1,29 @@
+// file : odb/qt/basic/mssql/default-mapping.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MSSQL_DEFAULT_MAPPING_HXX
+#define ODB_QT_BASIC_MSSQL_DEFAULT_MAPPING_HXX
+
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
+
+// By default map QString to SQL Server VARCHAR(512) for non-id members
+// and to VARCHAR(256) for id members (the same as the default mapping
+// for std::string). Allow NULL values by default as QString provides
+// a null representation.
+//
+#pragma db value(QString) type("VARCHAR(512)") id_type("VARCHAR(256)") null
+
+// By default map QByteArray to SQL Server VARBINARY(max). Allow NULL
+// values by default as QByteArray provides a null representation.
+//
+#pragma db value(QByteArray) type("VARBINARY(max)") null
+
+// By default map QUuid to SQL Server UNIQUEIDENTIFIER and use NULL to
+// represent null UUIDs. If NULL is disabled (e.g., at the member level),
+// then we store the null UUID (i.e., all bytes are zero).
+//
+#pragma db value(QUuid) type("UNIQUEIDENTIFIER") null
+
+#endif // ODB_QT_BASIC_MSSQL_DEFAULT_MAPPING_HXX
diff --git a/libodb-qt/odb/qt/basic/mssql/qbyte-array-traits.hxx b/libodb-qt/odb/qt/basic/mssql/qbyte-array-traits.hxx
new file mode 100644
index 0000000..8047691
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mssql/qbyte-array-traits.hxx
@@ -0,0 +1,177 @@
+// file : odb/qt/basic/mssql/qbyte-array-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MSSQL_QBYTE_ARRAY_TRAITS_HXX
+#define ODB_QT_BASIC_MSSQL_QBYTE_ARRAY_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+#include <cassert>
+
+#include <QtCore/QByteArray>
+
+#include <odb/mssql/traits.hxx>
+
+namespace odb
+{
+ namespace mssql
+ {
+ template <>
+ struct default_value_traits<QByteArray, id_binary>
+ {
+ typedef QByteArray value_type;
+ typedef QByteArray query_type;
+ typedef char* image_type;
+
+ static void
+ set_value (QByteArray& v, const char* b, std::size_t n, bool is_null)
+ {
+ if (is_null)
+ v = QByteArray ();
+ else
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b, n);
+ }
+ }
+
+ static void
+ set_image (char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ n = static_cast<std::size_t> (v.size ());
+
+ if (n > c)
+ n = c;
+
+ std::memcpy (b, v.constData (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QByteArray, id_long_binary>
+ {
+ typedef QByteArray value_type;
+ typedef QByteArray query_type;
+ typedef long_callback image_type;
+
+ static void
+ set_value (QByteArray& v,
+ result_callback_type& cb,
+ void*& context)
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ param_callback (const void* context,
+ std::size_t*,
+ const void** buffer,
+ std::size_t* size,
+ chunk_type* chunk,
+ void*,
+ std::size_t)
+ {
+ const QByteArray& v (*static_cast<const QByteArray*> (context));
+
+ *buffer = v.constData ();
+ *size = static_cast<std::size_t> (v.size ());
+ *chunk = chunk_one;
+ }
+
+ static void
+ result_callback (void* context,
+ std::size_t*,
+ void** buffer,
+ std::size_t* size,
+ chunk_type chunk,
+ std::size_t size_left,
+ void*,
+ std::size_t)
+ {
+ QByteArray& v (*static_cast<QByteArray*> (context));
+
+ switch (chunk)
+ {
+ case chunk_null:
+ {
+ v = QByteArray ();
+ break;
+ }
+ case chunk_one:
+ {
+ v.clear ();
+ break;
+ }
+ case chunk_first:
+ {
+ // The Native Client ODBC driver seems to always be able to
+ // return the total size. This makes things simple and
+ // efficient.
+ //
+ assert (size_left != 0);
+
+ v.resize (static_cast<int> (size_left));
+ *buffer = v.data ();
+ *size = size_left;
+ break;
+ }
+ case chunk_next:
+ {
+ // We should never get here.
+ //
+ assert (false);
+ break;
+ }
+ case chunk_last:
+ {
+ // Nothing to do here. The array is already of the correct size
+ // and should contain the data.
+ break;
+ }
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QByteArray>
+ {
+ static const database_type_id db_type_id = id_long_binary;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_MSSQL_QBYTE_ARRAY_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/mssql/qstring-traits.hxx b/libodb-qt/odb/qt/basic/mssql/qstring-traits.hxx
new file mode 100644
index 0000000..779120e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mssql/qstring-traits.hxx
@@ -0,0 +1,372 @@
+// file : odb/qt/basic/mssql/qstring-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MSSQL_QSTRING_TRAITS_HXX
+#define ODB_QT_BASIC_MSSQL_QSTRING_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+#include <cassert>
+
+#include <QtCore/QString>
+
+#include <odb/mssql/traits.hxx>
+
+namespace odb
+{
+ namespace mssql
+ {
+ template <>
+ struct default_value_traits<QString, id_string>
+ {
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef char* image_type;
+
+ static void
+ set_value (QString& v,
+ const char* b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (is_null)
+ v = QString ();
+ else
+ // On Windows the string data is in Windows code page. On Linux
+ // it is always UTF-8.
+ //
+#ifdef _WIN32
+ v = QString::fromLocal8Bit (b, static_cast<int> (n));
+#else
+ v = QString::fromUtf8 (b, static_cast<int> (n));
+#endif
+ }
+
+ static void
+ set_image (char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+#ifdef _WIN32
+ const QByteArray& a (v.toLocal8Bit ());
+#else
+ const QByteArray& a (v.toUtf8 ());
+#endif
+ n = static_cast<std::size_t> (a.size ());
+
+ if (n > c)
+ n = c;
+
+ std::memcpy (b, a.constData (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QString, id_nstring>
+ {
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef ucs2_char* image_type;
+
+ static void
+ set_value (QString& v,
+ const ucs2_char* b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (is_null)
+ v = QString ();
+ else
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b, n * 2);
+ }
+ }
+
+ static void
+ set_image (ucs2_char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ n = static_cast<std::size_t> (v.size ());
+
+ if (n > c)
+ n = c;
+
+ std::memcpy (b, v.constData (), n * 2);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QString, id_long_string>
+ {
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef long_callback image_type;
+
+ static void
+ set_value (QString& v,
+ result_callback_type& cb,
+ void*& context)
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ param_callback (const void* context,
+ std::size_t* position,
+ const void** buffer,
+ std::size_t* size,
+ chunk_type* chunk,
+ void* tmp_buf,
+ std::size_t tmp_capacity)
+ {
+ const QString& s (*static_cast<const QString*> (context));
+
+#ifdef _WIN32
+ const QByteArray& v (s.toLocal8Bit ());
+#else
+ const QByteArray& v (s.toUtf8 ());
+#endif
+
+ *size = static_cast<std::size_t> (v.size ());
+
+ if (*position == 0)
+ {
+ if (*size <= tmp_capacity)
+ *chunk = chunk_one;
+ else
+ {
+ *size = tmp_capacity;
+ *chunk = chunk_first;
+ }
+ }
+ else
+ {
+ *size -= *position;
+
+ if (*size <= tmp_capacity)
+ *chunk = chunk_last;
+ else
+ {
+ *size = tmp_capacity;
+ *chunk = chunk_next;
+ }
+ }
+
+ //@@ We might split a multi-byte sequence. Microsoft ODBC driver
+ // doesn't support this.
+ //
+ std::memcpy (tmp_buf, v.constData () + *position, *size);
+ *buffer = tmp_buf;
+ *position += *size;
+ }
+
+ static void
+ result_callback (void* context,
+ std::size_t*,
+ void** buffer,
+ std::size_t* size,
+ chunk_type chunk,
+ std::size_t,
+ void* tmp_buf,
+ std::size_t tmp_capacity)
+ {
+ QString& v (*static_cast<QString*> (context));
+
+ switch (chunk)
+ {
+ case chunk_null:
+ {
+ v = QString ();
+ break;
+ }
+ case chunk_one:
+ {
+ v.clear ();
+ break;
+ }
+ case chunk_first:
+ {
+ break;
+ }
+ case chunk_next:
+ case chunk_last:
+ {
+ // Append the data from the temporary buffer.
+ //
+#ifdef _WIN32
+ v += QString::fromLocal8Bit (static_cast<char*> (tmp_buf),
+ static_cast<int> (*size));
+#else
+ v += QString::fromUtf8 (static_cast<char*> (tmp_buf),
+ static_cast<int> (*size));
+#endif
+ break;
+ }
+ }
+
+ if (chunk == chunk_first || chunk == chunk_next)
+ {
+ *buffer = tmp_buf;
+ *size = tmp_capacity;
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QString, id_long_nstring>
+ {
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef long_callback image_type;
+
+ static void
+ set_value (QString& v,
+ result_callback_type& cb,
+ void*& context)
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ param_callback (const void* context,
+ std::size_t*,
+ const void** buffer,
+ std::size_t* size,
+ chunk_type* chunk,
+ void*,
+ std::size_t)
+ {
+ const QString& v (*static_cast<const QString*> (context));
+
+ *buffer = v.constData ();
+ *size = static_cast<std::size_t> (v.size ()) * 2;
+ *chunk = chunk_one;
+ }
+
+ static void
+ result_callback (void* context,
+ std::size_t*,
+ void** buffer,
+ std::size_t* size,
+ chunk_type chunk,
+ std::size_t size_left,
+ void*,
+ std::size_t)
+ {
+ QString& v (*static_cast<QString*> (context));
+
+ switch (chunk)
+ {
+ case chunk_null:
+ {
+ v = QString ();
+ break;
+ }
+ case chunk_one:
+ {
+ v.clear ();
+ break;
+ }
+ case chunk_first:
+ {
+ // The Native Client ODBC driver seems to always be able to
+ // return the total size. This makes things simple and
+ // efficient.
+ //
+ assert (size_left != 0);
+
+ size_left /= 2; // Convert to characters.
+ size_left++; // One extra for the null terminator.
+
+ v.resize (static_cast<int> (size_left));
+ *buffer = v.data ();
+ *size = size_left * 2; // In bytes.
+ break;
+ }
+ case chunk_next:
+ {
+ // We should never get here.
+ //
+ assert (false);
+ break;
+ }
+ case chunk_last:
+ {
+ // Get rid of the null terminator.
+ //
+ v.resize (static_cast<int> (*size / 2));
+ break;
+ }
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QString>
+ {
+ static const database_type_id db_type_id = id_long_string;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_MSSQL_QSTRING_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/mssql/quuid-traits.hxx b/libodb-qt/odb/qt/basic/mssql/quuid-traits.hxx
new file mode 100644
index 0000000..d65b80f
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mssql/quuid-traits.hxx
@@ -0,0 +1,58 @@
+// file : odb/qt/basic/mssql/uuid-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MSSQL_UUID_TRAITS_HXX
+#define ODB_QT_BASIC_MSSQL_UUID_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+
+#include <QtCore/QUuid>
+
+#include <odb/mssql/traits.hxx>
+
+namespace odb
+{
+ namespace mssql
+ {
+ template <>
+ class default_value_traits<QUuid, id_uniqueidentifier>
+ {
+ public:
+ typedef QUuid value_type;
+ typedef value_type query_type;
+ typedef uniqueidentifier image_type;
+
+ static void
+ set_value (value_type& v, const uniqueidentifier& i, bool is_null)
+ {
+ if (!is_null)
+ std::memcpy (&v.data1, &i, 16);
+ else
+ v = QUuid ();
+ }
+
+ static void
+ set_image (uniqueidentifier& i, bool& is_null, const value_type& v)
+ {
+ // If we can, store nil as NULL. Otherwise, store it as a value.
+ //
+ is_null = is_null && v.isNull ();
+
+ if (!is_null)
+ std::memcpy (&i, &v.data1, 16);
+ }
+ };
+
+ template <>
+ struct default_type_traits<QUuid>
+ {
+ static const database_type_id db_type_id = id_uniqueidentifier;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_MSSQL_UUID_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/mysql/default-mapping.hxx b/libodb-qt/odb/qt/basic/mysql/default-mapping.hxx
new file mode 100644
index 0000000..996895f
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mysql/default-mapping.hxx
@@ -0,0 +1,28 @@
+// file : odb/qt/basic/mysql/default-mapping.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MYSQL_DEFAULT_MAPPING_HXX
+#define ODB_QT_BASIC_MYSQL_DEFAULT_MAPPING_HXX
+
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
+
+// Map QString to MySQL TEXT for non-id and to VARCHAR(128) for id members.
+// MySQL cannot have primary key of the TEXT type. Allow NULL values by
+// default as QString provides a null representation.
+//
+#pragma db value(QString) type("TEXT") id_type("VARCHAR(128)") null
+
+// Map QByteArray to MySQL BLOB by default. Allow NULL values by default as
+// QByteArray provides a null representation.
+//
+#pragma db value(QByteArray) type("BLOB") null
+
+// By default map QUuid to MySQL BINARY(16) and use NULL to represent null
+// UUIDs. If NULL is disabled (e.g., at the member level), then we store
+// the null UUID (i.e., all bytes are zero).
+//
+#pragma db value(QUuid) type("BINARY(16)") null
+
+#endif // ODB_QT_BASIC_MYSQL_DEFAULT_MAPPING_HXX
diff --git a/libodb-qt/odb/qt/basic/mysql/qbyte-array-traits.hxx b/libodb-qt/odb/qt/basic/mysql/qbyte-array-traits.hxx
new file mode 100644
index 0000000..bfcfc69
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mysql/qbyte-array-traits.hxx
@@ -0,0 +1,78 @@
+// file : odb/qt/basic/mysql/qbyte-array-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MYSQL_QBYTE_ARRAY_TRAITS_HXX
+#define ODB_QT_BASIC_MYSQL_QBYTE_ARRAY_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QByteArray>
+
+#include <odb/details/buffer.hxx>
+#include <odb/mysql/traits.hxx>
+
+namespace odb
+{
+ namespace mysql
+ {
+ template <>
+ struct default_value_traits<QByteArray, id_blob>
+ {
+ 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
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ n = static_cast<std::size_t> (v.size ());
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), v.data (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QByteArray>
+ {
+ static const database_type_id db_type_id = id_blob;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_MYSQL_QBYTE_ARRAY_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/mysql/qstring-traits.hxx b/libodb-qt/odb/qt/basic/mysql/qstring-traits.hxx
new file mode 100644
index 0000000..6a5f315
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mysql/qstring-traits.hxx
@@ -0,0 +1,93 @@
+// file : odb/qt/basic/mysql/qstring-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MYSQL_QSTRING_TRAITS_HXX
+#define ODB_QT_BASIC_MYSQL_QSTRING_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/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 ();
+ else
+ v = QString::fromUtf8 (b.data (), static_cast<int> (n));
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ const QByteArray& a (v.toUtf8 ());
+ n = static_cast<std::size_t> (a.size ());
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), a.data (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QString, id_string>: qstring_value_traits
+ {
+ };
+
+ template <>
+ struct default_value_traits<QString, id_decimal>: qstring_value_traits
+ {
+ };
+
+ template <>
+ struct default_value_traits<QString, id_enum>: qstring_value_traits
+ {
+ };
+
+ template <>
+ struct default_value_traits<QString, 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_BASIC_MYSQL_QSTRING_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/mysql/quuid-traits.hxx b/libodb-qt/odb/qt/basic/mysql/quuid-traits.hxx
new file mode 100644
index 0000000..c672ee8
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/mysql/quuid-traits.hxx
@@ -0,0 +1,74 @@
+// file : odb/qt/basic/mysql/uuid-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_MYSQL_UUID_TRAITS_HXX
+#define ODB_QT_BASIC_MYSQL_UUID_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cassert>
+
+#include <QtCore/QUuid>
+
+#include <odb/mysql/traits.hxx>
+
+namespace odb
+{
+ namespace mysql
+ {
+ template <>
+ struct default_value_traits<QUuid, id_blob>
+ {
+ typedef QUuid value_type;
+ typedef value_type query_type;
+ typedef details::buffer image_type;
+
+ static void
+ set_value (value_type& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (!is_null)
+ {
+ assert (n == 16);
+ std::memcpy (&v.data1, b.data (), 16);
+ }
+ else
+ v = QUuid ();
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const value_type& v)
+ {
+ // If we can, store nil as NULL. Otherwise, store it as a value.
+ //
+ is_null = is_null && v.isNull ();
+
+ if (!is_null)
+ {
+ n = 16;
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), &v.data1, n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QUuid>
+ {
+ static const database_type_id db_type_id = id_blob;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_MYSQL_UUID_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/oracle/default-mapping.hxx b/libodb-qt/odb/qt/basic/oracle/default-mapping.hxx
new file mode 100644
index 0000000..8d72206
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/oracle/default-mapping.hxx
@@ -0,0 +1,27 @@
+// file : odb/qt/basic/oracle/default-mapping.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_ORACLE_DEFAULT_MAPPING_HXX
+#define ODB_QT_BASIC_ORACLE_DEFAULT_MAPPING_HXX
+
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
+
+// Map QString to Oracle VARCHAR2 by default. Allow NULL values by default as
+// QString provides a null representation.
+//
+#pragma db value(QString) type("VARCHAR2(512)") null
+
+// Map QByteArray to Oracle BLOB by default. Allow NULL values by default as
+// QByteArray provides a null representation.
+//
+#pragma db value(QByteArray) type("BLOB") null
+
+// By default map QUuid to Oracle RAW(16) and use NULL to represent null
+// UUIDs. If NULL is disabled (e.g., at the member level), then we store
+// the null UUID (i.e., all bytes are zero).
+//
+#pragma db value(QUuid) type("RAW(16)") null
+
+#endif // ODB_QT_BASIC_ORACLE_DEFAULT_MAPPING_HXX
diff --git a/libodb-qt/odb/qt/basic/oracle/qbyte-array-traits.hxx b/libodb-qt/odb/qt/basic/oracle/qbyte-array-traits.hxx
new file mode 100644
index 0000000..6979cc9
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/oracle/qbyte-array-traits.hxx
@@ -0,0 +1,167 @@
+// file : odb/qt/basic/oracle/qbyte-array-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_ORACLE_QBYTE_ARRAY_TRAITS_HXX
+#define ODB_QT_BASIC_ORACLE_QBYTE_ARRAY_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QByteArray>
+
+#include <odb/oracle/traits.hxx>
+
+namespace odb
+{
+ namespace oracle
+ {
+ template <>
+ struct default_value_traits<QByteArray, id_raw>
+ {
+ typedef QByteArray value_type;
+ typedef QByteArray query_type;
+ typedef char* image_type;
+
+ static void
+ set_value (QByteArray& v,
+ const char* b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (is_null)
+ v = QByteArray ();
+ else
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b, n);
+ }
+ }
+
+ static void
+ set_image (char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ n = static_cast<std::size_t> (v.size ());
+
+ if (n > c)
+ n = c;
+
+ std::memcpy (b, v.constData (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits<QByteArray, id_blob>
+ {
+ typedef QByteArray value_type;
+ typedef QByteArray query_type;
+ typedef lob_callback image_type;
+
+ static void
+ set_value (QByteArray& v,
+ result_callback_type& cb,
+ void*& context,
+ bool is_null)
+ {
+ if (is_null)
+ v = QByteArray ();
+ else
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static bool
+ result_callback (void* context,
+ ub4*,
+ void* b,
+ ub4 s,
+ chunk_position p)
+ {
+ QByteArray& v (*static_cast<QByteArray*> (context));
+
+ switch (p)
+ {
+ case chunk_one:
+ case chunk_first:
+ {
+ v.clear ();
+
+ // Falling through.
+ }
+ case chunk_next:
+ case chunk_last:
+ {
+ v.append (static_cast<char*> (b), static_cast<int> (s));
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ static bool
+ param_callback (const void* context,
+ ub4*,
+ const void** b,
+ ub4* s,
+ chunk_position* p,
+ void*,
+ ub4)
+ {
+ const QByteArray& v (*static_cast<const QByteArray*> (context));
+
+ *p = chunk_one;
+ *s = static_cast<ub4> (v.size ());
+ *b = v.constData ();
+
+ return true;
+ }
+ };
+
+ template <>
+ struct default_type_traits<QByteArray>
+ {
+ // Allow use of QByteArray in query expressions by default by specifying
+ // the default type id as RAW.
+ //
+ static const database_type_id db_type_id = id_raw;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_ORACLE_QBYTE_ARRAY_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/oracle/qstring-traits.hxx b/libodb-qt/odb/qt/basic/oracle/qstring-traits.hxx
new file mode 100644
index 0000000..418d30e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/oracle/qstring-traits.hxx
@@ -0,0 +1,206 @@
+// file : odb/qt/basic/oracle/qstring-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_ORACLE_QSTRING_TRAITS_HXX
+#define ODB_QT_BASIC_ORACLE_QSTRING_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QString>
+
+#include <odb/oracle/traits.hxx>
+
+namespace odb
+{
+ namespace oracle
+ {
+ struct qstring_value_traits
+ {
+ public:
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef char* image_type;
+
+ static void
+ set_value (QString& v,
+ const char* b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (is_null)
+ v = QString ();
+ else
+ v = QString::fromUtf8 (b, static_cast<int> (n));
+ }
+
+ static void
+ set_image (char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ const QByteArray& a (v.toUtf8 ());
+
+ n = static_cast<std::size_t> (a.size ());
+
+ if (n > c)
+ n = c;
+
+ std::memcpy (b, a.constData (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_value_traits <QString, id_string>: qstring_value_traits
+ {
+ };
+
+ template <>
+ struct default_value_traits <QString, id_nstring>: qstring_value_traits
+ {
+ };
+
+ class qstring_lob_value_traits
+ {
+ public:
+ typedef QString value_type;
+ typedef QString query_type;
+ typedef lob_callback image_type;
+
+ static void
+ set_value (QString& v,
+ result_callback_type& cb,
+ void*& context,
+ bool is_null)
+ {
+ if (is_null)
+ v = QString ();
+ else
+ {
+ cb = &result_callback;
+ context = &v;
+ }
+ }
+
+ static void
+ set_image (param_callback_type& cb,
+ const void*& context,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ cb = &param_callback;
+ context = &v;
+ }
+ }
+
+ static bool
+ result_callback (void* context,
+ ub4*,
+ void* b,
+ ub4 s,
+ chunk_position p)
+ {
+ QString& v (*static_cast<QString*> (context));
+
+ switch (p)
+ {
+ case chunk_one:
+ case chunk_first:
+ {
+ v.clear ();
+
+ // Falling through.
+ }
+ case chunk_next:
+ case chunk_last:
+ {
+ v += QString::fromUtf8(static_cast<char*> (b),
+ static_cast<int> (s));
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ static bool
+ param_callback (const void* context,
+ ub4* position_context,
+ const void** b,
+ ub4* s,
+ chunk_position* p,
+ void* temp_buffer,
+ ub4 capacity)
+ {
+ const QByteArray& v (static_cast<const QString*> (context)->toUtf8 ());
+
+ *s = static_cast<ub4> (v.size ());
+
+ if (*position_context == 0)
+ {
+ if (*s <= capacity)
+ *p = chunk_one;
+ else
+ {
+ *s = capacity;
+ *p = chunk_first;
+ }
+ }
+ else
+ {
+ *s -= *position_context;
+
+ if (*s <= capacity)
+ *p = chunk_last;
+ else
+ {
+ *s = capacity;
+ *p = chunk_next;
+ }
+ }
+
+ std::memcpy (temp_buffer, v.constData () + *position_context, *s);
+ *b = temp_buffer;
+ *position_context += *s;
+
+ return true;
+ }
+ };
+
+ template <>
+ struct default_value_traits<QString, id_clob>: qstring_lob_value_traits
+ {
+ };
+
+ template <>
+ struct default_value_traits<QString, id_nclob>: qstring_lob_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_BASIC_ORACLE_QSTRING_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/oracle/quuid-traits.hxx b/libodb-qt/odb/qt/basic/oracle/quuid-traits.hxx
new file mode 100644
index 0000000..5f8041e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/oracle/quuid-traits.hxx
@@ -0,0 +1,70 @@
+// file : odb/qt/basic/oracle/uuid-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_ORACLE_UUID_TRAITS_HXX
+#define ODB_QT_BASIC_ORACLE_UUID_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cassert>
+
+#include <QtCore/QUuid>
+
+#include <odb/oracle/traits.hxx>
+
+namespace odb
+{
+ namespace oracle
+ {
+ template <>
+ struct default_value_traits<QUuid, id_raw>
+ {
+ public:
+ typedef QUuid value_type;
+ typedef value_type query_type;
+ typedef char* image_type;
+
+ static void
+ set_value (value_type& v, const char* b, std::size_t n, bool is_null)
+ {
+ if (!is_null)
+ {
+ assert (n == 16);
+ std::memcpy (&v.data1, b, 16);
+ }
+ else
+ v = QUuid ();
+ }
+
+ static void
+ set_image (char* b,
+ std::size_t c,
+ std::size_t& n,
+ bool& is_null,
+ const value_type& v)
+ {
+ // If we can, store nil as NULL. Otherwise, store it as a value.
+ //
+ is_null = is_null && v.isNull ();
+
+ if (!is_null)
+ {
+ n = 16;
+ assert (c >= n);
+ std::memcpy (b, &v.data1, n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QUuid>
+ {
+ static const database_type_id db_type_id = id_raw;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_ORACLE_UUID_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/pgsql/default-mapping.hxx b/libodb-qt/odb/qt/basic/pgsql/default-mapping.hxx
new file mode 100644
index 0000000..13dbeb8
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/pgsql/default-mapping.hxx
@@ -0,0 +1,27 @@
+// file : odb/qt/basic/pgsql/default-mapping.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_PGSQL_DEFAULT_MAPPING_HXX
+#define ODB_QT_BASIC_PGSQL_DEFAULT_MAPPING_HXX
+
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
+
+// Map QString to PostgreSQL TEXT by default. Allow NULL values by default as
+// QString provides a null representation.
+//
+#pragma db value(QString) type("TEXT") null
+
+// Map QByteArray to PostgreSQL BYTEA by default. Allow NULL values by default
+// as QByteArray provides a null representation.
+//
+#pragma db value(QByteArray) type("BYTEA") null
+
+// By default map QUuid to PostgreSQL UUID and use NULL to represent null
+// UUIDs. If NULL is disabled (e.g., at the member level), then we store
+// the null UUID (i.e., all bytes are zero).
+//
+#pragma db value(QUuid) type("UUID") null
+
+#endif // ODB_QT_BASIC_PGSQL_DEFAULT_MAPPING_HXX
diff --git a/libodb-qt/odb/qt/basic/pgsql/qbyte-array-traits.hxx b/libodb-qt/odb/qt/basic/pgsql/qbyte-array-traits.hxx
new file mode 100644
index 0000000..3c3c496
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/pgsql/qbyte-array-traits.hxx
@@ -0,0 +1,77 @@
+// file : odb/qt/basic/pgsql/qbyte-array-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_PGSQL_QBYTE_ARRAY_TRAITS_HXX
+#define ODB_QT_BASIC_PGSQL_QBYTE_ARRAY_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QByteArray>
+
+#include <odb/details/buffer.hxx>
+#include <odb/pgsql/traits.hxx>
+
+namespace odb
+{
+ namespace pgsql
+ {
+ template <>
+ struct default_value_traits<QByteArray, id_bytea>
+ {
+ 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
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ n = static_cast<std::size_t> (v.size ());
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), v.data (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QByteArray>
+ {
+ static const database_type_id db_type_id = id_bytea;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_PGSQL_QBYTE_ARRAY_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/pgsql/qstring-traits.hxx b/libodb-qt/odb/qt/basic/pgsql/qstring-traits.hxx
new file mode 100644
index 0000000..f1ab53c
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/pgsql/qstring-traits.hxx
@@ -0,0 +1,74 @@
+// file : odb/qt/basic/pgsql/qstring-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_PGSQL_QSTRING_TRAITS_HXX
+#define ODB_QT_BASIC_PGSQL_QSTRING_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QString>
+
+#include <odb/details/buffer.hxx>
+#include <odb/pgsql/traits.hxx>
+
+namespace odb
+{
+ namespace pgsql
+ {
+ template <>
+ struct default_value_traits <QString, id_string>
+ {
+ 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 ();
+ else
+ v = QString::fromUtf8 (b.data (), static_cast<int> (n));
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ const QByteArray& a (v.toUtf8 ());
+ n = static_cast<std::size_t> (a.size ());
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), a.data (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QString>
+ {
+ static const database_type_id db_type_id = id_string;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_PGSQL_QSTRING_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/pgsql/quuid-traits.hxx b/libodb-qt/odb/qt/basic/pgsql/quuid-traits.hxx
new file mode 100644
index 0000000..5999b7e
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/pgsql/quuid-traits.hxx
@@ -0,0 +1,65 @@
+// file : odb/qt/basic/pgsql/uuid-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_PGSQL_UUID_TRAITS_HXX
+#define ODB_QT_BASIC_PGSQL_UUID_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+
+#include <QtCore/QUuid>
+
+#include <odb/pgsql/traits.hxx>
+
+namespace odb
+{
+ namespace pgsql
+ {
+ template <>
+ class default_value_traits<QUuid, id_uuid>
+ {
+ public:
+ typedef QUuid value_type;
+ typedef value_type query_type;
+ typedef unsigned char* image_type;
+
+ // PostgreSQL binary UUID representation is big-endian in the RFC 4122,
+ // section 4.1.2 order. While Qt provides (since 4.8) to/fromRfc4122(),
+ // they both incur a memory allocation (by QByteArray) which we could
+ // avoid, if we did it ourselves.
+ //
+
+ static void
+ set_value (value_type& v, const unsigned char* i, bool is_null)
+ {
+ if (!is_null)
+ v = QUuid::fromRfc4122 (
+ QByteArray (reinterpret_cast<const char*> (i), 16));
+ else
+ v = QUuid ();
+ }
+
+ static void
+ set_image (unsigned char* i, bool& is_null, const value_type& v)
+ {
+ // If we can, store nil as NULL. Otherwise, store it as a value.
+ //
+ is_null = is_null && v.isNull ();
+
+ if (!is_null)
+ std::memcpy (i, v.toRfc4122 ().constData (), 16);
+ }
+ };
+
+ template <>
+ struct default_type_traits<QUuid>
+ {
+ static const database_type_id db_type_id = id_uuid;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_PGSQL_UUID_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/sqlite/default-mapping.hxx b/libodb-qt/odb/qt/basic/sqlite/default-mapping.hxx
new file mode 100644
index 0000000..7d14a6c
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/sqlite/default-mapping.hxx
@@ -0,0 +1,27 @@
+// file : odb/qt/basic/sqlite/default-mapping.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_SQLITE_DEFAULT_MAPPING_HXX
+#define ODB_QT_BASIC_SQLITE_DEFAULT_MAPPING_HXX
+
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QUuid>
+
+// Map QString to SQLite TEXT by default. Allow NULL values by default as
+// QString provides a null representation.
+//
+#pragma db value(QString) type("TEXT") null
+
+// Map QByteArray to SQLite BLOB by default. Allow NULL values by default as
+// QByteArray provides a null representation.
+//
+#pragma db value(QByteArray) type("BLOB") null
+
+// By default map QUuid to SQLite BLOB and use NULL to represent null UUIDs.
+// If NULL is disabled (e.g., at the member level), then we store the null
+// UUID (i.e., all bytes are zero).
+//
+#pragma db value(QUuid) type("BLOB") null
+
+#endif // ODB_QT_BASIC_SQLITE_DEFAULT_MAPPING_HXX
diff --git a/libodb-qt/odb/qt/basic/sqlite/qbyte-array-traits.hxx b/libodb-qt/odb/qt/basic/sqlite/qbyte-array-traits.hxx
new file mode 100644
index 0000000..8a26bb1
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/sqlite/qbyte-array-traits.hxx
@@ -0,0 +1,77 @@
+// file : odb/qt/basic/sqlite/qbyte-array-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_SQLITE_QBYTE_ARRAY_TRAITS_HXX
+#define ODB_QT_BASIC_SQLITE_QBYTE_ARRAY_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QByteArray>
+
+#include <odb/details/buffer.hxx>
+#include <odb/sqlite/traits.hxx>
+
+namespace odb
+{
+ namespace sqlite
+ {
+ template <>
+ struct default_value_traits<QByteArray, id_blob>
+ {
+ 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
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QByteArray& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+
+ n = static_cast<std::size_t> (v.size ());
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), v.data (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QByteArray>
+ {
+ static const database_type_id db_type_id = id_blob;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_SQLITE_QBYTE_ARRAY_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/sqlite/qstring-traits.hxx b/libodb-qt/odb/qt/basic/sqlite/qstring-traits.hxx
new file mode 100644
index 0000000..30a2136
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/sqlite/qstring-traits.hxx
@@ -0,0 +1,83 @@
+// file : odb/qt/basic/sqlite/qstring-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_SQLITE_QSTRING_TRAITS_HXX
+#define ODB_QT_BASIC_SQLITE_QSTRING_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cstddef> // std::size_t
+
+#include <QtCore/QString>
+
+#include <odb/details/buffer.hxx>
+#include <odb/sqlite/traits.hxx>
+
+namespace odb
+{
+ namespace sqlite
+ {
+ template <>
+ struct image_traits<QString, id_text>
+ {
+ typedef details::buffer image_type;
+
+ // Use UTF-16 binding for QString.
+ //
+ static const bind::buffer_type bind_value = bind::text16;
+ };
+
+ template <>
+ struct default_value_traits <QString, id_text>
+ {
+ 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 ();
+ else
+ v.setUtf16 (reinterpret_cast<const ushort*> (b.data ()),
+ static_cast<int> (n / 2)); // In characters.
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const QString& v)
+ {
+ if (v.isNull ())
+ is_null = true;
+ else
+ {
+ is_null = false;
+ n = static_cast<std::size_t> (v.size ()) * 2; // In bytes.
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), v.utf16 (), n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QString>
+ {
+ static const database_type_id db_type_id = id_text;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_SQLITE_QSTRING_TRAITS_HXX
diff --git a/libodb-qt/odb/qt/basic/sqlite/quuid-traits.hxx b/libodb-qt/odb/qt/basic/sqlite/quuid-traits.hxx
new file mode 100644
index 0000000..20d4a94
--- /dev/null
+++ b/libodb-qt/odb/qt/basic/sqlite/quuid-traits.hxx
@@ -0,0 +1,74 @@
+// file : odb/qt/basic/sqlite/uuid-traits.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_QT_BASIC_SQLITE_UUID_TRAITS_HXX
+#define ODB_QT_BASIC_SQLITE_UUID_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <cstring> // std::memcpy
+#include <cassert>
+
+#include <QtCore/QUuid>
+
+#include <odb/sqlite/traits.hxx>
+
+namespace odb
+{
+ namespace sqlite
+ {
+ template <>
+ struct default_value_traits<QUuid, id_blob>
+ {
+ typedef QUuid value_type;
+ typedef value_type query_type;
+ typedef details::buffer image_type;
+
+ static void
+ set_value (value_type& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (!is_null)
+ {
+ assert (n == 16);
+ std::memcpy (&v.data1, b.data (), 16);
+ }
+ else
+ v = QUuid ();
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const value_type& v)
+ {
+ // If we can, store nil as NULL. Otherwise, store it as a value.
+ //
+ is_null = is_null && v.isNull ();
+
+ if (!is_null)
+ {
+ n = 16;
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ std::memcpy (b.data (), &v.data1, n);
+ }
+ }
+ };
+
+ template <>
+ struct default_type_traits<QUuid>
+ {
+ static const database_type_id db_type_id = id_blob;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_BASIC_SQLITE_UUID_TRAITS_HXX