From 0e272ec96fbcce93ec3be49eca753a7cd0079893 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 Sep 2012 14:58:54 +0200 Subject: Support for Qt QUuid persistence This support was added to the basic sub-profile. New test: qt/common/basic. Updated the qt example to use QUuid as an object id. --- qt/README | 7 ++++--- qt/driver.cxx | 1 + qt/employee.hxx | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/qt/README b/qt/README index 077edba..2b30003 100644 --- a/qt/README +++ b/qt/README @@ -11,9 +11,10 @@ employee.hxx establish a bidirectional employee-employer relationship. The QList type is used to store the collection of employees employed by the employer. We also use the QDateTime type to store the employee's date - of birth and QString to store the employee's first and last name. A - QSet instance keeps track of the employee's email addresses. Finally - we use QByteArray to store the employee's public key. + of birth and QString to store the employee's first and last name. While + the employee's object id is QUuid and a QSet instance keeps track of + the employee's email addresses. Finally we use QByteArray to store the + employee's public key. employee-odb.hxx employee-odb.ixx diff --git a/qt/driver.cxx b/qt/driver.cxx index 3d05703..377594f 100644 --- a/qt/driver.cxx +++ b/qt/driver.cxx @@ -144,6 +144,7 @@ main (int argc, char* argv[]) cout << " public key length: " << p->publicKey ().size () << endl << " employer: " << pe->name () << endl + << " id: " << p->id ().toString () << endl << endl; } diff --git a/qt/employee.hxx b/qt/employee.hxx index f2c34da..82bbcfb 100644 --- a/qt/employee.hxx +++ b/qt/employee.hxx @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,8 @@ public: const QDate& born, const QByteArray& publicKey, QSharedPointer employer) - : first_ (first), + : id_ (QUuid::createUuid ()), + first_ (first), last_ (last), born_ (born), publicKey_ (publicKey), @@ -80,6 +82,14 @@ public: { } + // Id. + // + const QUuid& + id () const + { + return id_; + } + // Name. // const QString& @@ -141,8 +151,8 @@ private: Employee () {} - #pragma db id auto - unsigned long id_; + #pragma db id + QUuid id_; QString first_; QString last_; -- cgit v1.1