65   m_shortName = basename.substr (0, basename.rfind (
".cc"));
    89   std::copy (
cmd.m_options.begin (), 
cmd.m_options.end (), 
m_options.end ());
   143   if (args.size () > 0)
   145       args.erase (args.begin ());  
   147       for (
auto param : args)
   160                          "unexpected error parsing command line parameter: '"   166 #ifdef ENABLE_DES_METRICS   176   std::string arg = param;
   177   std::string::size_type cur = arg.find (
"--");
   180       arg = arg.substr (2, arg.size () - 2);
   184       cur = arg.find (
"-");
   187           arg = arg.substr (1, arg.size () - 1);
   196   cur = arg.find (
"=");
   197   std::string name, value;
   198   if (cur == std::string::npos)
   205       name = arg.substr (0, cur);
   206       value = arg.substr (cur + 1, arg.size () - (cur + 1));
   224       item->
m_name = 
"extra-non-option-argument";
   225       item->m_help = 
"Extra non-option argument encountered.";
   226       item->m_value = value;
   231   if (!i->Parse (value))
   233       std::cerr << 
"Invalid non-option argument value "   234                 << value << 
" for " << i->m_name
   249   std::vector<std::string> args (argv, argv + argc);
   262      << (
m_options.size ()  ? 
" [Program Options]" : 
"")
   263      << (nonOptions.size () ? 
" [Program Arguments]" : 
"")
   264      << 
" [General Arguments]"   273   std::size_t width = 0;
   276       width = 
std::max (width, it->m_name.size ());
   278   for (
auto it : nonOptions)
   280       width = 
std::max (width, it->m_name.size ());
   287       os << 
"Program Options:" << std::endl;
   291              << std::left << std::setw (width) << ( i->m_name + 
":")
   295           if ( i->HasDefault ())
   297               os << 
" [" << i->GetDefault () << 
"]";
   303   if (!nonOptions.empty ())
   307       os << 
"Program Arguments:" << std::endl;
   308       for (
auto i : nonOptions)
   311              << std::left << std::setw (width) << ( i->m_name + 
":")
   315           if ( i->HasDefault ())
   317               os << 
" [" << i->GetDefault () << 
"]";
   325     << 
"General Arguments:\n"   326     << 
"    --PrintGlobals:              Print the list of globals.\n"   327     << 
"    --PrintGroups:               Print the list of groups.\n"   328     << 
"    --PrintGroup=[group]:        Print all TypeIds of group.\n"   329     << 
"    --PrintTypeIds:              Print all TypeIds.\n"   330     << 
"    --PrintAttributes=[typeid]:  Print all attributes of typeid.\n"   331     << 
"    --PrintHelp:                 Print this help message.\n"   342   const char * envVar = std::getenv (
"NS_COMMANDLINE_INTROSPECTION");
   343   if (envVar == 0 || std::strlen (envVar) == 0)
   350       NS_FATAL_ERROR (
"No file name on example-to-run; forgot to use CommandLine var (__FILE__)?");
   360   NS_LOG_INFO (
"Writing CommandLine doxy to " << outf);
   362   std::fstream os (outf, std::fstream::out);
   366      << 
"<h3>Usage</h3>\n"   368      << (
m_options.size ()  ? 
" [Program Options]" : 
"")
   369      << (nonOptions.size () ? 
" [Program Arguments]" : 
"")
   380       os << 
"<h3>Program Options</h3>\n"   384           os << 
"  <dt>\\c --" << i->m_name << 
" </dt>\n"   385              << 
"    <dd>" << i->m_help;
   387           if ( i->HasDefault ())
   389               os << 
" [" << i->GetDefault () << 
"]";
   396   if (!nonOptions.empty ())
   399       os << 
"<h3>Program Arguments</h3>\n"   401       for (
auto i : nonOptions)
   403           os << 
"  <dt> \\c " << i->m_name << 
" </dt>\n"   404              << 
"    <dd>" << i->m_help;
   406           if ( i->HasDefault ())
   408               os << 
" [" << i->GetDefault () << 
"]";
   415   os << 
"*/" << std::endl;
   427   os << 
"Global values:" << std::endl;
   430   std::vector<std::string> globals;
   436       std::stringstream ss;
   437       ss << 
"    --" << (*i)->GetName () << 
"=[";
   441       ss << v.
Get () << 
"]" << std::endl;
   442       ss << 
