summaryrefslogtreecommitdiff
path: root/cli/runtime-inline.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-12-10 09:47:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-12-10 09:47:29 +0200
commitf8edfd22cb45b554a573d2722900196758e9e958 (patch)
treeb2c800c8793f08be287a67ed72517f9cc2831fda /cli/runtime-inline.cxx
parenteddefea6ea39e64e9eb5adf74a279a230a63cf5b (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/runtime-inline.cxx')
-rw-r--r--cli/runtime-inline.cxx63
1 files changed, 59 insertions, 4 deletions
diff --git a/cli/runtime-inline.cxx b/cli/runtime-inline.cxx
index d4ce3ec..c99739c 100644
--- a/cli/runtime-inline.cxx
+++ b/cli/runtime-inline.cxx
@@ -103,18 +103,36 @@ generate_runtime_inline (context& ctx)
<< "return value_;"
<< "}";
+ if (ctx.options.generate_file_scanner ())
+ {
+ os << "// file_io_failure" << endl
+ << "//" << endl
+
+ << inl << "file_io_failure::" << endl
+ << "file_io_failure (const std::string& file)" << endl
+ << ": file_ (file)"
+ << "{"
+ << "}"
+
+ << inl << "const std::string& file_io_failure::" << endl
+ << "file () const"
+ << "{"
+ << "return file_;"
+ << "}";
+ }
+
os << "// argv_scanner" << endl
<< "//" << endl;
os << inl << "argv_scanner::" << endl
- << "argv_scanner (int argc, char** argv)" << endl
- << ": i_ (1), argc_ (argc), argv_ (argv)"
+ << "argv_scanner (int& argc, char** argv, bool erase)" << endl
+ << ": i_ (1), argc_ (argc), argv_ (argv), erase_ (erase)"
<< "{"
<< "}";
os << inl << "argv_scanner::" << endl
- << "argv_scanner (int start, int argc, char** argv)" << endl
- << ": i_ (start), argc_ (argc), argv_ (argv)"
+ << "argv_scanner (int start, int& argc, char** argv, bool erase)" << endl
+ << ": i_ (start), argc_ (argc), argv_ (argv), erase_ (erase)"
<< "{"
<< "}";
@@ -124,5 +142,42 @@ generate_runtime_inline (context& ctx)
<< "return i_;"
<< "}";
+ // argv_file_scanner
+ //
+ if (ctx.options.generate_file_scanner ())
+ {
+ bool sep (!ctx.opt_sep.empty ());
+
+ os << "// argv_file_scanner" << endl
+ << "//" << endl;
+
+ os << inl << "argv_file_scanner::" << endl
+ << "argv_file_scanner (int& argc," << endl
+ << "char** argv," << endl
+ << "const std::string& option," << endl
+ << "bool erase)" << endl
+ << ": argv_scanner (argc, argv, erase)," << endl
+ << " option_ (option)";
+ if (sep)
+ os << "," << endl
+ << " skip_ (false)";
+ os << "{"
+ << "}";
+
+ os << inl << "argv_file_scanner::" << endl
+ << "argv_file_scanner (int start," << endl
+ << "int& argc," << endl
+ << "char** argv," << endl
+ << "const std::string& option," << endl
+ << "bool erase)" << endl
+ << ": argv_scanner (start, argc, argv, erase)," << endl
+ << " option_ (option)";
+ if (sep)
+ os << "," << endl
+ << " skip_ (false)";
+ os << "{"
+ << "}";
+ }
+
os << "}"; // namespace cli
}