summaryrefslogtreecommitdiff
path: root/cli/runtime-header.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-19 10:12:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-19 10:12:22 +0200
commit0b4fcbeae101f2a5171217f65bab9c6545e853ba (patch)
treed4a80d33799ba874c8ab4ff26185a9bccce9b6ce /cli/runtime-header.cxx
parent89ce153311d9163bbc356927346c0b30e158a75f (diff)
Add option description that can be examined at runtime.
New option: --generate-description.
Diffstat (limited to 'cli/runtime-header.cxx')
-rw-r--r--cli/runtime-header.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/cli/runtime-header.cxx b/cli/runtime-header.cxx
index 99da036..de24073 100644
--- a/cli/runtime-header.cxx
+++ b/cli/runtime-header.cxx
@@ -15,6 +15,10 @@ generate_runtime_header (context& ctx)
if (ctx.options.generate_file_scanner ())
os << "#include <deque>" << endl;
+ if (ctx.options.generate_description ())
+ os << "#include <map>" << endl
+ << "#include <vector>" << endl;
+
os << "#include <iosfwd>" << endl
<< "#include <string>" << endl
<< "#include <exception>" << endl
@@ -299,5 +303,58 @@ generate_runtime_header (context& ctx)
os << "};";
}
+ // Option description.
+ //
+ if (ctx.options.generate_description ())
+ {
+ os << "typedef std::vector<std::string> option_names;"
+ << endl;
+
+ os << "class option"
+ << "{"
+ << "public:" << endl
+ << endl
+ << "const std::string&" << endl
+ << "name () const;"
+ << endl
+ << "const option_names&" << endl
+ << "aliases () const;"
+ << endl
+ << "bool" << endl
+ << "flag () const;"
+ << endl
+ << "const std::string&" << endl
+ << "default_value () const;"
+ << endl
+ << "public:"
+ << "option ();"
+ << "option (const std::string& name," << endl
+ << "const option_names& aliases," << endl
+ << "bool flag," << endl
+ << "const std::string& default_value);"
+ << endl
+ << "private:"
+ << "std::string name_;"
+ << "option_names aliases_;"
+ << "bool flag_;"
+ << "std::string default_value_;"
+ << "};";
+
+ os << "class options: public std::vector<option>"
+ << "{"
+ << "public:" << endl
+ << "typedef std::vector<option> container_type;"
+ << endl
+ << "container_type::const_iterator" << endl
+ << "find (const std::string& name) const;"
+ << endl
+ << "void" << endl
+ << "push_back (const option&);"
+ << "private:"
+ << "typedef std::map<std::string, container_type::size_type> map_type;"
+ << "map_type map_;"
+ << "};";
+ }
+
ctx.cli_close ();
}