tCommandLineParser Struct Reference

command line data More...

#include <tCommandLine.h>

List of all members.

Public Member Functions

bool GetSwitch (char const *option, char const *option_short=NULL)
bool GetOption (tString &target, char const *option, char const *option_short=NULL)
 Tests whether the current argument is the given switch.
bool End () const
 Tests whether the current argument is the given option and extracts the value.
const char * Executable () const
 Tests whether the command line parsing is done.
const char * Current () const
 Returns the full path to the executable.
void Advance ()
 Returns the current option.
 tCommandLineParser (int argc, char **argv)
 Advances to the next option.

Private Member Functions

 tCommandLineParser ()
 constructor

Private Attributes

const int argc
 constructor
char ** argv
 total number of arguments
int index
 pointer array to arguments


Detailed Description

command line data

Definition at line 62 of file tCommandLine.h.


Constructor & Destructor Documentation

tCommandLineParser::tCommandLineParser ( int  a_argc,
char **  a_argv 
)

Advances to the next option.

Parameters:
a_argc number of arguments
a_argv arguments

Definition at line 303 of file tCommandLine.cpp.

00304         : argc( a_argc ), argv( a_argv ), index( 0 )
00305 {
00306 }

tCommandLineParser::tCommandLineParser (  )  [private]

constructor


Member Function Documentation

bool tCommandLineParser::GetSwitch ( char const *  option,
char const *  option_short = NULL 
)

Parameters:
option long version of the switch
option_short short version of the switch
Returns:
true if the switch was detected

Definition at line 222 of file tCommandLine.cpp.

References argv, End(), index, and tASSERT.

Referenced by tCommandLineData::Analyse(), gMainCommandLineAnalyzer::DoAnalyze(), tDirectoriesCommandLineAnalyzer::DoAnalyze(), rFastForwardCommandLineAnalyzer::DoAnalyze(), and GetOption().

00223 {
00224     if ( End() )
00225         return false;
00226 
00227     char * argument = argv[index];
00228     tASSERT( argument );
00229     if ( !strcmp(argument,option) || ( option_short && !strcmp(argument,option_short ) ) )
00230     {
00231         index++;
00232         return true;
00233     }
00234 
00235     return false;
00236 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool tCommandLineParser::GetOption ( tString target,
char const *  option,
char const *  option_short = NULL 
)

Tests whether the current argument is the given switch.

Parameters:
target string to store option to
option long version of the option
option_short short version of the option
Returns:
true if the option was detected

Definition at line 251 of file tCommandLine.cpp.

References argv, End(), GetSwitch(), index, QUIT, and tASSERT.

Referenced by gCommandLineJumpStartAnalyzer::DoAnalyze(), tRecordingCommandLineAnalyzer::DoAnalyze(), rFastForwardCommandLineAnalyzer::DoAnalyze(), and ReadDir().

00252 {
00253     if ( End() )
00254         return false;
00255 
00256     char * argument = argv[index];
00257     tASSERT( argument );
00258     if ( GetSwitch( option, option_short ) )
00259     {
00260         if ( !End() )
00261         {
00262             target = argv[index];
00263             index++;
00264             return true;
00265         }
00266         else
00267         {
00268             index--;
00269             tString name_;
00270             QUIT( "  " << argument << " needs another argument.\n" );
00271         }
00272     }
00273 
00274     return false;
00275 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool tCommandLineParser::End ( void   )  const

Tests whether the current argument is the given option and extracts the value.

Returns:
true if the options have been parsed to the end

Definition at line 287 of file tCommandLine.cpp.

References argc, and index.

Referenced by Advance(), tCommandLineData::Analyse(), GetOption(), and GetSwitch().

00288 {
00289     return ( index >= argc );
00290 }

Here is the caller graph for this function:

const char * tCommandLineParser::Executable ( void   )  const

Tests whether the command line parsing is done.

Returns:
the full path of the executable

Definition at line 333 of file tCommandLine.cpp.

References argv.

Referenced by tDirectoriesCommandLineAnalyzer::DoInitialize().

00334 {
00335     return argv[ 0 ];
00336 }

Here is the caller graph for this function:

const char * tCommandLineParser::Current ( void   )  const

Returns the full path to the executable.

Returns:
the current command line option

Definition at line 348 of file tCommandLine.cpp.

References argv, and index.

Referenced by tCommandLineData::Analyse().

00349 {
00350     return argv[ index ];
00351 }

Here is the caller graph for this function:

void tCommandLineParser::Advance ( void   ) 

Returns the current option.

Definition at line 362 of file tCommandLine.cpp.

References End(), index, and tASSERT.

Referenced by tCommandLineData::Analyse().

00363 {
00364     tASSERT( !End() );
00365     index ++;
00366 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const int tCommandLineParser::argc [private]

constructor

Definition at line 78 of file tCommandLine.h.

Referenced by End().

char* * tCommandLineParser::argv [private]

total number of arguments

Definition at line 79 of file tCommandLine.h.

Referenced by Current(), Executable(), GetOption(), and GetSwitch().

int tCommandLineParser::index [private]

pointer array to arguments

Definition at line 80 of file tCommandLine.h.

Referenced by Advance(), Current(), End(), GetOption(), and GetSwitch().


The documentation for this struct was generated from the following files:
Generated on Sat Mar 15 23:55:10 2008 for Armagetron Advanced by  doxygen 1.5.4