A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::CommandLine Class Reference

parse command-line argumentsInstances of this class can be used to parse command-line arguments: users can register new arguments with CommandLine::AddValue but the most important functionality provided by this class is that it can be used to set the 'initial value' of every attribute in the system with the More...

#include <command-line.h>

Classes

class  CallbackItem
 
class  Item
 
class  UserItem
 

Public Member Functions

 CommandLine (const CommandLine &cmd)
 
template<typename T >
void AddValue (const std::string &name, const std::string &help, T &value)
 
void AddValue (const std::string &name, const std::string &help, Callback< bool, std::string > callback)
 
CommandLineoperator= (const CommandLine &cmd)
 
void Parse (int argc, char *argv[]) const
 

Private Types

typedef std::list< Item * > Items
 

Private Member Functions

void Clear (void)
 
void Copy (const CommandLine &cmd)
 
void HandleArgument (std::string name, std::string value) const
 
void PrintAttributes (std::string type) const
 
void PrintGlobals (void) const
 
void PrintGroup (std::string group) const
 
void PrintGroups (void) const
 
void PrintHelp (void) const
 
void PrintTypeIds (void) const
 

Private Attributes

Items m_items
 

Detailed Description

parse command-line arguments

Instances of this class can be used to parse command-line arguments: users can register new arguments with CommandLine::AddValue but the most important functionality provided by this class is that it can be used to set the 'initial value' of every attribute in the system with the

*   --TypeIdName::AttributeName=value
* 

syntax and it can be used to set the value of every GlobalValue in the system with the

*   --GlobalValueName=value
* 

syntax.

Definition at line 50 of file command-line.h.

Member Function Documentation

template<typename T >
void ns3::CommandLine::AddValue ( const std::string &  name,
const std::string &  help,
T &  value 
)
Parameters
namethe name of the user-supplied argument
helpsome help text used by –PrintHelp
valuea reference to the variable where the value parsed will be stored (if no value is parsed, this variable is not modified).

Definition at line 134 of file command-line.h.

Referenced by AodvExample::Configure(), MeshTest::Configure(), CommandLineBooleanTestCase::DoRun(), CommandLineIntTestCase::DoRun(), CommandLineUnsignedIntTestCase::DoRun(), and CommandLineStringTestCase::DoRun().

void ns3::CommandLine::AddValue ( const std::string &  name,
const std::string &  help,
Callback< bool, std::string >  callback 
)
Parameters
namethe name of the user-supplied argument
helpsome help text used by –PrintHelp
callbacka callback function that will be invoked to parse and collect the value. This normally used by language bindings.

Definition at line 323 of file command-line.cc.

References NS_LOG_FUNCTION.

void ns3::CommandLine::Parse ( int  argc,
char *  argv[] 
) const
Parameters
argcthe 'argc' variable: number of arguments (including the main program name as first element).
argvthe 'argv' variable: a null-terminated array of strings, each of which identifies a command-line argument.

Obviously, this method will parse the input command-line arguments and will attempt to handle them all.

Definition at line 84 of file command-line.cc.

References NS_LOG_FUNCTION.

Referenced by AodvExample::Configure(), and MeshTest::Configure().


The documentation for this class was generated from the following files: