Fixed arguments not setting fully

This commit is contained in:
TriantaTV 2023-02-11 19:28:12 -06:00
parent 79e00e3479
commit 27aa8cfeef
2 changed files with 8 additions and 9 deletions

View File

@ -17,7 +17,7 @@ private:
public: public:
Sorter(); Sorter();
std::vector<std::string> newWordList; std::vector<std::string> newWordList;
bool defaultOnly, fileGiven, allLists, sortGiven; bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven;
SortType currentType; SortType currentType;
std::string GetFilename(void); std::string GetFilename(void);
void SetFilename(std::string newName); void SetFilename(std::string newName);

View File

@ -10,7 +10,8 @@ Sorter::Sorter()
{ {
lineCount = 0; lineCount = 0;
currentType = INSERTION; currentType = INSERTION;
defaultOnly = 0; defaultFile = 0;
defaultOnly = 1;
fileGiven = 0; fileGiven = 0;
allLists = 0; allLists = 0;
sortGiven = 0; sortGiven = 0;
@ -246,27 +247,25 @@ void CheckArguments(int argc, char* arguments[], Sorter* sortObj)
tempStr = arguments[i]; tempStr = arguments[i];
if ((tempStr == "-a") || (tempStr == "--all")) if ((tempStr == "-a") || (tempStr == "--all"))
{ {
sortObj->defaultOnly = 0;
sortObj->allLists = 1; sortObj->allLists = 1;
return;
} }
if ((tempStr == "-f") || (tempStr == "--filename")) if ((tempStr == "-f") || (tempStr == "--filename"))
{ {
sortObj->SetFilename(arguments[i + 1]); sortObj->SetFilename(arguments[i + 1]);
sortObj->defaultOnly = 0;
sortObj->fileGiven = 1; sortObj->fileGiven = 1;
return;
} }
if ((tempStr == "-d") || (tempStr == "--default")) if ((tempStr == "-d") || (tempStr == "--default"))
{ {
sortObj->SetFilename("test/PERM/perm15K.txt"); sortObj->SetFilename("test/PERM/perm15K.txt");
sortObj->defaultOnly = 1; sortObj->defaultFile = 1;
return;
} }
if ((tempStr == "-s") || (tempStr == "--sort-type")) if ((tempStr == "-s") || (tempStr == "--sort-type"))
{ {
sortObj->sortGiven = 1; sortObj->sortGiven = 1;
tempStr = arguments[i + 1]; tempStr = arguments[i + 1];
std::cout << tempStr << '\n';
if (tempStr == "insertion") if (tempStr == "insertion")
sortObj->currentType = INSERTION; sortObj->currentType = INSERTION;
if (tempStr == "merge") if (tempStr == "merge")
@ -277,7 +276,7 @@ void CheckArguments(int argc, char* arguments[], Sorter* sortObj)
sortObj->sortGiven = 0; sortObj->sortGiven = 0;
} }
} }
if (sortObj->defaultOnly)
sortObj->SetFilename("test/PERM/perm15K.txt"); sortObj->SetFilename("test/PERM/perm15K.txt");
sortObj->defaultOnly = 1;
return; return;
} }