"        " << (*i)->GetHelp () << std::endl;
   443       globals.push_back (ss.str ());
   445   std::sort (globals.begin (), globals.end ());
   446   for (std::vector<std::string>::const_iterator it = globals.begin ();
   462       NS_FATAL_ERROR (
"Unknown type=" << type << 
" in --PrintAttributes");
   465   os << 
"Attributes for TypeId " << tid.
GetName () << std::endl;
   468   std::vector<std::string> attributes;
   472       std::stringstream ss;
   477       ss << 
"        " << info.
help << std::endl;
   478       attributes.push_back (ss.str ());
   480   std::sort (attributes.begin (), attributes.end ());
   481   for (std::vector<std::string>::const_iterator it = attributes.begin ();
   482        it < attributes.end ();
   495   os << 
"TypeIds in group " << group << 
":" << std::endl;
   498   std::vector<std::string> groupTypes;
   502       std::stringstream ss;
   506           ss << 
"    " << tid.
GetName () << std::endl;
   508       groupTypes.push_back (ss.str ());
   510   std::sort (groupTypes.begin (), groupTypes.end ());
   511   for (std::vector<std::string>::const_iterator it = groupTypes.begin ();
   512        it < groupTypes.end ();
   523   os << 
"Registered TypeIds:" << std::endl;
   526   std::vector<std::string> types;
   530       std::stringstream ss;
   532       ss << 
"    " << tid.
GetName () << std::endl;
   533       types.push_back (ss.str ());
   535   std::sort (types.begin (), types.end ());
   536   for (std::vector<std::string>::const_iterator it = types.begin ();
   549   std::set<std::string> groups;
   556   os << 
"Registered TypeId groups:" << std::endl;
   558   for (std::set<std::string>::const_iterator k = groups.begin ();
   562       os << 
"    " << *k << std::endl;
   571   NS_LOG_DEBUG (
"Handle arg name=" << name << 
" value=" << value);
   574   if (name == 
"PrintHelp" || name == 
"help")
   580   else if (name == 
"PrintGroups")
   586   else if (name == 
"PrintTypeIds")
   592   else if (name == 
"PrintGlobals")
   598   else if (name == 
"PrintGroup")
   604   else if (name == 
"PrintAttributes")
   614           if (i->m_name == name)
   616               if (!i->Parse (value))
   618                   std::cerr << 
"Invalid argument value: "   619                             << name << 
"=" << value << std::endl;
   634       std::cerr << 
"Invalid command-line arguments: --"   635                 << name << 
"=" << value << std::endl;
   644   return m_default != 
"";
   657   NS_LOG_DEBUG (
"CommandLine::CallbackItem::Parse \"" << value << 
"\"");
   658   return m_callback (value);
   663                        const std::string &help,
   665                        std::string defaultValue )
   679                        const std::string &attributePath)
   683   std::size_t colon = attributePath.rfind (
"::");
   684   const std::string typeName = attributePath.substr (0, colon);
   685   NS_LOG_DEBUG (
"typeName: '" << typeName << 
"', colon: " << colon);
   693   const std::string attrName = attributePath.substr (colon + 2);
   700   std::stringstream ss;
   702      << 
" (" << attributePath << 
") ["   742                               const std::string value)
   789   std::ostringstream oss;
   790   oss << std::boolalpha << val;
   798   std::string src = value;
   799   std::transform (src.begin (), src.end (), src.begin (),
   800                   [](
char c) {
return static_cast<char> (std::tolower (c)); });
   801   if (src.length () == 0)
   806   else if ( (src == 
"true") || (src == 
"t") )
   811   else if ( (src == 
"false") || (src == 
"f") )
   818       std::istringstream iss;
   821       return !iss.bad () && !iss.fail ();
   829   uint8_t oldVal = val;
   834       newVal = std::stoi (value);
   836   catch (std::invalid_argument & ia)
   842   catch (std::out_of_range & oor)
   848   if (newVal < 0 || newVal > 255)
 ~CommandLine()
Destructor. 
 
void PrintHelp(std::ostream &os) const
Print program usage to the desired output stream. 
 
bool UserItemParse< bool >(const std::string value, bool &val)
Specialization of CommandLine::UserItem to bool. 
 
std::string GetName(void) const
Get the name. 
 
void PrintGroups(std::ostream &os) const
Handler for --PrintGroups: print all TypeId group names. 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
 
void PrintDoxygenUsage(void) const
Append usage message in Doxygen format to the file indicated by the NS_COMMANDLINE_INTROSPECTION envi...
 
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
 
Hold variables of type string. 
 
std::vector< Item * > Items
Argument list container. 
 
ns3::StringValue attribute value declarations. 
 
bool SetGlobalFailSafe(std::string name, const AttributeValue &value)
 
std::string m_value
The argument value. 
 
std::string GetName() const
Get the program name. 
 
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument. 
 
Items m_nonOptions
The list of non-option arguments. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
Vector::const_iterator Iterator
Iterator type for the list of all global values. 
 
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index. 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name. 
 
std::string GetDefault< bool >(const bool &val)
Helper to specialize CommandLine::UserItem::GetDefault() on bool. 
 
void PrintGlobals(std::ostream &os) const
Handler for --PrintGlobals: print all global variables and values. 
 
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const
Find an Attribute by name, retrieving the associated AttributeInformation. 
 
Declaration of the various ns3::Config functions and classes. 
 
static DesMetrics * Get(void)
Get a pointer to the singleton instance. 
 
ns3::DesMetrics declaration. 
 
void PrintAttributes(std::ostream &os, const std::string &type) const
Handler for --PrintAttributes: print the attributes for a given type. 
 
std::list< std::string > Split(std::string path)
Split a file system path into directories according to the local path separator. 
 
void Usage(const std::string usage)
Supply the program usage and documentation. 
 
bool HandleNonOption(const std::string &value)
Handle a non-option. 
 
ns3::SystemPath declarations. 
 
void Clear(void)
Remove all arguments, Usage(), name. 
 
An argument Item using a Callback to parse the input. 
 
void Initialize(std::vector< std::string > args, std::string outDir="")
Open the DesMetrics trace file and print the header. 
 
bool UserItemParse< uint8_t >(const std::string value, uint8_t &val)
Specialization of CommandLine::UserItem to uint8_t to distinguish from char. 
 
static bool HandleAttribute(const std::string name, const std::string value)
Callback function to handle attributes. 
 
virtual std::string GetDefault() const
 
Items m_options
The list of option arguments. 
 
bool HandleOption(const std::string ¶m) const
Handle an option in the form param=value. 
 
std::string Get(void) const
  
 
std::string m_shortName
The source file name (without .cc), as would be given to waf --run 
 
std::string m_usage
The Usage string. 
 
std::string GetDefault(void) const
 
static Iterator Begin(void)
The Begin iterator. 
 
ns3::Callback< bool, std::string > m_callback
The Callback. 
 
bool HasDefault(void) const
 
std::string m_default
The default value, as a string, if it exists. 
 
std::size_t GetNExtraNonOptions(void) const
Get the total number of non-option arguments found, including those configured with AddNonOption() an...
 
bool Parse(const std::string value)
Parse from a string. 
 
std::string GetDefault(void) const
 
std::string GetExtraNonOption(std::size_t i) const
Get extra non-option arguments by index. 
 
Parse command-line arguments. 
 
bool HasDefault(void) const
 
void HandleArgument(const std::string &name, const std::string &value) const
Match name against the program or general arguments, and dispatch to the appropriate handler...
 
std::size_t m_nonOptionCount
The number of actual non-option arguments seen so far. 
 
virtual bool Parse(const std::string value)
Parse from a string. 
 
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output 
 
ns3::CommandLine declaration. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
CommandLine & operator=(const CommandLine &cmd)
Assignment. 
 
std::string GetGroupName(void) const
Get the group name. 
 
ns3::TypeId declaration; inline and template implementations. 
 
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index. 
 
std::string m_name
Argument label: ---m_name=... 
 
void PrintGroup(std::ostream &os, const std::string &group) const
Handler for --PrintGroup: print all types belonging to a given group. 
 
ns3::GlobalValue declaration. 
 
CommandLine(void)
Constructor. 
 
virtual ~Item()
Destructor. 
 
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
 
std::string m_help
Argument help string. 
 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
 
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD. 
 
std::size_t GetAttributeN(void) const
Get the number of attributes. 
 
static Iterator End(void)
The End iterator. 
 
std::string Append(std::string left, std::string right)
Join two file system path elements. 
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index. 
 
void Copy(const CommandLine &cmd)
Copy constructor. 
 
void Parse(int argc, char *argv[])
Parse the program arguments. 
 
std::size_t m_NNonOptions
The expected number of non-option arguments. 
 
static uint16_t GetRegisteredN(void)
Get the number of registered TypeIds. 
 
a unique identifier for an interface. 
 
void PrintTypeIds(std::ostream &os) const
Handler for --PrintTypeIds: print all TypeId names. 
 
virtual bool HasDefault() const
 
Extension of Item for strings.