0
2
0
22
21
23
20
... | ... |
@@ -241,3 +241,3 @@ |
241 | 241 |
|
242 |
void ArgParser::show(std::ostream &os,Opts:: |
|
242 |
void ArgParser::show(std::ostream &os,Opts::const_iterator i) const |
|
243 | 243 |
{ |
... | ... |
@@ -245,3 +245,3 @@ |
245 | 245 |
if(i->second.has_syn) |
246 |
for(Opts:: |
|
246 |
for(Opts::const_iterator j=_opts.begin();j!=_opts.end();++j) |
|
247 | 247 |
if(j->second.syn&&j->second.help==i->first) |
... | ... |
@@ -263,5 +263,5 @@ |
263 | 263 |
|
264 |
void ArgParser::show(std::ostream &os,Groups:: |
|
264 |
void ArgParser::show(std::ostream &os,Groups::const_iterator i) const |
|
265 | 265 |
{ |
266 |
GroupData::Opts:: |
|
266 |
GroupData::Opts::const_iterator o=i->second.opts.begin(); |
|
267 | 267 |
while(o!=i->second.opts.end()) { |
... | ... |
@@ -273,3 +273,3 @@ |
273 | 273 |
|
274 |
void ArgParser::showHelp(Opts:: |
|
274 |
void ArgParser::showHelp(Opts::const_iterator i) const |
|
275 | 275 |
{ |
... | ... |
@@ -281,3 +281,4 @@ |
281 | 281 |
} |
282 |
void ArgParser::showHelp(std::vector<ArgParser::OtherArg>:: |
|
282 |
void ArgParser::showHelp(std::vector<ArgParser::OtherArg>::const_iterator i) |
|
283 |
const |
|
283 | 284 |
{ |
... | ... |
@@ -288,3 +289,3 @@ |
288 | 289 |
|
289 |
void ArgParser::shortHelp() |
|
290 |
void ArgParser::shortHelp() const |
|
290 | 291 |
{ |
... | ... |
@@ -294,3 +295,3 @@ |
294 | 295 |
int pos=_command_name.size()+2; |
295 |
for(Groups:: |
|
296 |
for(Groups::const_iterator g=_groups.begin();g!=_groups.end();++g) { |
|
296 | 297 |
std::ostringstream cstr; |
... | ... |
@@ -307,3 +308,3 @@ |
307 | 308 |
} |
308 |
for(Opts:: |
|
309 |
for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) |
|
309 | 310 |
if(!i->second.ingroup&&!i->second.syn) { |
... | ... |
@@ -321,3 +322,3 @@ |
321 | 322 |
} |
322 |
for(std::vector<OtherArg>:: |
|
323 |
for(std::vector<OtherArg>::const_iterator i=_others_help.begin(); |
|
323 | 324 |
i!=_others_help.end();++i) |
... | ... |
@@ -337,3 +338,3 @@ |
337 | 338 |
|
338 |
void ArgParser::showHelp() |
|
339 |
void ArgParser::showHelp() const |
|
339 | 340 |
{ |
... | ... |
@@ -341,5 +342,5 @@ |
341 | 342 |
std::cerr << "Where:\n"; |
342 |
for(std::vector<OtherArg>:: |
|
343 |
for(std::vector<OtherArg>::const_iterator i=_others_help.begin(); |
|
343 | 344 |
i!=_others_help.end();++i) showHelp(i); |
344 |
for(Opts:: |
|
345 |
for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i); |
|
345 | 346 |
exit(1); |
... | ... |
@@ -348,3 +349,3 @@ |
348 | 349 |
|
349 |
void ArgParser::unknownOpt(std::string arg) |
|
350 |
void ArgParser::unknownOpt(std::string arg) const |
|
350 | 351 |
{ |
... | ... |
@@ -356,3 +357,3 @@ |
356 | 357 |
|
357 |
void ArgParser::requiresValue(std::string arg, OptType t) |
|
358 |
void ArgParser::requiresValue(std::string arg, OptType t) const |
|
358 | 359 |
{ |
... | ... |
@@ -377,6 +378,6 @@ |
377 | 378 |
|
378 |
void ArgParser::checkMandatories() |
|
379 |
void ArgParser::checkMandatories() const |
|
379 | 380 |
{ |
380 | 381 |
bool ok=true; |
381 |
for(Opts:: |
|
382 |
for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) |
|
382 | 383 |
if(i->second.mandatory&&!i->second.set) |
... | ... |
@@ -389,3 +390,3 @@ |
389 | 390 |
} |
390 |
for(Groups:: |
|
391 |
for(Groups::const_iterator i=_groups.begin();i!=_groups.end();++i) |
|
391 | 392 |
if(i->second.mandatory||i->second.only_one) |
... | ... |
@@ -393,3 +394,3 @@ |
393 | 394 |
int set=0; |
394 |
for(GroupData::Opts:: |
|
395 |
for(GroupData::Opts::const_iterator o=i->second.opts.begin(); |
|
395 | 396 |
o!=i->second.opts.end();++o) |
... | ... |
@@ -400,3 +401,3 @@ |
400 | 401 |
ok=false; |
401 |
for(GroupData::Opts:: |
|
402 |
for(GroupData::Opts::const_iterator o=i->second.opts.begin(); |
|
402 | 403 |
o!=i->second.opts.end();++o) |
... | ... |
@@ -408,3 +409,3 @@ |
408 | 409 |
ok=false; |
409 |
for(GroupData::Opts:: |
|
410 |
for(GroupData::Opts::const_iterator o=i->second.opts.begin(); |
|
410 | 411 |
o!=i->second.opts.end();++o) |
... | ... |
@@ -273,13 +273,16 @@ |
273 | 273 |
|
274 |
void show(std::ostream &os,Opts::iterator i); |
|
275 |
void show(std::ostream &os,Groups::iterator i); |
|
276 |
void showHelp(Opts::iterator i); |
|
277 |
void showHelp(std::vector<OtherArg>::iterator i); |
|
278 |
void shortHelp(); |
|
279 |
void showHelp(); |
|
274 |
private: |
|
275 |
void show(std::ostream &os,Opts::const_iterator i) const; |
|
276 |
void show(std::ostream &os,Groups::const_iterator i) const; |
|
277 |
void showHelp(Opts::const_iterator i) const; |
|
278 |
void showHelp(std::vector<OtherArg>::const_iterator i) const; |
|
280 | 279 |
|
281 |
void unknownOpt(std::string arg); |
|
280 |
void unknownOpt(std::string arg) const; |
|
282 | 281 |
|
283 |
void requiresValue(std::string arg, OptType t); |
|
284 |
void checkMandatories(); |
|
282 |
void requiresValue(std::string arg, OptType t) const; |
|
283 |
void checkMandatories() const; |
|
284 |
|
|
285 |
void shortHelp() const; |
|
286 |
void showHelp() const; |
|
287 |
public: |
|
285 | 288 |
|
... | ... |
@@ -295,8 +298,8 @@ |
295 | 298 |
///Give back the command name (the 0th argument) |
296 |
const std::string &commandName() { return _command_name; } |
|
299 |
const std::string &commandName() const { return _command_name; } |
|
297 | 300 |
|
298 | 301 |
///Check if an opion has been given to the command. |
299 |
bool given(std::string op) |
|
302 |
bool given(std::string op) const |
|
300 | 303 |
{ |
301 |
Opts:: |
|
304 |
Opts::const_iterator i = _opts.find(op); |
|
302 | 305 |
return i!=_opts.end()?i->second.set:false; |
... | ... |
@@ -313,3 +316,3 @@ |
313 | 316 |
{ |
314 |
ArgParser &_parser; |
|
317 |
const ArgParser &_parser; |
|
315 | 318 |
std::string _name; |
... | ... |
@@ -317,3 +320,3 @@ |
317 | 320 |
///\e |
318 |
RefType(ArgParser &p,const std::string &n) :_parser(p),_name(n) {} |
|
321 |
RefType(const ArgParser &p,const std::string &n) :_parser(p),_name(n) {} |
|
319 | 322 |
///\e |
... | ... |
@@ -321,3 +324,3 @@ |
321 | 324 |
{ |
322 |
Opts:: |
|
325 |
Opts::const_iterator i = _parser._opts.find(_name); |
|
323 | 326 |
LEMON_ASSERT(i!=_parser._opts.end(), |
... | ... |
@@ -331,3 +334,3 @@ |
331 | 334 |
{ |
332 |
Opts:: |
|
335 |
Opts::const_iterator i = _parser._opts.find(_name); |
|
333 | 336 |
LEMON_ASSERT(i!=_parser._opts.end(), |
... | ... |
@@ -341,3 +344,3 @@ |
341 | 344 |
{ |
342 |
Opts:: |
|
345 |
Opts::const_iterator i = _parser._opts.find(_name); |
|
343 | 346 |
LEMON_ASSERT(i!=_parser._opts.end(), |
... | ... |
@@ -353,3 +356,3 @@ |
353 | 356 |
{ |
354 |
Opts:: |
|
357 |
Opts::const_iterator i = _parser._opts.find(_name); |
|
355 | 358 |
LEMON_ASSERT(i!=_parser._opts.end(), |
... | ... |
@@ -367,3 +370,3 @@ |
367 | 370 |
///\sa RefType |
368 |
RefType operator[](const std::string &n) |
|
371 |
RefType operator[](const std::string &n) const |
|
369 | 372 |
{ |
... | ... |
@@ -376,3 +379,3 @@ |
376 | 379 |
///not starting with a '-' character. |
377 |
std::vector<std::string> &files() { return _file_args; } |
|
380 |
const std::vector<std::string> &files() const { return _file_args; } |
|
378 | 381 |
|
0 comments (0 inline)