From 7fa6f3a40d4df931e86add02e75678800395a374 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 Mar 2014 08:16:58 +0200 Subject: Generate pro/epilogues outside pre/post.hxx includes --- NEWS | 4 ++++ odb/generator.cxx | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index 5396abb..576aad1 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,10 @@ Version 2.4.0 (translated to the ON DELETE SQL clause) for an object pointer. For more information, refer to Section 14.4.15, "on_delete" in the ODB manual. + * User-supplied prologues and epilogues are now generated outside the + pre.hxx/post.hxx includes. This allows the use of precompiled headers + with the generated files. + Version 2.3.0 * Support for database schema evolution, including schema migration, data diff --git a/odb/generator.cxx b/odb/generator.cxx index 6971059..6f4c4a7 100644 --- a/odb/generator.cxx +++ b/odb/generator.cxx @@ -482,6 +482,15 @@ generate (options const& ops, << "#define " << guard << endl << endl; + // Copy prologue. + // + append_logue (hxx, + db, + ops.hxx_prologue (), + ops.hxx_prologue_file (), + "// Begin prologue.\n//", + "//\n// End prologue."); + // Version check. // hxx << "#include " << endl @@ -494,15 +503,6 @@ generate (options const& ops, hxx << "#include " << endl << endl; - // Copy prologue. - // - append_logue (hxx, - db, - ops.hxx_prologue (), - ops.hxx_prologue_file (), - "// Begin prologue.\n//", - "//\n// End prologue."); - // Include main file(s). // for (paths::const_iterator i (inputs.begin ()); i != inputs.end (); ++i) @@ -557,6 +557,9 @@ generate (options const& ops, hxx << "#include " << ctx->process_include_path (ixx_name) << endl << endl; + hxx << "#include " << endl + << endl; + // Copy epilogue. // append_logue (hxx, @@ -566,9 +569,6 @@ generate (options const& ops, "// Begin epilogue.\n//", "//\n// End epilogue."); - hxx << "#include " << endl - << endl; - hxx << "#endif // " << guard << endl; if (ops.show_sloc ()) @@ -646,9 +646,6 @@ generate (options const& ops, sloc_filter sloc (ctx->os); - cxx << "#include " << endl - << endl; - // Copy prologue. // append_logue (cxx, @@ -658,6 +655,9 @@ generate (options const& ops, "// Begin prologue.\n//", "//\n// End prologue."); + cxx << "#include " << endl + << endl; + // Include query columns implementations for explicit instantiations. // string impl_guard; @@ -713,6 +713,8 @@ generate (options const& ops, } } + cxx << "#include " << endl; + // Copy epilogue. // append_logue (cxx, @@ -722,8 +724,6 @@ generate (options const& ops, "// Begin epilogue.\n//", "//\n// End epilogue."); - cxx << "#include " << endl; - if (ops.show_sloc ()) cerr << cxx_name << ": " << sloc.stream ().count () << endl; @@ -739,9 +739,6 @@ generate (options const& ops, sloc_filter sloc (ctx->os); - sch << "#include " << endl - << endl; - // Copy prologue. // append_logue (sch, @@ -751,6 +748,9 @@ generate (options const& ops, "// Begin prologue.\n//", "//\n// End prologue."); + sch << "#include " << endl + << endl; + sch << "#include " << endl << "#include " << endl << endl @@ -778,6 +778,8 @@ generate (options const& ops, } } + sch << "#include " << endl; + // Copy epilogue. // append_logue (sch, @@ -787,8 +789,6 @@ generate (options const& ops, "// Begin epilogue.\n//", "//\n// End epilogue."); - sch << "#include " << endl; - if (ops.show_sloc ()) cerr << sch_name << ": " << sloc.stream ().count () << endl; -- cgit v1.1