summaryrefslogtreecommitdiff
path: root/odb/mysql/schema.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/mysql/schema.cxx')
-rw-r--r--odb/mysql/schema.cxx170
1 files changed, 85 insertions, 85 deletions
diff --git a/odb/mysql/schema.cxx b/odb/mysql/schema.cxx
index b405016..866cfcc 100644
--- a/odb/mysql/schema.cxx
+++ b/odb/mysql/schema.cxx
@@ -6,124 +6,124 @@
#include <set>
#include <odb/mysql/schema.hxx>
-namespace
+namespace mysql
{
- struct data_member: traversal::data_member, context
+ namespace
{
- data_member (context& c)
- : context (c), first_ (true)
+ struct data_member: traversal::data_member, context
{
- }
+ data_member (context& c)
+ : context (c), first_ (true)
+ {
+ }
- virtual void
- traverse (type& m)
- {
- if (m.count ("transient"))
- return;
+ virtual void
+ traverse (type& m)
+ {
+ if (m.count ("transient"))
+ return;
- if (first_)
- first_ = false;
- else
- os << "," << endl;
+ if (first_)
+ first_ = false;
+ else
+ os << "," << endl;
- os << " `" << column_name (m) << "` " << column_type (m);
+ os << " `" << column_name (m) << "` " << column_type (m);
- if (m.count ("id"))
- os << " PRIMARY KEY";
- }
+ if (m.count ("id"))
+ os << " PRIMARY KEY";
+ }
- private:
- bool first_;
- };
+ private:
+ bool first_;
+ };
- struct class_create: traversal::class_, context
- {
- class_create (context& c)
- : context (c)
+ struct class_create: traversal::class_, context
{
- }
+ class_create (context& c)
+ : context (c)
+ {
+ }
- virtual void
- traverse (type& c)
- {
- if (c.file () != unit.file ())
- return;
+ virtual void
+ traverse (type& c)
+ {
+ if (c.file () != unit.file ())
+ return;
- if (!c.count ("object"))
- return;
+ if (!c.count ("object"))
+ return;
- string const& name (table_name (c));
+ string const& name (table_name (c));
- // If the table with this name was already created, assume the
- // user knows what they are doing and skip it.
- //
- if (tables_.count (name))
- return;
+ // If the table with this name was already created, assume the
+ // user knows what they are doing and skip it.
+ //
+ if (tables_.count (name))
+ return;
- os << "CREATE TABLE `" << name << "` (" << endl;
+ os << "CREATE TABLE `" << name << "` (" << endl;
- {
- data_member m (*this);
- traversal::names n (m);
- names (c, n);
- }
+ {
+ data_member m (*this);
+ traversal::names n (m);
+ names (c, n);
+ }
- os << ")";
+ os << ")";
- string const& engine (options.mysql_engine ());
+ string const& engine (options.mysql_engine ());
- if (engine != "default")
- os << endl
- << " ENGINE=" << engine;
+ if (engine != "default")
+ os << endl
+ << " ENGINE=" << engine;
- os << ";" << endl
- << endl;
+ os << ";" << endl
+ << endl;
- tables_.insert (name);
- }
+ tables_.insert (name);
+ }
- private:
- std::set<string> tables_;
- };
+ private:
+ std::set<string> tables_;
+ };
- struct class_drop: traversal::class_, context
- {
- class_drop (context& c)
- : context (c)
+ struct class_drop: traversal::class_, context
{
- }
+ class_drop (context& c)
+ : context (c)
+ {
+ }
- virtual void
- traverse (type& c)
- {
- if (c.file () != unit.file ())
- return;
+ virtual void
+ traverse (type& c)
+ {
+ if (c.file () != unit.file ())
+ return;
- if (!c.count ("object"))
- return;
+ if (!c.count ("object"))
+ return;
- string const& name (table_name (c));
+ string const& name (table_name (c));
- if (tables_.count (name))
- return;
+ if (tables_.count (name))
+ return;
- os << "DROP TABLE IF EXISTS `" << name << "`;" << endl;
+ os << "DROP TABLE IF EXISTS `" << name << "`;" << endl;
- tables_.insert (name);
- }
+ tables_.insert (name);
+ }
- private:
- std::set<string> tables_;
- };
-}
+ private:
+ std::set<string> tables_;
+ };
-static char const file_header[] =
- "/* This file was generated by CodeSynthesis ODB object persistence\n"
- " * compiler for C++.\n"
- " */\n\n";
+ static char const file_header[] =
+ "/* This file was generated by CodeSynthesis ODB object persistence\n"
+ " * compiler for C++.\n"
+ " */\n\n";
+ }
-namespace mysql
-{
void
generate_schema (context& ctx)
{