diff options
Diffstat (limited to 'odb-examples/c++11')
-rw-r--r-- | odb-examples/c++11/README | 16 | ||||
-rw-r--r-- | odb-examples/c++11/buildfile | 2 | ||||
-rw-r--r-- | odb-examples/c++11/driver.cxx | 4 | ||||
-rw-r--r-- | odb-examples/c++11/employee.hxx | 10 | ||||
-rw-r--r-- | odb-examples/c++11/testscript | 3 |
5 files changed, 17 insertions, 18 deletions
diff --git a/odb-examples/c++11/README b/odb-examples/c++11/README index 638b9a2..0cf15ac 100644 --- a/odb-examples/c++11/README +++ b/odb-examples/c++11/README @@ -31,7 +31,7 @@ employee.sql employee.hxx Where <database> stands for the database system we are using, for example, - 'mysql'. + 'pgsql'. database.hxx Contains the create_database() function which instantiates the concrete @@ -50,25 +50,25 @@ driver.cxx relationships. Finally, the driver performs a database query and iterates over the result printing basic information about the returned objects. -To compile and link the example manually from the command line we can use -the following commands (using MySQL as an example; replace 'c++' with your +To compile and link the example manually from the command line we can use the +following commands (using PostgreSQL as an example; replace 'c++' with your C++ compiler name): c++ -c employee-odb.cxx -c++ -DDATABASE_MYSQL -c driver.cxx -c++ -o driver driver.o employee-odb.o -lodb-mysql -lodb +c++ DDATABASE_PGSQL -c driver.cxx +c++ -o driver driver.o employee-odb.o -lodb-pgsql -lodb To run the example we may first need to create the database schema (for some database systems, such as SQLite, the schema is embedded into the generated -code which makes this step unnecessary). Using MySQL as an example, this +code which makes this step unnecessary). Using PostgreSQL as an example, this can be achieved with the following command: -mysql --user=odb_test --database=odb_test < employee.sql +psql --username=odb_test --dbname=odb_test -f employee.sql Here we use 'odb_test' as the database login and also 'odb_test' as the database name. -Once the database schema is ready, we can run the example (using MySQL as +Once the database schema is ready, we can run the example (using PostgreSQL as the database): ./driver --user odb_test --database odb_test diff --git a/odb-examples/c++11/buildfile b/odb-examples/c++11/buildfile index e921434..8788275 100644 --- a/odb-examples/c++11/buildfile +++ b/odb-examples/c++11/buildfile @@ -1,5 +1,5 @@ # file : c++11/buildfile -# license : GNU GPL v2; see accompanying LICENSE file +# license : not copyrighted - public domain import libodb = libodb%lib{odb} diff --git a/odb-examples/c++11/driver.cxx b/odb-examples/c++11/driver.cxx index 68793b1..d722882 100644 --- a/odb-examples/c++11/driver.cxx +++ b/odb-examples/c++11/driver.cxx @@ -176,8 +176,8 @@ main (int argc, char* argv[]) // Search for Complex Systems Inc employees with the John first name. // { - typedef odb::query<employee> query; - typedef odb::result<employee> result; + using query = odb::query<employee>; + using result = odb::result<employee>; session s; transaction t (db->begin ()); diff --git a/odb-examples/c++11/employee.hxx b/odb-examples/c++11/employee.hxx index a921e31..94bc4ba 100644 --- a/odb-examples/c++11/employee.hxx +++ b/odb-examples/c++11/employee.hxx @@ -34,7 +34,7 @@ public: // Employees of this employer. // - typedef std::vector<odb::lazy_weak_ptr<employee>> employees_type; + using employees_type = std::vector<odb::lazy_weak_ptr<employee>>; const employees_type& employees () const @@ -64,7 +64,7 @@ private: class employee { public: - typedef ::employer employer_type; + using employer_type = ::employer; employee (const std::string& first, const std::string& last, @@ -89,7 +89,7 @@ public: // Emails. // - typedef std::unordered_set<std::string> emails_type; + using emails_type = std::unordered_set<std::string>; const emails_type& emails () const @@ -123,7 +123,7 @@ private: employee () {} #pragma db id auto - unsigned long id_; + unsigned long long id_; std::string first_; std::string last_; @@ -153,7 +153,7 @@ public: // Members of this fund. // - typedef std::vector<odb::lazy_shared_ptr<employee>> members_type; + using members_type = std::vector<odb::lazy_shared_ptr<employee>>; const members_type& members () const diff --git a/odb-examples/c++11/testscript b/odb-examples/c++11/testscript index cb942f6..27634a3 100644 --- a/odb-examples/c++11/testscript +++ b/odb-examples/c++11/testscript @@ -1,12 +1,11 @@ # file : cxx11/testscript -# license : GNU GPL v2; see accompanying LICENSE file +# license : not copyrighted - public domain .include ../database-options.testscript .include ../$(database).testscript +if! $sqlite $create_schema -end : basics : |