The is not currently parsing multiple config files properly. Changed up
the parser function without complicated check ahead logic. Will test if
this works.
This commit is contained in:
Maurice ONeal 2023-01-18 20:51:16 -05:00
parent 528b4105f7
commit 62a6139f3a
2 changed files with 33 additions and 41 deletions

View File

@ -282,29 +282,35 @@ bool rdConf(shared_t *share)
return ret;
}
string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int &offs)
vector<string> parseForList(const string &arg, int argc, char** argv, bool argOnly, int count)
{
auto ret = string();
auto argPresent = false;
auto argCount = 0;
auto ret = vector<string>();
for (; offs < argc; ++offs)
for (auto i = 0; i < argc; ++i)
{
auto argInParams = string(argv[offs]);
auto argInParams = string(argv[i]);
if (arg.compare(argInParams) == 0)
if (argPresent)
{
if (!argOnly)
{
offs++;
// check ahead, make sure offs + 1 won't cause out-of-range exception
if (offs <= (argc - 1))
{
ret = string(argv[offs]);
ret.push_back(argInParams);
argPresent = false;
}
}
else
else if (arg.compare(argInParams) == 0)
{
ret = string("true");
argPresent = true; argCount++;
}
if (argPresent && argOnly)
{
ret.push_back(string("true"));
}
if (count != 0)
{
if (argCount >= count) break;
}
}
@ -313,29 +319,16 @@ string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int
string parseForParam(const string &arg, int argc, char** argv, bool argOnly)
{
auto notUsed = 0;
auto params = parseForList(arg, argc, argv, argOnly, 1);
return parseForParam(arg, argc, argv, argOnly, notUsed);
}
vector<string> parseForList(const string &arg, int argc, char** argv)
if (params.empty())
{
auto offs = 0;
auto ret = vector<string>();
string param;
do
{
param = parseForParam(arg, argc, argv, false, offs);
if (!param.empty())
{
ret.push_back(param);
return string();
}
else
{
return params[0];
}
while (!param.empty());
return ret;
}
void waitForDetThreads(shared_t *share)

View File

@ -35,7 +35,7 @@ using namespace cv;
using namespace std;
using namespace std::filesystem;
#define APP_VER "1.6"
#define APP_VER "1.6.t1"
#define APP_NAME "Motion Watch"
struct shared_t
@ -73,7 +73,6 @@ struct shared_t
string genDstFile(const string &dirOut, const char *fmt, const string &ext);
string genTimeStr(const char *fmt);
string cleanDir(const string &path);
string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int &offs);
string parseForParam(const string &arg, int argc, char** argv, bool argOnly);
bool createDir(const string &dir);
bool createDirTree(const string &full_path);
@ -84,7 +83,7 @@ void rdLine(const string &param, const string &line, int *value);
void statOut(shared_t *share);
void waitForDetThreads(shared_t *share);
bool rdConf(shared_t *share);
vector<string> parseForList(const string &arg, int argc, char** argv);
vector<string> parseForList(const string &arg, int argc, char** argv, bool argOnly = false, int count = 0);
vector<string> lsFilesInDir(const string &path, const string &ext = string());
vector<string> lsDirsInDir(const string &path);