From f8677f8bfaa68e6714f4af7b030d0f365e60b918 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Oct 2012 10:03:36 +0200 Subject: Add support for database prefixes in command line interface --- odb/odb.cxx | 110 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 48 deletions(-) (limited to 'odb/odb.cxx') diff --git a/odb/odb.cxx b/odb/odb.cxx index b80f577..260f9b8 100644 --- a/odb/odb.cxx +++ b/odb/odb.cxx @@ -817,38 +817,45 @@ main (int argc, char* argv[]) // NOTE: if you change the format, you also need to update code // in include.cxx // - strings const& pro (ops.odb_prologue ()); - for (size_t i (0); i < pro.size (); ++i) + size_t pro_count (1); + if (ops.odb_prologue ().count (db) != 0) { - os << "#line 1 \"\"" << endl - << pro[i] << endl; + strings const& pro (ops.odb_prologue ()[db]); + for (size_t i (0); i < pro.size (); ++i, ++pro_count) + { + os << "#line 1 \"\"" << endl + << pro[i] << endl; + } } - strings const& prof (ops.odb_prologue_file ()); - for (size_t i (0); i < prof.size (); ++i) + if (ops.odb_prologue_file ().count (db) != 0) { - os << "#line 1 \"\"" - << endl; + strings const& prof (ops.odb_prologue_file ()[db]); + for (size_t i (0); i < prof.size (); ++i, ++pro_count) + { + os << "#line 1 \"\"" + << endl; - ifstream ifs (prof[i].c_str (), ios_base::in | ios_base::binary); + ifstream ifs (prof[i].c_str (), ios_base::in | ios_base::binary); - if (!ifs.is_open ()) - { - e << prof[i] << ": error: unable to open in read mode" << endl; - fb.close (); - wait_process (pi, argv[0]); - return 1; - } + if (!ifs.is_open ()) + { + e << prof[i] << ": error: unable to open in read mode" << endl; + fb.close (); + wait_process (pi, argv[0]); + return 1; + } - if (!(os << ifs.rdbuf ())) - { - e << prof[i] << ": error: io failure" << endl; - fb.close (); - wait_process (pi, argv[0]); - return 1; - } + if (!(os << ifs.rdbuf ())) + { + e << prof[i] << ": error: io failure" << endl; + fb.close (); + wait_process (pi, argv[0]); + return 1; + } - os << endl; + os << endl; + } } if (at_once) @@ -887,38 +894,45 @@ main (int argc, char* argv[]) // NOTE: if you change the format, you also need to update code // in include.cxx // - strings const& epi (ops.odb_epilogue ()); - for (size_t i (0); i < epi.size (); ++i) + size_t epi_count (1); + if (ops.odb_epilogue ().count (db) != 0) { - os << "#line 1 \"\"" << endl - << epi[i] << endl; + strings const& epi (ops.odb_epilogue ()[db]); + for (size_t i (0); i < epi.size (); ++i, ++epi_count) + { + os << "#line 1 \"\"" << endl + << epi[i] << endl; + } } - strings const& epif (ops.odb_epilogue_file ()); - for (size_t i (0); i < epif.size (); ++i) + if (ops.odb_epilogue_file ().count (db) != 0) { - os << "#line 1 \"\"" - << endl; + strings const& epif (ops.odb_epilogue_file ()[db]); + for (size_t i (0); i < epif.size (); ++i, ++epi_count) + { + os << "#line 1 \"\"" + << endl; - ifstream ifs (epif[i].c_str (), ios_base::in | ios_base::binary); + ifstream ifs (epif[i].c_str (), ios_base::in | ios_base::binary); - if (!ifs.is_open ()) - { - e << epif[i] << ": error: unable to open in read mode" << endl; - fb.close (); - wait_process (pi, argv[0]); - return 1; - } + if (!ifs.is_open ()) + { + e << epif[i] << ": error: unable to open in read mode" << endl; + fb.close (); + wait_process (pi, argv[0]); + return 1; + } - if (!(os << ifs.rdbuf ())) - { - e << epif[i] << ": error: io failure" << endl; - fb.close (); - wait_process (pi, argv[0]); - return 1; - } + if (!(os << ifs.rdbuf ())) + { + e << epif[i] << ": error: io failure" << endl; + fb.close (); + wait_process (pi, argv[0]); + return 1; + } - os << endl; + os << endl; + } } if (!ops.trace ()) -- cgit v1.1