aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-05-08 10:19:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-05-08 10:19:40 +0200
commit0a794bb81ab2efa614c190089b5dc63a5c194db2 (patch)
treed8815f0580f90d469d0ad7ba9c35f84797d7cbdc
parent540de8a520cde7755e8fd22af33690cafa9ee36e (diff)
Don't (re)indent user-supplied prologues and epilogues
-rw-r--r--odb/generator.cxx126
1 files changed, 69 insertions, 57 deletions
diff --git a/odb/generator.cxx b/odb/generator.cxx
index ffed9d9..2d787a1 100644
--- a/odb/generator.cxx
+++ b/odb/generator.cxx
@@ -225,12 +225,11 @@ generate (options const& ops,
// HXX
//
{
- sloc_filter sloc (hxx);
- ind_filter ind (hxx);
-
auto_ptr<context> ctx (
create_context (hxx, unit, ops, fts, model.get ()));
+ sloc_filter sloc (ctx->os);
+
string guard (ctx->make_guard (gp + hxx_name));
hxx << "#ifndef " << guard << endl
@@ -261,19 +260,25 @@ generate (options const& ops,
hxx << "#include " << ctx->process_include_path (file.string ()) << endl
<< endl;
- include::generate ();
- header::generate ();
-
- switch (ops.database ())
{
- case database::mssql:
- case database::mysql:
- case database::oracle:
- case database::pgsql:
- case database::sqlite:
+ // We don't want to indent prologues/epilogues.
+ //
+ ind_filter ind (ctx->os);
+
+ include::generate ();
+ header::generate ();
+
+ switch (ops.database ())
{
- relational::header::generate ();
- break;
+ case database::mssql:
+ case database::mysql:
+ case database::oracle:
+ case database::pgsql:
+ case database::sqlite:
+ {
+ relational::header::generate ();
+ break;
+ }
}
}
@@ -294,8 +299,6 @@ generate (options const& ops,
hxx << "#endif // " << guard << endl;
- ind.stream ().unbuffer (); // Flush buffers to get correct SLOC.
-
if (ops.show_sloc ())
cerr << hxx_name << ": " << sloc.stream ().count () << endl;
@@ -305,12 +308,11 @@ generate (options const& ops,
// IXX
//
{
- sloc_filter sloc (ixx);
- ind_filter ind (ixx);
-
auto_ptr<context> ctx (
create_context (ixx, unit, ops, fts, model.get ()));
+ sloc_filter sloc (ctx->os);
+
// Copy prologue.
//
ixx << "// Begin prologue." << endl
@@ -320,18 +322,24 @@ generate (options const& ops,
<< "// End prologue." << endl
<< endl;
- inline_::generate ();
-
- switch (ops.database ())
{
- case database::mssql:
- case database::mysql:
- case database::oracle:
- case database::pgsql:
- case database::sqlite:
+ // We don't want to indent prologues/epilogues.
+ //
+ ind_filter ind (ctx->os);
+
+ inline_::generate ();
+
+ switch (ops.database ())
{
- relational::inline_::generate ();
- break;
+ case database::mssql:
+ case database::mysql:
+ case database::oracle:
+ case database::pgsql:
+ case database::sqlite:
+ {
+ relational::inline_::generate ();
+ break;
+ }
}
}
@@ -343,8 +351,6 @@ generate (options const& ops,
ixx << "//" << endl
<< "// End epilogue." << endl;
- ind.stream ().unbuffer (); // Flush buffers to get correct SLOC.
-
if (ops.show_sloc ())
cerr << ixx_name << ": " << sloc.stream ().count () << endl;
@@ -354,12 +360,11 @@ generate (options const& ops,
// CXX
//
{
- sloc_filter sloc (cxx);
- ind_filter ind (cxx);
-
auto_ptr<context> ctx (
create_context (cxx, unit, ops, fts, model.get ()));
+ sloc_filter sloc (ctx->os);
+
cxx << "#include <odb/pre.hxx>" << endl
<< endl;
@@ -375,16 +380,22 @@ generate (options const& ops,
cxx << "#include " << ctx->process_include_path (hxx_name) << endl
<< endl;
- switch (ops.database ())
{
- case database::mssql:
- case database::mysql:
- case database::oracle:
- case database::pgsql:
- case database::sqlite:
+ // We don't want to indent prologues/epilogues.
+ //
+ ind_filter ind (ctx->os);
+
+ switch (ops.database ())
{
- relational::source::generate ();
- break;
+ case database::mssql:
+ case database::mysql:
+ case database::oracle:
+ case database::pgsql:
+ case database::sqlite:
+ {
+ relational::source::generate ();
+ break;
+ }
}
}
@@ -399,8 +410,6 @@ generate (options const& ops,
cxx << "#include <odb/post.hxx>" << endl;
- ind.stream ().unbuffer (); // Flush buffers to get correct SLOC.
-
if (ops.show_sloc ())
cerr << cxx_name << ": " << sloc.stream ().count () << endl;
@@ -411,12 +420,11 @@ generate (options const& ops,
//
if (sep_schema)
{
- sloc_filter sloc (sch);
- ind_filter ind (sch);
-
auto_ptr<context> ctx (
create_context (sch, unit, ops, fts, model.get ()));
+ sloc_filter sloc (ctx->os);
+
// Copy prologue.
//
sch << "#include <odb/pre.hxx>" << endl
@@ -434,16 +442,22 @@ generate (options const& ops,
sch << "#include " << ctx->process_include_path (hxx_name) << endl
<< endl;
- switch (ops.database ())
{
- case database::mssql:
- case database::mysql:
- case database::oracle:
- case database::pgsql:
- case database::sqlite:
+ // We don't want to indent prologues/epilogues.
+ //
+ ind_filter ind (ctx->os);
+
+ switch (ops.database ())
{
- relational::schema_source::generate ();
- break;
+ case database::mssql:
+ case database::mysql:
+ case database::oracle:
+ case database::pgsql:
+ case database::sqlite:
+ {
+ relational::schema_source::generate ();
+ break;
+ }
}
}
@@ -458,8 +472,6 @@ generate (options const& ops,
sch << "#include <odb/post.hxx>" << endl;
- ind.stream ().unbuffer (); // Flush buffers to get correct SLOC.
-
if (ops.show_sloc ())
cerr << sch_name << ": " << sloc.stream ().count () << endl;