76 lines
1.3 KiB
C++
76 lines
1.3 KiB
C++
#ifndef _PROTO_COMMANDLINE_HPP_
|
|
#define _PROTO_COMMANDLINE_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BLOCK_HPP_
|
|
#include <common/block.hpp>
|
|
#endif
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
|
|
class CommandLine
|
|
{
|
|
public:
|
|
CommandLine(String commandLine=::GetCommandLine());
|
|
virtual ~CommandLine();
|
|
BOOL operator++(void);
|
|
BOOL operator++(int postFixDummy);
|
|
BOOL operator--(void);
|
|
BOOL operator--(int postFixDummy);
|
|
String argument(void)const;
|
|
String option(void)const;
|
|
String optionArg(void)const;
|
|
BOOL isOption(void)const;
|
|
private:
|
|
void createCommands(String commandLine);
|
|
Block<String> mBlockCmds;
|
|
int mArgIndex;
|
|
};
|
|
|
|
inline
|
|
CommandLine::CommandLine(String commandLine)
|
|
: mArgIndex(0)
|
|
{
|
|
createCommands(commandLine);
|
|
}
|
|
|
|
inline
|
|
CommandLine::~CommandLine()
|
|
{
|
|
}
|
|
|
|
inline
|
|
BOOL CommandLine::operator++(void)
|
|
{
|
|
if(mArgIndex+1>=mBlockCmds.size())return FALSE;
|
|
mArgIndex++;
|
|
return TRUE;
|
|
}
|
|
|
|
inline
|
|
BOOL CommandLine::operator--(void)
|
|
{
|
|
if(mArgIndex-1<0)return FALSE;
|
|
mArgIndex--;
|
|
return TRUE;
|
|
}
|
|
|
|
inline
|
|
BOOL CommandLine::operator++(int /*postFixDummy*/)
|
|
{
|
|
if(mArgIndex+1>=mBlockCmds.size())return FALSE;
|
|
mArgIndex++;
|
|
return TRUE;
|
|
}
|
|
|
|
inline
|
|
BOOL CommandLine::operator--(int /*postFixDummy*/)
|
|
{
|
|
if(mArgIndex-1<0)return FALSE;
|
|
mArgIndex--;
|
|
return TRUE;
|
|
}
|
|
#endif
|