00001
00002
00003
#ifndef Commands_H
00004
#define Commands_H
00005
00006
#include "RageTypes.h"
00007
00008 class Command
00009 {
00010
public:
00011
void Load(
const CString &sCommand );
00012
00013
CString GetOriginalCommandString()
const;
00014
00015
CString GetName()
const;
00016
00017 void Clear() {
m_vsArgs.clear(); }
00018
00019 struct Arg
00020 {
00021 CString s;
00022
operator CString ();
00023
operator float ();
00024
operator int ();
00025
operator bool ();
00026 };
00027
Arg GetArg(
unsigned index )
const;
00028
00029 vector<CString>
m_vsArgs;
00030 };
00031
00032 class Commands
00033 {
00034
public:
00035 vector<Command>
v;
00036 };
00037
00038
00039
00040
00041
00042
00043
void ParseCommands(
const CString &sCmds,
Commands &vCmdsOut );
00044
Commands ParseCommands(
const CString &sCmds );
00045
00046
00047 #define BeginHandleArgs int iMaxIndexAccessed = 0;
00048 #define GET_ARG(type,i) iMaxIndexAccessed = max( i, iMaxIndexAccessed ); command.GetArg##type( i );
00049 #define sArg(i) GetArg<CString>(command,i,iMaxIndexAccessed)
00050 #define fArg(i) GetArg<float>(command,i,iMaxIndexAccessed)
00051 #define iArg(i) GetArg<int>(command,i,iMaxIndexAccessed)
00052 #define bArg(i) GetArg<bool>(command,i,iMaxIndexAccessed)
00053 #define cArg(i) GetColorArg(command,i,iMaxIndexAccessed)
00054 #define EndHandleArgs if( iMaxIndexAccessed != (int)command.m_vsArgs.size()-1 ) { IncorrectNumberArgsWarning( command, iMaxIndexAccessed ); }
00055
void IncorrectNumberArgsWarning(
const Command& command,
int iMaxIndexAccessed );
00056
00057
template<
class T>
00058 inline T GetArg(
const Command& command,
int iIndex,
int& iMaxIndexAccessedOut )
00059 {
00060 iMaxIndexAccessedOut =
max( iIndex, iMaxIndexAccessedOut );
00061
return (
T)command.
GetArg(iIndex);
00062 }
00063
00064 inline RageColor GetColorArg(
const Command& command,
int iIndex,
int& iMaxIndexAccessed )
00065 {
00066
RageColor c;
00067
if( c.
FromString( GetArg<CString>(command,iIndex,iMaxIndexAccessed) ) )
00068
return c;
00069
else
00070
return RageColor(
fArg(iIndex+0),
fArg(iIndex+1),
fArg(iIndex+2),
fArg(iIndex+3) );
00071 }
00072
00073
#endif
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098