Changed containers the two containers that help actions and flags respectively to std::array, removed some unneeded functions
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#define ACTIONMANAGER_H_
|
#define ACTIONMANAGER_H_
|
||||||
|
|
||||||
#include<string>
|
#include<string>
|
||||||
|
#include<array>
|
||||||
#include<vector>
|
#include<vector>
|
||||||
|
|
||||||
#include"Models/Flags.h"
|
#include"Models/Flags.h"
|
||||||
@@ -21,8 +22,6 @@ namespace Managers
|
|||||||
bool isNumber(std::string);
|
bool isNumber(std::string);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void initializeSupportedActions();
|
|
||||||
void initializeSupportedFlags();
|
|
||||||
void validateAction();
|
void validateAction();
|
||||||
void validateFlags();
|
void validateFlags();
|
||||||
|
|
||||||
@@ -33,8 +32,13 @@ namespace Managers
|
|||||||
void printFlags();
|
void printFlags();
|
||||||
|
|
||||||
std::string action;
|
std::string action;
|
||||||
std::vector<std::string> supportedActions;
|
std::array<std::string, 4> supportedActions{
|
||||||
std::vector<std::string> supportedFlags;
|
"download", "upload", "retrieve", "delete"
|
||||||
|
};
|
||||||
|
std::array<std::string, 9> supportedFlags{
|
||||||
|
"-u", "-p", "-t", "-h", "-s",
|
||||||
|
"-d", "-D", "-b", "-rt"
|
||||||
|
};
|
||||||
std::vector<Models::Flags> flags;
|
std::vector<Models::Flags> flags;
|
||||||
char **params;
|
char **params;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ namespace Managers
|
|||||||
{
|
{
|
||||||
this->params = param;
|
this->params = param;
|
||||||
|
|
||||||
action = string{params[1]};
|
|
||||||
transform(action.begin(), action.end(),
|
|
||||||
action.begin(), ::tolower);
|
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
#pragma Constructors
|
#pragma Constructors
|
||||||
@@ -59,23 +55,11 @@ namespace Managers
|
|||||||
|
|
||||||
void ActionManager::initialize()
|
void ActionManager::initialize()
|
||||||
{
|
{
|
||||||
initializeSupportedActions();
|
|
||||||
validateAction();
|
|
||||||
validateFlags();
|
validateFlags();
|
||||||
}
|
|
||||||
void ActionManager::initializeSupportedActions()
|
action = string{params[1]};
|
||||||
{
|
transform(action.begin(), action.end(),
|
||||||
supportedActions = vector<string>{
|
action.begin(), ::tolower);
|
||||||
"download", "delete",
|
|
||||||
"retrieve", "upload"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
void ActionManager::initializeSupportedFlags()
|
|
||||||
{
|
|
||||||
supportedFlags = vector<string>{
|
|
||||||
"-u", "-p", "-t", "-h", "-s",
|
|
||||||
"-d", "-D", "-b", "-rt"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
void ActionManager::validateAction()
|
void ActionManager::validateAction()
|
||||||
{
|
{
|
||||||
@@ -100,7 +84,6 @@ namespace Managers
|
|||||||
cout<<"Validating flags"<<endl;
|
cout<<"Validating flags"<<endl;
|
||||||
|
|
||||||
auto flagVals = parsedFlags();
|
auto flagVals = parsedFlags();
|
||||||
initializeSupportedFlags();
|
|
||||||
|
|
||||||
Flags flg{};
|
Flags flg{};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user