From 0b4fcbeae101f2a5171217f65bab9c6545e853ba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Nov 2010 10:12:22 +0200 Subject: Add option description that can be examined at runtime. New option: --generate-description. --- cli/runtime-header.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'cli/runtime-header.cxx') 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 " << endl; + if (ctx.options.generate_description ()) + os << "#include " << endl + << "#include " << endl; + os << "#include " << endl << "#include " << endl << "#include " << endl @@ -299,5 +303,58 @@ generate_runtime_header (context& ctx) os << "};"; } + // Option description. + // + if (ctx.options.generate_description ()) + { + os << "typedef std::vector 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