diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-10 08:44:28 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-21 15:39:59 +0200 |
commit | 7ae497743c7b042904fe1f6b4153ab3f4763ff2b (patch) | |
tree | 08ba3f742f20d16d893856ccceb070094bd69225 /odb/relational/mysql/schema.cxx | |
parent | 2436f20262a41bd1cafa5107ab6d6799c03e0964 (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/mysql/schema.cxx')
-rw-r--r-- | odb/relational/mysql/schema.cxx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/odb/relational/mysql/schema.cxx b/odb/relational/mysql/schema.cxx new file mode 100644 index 0000000..19569e4 --- /dev/null +++ b/odb/relational/mysql/schema.cxx @@ -0,0 +1,53 @@ +// file : odb/relational/mysql/schema.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/schema.hxx> + +#include <odb/relational/mysql/common.hxx> +#include <odb/relational/mysql/context.hxx> + +namespace relational +{ + namespace mysql + { + namespace schema + { + namespace relational = relational::schema; + + // + // Create. + // + + struct create_common: virtual relational::create_common + { + virtual void + create_post () + { + os << ")"; + + string const& engine (options.mysql_engine ()); + + if (engine != "default") + os << endl + << " ENGINE=" << engine; + + os << endl; + } + }; + + struct member_create: relational::member_create, create_common + { + member_create (base const& x): base (x) {} + }; + entry<member_create> member_create_; + + struct class_create: relational::class_create, create_common + { + class_create (base const& x): base (x) {} + }; + entry<class_create> class_create_; + } + } +} |