Bug 1653 - Extension of CommandLine interface
Extension of CommandLine interface
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
All All
: P5 normal
Assigned To: Alex Afanasyev
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-26 18:20 EDT by Alex Afanasyev
Modified: 2014-02-21 01:01 EST (History)
4 users (show)

See Also:


Attachments
Patch (6.91 KB, application/octet-stream)
2013-04-26 18:20 EDT, Alex Afanasyev
Details
Patch (11.09 KB, patch)
2013-07-27 18:51 EDT, Alex Afanasyev
Details | Diff
Fixup of previous patch (10.43 KB, patch)
2013-07-28 16:10 EDT, Alex Afanasyev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Afanasyev 2013-04-26 18:20:55 EDT
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.
Comment 1 Mathieu Lacage 2013-04-30 09:24:55 EDT
(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.
Comment 2 Tommaso Pecorella 2013-06-16 08:05:34 EDT
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"
Comment 3 Alex Afanasyev 2013-07-27 18:51:18 EDT
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 :)
Comment 4 Tom Henderson 2013-07-28 15:45:38 EDT
(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?
Comment 5 Alex Afanasyev 2013-07-28 16:10:32 EDT
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?
Comment 6 Tom Henderson 2013-07-29 00:40:46 EDT
(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.
Comment 7 Tom Henderson 2013-08-14 02:20:14 EDT
changeset 48f66512ec9b
Comment 8 Alex Afanasyev 2013-11-01 17:30:15 EDT
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?
Comment 9 Peter Barnes 2014-02-21 01:01:36 EST
operator << (std::ostream, CommandLine0 restored in patch r10621 
http://code.nsnam.org/ns-3-dev/rev/c23778df1349