aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/qt.options1
-rw-r--r--odb/qt/basic/sqlite/default-mapping.hxx2
-rw-r--r--odb/qt/containers.options20
-rw-r--r--odb/qt/containers/qhash-traits.hxx129
-rw-r--r--odb/qt/containers/qlinked-list-traits.hxx74
-rw-r--r--odb/qt/containers/qlist-traits.hxx73
-rw-r--r--odb/qt/containers/qmap-traits.hxx130
-rw-r--r--odb/qt/containers/qset-traits.hxx70
-rw-r--r--odb/qt/containers/qvector-traits.hxx73
-rw-r--r--odb/qt/date-time/sqlite/qdate-traits.hxx2
10 files changed, 572 insertions, 2 deletions
diff --git a/odb/qt.options b/odb/qt.options
index a1360f2..542e3fe 100644
--- a/odb/qt.options
+++ b/odb/qt.options
@@ -4,5 +4,6 @@
# license : GNU GPL v2; see accompanying LICENSE file
--profile qt/basic
+--profile qt/containers
--profile qt/date-time
--profile qt/smart-ptr
diff --git a/odb/qt/basic/sqlite/default-mapping.hxx b/odb/qt/basic/sqlite/default-mapping.hxx
index ea8108e..7211700 100644
--- a/odb/qt/basic/sqlite/default-mapping.hxx
+++ b/odb/qt/basic/sqlite/default-mapping.hxx
@@ -14,7 +14,7 @@
//
#pragma db value(QString) type("TEXT")
-// Map QByteArray to SQLite TEXT by default. Allow NULL values by default as
+// Map QByteArray to SQLite BLOB by default. Allow NULL values by default as
// QByteArray provides a null representation.
//
#pragma db value(QByteArray) type("BLOB")
diff --git a/odb/qt/containers.options b/odb/qt/containers.options
new file mode 100644
index 0000000..3651b9e
--- /dev/null
+++ b/odb/qt/containers.options
@@ -0,0 +1,20 @@
+# file : odb/qt/containers.options
+# author : Constantin Michael <constantin@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# licences : GNU GPL v2; see accompanying LICENSE file
+
+--profile qt/version
+
+--odb-epilogue '#include <odb/qt/containers/qhash-traits.hxx>'
+--odb-epilogue '#include <odb/qt/containers/qlist-traits.hxx>'
+--odb-epilogue '#include <odb/qt/containers/qlinked-list-traits.hxx>'
+--odb-epilogue '#include <odb/qt/containers/qmap-traits.hxx>'
+--odb-epilogue '#include <odb/qt/containers/qset-traits.hxx>'
+--odb-epilogue '#include <odb/qt/containers/qvector-traits.hxx>'
+
+--hxx-prologue '#include <odb/qt/containers/qhash-traits.hxx>'
+--hxx-prologue '#include <odb/qt/containers/qlist-traits.hxx>'
+--hxx-prologue '#include <odb/qt/containers/qlinked-list-traits.hxx>'
+--hxx-prologue '#include <odb/qt/containers/qmap-traits.hxx>'
+--hxx-prologue '#include <odb/qt/containers/qset-traits.hxx>'
+--hxx-prologue '#include <odb/qt/containers/qvector-traits.hxx>'
diff --git a/odb/qt/containers/qhash-traits.hxx b/odb/qt/containers/qhash-traits.hxx
new file mode 100644
index 0000000..c34b768
--- /dev/null
+++ b/odb/qt/containers/qhash-traits.hxx
@@ -0,0 +1,129 @@
+// file : odb/qt/containers/qhash-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_CONTAINER_QHASH_TRAITS_HXX
+#define ODB_QT_CONTAINER_QHASH_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QHash>
+#include <QMultiHash>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename Key, typename T>
+ class access::container_traits<QHash<Key, T> >
+ {
+ public:
+ static container_kind const kind = ck_map;
+
+ typedef QHash<Key, T> container_type;
+ typedef Key key_type;
+ typedef T value_type;
+
+ typedef map_functions<key_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ key_type k;
+ value_type v;
+ more = f.load_all (k, v);
+ c.insert (k, v);
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+
+ // @@ QMultiHash guarantees elements to be stored in reverse order of
+ // insertion. The current implementation of the generated code does
+ // not guarantee this.
+ //
+ template <typename Key, typename T>
+ class access::container_traits<QMultiHash<Key, T> >
+ {
+ public:
+ static container_kind const kind = ck_multimap;
+
+ typedef QMultiHash<Key, T> container_type;
+ typedef Key key_type;
+ typedef T value_type;
+
+ typedef map_functions<key_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ key_type k;
+ value_type v;
+ more = f.load_all (k, v);
+ c.insert (k, v);
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QHASH_TRAITS_HXX
diff --git a/odb/qt/containers/qlinked-list-traits.hxx b/odb/qt/containers/qlinked-list-traits.hxx
new file mode 100644
index 0000000..708e240
--- /dev/null
+++ b/odb/qt/containers/qlinked-list-traits.hxx
@@ -0,0 +1,74 @@
+// file : odb/qt/containers/qlinked-list-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_CONTAINER_QLINKED_LIST_TRAITS_HXX
+#define ODB_QT_CONTAINER_QLINKED_LIST_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QLinkedList>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename T>
+ class access::container_traits<QLinkedList<T> >
+ {
+ public:
+ static container_kind const kind = ck_ordered;
+
+ typedef QLinkedList<T> container_type;
+
+ typedef T value_type;
+ typedef typename container_type::size_type index_type;
+
+ typedef ordered_functions<index_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ index_type i (0);
+ for (typename container_type::const_iterator j (c.begin ()),
+ e (c.end ()); j != e; ++j)
+ f.insert_one (i++, *j);
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ index_type dummy;
+ c.append (value_type ());
+ more = f.load_all (dummy, c.back ());
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ index_type i (0);
+ for (typename container_type::const_iterator j (c.begin ()),
+ e (c.end ()); j != e; ++j)
+ f.insert_one (i++, *j);
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QLINKED_LIST_TRAITS_HXX
diff --git a/odb/qt/containers/qlist-traits.hxx b/odb/qt/containers/qlist-traits.hxx
new file mode 100644
index 0000000..9ac7cbf
--- /dev/null
+++ b/odb/qt/containers/qlist-traits.hxx
@@ -0,0 +1,73 @@
+// file : odb/qt/containers/qlist-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_CONTAINER_QLIST_TRAITS_HXX
+#define ODB_QT_CONTAINER_QLIST_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QList>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename T>
+ class access::container_traits<QList<T> >
+ {
+ public:
+ static const container_kind kind = ck_ordered;
+
+ typedef QList<T> container_type;
+
+ typedef T value_type;
+ typedef typename container_type::size_type index_type;
+
+ typedef ordered_functions<index_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ // Index based access is just as fast as iterator based access for
+ // QList.
+ //
+ for (index_type i (0), n (c.size ()); i < n; ++i)
+ f.insert_one (i, c[i]);
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ index_type dummy;
+ c.append (value_type ());
+ more = f.load_all (dummy, c.back ());
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (index_type i (0), n (c.size ()); i < n; ++i)
+ f.insert_one (i, c[i]);
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QLIST_TRAITS_HXX
diff --git a/odb/qt/containers/qmap-traits.hxx b/odb/qt/containers/qmap-traits.hxx
new file mode 100644
index 0000000..854dc87
--- /dev/null
+++ b/odb/qt/containers/qmap-traits.hxx
@@ -0,0 +1,130 @@
+// file : odb/qt/containers/qmap-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_CONTAINER_QMAP_TRAITS_HXX
+#define ODB_QT_CONTAINER_QMAP_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QMap>
+#include <QMultiMap>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename Key, typename T>
+ class access::container_traits<QMap<Key, T> >
+ {
+ public:
+ static const container_kind kind = ck_map;
+
+ typedef QMap<Key, T> container_type;
+
+ typedef Key key_type;
+ typedef T value_type;
+
+ typedef map_functions<key_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ key_type k;
+ value_type v;
+ more = f.load_all (k, v);
+ c.insert (k, v);
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+ // @@ QMultiMap guarantees elements to be stored in reverse order of
+ // insertion. The current implementation of the generated code does
+ // not guarantee this.
+ //
+ template <typename Key, typename T>
+ class access::container_traits<QMultiMap<Key, T> >
+ {
+ public:
+ static const container_kind kind = ck_multimap;
+
+ typedef QMultiMap<Key, T> container_type;
+
+ typedef Key key_type;
+ typedef T value_type;
+
+ typedef map_functions<key_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ key_type k;
+ value_type v;
+ more = f.load_all (k, v);
+ c.insert (k, v);
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (i.key (), i.value ());
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QMAP_TRAITS_HXX
diff --git a/odb/qt/containers/qset-traits.hxx b/odb/qt/containers/qset-traits.hxx
new file mode 100644
index 0000000..13216b9
--- /dev/null
+++ b/odb/qt/containers/qset-traits.hxx
@@ -0,0 +1,70 @@
+// file : odb/qt/containers/qset-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_CONTAINER_QSET_TRAITS_HXX
+#define ODB_QT_CONTAINER_QSET_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QSet>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename T>
+ class access::container_traits<QSet<T> >
+ {
+ public:
+ static const container_kind kind = ck_set;
+
+ typedef QSet<T> container_type;
+ typedef T value_type;
+
+ typedef set_functions<value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (*i);
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ value_type v;
+ more = f.load_all (v);
+ c.insert (v);
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (typename container_type::const_iterator i (c.begin ()),
+ e (c.end ()); i != e; ++i)
+ f.insert_one (*i);
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QSET_TRAITS_HXX
diff --git a/odb/qt/containers/qvector-traits.hxx b/odb/qt/containers/qvector-traits.hxx
new file mode 100644
index 0000000..c86aa01
--- /dev/null
+++ b/odb/qt/containers/qvector-traits.hxx
@@ -0,0 +1,73 @@
+// file : odb/qt/containers/qvector-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_CONTAINER_QVECTOR_TRAITS_HXX
+#define ODB_QT_CONTAINER_QVECTOR_TRAITS_HXX
+
+#include <odb/pre.hxx>
+
+#include <QVector>
+
+#include <odb/container-traits.hxx>
+
+namespace odb
+{
+ template <typename T>
+ class access::container_traits<QVector<T> >
+ {
+ public:
+ static const container_kind kind = ck_ordered;
+
+ typedef QVector<T> container_type;
+
+ typedef T value_type;
+ typedef typename container_type::size_type index_type;
+
+ typedef ordered_functions<index_type, value_type> functions;
+
+ public:
+ static void
+ persist (const container_type& c, const functions& f)
+ {
+ // Index based access is just as fast as iterator based access for
+ // QVector.
+ //
+ for (index_type i (0), n (c.size ()); i < n; ++i)
+ f.insert_one (i, c[i]);
+ }
+
+ static void
+ load (container_type& c, bool more, const functions& f)
+ {
+ c.clear ();
+
+ while (more)
+ {
+ index_type dummy;
+ c.append (value_type ());
+ more = f.load_all (dummy, c.back ());
+ }
+ }
+
+ static void
+ update (const container_type& c, const functions& f)
+ {
+ f.delete_all ();
+
+ for (index_type i (0), n (c.size ()); i < n; ++i)
+ f.insert_one (i, c[i]);
+ }
+
+ static void
+ erase (const functions& f)
+ {
+ f.delete_all ();
+ }
+ };
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_QT_CONTAINER_QVECTOR_TRAITS_HXX
diff --git a/odb/qt/date-time/sqlite/qdate-traits.hxx b/odb/qt/date-time/sqlite/qdate-traits.hxx
index d8df614..16940c3 100644
--- a/odb/qt/date-time/sqlite/qdate-traits.hxx
+++ b/odb/qt/date-time/sqlite/qdate-traits.hxx
@@ -93,7 +93,7 @@ namespace odb
{
QDateTime dt;
dt.setTimeSpec (Qt::UTC);
- dt.setTime_t(static_cast<uint> (i));
+ dt.setTime_t (static_cast<uint> (i));
v = dt.date ();
}