Arguments Class Reference

generic class to manage command arguments More...

#include <Arguments.hh>

Collaboration diagram for Arguments:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Arguments (int argc, char **argv, std::string usage="")
 ~Arguments ()
std::string getCommand ()
std::string getOption (const std::string) const
std::string getArgument (const unsigned int) const
unsigned int getNbOfArgs ()
unsigned int getNbOfOptions ()
void usage (void)

Private Attributes

std::string command
std::map< const std::string,
std::string > 
stringKeyMap
std::map< const unsigned int,
std::string > 
orderKeyMap
std::string pUsage

Detailed Description

generic class to manage command arguments

Distinguish command, arguments and options

Command name is not include in arguments list but can be accessed via getCommand() method

Options: words after a "-string": Examples : command -f option. : command -option1 option1. Option are not mandatory, and order in which they arrive does not matter. Access option with getOption("-string") method

Arguments are mandatory, and order in which they arrive is take in account Access argument with getArgument(order) method

Definition at line 27 of file Arguments.hh.


Constructor & Destructor Documentation

Arguments::Arguments ( int  argc,
char **  argv,
std::string  usage = "" 
)

Arguments::~Arguments (  ) 

Definition at line 34 of file Arguments.cpp.

00035 {
00036 }


Member Function Documentation

std::string Arguments::getCommand (  )  [inline]

Definition at line 34 of file Arguments.hh.

00034 { return command; } 

std::string Arguments::getOption ( const std::string   )  const

Referenced by main().

string Arguments::getArgument ( const unsigned  int  )  const

Definition at line 48 of file Arguments.cpp.

Referenced by main().

00049 {
00050 
00051   map<const unsigned int, string>::const_iterator it = orderKeyMap.find(key);
00052   if ( it !=  orderKeyMap.end() )  { return orderKeyMap.find(key)->second; }
00053   return string("");
00054 }

unsigned int Arguments::getNbOfArgs (  )  [inline]

Definition at line 37 of file Arguments.hh.

Referenced by main().

00037 { return orderKeyMap.size(); } 

unsigned int Arguments::getNbOfOptions (  )  [inline]

Definition at line 38 of file Arguments.hh.

Referenced by main().

00038 { return stringKeyMap.size(); } 

void Arguments::usage ( void   ) 

Definition at line 57 of file Arguments.cpp.

Referenced by main().

00058 {
00059   cout << "usage: " << pUsage << endl;
00060 }


Member Data Documentation

std::string Arguments::command [private]

Definition at line 43 of file Arguments.hh.

Referenced by getCommand().

std::map<const std::string , std::string> Arguments::stringKeyMap [private]

Definition at line 44 of file Arguments.hh.

Referenced by getNbOfOptions().

std::map< const unsigned int , std::string> Arguments::orderKeyMap [private]

Definition at line 45 of file Arguments.hh.

Referenced by getArgument(), and getNbOfArgs().

std::string Arguments::pUsage [private]

Definition at line 46 of file Arguments.hh.

Referenced by usage().


The documentation for this class was generated from the following files:
Generated on Mon Jan 7 13:17:56 2013 for MicromegasFramework by  doxygen 1.4.7