aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-10 08:44:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-21 15:39:59 +0200
commit7ae497743c7b042904fe1f6b4153ab3f4763ff2b (patch)
tree08ba3f742f20d16d893856ccceb070094bd69225 /odb/relational/source.cxx
parent2436f20262a41bd1cafa5107ab6d6799c03e0964 (diff)
Split MySQL code generator into common and db-specific parts
The common part (in relational/) still has some MySQL-specific parts. Also, add the notion of the current context which is used to avoid explicitly passing the context object to every generator's c-tor.
Diffstat (limited to 'odb/relational/source.cxx')
-rw-r--r--odb/relational/source.cxx79
1 files changed, 79 insertions, 0 deletions
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
new file mode 100644
index 0000000..be9da93
--- /dev/null
+++ b/odb/relational/source.cxx
@@ -0,0 +1,79 @@
+// file : odb/relational/source.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v3; see accompanying LICENSE file
+
+#include <odb/relational/source.hxx>
+#include <odb/relational/generate.hxx>
+
+using namespace std;
+
+namespace relational
+{
+ namespace source
+ {
+ void
+ generate ()
+ {
+ context ctx;
+ ostream& os (ctx.os);
+ options const& ops (ctx.options);
+
+ traversal::unit unit;
+ traversal::defines unit_defines;
+ traversal::namespace_ ns;
+ class_ c;
+
+ unit >> unit_defines >> ns;
+ unit_defines >> c;
+
+ traversal::defines ns_defines;
+
+ ns >> ns_defines >> ns;
+ ns_defines >> c;
+
+ //
+ //
+ os << "#include <odb/cache-traits.hxx>" << endl;
+
+ if (ctx.embedded_schema)
+ os << "#include <odb/schema-catalog-impl.hxx>" << endl;
+
+ os << endl;
+
+ //
+ //
+ os << "#include <odb/mysql/mysql.hxx>" << endl
+ << "#include <odb/mysql/traits.hxx>" << endl
+ << "#include <odb/mysql/database.hxx>" << endl
+ << "#include <odb/mysql/transaction.hxx>" << endl
+ << "#include <odb/mysql/connection.hxx>" << endl
+ << "#include <odb/mysql/statement.hxx>" << endl
+ << "#include <odb/mysql/statement-cache.hxx>" << endl
+ << "#include <odb/mysql/object-statements.hxx>" << endl
+ << "#include <odb/mysql/container-statements.hxx>" << endl
+ << "#include <odb/mysql/exceptions.hxx>" << endl;
+
+ if (ops.generate_query ())
+ os << "#include <odb/mysql/result.hxx>" << endl;
+
+ os << endl;
+
+ // Details includes.
+ //
+ os << "#include <odb/details/unused.hxx>" << endl;
+
+ if (ops.generate_query ())
+ os << "#include <odb/details/shared-ptr.hxx>" << endl;
+
+ os << endl;
+
+ os << "namespace odb"
+ << "{";
+
+ unit.dispatch (ctx.unit);
+
+ os << "}";
+ }
+ }
+}