summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-14 15:05:26 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 11:47:13 +0200
commit8c37ec27c06341572d947342869345e59f7bdcf5 (patch)
tree8d80239d90e76cc76122b17f84d900f0676c447a
parent9aa4062b27b52fb8348f125dc58ccca48f3366ac (diff)
Allow per database specialization of schema_emitter
-rw-r--r--odb/relational/schema.cxx37
-rw-r--r--odb/relational/schema.hxx33
2 files changed, 36 insertions, 34 deletions
diff --git a/odb/relational/schema.cxx b/odb/relational/schema.cxx
index df871e7..4c3bfd0 100644
--- a/odb/relational/schema.cxx
+++ b/odb/relational/schema.cxx
@@ -115,37 +115,6 @@ namespace relational
}
}
- struct schema_emitter: emitter, context
- {
- virtual void
- pre ()
- {
- first_ = true;
- }
-
- virtual void
- line (const std::string& l)
- {
- if (first_)
- first_ = false;
- else
- os << endl;
-
- os << l;
- }
-
- virtual void
- post ()
- {
- if (!first_) // Ignore empty statements.
- os << ';' << endl
- << endl;
- }
-
- private:
- bool first_;
- };
-
static char const file_header[] =
"/* This file was generated by ODB, object-relational mapping (ORM)\n"
" * compiler for C++.\n"
@@ -159,7 +128,7 @@ namespace relational
os << file_header;
- schema_emitter emitter;
+ instance<schema_emitter> emitter;
// Drop.
//
@@ -167,7 +136,7 @@ namespace relational
traversal::unit unit;
traversal::defines unit_defines;
traversal::namespace_ ns;
- instance<class_drop> c (emitter);
+ instance<class_drop> c (*emitter);
unit >> unit_defines >> ns;
unit_defines >> c;
@@ -194,7 +163,7 @@ namespace relational
traversal::unit unit;
traversal::defines unit_defines;
traversal::namespace_ ns;
- instance<class_create> c (emitter);
+ instance<class_create> c (*emitter);
unit >> unit_defines >> ns;
unit_defines >> c;
diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx
index 8e56ff9..2911c40 100644
--- a/odb/relational/schema.hxx
+++ b/odb/relational/schema.hxx
@@ -44,6 +44,39 @@ namespace relational
ostream& os_;
};
+ struct schema_emitter: emitter, virtual context
+ {
+ typedef schema_emitter base;
+
+ virtual void
+ pre ()
+ {
+ first_ = true;
+ }
+
+ virtual void
+ line (const std::string& l)
+ {
+ if (first_)
+ first_ = false;
+ else
+ os << endl;
+
+ os << l;
+ }
+
+ virtual void
+ post ()
+ {
+ if (!first_) // Ignore empty statements.
+ os << ';' << endl
+ << endl;
+ }
+
+ private:
+ bool first_;
+ };
+
//
// Drop.
//