summaryrefslogtreecommitdiff
path: root/odb/relational/schema-source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-03-05 11:59:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-03-05 11:59:00 +0200
commitcd44a367fd73293b1c8edc36aa61667ca020a2eb (patch)
tree1e4ce550a525e23fb7c8c29f18ddda31b61bf066 /odb/relational/schema-source.cxx
parent2528431334b0c8aa07c85ec798be5fc9eb5b2add (diff)
Add support for generating schema creation code into separate C++ file
Diffstat (limited to 'odb/relational/schema-source.cxx')
-rw-r--r--odb/relational/schema-source.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/odb/relational/schema-source.cxx b/odb/relational/schema-source.cxx
new file mode 100644
index 0000000..0acb6c4
--- /dev/null
+++ b/odb/relational/schema-source.cxx
@@ -0,0 +1,44 @@
+// file : odb/relational/schema-source.cxx
+// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
+// license : GNU GPL v3; see accompanying LICENSE file
+
+#include <odb/relational/schema-source.hxx>
+#include <odb/relational/generate.hxx>
+
+using namespace std;
+
+namespace relational
+{
+ namespace schema_source
+ {
+ void
+ generate ()
+ {
+ context ctx;
+ ostream& os (ctx.os);
+
+ traversal::unit unit;
+ traversal::defines unit_defines;
+ traversal::namespace_ ns;
+ instance<class_> c;
+
+ unit >> unit_defines >> ns;
+ unit_defines >> c;
+
+ traversal::defines ns_defines;
+
+ ns >> ns_defines >> ns;
+ ns_defines >> c;
+
+ instance<include> i;
+ i->generate ();
+
+ os << "namespace odb"
+ << "{";
+
+ unit.dispatch (ctx.unit);
+
+ os << "}";
+ }
+ }
+}