Initial
This commit is contained in:
52
proto/source/COMMAND.CPP
Normal file
52
proto/source/COMMAND.CPP
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <proto/command.hpp>
|
||||
|
||||
void CommandLine::createCommands(String commandLine)
|
||||
{
|
||||
// String commandLine(::GetCommandLine());
|
||||
char *strPtr=(char*)commandLine;
|
||||
|
||||
mBlockCmds.remove();
|
||||
strPtr=::strtok(commandLine," \0");
|
||||
if(!strPtr)return;
|
||||
mBlockCmds.insert(&String(strPtr));
|
||||
while(TRUE)
|
||||
{
|
||||
strPtr=::strtok(0," \0");
|
||||
if(!strPtr)break;
|
||||
mBlockCmds.insert(&String(strPtr));
|
||||
}
|
||||
}
|
||||
|
||||
String CommandLine::argument(void)const
|
||||
{
|
||||
if(!mBlockCmds.size())return String();
|
||||
return const_cast<Block<String>&>(mBlockCmds)[mArgIndex];
|
||||
}
|
||||
|
||||
BOOL CommandLine::isOption(void)const
|
||||
{
|
||||
if(!mBlockCmds.size())return FALSE;
|
||||
String strArgument(const_cast<Block<String>&>(mBlockCmds)[mArgIndex]);
|
||||
if(strArgument.isNull()||*(strArgument)!='-')return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
String CommandLine::option(void)const
|
||||
{
|
||||
String optionString;
|
||||
|
||||
if(!mBlockCmds.size())return String();
|
||||
optionString=const_cast<Block<String>&>(mBlockCmds)[mArgIndex];
|
||||
if(optionString.isNull()||*(optionString)!='-'||optionString.length()<2)return String();
|
||||
return String(*((char*)optionString+1));
|
||||
}
|
||||
|
||||
String CommandLine::optionArg(void)const
|
||||
{
|
||||
String optionString;
|
||||
|
||||
if(!mBlockCmds.size())return String();
|
||||
optionString=const_cast<Block<String>&>(mBlockCmds)[mArgIndex];
|
||||
if(optionString.isNull()||*(optionString)!='-'||optionString.length()<=2)return String();
|
||||
return String(((char*)optionString+2));
|
||||
}
|
||||
Reference in New Issue
Block a user