aboutsummaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
Diffstat (limited to 'qt')
-rw-r--r--qt/README10
-rw-r--r--qt/driver.cxx21
-rw-r--r--qt/employee.hxx15
-rw-r--r--qt/makefile4
-rw-r--r--qt/person.hxx41
-rw-r--r--qt/qt-vc10.vcxproj8
-rw-r--r--qt/qt-vc9.vcproj8
7 files changed, 66 insertions, 41 deletions
diff --git a/qt/README b/qt/README
index 4e94255..94663e1 100644
--- a/qt/README
+++ b/qt/README
@@ -4,13 +4,13 @@ containers, and value types with the help of the Qt profile library
The example consists of the following files:
-employee.hxx
+person.hxx
Describe contents.
-employee-odb.hxx
-employee-odb.ixx
-employee-odb.cxx
-employee.sql
+person-odb.hxx
+person-odb.ixx
+person-odb.cxx
+person.sql
The first three files contain the database support code and the last file
contains the database schema for the employee.hxx header.
diff --git a/qt/driver.cxx b/qt/driver.cxx
index 14f0c0e..1d4e2b3 100644
--- a/qt/driver.cxx
+++ b/qt/driver.cxx
@@ -11,8 +11,8 @@
#include "database.hxx" // create_database
-#include "employee.hxx"
-#include "employee-odb.hxx"
+#include "person.hxx"
+#include "person-odb.hxx"
using namespace std;
using namespace odb::core;
@@ -24,18 +24,17 @@ main (int argc, char* argv[])
{
auto_ptr<database> db (create_database (argc, argv));
- employee e;
- e.name = "John Doe";
+ person p1;
+ p1.name = "Constantin Michael";
+ p1.date_of_birth.setDate (1979, 03, 07);
- QChar* c = e.name.data ();
-
- while (!c->isNull ())
+ // Persist.
+ //
{
- cout << c->toAscii ();
- ++c;
+ transaction t (db->begin ());
+ db->persist (p1);
+ t.commit ();
}
-
- cout << endl;
}
catch (const odb::exception& e)
{
diff --git a/qt/employee.hxx b/qt/employee.hxx
deleted file mode 100644
index 2fc124d..0000000
--- a/qt/employee.hxx
+++ /dev/null
@@ -1,15 +0,0 @@
-// file : qt/employee.hxx
-// author : Constantin Michael <constantin@codesynthesis.com>
-// copyright : not copyrighted - public domain
-
-#ifndef EMPLOYEE_HXX
-#define EMPLOYEE_HXX
-
-#include <QString>
-
-struct employee
-{
- QString name;
-};
-
-#endif // EMPLOYEE_HXX
diff --git a/qt/makefile b/qt/makefile
index 17e9290..a47858d 100644
--- a/qt/makefile
+++ b/qt/makefile
@@ -6,7 +6,7 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
cxx_tun := driver.cxx
-odb_hdr := employee.hxx
+odb_hdr := person.hxx
cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
cxx_od := $(cxx_obj:.o=.o.d)
@@ -59,7 +59,7 @@ gen := $(addprefix $(out_base)/,$(genf))
$(gen): $(odb)
$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --database $(db_id) \
+$(gen) $(dist): export odb_options += --database $(db_id) --profile qt \
--generate-query --generate-schema
$(gen): cpp_options := -I$(out_base)
$(gen): $(odb.l.cpp-options) $(odb_qt.l.cpp-options) $(qt.l.cpp-options)
diff --git a/qt/person.hxx b/qt/person.hxx
new file mode 100644
index 0000000..28460c4
--- /dev/null
+++ b/qt/person.hxx
@@ -0,0 +1,41 @@
+// file : qt/person.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#ifndef EMPLOYEE_HXX
+#define EMPLOYEE_HXX
+
+#include <QString>
+#include <QDate>
+#include <QTime>
+#include <QDateTime>
+
+#pragma db object
+struct time_punchcard
+{
+ #pragma db id auto
+ unsigned long id;
+
+ QDateTime date_time;
+};
+
+#pragma db object
+struct person
+{
+ bool
+ operator== (const person& x) const
+ {
+ return name == x.name &&
+ date_of_birth == x.date_of_birth &&
+ time_of_birth == x.time_of_birth;
+ }
+
+ #pragma db id
+ QString name;
+
+ #pragma db type("DATE NOT NULL")
+ QDate date_of_birth;
+ QTime time_of_birth;
+};
+
+#endif // EMPLOYEE_HXX
diff --git a/qt/qt-vc10.vcxproj b/qt/qt-vc10.vcxproj
index d252a8a..da70445 100644
--- a/qt/qt-vc10.vcxproj
+++ b/qt/qt-vc10.vcxproj
@@ -92,7 +92,7 @@
<DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>odb-__value__(database)-d.lib;odb-qt-d.lib;qt-core-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>odb-__value__(database)-d.lib;QtCored4.lib;odb-qt-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
@@ -107,7 +107,7 @@
<DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>odb-__value__(database)-d.lib;odb-qt-d.lib;qt-core-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>odb-__value__(database)-d.lib;QtCored4.lib;odb-qt-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
@@ -124,7 +124,7 @@
<DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>odb-__value__(database).lib;odb-qt.lib;qt-core.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>odb-__value__(database).lib;QtCore4.lib;odb-qt.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -143,7 +143,7 @@
<DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>odb-__value__(database).lib;odb-qt.lib;qt-core.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>odb-__value__(database).lib;QtCore4.lib;odb-qt.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
diff --git a/qt/qt-vc9.vcproj b/qt/qt-vc9.vcproj
index 0e7ed9c..81e3fd6 100644
--- a/qt/qt-vc9.vcproj
+++ b/qt/qt-vc9.vcproj
@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odb-__value__(database)-d.lib odb-qt-d.lib odb-d.lib qt-core-d.lib"
+ AdditionalDependencies="odb-__value__(database)-d.lib QtCored4.lib odb-qt-d.lib odb-d.lib"
OutputFile="$(OutDir)\driver.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
@@ -139,7 +139,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odb-__value__(database).lib odb-qt.lib odb.lib qt-core.lib"
+ AdditionalDependencies="odb-__value__(database).lib QtCore4.lib odb-qt.lib odb.lib"
OutputFile="$(OutDir)\driver.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
@@ -216,7 +216,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odb-__value__(database)-d.lib odb-qt-d.lib odb-d.lib qt-core-d.lib"
+ AdditionalDependencies="odb-__value__(database)-d.lib QtCored4.lib odb-qt-d.lib odb-d.lib"
OutputFile="$(OutDir)\driver.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
@@ -292,7 +292,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odb-__value__(database).lib odb-qt.lib odb.lib qt-core.lib"
+ AdditionalDependencies="odb-__value__(database).lib QtCore4.lib odb-qt.lib odb.lib"
OutputFile="$(OutDir)\driver.exe"
LinkIncremental="1"
GenerateDebugInformation="true"