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:
Sorter();
std::vector<std::string> newWordList;
bool defaultOnly, fileGiven, allLists, sortGiven;
bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven;
SortType currentType;
std::string GetFilename(void);
void SetFilename(std::string newName);

View File

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