60 progName_(
""), description_(description) {
87 string name = (*i).first;
94 string name = (*i).first;
114 for (
int i = 1; i < argc; i++) {
133 for (
unsigned int i = 0; i <
options.size(); i++) {
135 string::size_type curPos = 0;
137 string::size_type pos =
options[i].find(
" ", curPos);
138 if (pos != string::npos) {
142 if (
options[i].length() - curPos > 0) {
171 string msg =
"Unknown option: " + name;
172 string method =
"CmdLineParser::findOption()";
185 bool finished =
false;
189 bool checkArguments =
true;
198 string arguments =
"";
201 bool hasArgument =
true;
203 if (!
parseOption(optString, name, arguments, prefix, hasArgument)) {
205 if (optString ==
"--") {
206 checkArguments =
false;
218 if (arguments ==
"" &&
230 bool doneWithParsing = opt->
parseValue(arguments, prefix);
232 if (!doneWithParsing) {
241 for (
unsigned int i = 0; i < arguments.length(); i++) {
250 if (checkArguments && optString[0] ==
'-') {
251 string msg =
"Illegal command line argument: " + optString;
252 string method =
"CmdLineParser::parse()";
278 std::string option, std::string& name, std::string& arguments,
279 std::string& prefix,
bool& hasArgument)
const {
281 bool longOption =
false;
282 if (!
readPrefix(option, prefix, longOption)) {
288 unsigned int pos = 0;
289 while (pos < option.length() && option[pos] !=
'=') {
292 name = option.substr(0, pos);
293 option.erase(0, pos);
296 name = option.substr(0, 1);
301 if (option.length() > 0 && option[0] ==
'=') {
303 string method =
"CmdLineParser::parseOption()";
304 string message =
"Illegal short option: = not allowed.";
311 if (arguments ==
"" || !longOption) {
330 bool& longOption)
const {
332 if (option ==
"--") {
334 }
else if (option.substr(0, 1) !=
"-") {
338 if (option.substr(0, 1) ==
"-") {
345 for (
unsigned int i = 0; i <
prefixes_.size(); i++) {
347 if (option.length() >
prefixes_[i].length() &&
351 option.erase(0, prefix.length());