34 lines
712 B
C++
34 lines
712 B
C++
|
#include "command.h"
|
||
|
|
||
|
Command::Command(const string& n, int (*funcptr)(const vector<string>* args)) : name(n) , funcCommand(funcptr){
|
||
|
checkObj();
|
||
|
numCom++;
|
||
|
}
|
||
|
|
||
|
int Command::execute(const vector<string>* args){
|
||
|
return (*funcCommand)(args);
|
||
|
}
|
||
|
|
||
|
string Command::getName(){
|
||
|
return this->name;
|
||
|
}
|
||
|
|
||
|
Command::Command(const Command& old) : name(old.name) , funcCommand(old.funcCommand){
|
||
|
checkObj();
|
||
|
numCom++;
|
||
|
}
|
||
|
|
||
|
void Command::checkObj(){
|
||
|
for(unsigned int i=0; i<name.length(); i++){
|
||
|
if(!((name[i]>'a'&&name[i]<'z')||(name[i]>'A'&&name[i]<'Z'))){
|
||
|
throw CommandNameNotValidException();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Command::~Command(){
|
||
|
numCom--;
|
||
|
}
|
||
|
|
||
|
unsigned int Command::numCom = 0;
|