diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-29 10:03:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-29 10:03:36 +0200 |
commit | f8677f8bfaa68e6714f4af7b030d0f365e60b918 (patch) | |
tree | 5f64e69bd7261348d966b80d0433f6bd34be76f2 /odb/odb.cxx | |
parent | 938d136b09b868f633574c722d48c2953dde1be4 (diff) |
Add support for database prefixes in command line interface
Diffstat (limited to 'odb/odb.cxx')
-rw-r--r-- | odb/odb.cxx | 110 |
1 files changed, 62 insertions, 48 deletions
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 \"<odb-prologue-" << i + 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 \"<odb-prologue-" << pro_count << ">\"" << 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 \"<odb-prologue-" << pro.size () + i + 1 << ">\"" - << endl; + strings const& prof (ops.odb_prologue_file ()[db]); + for (size_t i (0); i < prof.size (); ++i, ++pro_count) + { + os << "#line 1 \"<odb-prologue-" << pro_count << ">\"" + << 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 \"<odb-epilogue-" << i + 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 \"<odb-epilogue-" << epi_count << ">\"" << 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 \"<odb-epilogue-" << epi.size () + i + 1 << ">\"" - << endl; + strings const& epif (ops.odb_epilogue_file ()[db]); + for (size_t i (0); i < epif.size (); ++i, ++epi_count) + { + os << "#line 1 \"<odb-epilogue-" << epi_count << ">\"" + << 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 ()) |