From a9a87afc39f815024b1908473a3ed33a82ddd25e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Feb 2011 10:42:41 +0200 Subject: Add odb::core namespace to be used in using-directives Port all the examples and tests. --- doc/manual.xhtml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 5b5e3d6..04a967f 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -1080,14 +1080,14 @@ mysql --user=odb_test --database=odb_test < person.sql #include "person-odb.hxx" using namespace std; -using namespace odb; +using namespace odb::core; int main (int argc, char* argv[]) { try { - auto_ptr<database> db (new mysql::database (argc, argv)); + auto_ptr<database> db (new odb::mysql::database (argc, argv)); unsigned long john_id, jane_id, joe_id; @@ -1128,6 +1128,19 @@ main (int argc, char* argv[]) we include person.hxx and person-odb.hxx which define our persistent person class.

+

Then we have two using namespace directives. The first + one brings in the names from the standard namespace and the second + brings in the ODB declarations which we will use later in the file. + Notice that in the second directive we use the odb::core + namespace instead of just odb. The former only brings + into the current namespace the essential ODB names, such as the + database and transaction classes, without + any of the auxiliary objects. This minimizes the likelihood of name + conflicts with other libraries. Note also that you should continue + using the odb namespace when qualifying individual names. + For example, you should write odb::database, not + odb::core::database.

+

Once we are in main(), the first thing we do is create the MySQL database object. Notice that this is the last line in driver.cxx that mentions MySQL explicitly; the rest @@ -4823,7 +4836,7 @@ CREATE TABLE `person_nickname` ( #include <odb/session.hxx> #include <odb/transaction.hxx> -using namespace odb; +using namespace odb::core; { session s; -- cgit v1.1