aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qt/README2
-rw-r--r--qt/database.hxx22
-rw-r--r--qt/driver.cxx5
-rw-r--r--qt/employee.hxx5
4 files changed, 28 insertions, 6 deletions
diff --git a/qt/README b/qt/README
index b67eea4..111a39b 100644
--- a/qt/README
+++ b/qt/README
@@ -11,7 +11,7 @@ employee.hxx
establish a bidirectional employee-employer relationship. 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. Finally we use QByteArray
- to represent the persons genetic fingerprint.
+ to store the person's public key.
employee-odb.hxx
employee-odb.ixx
diff --git a/qt/database.hxx b/qt/database.hxx
index c7c6957..5b96ae9 100644
--- a/qt/database.hxx
+++ b/qt/database.hxx
@@ -18,6 +18,10 @@
#if defined(DATABASE_MYSQL)
# include <odb/mysql/database.hxx>
+#elif defined(DATABASE_SQLITE)
+# include <odb/transaction.hxx>
+# include <odb/schema-catalog.hxx>
+# include <odb/sqlite/database.hxx>
#endif
inline std::auto_ptr<odb::database>
@@ -33,14 +37,30 @@ create_database (int& argc, char* argv[])
#if defined(DATABASE_MYSQL)
odb::mysql::database::print_usage (cerr);
+#elif defined(DATABASE_SQLITE)
+ odb::sqlite::database::print_usage (cerr);
#endif
exit (0);
}
#if defined(DATABASE_MYSQL)
- return auto_ptr<database> (new odb::mysql::database (argc, argv));
+ auto_ptr<database> db (new odb::mysql::database (argc, argv));
+#elif defined(DATABASE_SQLITE)
+ auto_ptr<database> db (
+ new odb::sqlite::database (
+ argc, argv, false, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE));
+
+ // Create the database schema.
+ //
+ {
+ transaction t (db->begin ());
+ schema_catalog::create_schema (*db);
+ t.commit ();
+ }
#endif
+
+ return db;
}
#endif // DATABASE_HXX
diff --git a/qt/driver.cxx b/qt/driver.cxx
index 5dfe13f..f41e4d6 100644
--- a/qt/driver.cxx
+++ b/qt/driver.cxx
@@ -18,8 +18,7 @@ using namespace odb::core;
ostream& operator << (ostream& os, const QString& s)
{
- os << s.toStdString ();
- return os;
+ return os << s.toStdString ();
}
int
@@ -66,7 +65,7 @@ main (int argc, char* argv[])
t.commit ();
}
- // Complex Systems Inc.dob
+ // Complex Systems Inc.
//
{
shared_ptr<employer> er (new employer ("Complex Systems Inc"));
diff --git a/qt/employee.hxx b/qt/employee.hxx
index 1e39993..60c6980 100644
--- a/qt/employee.hxx
+++ b/qt/employee.hxx
@@ -86,7 +86,10 @@ public:
const QDate& born,
const QByteArray& public_key,
shared_ptr<employer_type> employer)
- : first_ (first), last_ (last), born_(born), public_key_(public_key),
+ : first_ (first),
+ last_ (last),
+ born_ (born),
+ public_key_ (public_key),
employer_ (employer)
{
}