diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-02 17:06:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-02 17:06:10 +0200 |
commit | 7c83b407648f1ef919218d8965d4c21378910755 (patch) | |
tree | 52f62723ccf07bb59a45737cb2d0fc89ae691f4f /cli/header.cxx | |
parent | 2eb28736a05c7083f2b30b501954a789bbd85f88 (diff) |
Add --generate-parse option
When specified, CLI will generate parse() functions instead of parsing
constructors. This is primarily useful for being able to parse into an
already initialized options class instance, for example, to implement
merging/overriding.
Diffstat (limited to 'cli/header.cxx')
-rw-r--r-- | cli/header.cxx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/cli/header.cxx b/cli/header.cxx index ddf0895..6ff1f6b 100644 --- a/cli/header.cxx +++ b/cli/header.cxx @@ -129,14 +129,23 @@ namespace // if (!abst) { - os << name << " (int& argc," << endl + os << name << " ();" + << endl; + + // Are we generating parsing constructors or parse() functions? + // + string n (options.generate_parse () + ? string ("void\n") + (name != "parse" ? "parse" : "parse_") + : name); + + os << n << " (int& argc," << endl << "char** argv," << endl << "bool erase = false," << endl << um << " option = " << um << "::fail," << endl << um << " argument = " << um << "::stop);" << endl; - os << name << " (int start," << endl + os << n << " (int start," << endl << "int& argc," << endl << "char** argv," << endl << "bool erase = false," << endl @@ -144,7 +153,7 @@ namespace << um << " argument = " << um << "::stop);" << endl; - os << name << " (int& argc," << endl + os << n << " (int& argc," << endl << "char** argv," << endl << "int& end," << endl << "bool erase = false," << endl @@ -152,7 +161,7 @@ namespace << um << " argument = " << um << "::stop);" << endl; - os << name << " (int start," << endl + os << n << " (int start," << endl << "int& argc," << endl << "char** argv," << endl << "int& end," << endl @@ -161,13 +170,10 @@ namespace << um << " argument = " << um << "::stop);" << endl; - os << name << " (" << cli << "::scanner&," << endl + os << n << " (" << cli << "::scanner&," << endl << um << " option = " << um << "::fail," << endl << um << " argument = " << um << "::stop);" << endl; - - os << name << " ();" - << endl; } // |