22 #ifndef CLIOPTION20140107H
23 #define CLIOPTION20140107H
45 const std::string& description)
46 : description_(description)
48 c_opt_.name = longname;
50 c_opt_.has_arg = has_argument;
52 c_opt_.val = shortname;
56 option
c_opt()
const {
return c_opt_; }
65 opt_code += std::string(1, c_opt_.val);
66 if(c_opt_.has_arg == no_argument)
68 else if(c_opt_.has_arg == required_argument)
70 else if(c_opt_.has_arg == optional_argument)
80 std::stringstream
usage;
82 usage <<
"-" << (char)c_opt_.val <<
", ";
83 usage <<
"--" << c_opt_.name;
84 usage << std::string(std::max(1, (
int)(20-
usage.str().size())),
' ') << description_;
89 static void convert_vector(
const std::vector<Option>& options, std::vector<option>* c_options, std::string* opt_string)
91 for(
int i = 0, n = options.size(); i < n; ++i)
93 c_options->push_back(options[i].
c_opt());
94 *opt_string += options[i].opt_code();
96 option zero = { 0, 0, 0, 0 };
97 c_options->push_back(zero);
102 std::string description_;