From 8c37ec27c06341572d947342869345e59f7bdcf5 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Fri, 14 Oct 2011 15:05:26 +0200 Subject: Allow per database specialization of schema_emitter --- odb/relational/schema.cxx | 37 +++---------------------------------- odb/relational/schema.hxx | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 34 deletions(-) (limited to 'odb') 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 emitter; // Drop. // @@ -167,7 +136,7 @@ namespace relational traversal::unit unit; traversal::defines unit_defines; traversal::namespace_ ns; - instance c (emitter); + instance 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 c (emitter); + instance 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. // -- cgit v1.1