Commit d96e8e84 authored by David Flynn's avatar David Flynn
Browse files

po-lite: add printing of option defaults in help text

The Options collection already knows the default value for each
option.  This commit extends the help text to show the default
value against the long option name.



git-svn-id: http://wg11.sc29.org/svn/repos/MPEG-I/Part5-PointCloudCompression/TM/TMC3/trunk@1315 94298a81-5874-47c9-aab8-bfb24faeed7f
parent 71afbe35
......@@ -157,6 +157,8 @@ namespace df
if (!entry.opt_long.empty())
{
out << "--" << entry.opt_long.front();
out << '=';
entry.opt->writeDefault(out);
}
}
......
......@@ -89,9 +89,13 @@ namespace df
/* parse argument arg, to obtain a value for the option */
virtual void parse(const std::string& arg, ErrorReporter&) = 0;
/* set the argument to the default value */
virtual void setDefault() = 0;
/* write the default value to out */
virtual void writeDefault(std::ostream& out) = 0;
std::string opt_string;
std::string opt_desc;
};
......@@ -111,6 +115,11 @@ namespace df
opt_storage = opt_default_val;
}
void writeDefault(std::ostream& out)
{
out << opt_default_val;
}
T& opt_storage;
T opt_default_val;
};
......@@ -141,6 +150,15 @@ namespace df
opt_storage = arg;
}
/* strings are pecialized -- output whole string rather than treating as
* a sequence of characters */
template<>
inline void
Option<std::string>::writeDefault(std::ostream& out)
{
out << '"' << opt_default_val << '"';
}
/** Option class for argument handling using a user provided function */
struct OptionFunc : public OptionBase
{
......@@ -160,6 +178,12 @@ namespace df
return;
}
void writeDefault(std::ostream& out)
{
/* there is no default */
out << "...";
}
private:
Options& parent;
Func* func;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment