diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-10 09:47:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-10 09:47:29 +0200 |
commit | f8edfd22cb45b554a573d2722900196758e9e958 (patch) | |
tree | b2c800c8793f08be287a67ed72517f9cc2831fda /cli/source.cxx | |
parent | eddefea6ea39e64e9eb5adf74a279a230a63cf5b (diff) |
Scanner-based parsing with support for element erasing
Also implement argv_file_scanner which provides support for reading command
line arguments from the argv array as well as files specified with command
line options. New examples: file. New tests: ctor, erase, file.
Diffstat (limited to 'cli/source.cxx')
-rw-r--r-- | cli/source.cxx | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/cli/source.cxx b/cli/source.cxx index 5f0b199..1c0b890 100644 --- a/cli/source.cxx +++ b/cli/source.cxx @@ -24,7 +24,11 @@ namespace os << "," << endl << " "; else + { + os << endl + << ": "; comma_ = true; + } os << emember (o); @@ -356,75 +360,88 @@ namespace string um ("::cli::unknown_mode"); os << name << "::" << endl - << name << " (int argc," << endl + << name << " (int& argc," << endl << "char** argv," << endl + << "bool erase," << endl << um << " opt," << endl - << um << " arg)" << endl - << ": "; + << um << " arg)"; { option_init init (*this); traversal::names names_init (init); names (c, names_init); } os << "{" - << "::cli::argv_scanner s (argc, argv);" + << "::cli::argv_scanner s (argc, argv, erase);" << "_parse (s, opt, arg);" << "}"; os << name << "::" << endl << name << " (int start," << endl - << "int argc," << endl + << "int& argc," << endl << "char** argv," << endl + << "bool erase," << endl << um << " opt," << endl - << um << " arg)" << endl - << ": "; + << um << " arg)"; { option_init init (*this); traversal::names names_init (init); names (c, names_init); } os << "{" - << "::cli::argv_scanner s (start, argc, argv);" + << "::cli::argv_scanner s (start, argc, argv, erase);" << "_parse (s, opt, arg);" << "}"; os << name << "::" << endl - << name << " (int argc," << endl + << name << " (int& argc," << endl << "char** argv," << endl << "int& end," << endl + << "bool erase," << endl << um << " opt," << endl - << um << " arg)" << endl - << ": "; + << um << " arg)"; { option_init init (*this); traversal::names names_init (init); names (c, names_init); } os << "{" - << "::cli::argv_scanner s (argc, argv);" + << "::cli::argv_scanner s (argc, argv, erase);" << "_parse (s, opt, arg);" << "end = s.end ();" << "}"; os << name << "::" << endl << name << " (int start," << endl - << "int argc," << endl + << "int& argc," << endl << "char** argv," << endl << "int& end," << endl + << "bool erase," << endl << um << " opt," << endl - << um << " arg)" << endl - << ": "; + << um << " arg)"; { option_init init (*this); traversal::names names_init (init); names (c, names_init); } os << "{" - << "::cli::argv_scanner s (start, argc, argv);" + << "::cli::argv_scanner s (start, argc, argv, erase);" << "_parse (s, opt, arg);" << "end = s.end ();" << "}"; + os << name << "::" << endl + << name << " (::cli::scanner& s," << endl + << um << " opt," << endl + << um << " arg)"; + { + option_init init (*this); + traversal::names names_init (init); + names (c, names_init); + } + os << "{" + << "_parse (s, opt, arg);" + << "}"; + // usage // if (usage) |