From 8f59ca1a8d7093655f8f7d61f101abc6df3839d5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Mar 2011 12:35:08 +0200 Subject: Generalization work for MySQL and SQLite support --- odb/relational/header.hxx | 72 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 20 deletions(-) (limited to 'odb/relational/header.hxx') diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx index 9394f21..662e3cb 100644 --- a/odb/relational/header.hxx +++ b/odb/relational/header.hxx @@ -171,7 +171,10 @@ namespace relational if (ordered) { data_columns++; - cond_columns++; + + // Index is not currently used (see also bind()). + // + // cond_columns++; } break; } @@ -188,18 +191,24 @@ namespace relational n = 1; data_columns += n; - cond_columns += n; + + // Key is not currently used (see also bind()). + // + // cond_columns += n; + break; } case ck_set: case ck_multiset: { + // Not currently used (see also bind()) + // // Value is also a key. // - if (class_* vc = comp_value (vt)) - cond_columns += in_column_count (*vc); - else - cond_columns++; + //if (class_* vc = comp_value (vt)) + // cond_columns += in_column_count (*vc); + //else + // cond_columns++; break; } @@ -279,7 +288,7 @@ namespace relational } } - os << "typedef mysql::container_statements< " << name << + os << "typedef " << db << "::container_statements< " << name << " > statements_type;" << endl; @@ -389,19 +398,19 @@ namespace relational // bind (cond_image) // os << "static void" << endl - << "bind (MYSQL_BIND*, id_image_type*, cond_image_type&);" + << "bind (" << bind_vector << ", id_image_type*, cond_image_type&);" << endl; // bind (data_image) // os << "static void" << endl - << "bind (MYSQL_BIND*, id_image_type*, data_image_type&);" + << "bind (" << bind_vector << ", id_image_type*, data_image_type&);" << endl; // grow () // os << "static void" << endl - << "grow (data_image_type&, my_bool*);" + << "grow (data_image_type&, " << truncated_vector << ");" << endl; // init (data_image) @@ -642,7 +651,7 @@ namespace relational { // query_base_type // - os << "typedef mysql::query query_base_type;" + os << "typedef " << db << "::query query_base_type;" << endl; // query_type @@ -715,19 +724,19 @@ namespace relational // grow () // os << "static void" << endl - << "grow (image_type&, my_bool*);" + << "grow (image_type&, " << truncated_vector << ");" << endl; // bind (image_type) // os << "static void" << endl - << "bind (MYSQL_BIND*, image_type&, bool);" + << "bind (" << bind_vector << ", image_type&, bool);" << endl; // bind (id_image_type) // os << "static void" << endl - << "bind (MYSQL_BIND*, id_image_type&);" + << "bind (" << bind_vector << ", id_image_type&);" << endl; // init (image, object) @@ -802,7 +811,8 @@ namespace relational // Load the object image. // os << "static bool" << endl - << "find_ (mysql::object_statements< object_type >&, const id_type&);" + << "find_ (" << db << "::object_statements< object_type >&, " << + "const id_type&);" << endl; // Load the rest of the object (containers, etc). Expects the id @@ -810,15 +820,16 @@ namespace relational // id. // os << "static void" << endl - << "load_ (mysql::object_statements< object_type >&, object_type&);" + << "load_ (" << db << "::object_statements< object_type >&, " << + "object_type&);" << endl; if (options.generate_query ()) os << "static void" << endl << "query_ (database&," << endl << "const query_type&," << endl - << "mysql::object_statements< object_type >&," << endl - << "details::shared_ptr< mysql::select_statement >&);" + << db << "::object_statements< object_type >&," << endl + << "details::shared_ptr< " << db << "::select_statement >&);" << endl; os << "};"; @@ -849,13 +860,13 @@ namespace relational // grow () // os << "static bool" << endl - << "grow (image_type&, my_bool*);" + << "grow (image_type&, " << truncated_vector << ");" << endl; // bind (image_type) // os << "static void" << endl - << "bind (MYSQL_BIND*, image_type&);" + << "bind (" << bind_vector << ", image_type&);" << endl; // init (image, object) @@ -877,6 +888,27 @@ namespace relational instance image_type_; instance id_image_member_; }; + + struct include: virtual context + { + typedef include base; + + virtual void + generate () + { + os << "#include " << endl + << endl; + + os << "#include " << endl + << "#include " << endl + << "#include " << endl; + + if (options.generate_query ()) + os << "#include " << endl; + + os << endl; + } + }; } } -- cgit v1.1