--- a/CHANGES.html Tue Apr 03 14:45:16 2018 -0700
+++ b/CHANGES.html Tue Apr 03 14:49:27 2018 -0700
@@ -53,6 +53,8 @@
<hr>
<h1>Changes from ns-3.28 to ns-3-dev</h1>
<h2>New API:</h2>
+ <li> Added CommandLine::Parse (const std::vector<std::string>> args) </li>
+ <li> NS_LOG_FUNCTION can now log the contents of vectors </li>
<ul>
</ul>
<h2>Changes to existing API:</h2>
--- a/RELEASE_NOTES Tue Apr 03 14:45:16 2018 -0700
+++ b/RELEASE_NOTES Tue Apr 03 14:49:27 2018 -0700
@@ -28,6 +28,7 @@
Bugs fixed
----------
+- Bug 2901 - Add CommandLine::Parse (const std::vector<std::string>> args)
Known issues
------------
--- a/src/core/model/command-line.cc Tue Apr 03 14:45:16 2018 -0700
+++ b/src/core/model/command-line.cc Tue Apr 03 14:49:27 2018 -0700
@@ -110,16 +110,15 @@
}
void
-CommandLine::Parse (int argc, char *argv[])
+CommandLine::Parse (std::vector<std::string> args)
{
- NS_LOG_FUNCTION (this << argc << argv);
+ NS_LOG_FUNCTION (this << args.size () << args);
- m_name = SystemPath::Split (argv[0]).back ();
+ m_name = SystemPath::Split (args[0]).back ();
- for (int iargc = 1; iargc < argc; iargc++)
+ for (auto param : args)
{
// remove "--" or "-" heading.
- std::string param = argv[iargc];
std::string::size_type cur = param.find ("--");
if (cur == 0)
{
@@ -160,6 +159,14 @@
}
void
+CommandLine::Parse (int argc, char *argv[])
+{
+ NS_LOG_FUNCTION (this << argc);
+ std::vector<std::string> args (argv, argv + argc);
+ Parse (args);
+}
+
+void
CommandLine::PrintHelp (std::ostream &os) const
{
NS_LOG_FUNCTION (this);
--- a/src/core/model/command-line.h Tue Apr 03 14:45:16 2018 -0700
+++ b/src/core/model/command-line.h Tue Apr 03 14:49:27 2018 -0700
@@ -23,6 +23,7 @@
#include <string>
#include <sstream>
#include <list>
+#include <vector>
#include "callback.h"
@@ -285,6 +286,17 @@
void Parse (int argc, char *argv[]);
/**
+ * Parse the program arguments.
+ *
+ * This version may be convenient when synthesizing arguments
+ * programmatically. Other than the type of argument this behaves
+ * identically to Parse(int, char *)
+ *
+ * \param [in] args The vector of arguments.
+ */
+ void Parse (std::vector<std::string> args);
+
+ /**
* Get the program name
*
* \return The program name. Only valid after calling Parse()