Add function to better process function args and such

This commit is contained in:
sam-astro 2022-05-23 09:20:24 -04:00 committed by GitHub
parent ebb54a0a27
commit 5e02c71b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,6 +150,32 @@ int countNoOverlap(const string& str, const char& searchFor, const char& ch1, co
return cnt;
}
vector<string> splitNoOverlap(const string& str, const char& splitBy, const char& openChar, const char& closeChar)
{
vector<string> newStr;
int openCount = 0;
string tmpStr = "";
for (int i = 0; i < (int)str.size(); i++)
{
if (str[i] == splitBy && openCount == 0)
{
newStr.push_back(tmpStr);
tmpStr = "";
continue;
}
else if (str[i] == openChar)
openCount += 1;
else if (str[i] == closeChar)
openCount -= 1;
else
tmpStr += str[i];
}
return newStr;
}
string betweenChars(const string& str, const char& openChar, const char& closeChar)
{
string content = "";
@ -384,4 +410,4 @@ bool isEscaped(const string& str, int curChar)
return true;
return false;
}
}