|
Bugzilla – Full Text Bug Listing |
| Summary: | Extension of CommandLine interface | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Alex Afanasyev <alexander.afanasyev> |
| Component: | core | Assignee: | Alex Afanasyev <alexander.afanasyev> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | ns-bugs, pdbarnes, tomh, tommaso.pecorella |
| Priority: | P5 | ||
| Version: | ns-3-dev | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Patch
Patch Fixup of previous patch |
||
(In reply to comment #0) > Created attachment 1574 [details] > Patch > > The attached patch extends CommandLine interface and allows requesting output > of command line arguments help message using a couple of alternative methods. ok, +1 for merging. I didn't understand the changes to be honest. I mean, I'm ok with it but I couldn't find the "couple of alternative methods" Created attachment 1648 [details]
Patch
Updated patch against the most recent changes in command-line.h|cc
The basic desire originally was (and still is) to be able to print out help message, in case scenario detects incompatible command-line arguments (rather than just exiting with just error message). There are two basic changes:
1. Moving PrintHelp to public section of the class
2. Changing prototype of all Print* functions to accept output stream as a first argument and then implementing an overloaded operator>>.
By "a couple methods" I meant just "cmd.PrintHelper (std::cout)" and "std::cout << cmd", but I agree this was a little bit confusing :)
(In reply to comment #3) > Created attachment 1648 [details] > Patch > > Updated patch against the most recent changes in command-line.h|cc > > The basic desire originally was (and still is) to be able to print out help > message, in case scenario detects incompatible command-line arguments (rather > than just exiting with just error message). There are two basic changes: > > 1. Moving PrintHelp to public section of the class > 2. Changing prototype of all Print* functions to accept output stream as a > first argument and then implementing an overloaded operator>>. > > By "a couple methods" I meant just "cmd.PrintHelper (std::cout)" and "std::cout > << cmd", but I agree this was a little bit confusing :) Does your documentation of PrintHelp() need updating, to match the commit message? Also, is it operator >> or insertion operator<< ? + * Alternatively, an overloaded operator >> can be used: + * @code + * CommandLine cmd; + * cmd.Parse (argc, argv); + * ... + * + * std::cerr << cmd; + * @endcode + */ Is this something that should be patched into the tutorial and one or more examples? Created attachment 1649 [details]
Fixup of previous patch
Oops. My mistake. Uploaded the corrected commit with corrected documentation of PrintHelp and similar documentation for operator<<.
Are you suggesting to make a new example or modify some existing example to show potential usage?
(In reply to comment #5) > Created attachment 1649 [details] > Fixup of previous patch > > Oops. My mistake. Uploaded the corrected commit with corrected documentation > of PrintHelp and similar documentation for operator<<. > > Are you suggesting to make a new example or modify some existing example to > show potential usage? Yes, I was just suggesting to feel free to extend the tutorial or example in an appropriate place; many people only learn about features they see in the tutorials or examples. I'll plan to push this later this week if there are no other comments. changeset 48f66512ec9b I noticed that one of the commits (http://code.nsnam.org/ns-3-dev/rev/5f6bab1bf0f4) undoes some of the previously added functions. In particular, it removes overloaded operator<< for CommandLine. Is there a particular reason for this removal or is just an accident? operator << (std::ostream, CommandLine0 restored in patch r10621 http://code.nsnam.org/ns-3-dev/rev/c23778df1349 |
Created attachment 1574 [details] Patch The attached patch extends CommandLine interface and allows requesting output of command line arguments help message using a couple of alternative methods.