diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-19 10:12:22 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-19 10:12:22 +0200 |
commit | 0b4fcbeae101f2a5171217f65bab9c6545e853ba (patch) | |
tree | d4a80d33799ba874c8ab4ff26185a9bccce9b6ce /cli/runtime-inline.cxx | |
parent | 89ce153311d9163bbc356927346c0b30e158a75f (diff) |
Add option description that can be examined at runtime.
New option: --generate-description.
Diffstat (limited to 'cli/runtime-inline.cxx')
-rw-r--r-- | cli/runtime-inline.cxx | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/cli/runtime-inline.cxx b/cli/runtime-inline.cxx index 753e86b..fecbd02 100644 --- a/cli/runtime-inline.cxx +++ b/cli/runtime-inline.cxx @@ -211,5 +211,59 @@ generate_runtime_inline (context& ctx) << "}"; } + // Option description. + // + if (ctx.options.generate_description ()) + { + // option + // + os << inl << "const std::string& option::" << endl + << "name () const" + << "{" + << "return name_;" + << "}"; + + os << inl << "const option_names& option::" << endl + << "aliases () const" + << "{" + << "return aliases_;" + << "}"; + + os << inl << "bool option::" << endl + << "flag () const" + << "{" + << "return flag_;" + << "}"; + + os << inl << "const std::string& option::" << endl + << "default_value () const" + << "{" + << "return default_value_;" + << "}"; + + os << inl << "option::" << endl + << "option ()" + << "{" + << "}"; + + os << inl << "option::" << endl + << "option (const std::string& n," << endl + << "const option_names& a," << endl + << "bool f," << endl + << "const std::string& dv)" << endl + << ": name_ (n), aliases_ (a), flag_ (f), default_value_ (dv)" + << "{" + << "}"; + + // options + // + os << inl << "options::container_type::const_iterator options::" << endl + << "find (const std::string& name) const" + << "{" + << "map_type::const_iterator i (map_.find (name));" + << "return i != map_.end () ? begin () + i->second : end ();" + << "}"; + } + ctx.cli_close (); } |