#include <tCommandLine.h>
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 |
Definition at line 62 of file tCommandLine.h.
tCommandLineParser::tCommandLineParser | ( | int | a_argc, | |
char ** | a_argv | |||
) |
Advances to the next option.
a_argc | number of arguments | |
a_argv | arguments |
Definition at line 303 of file tCommandLine.cpp.
tCommandLineParser::tCommandLineParser | ( | ) | [private] |
constructor
bool tCommandLineParser::GetSwitch | ( | char const * | option, | |
char const * | option_short = NULL | |||
) |
option | long version of the switch | |
option_short | short version of the switch |
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 }
bool tCommandLineParser::GetOption | ( | tString & | target, | |
char const * | option, | |||
char const * | option_short = NULL | |||
) |
Tests whether the current argument is the given switch.
target | string to store option to | |
option | long version of the option | |
option_short | short version of the option |
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 }
bool tCommandLineParser::End | ( | void | ) | const |
Tests whether the current argument is the given option and extracts the value.
Definition at line 287 of file tCommandLine.cpp.
Referenced by Advance(), tCommandLineData::Analyse(), GetOption(), and GetSwitch().
const char * tCommandLineParser::Executable | ( | void | ) | const |
Tests whether the command line parsing is done.
Definition at line 333 of file tCommandLine.cpp.
References argv.
Referenced by tDirectoriesCommandLineAnalyzer::DoInitialize().
00334 { 00335 return argv[ 0 ]; 00336 }
const char * tCommandLineParser::Current | ( | void | ) | const |
Returns the full path to the executable.
Definition at line 348 of file tCommandLine.cpp.
Referenced by tCommandLineData::Analyse().
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().
const int tCommandLineParser::argc [private] |
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().