24#include "../utils/timer.hpp"
25#include "../structures.hpp"
74 if (sLine.find_first_of(
"({") == std::string::npos)
78 while ((n_pos =
findNextFunction(
"string(", sLine, n_pos, nEndPosition)) != std::string::npos)
98 std::string sLeft = sLine.substr(0, n_pos);
101 if (sLeft.length() > 3 && sLeft.substr(sLeft.length() - 4) ==
"num(")
102 sLine = sLeft.substr(0, sLeft.length() - 4) +
toString(_idx.
row.
size()) + sLine.substr(sLine.find(
')', nEndPosition + 1) + 1);
103 else if (sLeft.length() > 3 && sLeft.substr(sLeft.length() - 4) ==
"max(")
104 sLine = sLeft.substr(0, sLeft.length() - 4) +
"\"" +
_data.
maxString(_idx.
row, _idx.
col) +
"\"" + sLine.substr(sLine.find(
')', nEndPosition + 1) + 1);
105 else if (sLeft.length() > 3 && sLeft.substr(sLeft.length() - 4) ==
"min(")
106 sLine = sLeft.substr(0, sLeft.length() - 4) +
"\"" +
_data.
minString(_idx.
row, _idx.
col) +
"\"" + sLine.substr(sLine.find(
')', nEndPosition + 1) + 1);
107 else if (sLeft.length() > 3 && sLeft.substr(sLeft.length() - 4) ==
"sum(")
108 sLine = sLeft.substr(0, sLeft.length() - 4) +
"\"" +
_data.
sumString(_idx.
row, _idx.
col) +
"\"" + sLine.substr(sLine.find(
')', nEndPosition + 1) + 1);
115 std::string sString =
"";
116 std::vector<std::string> vStrings;
118 for (
size_t i = 0; i < _idx.
row.
size(); i++)
124 sLine = sLine.substr(0, n_pos) + sString + sLine.substr(nEndPosition + 1);
127 sLine = sLine.substr(0, n_pos) +
"\"\"" + sLine.substr(nEndPosition + 1);
133 if (sLine.find_first_of(
"({") == std::string::npos)
139 if (sLine.find(
'(') == std::string::npos)
145 if (sLine.find(
'{') == std::string::npos)
151 if (sLine.find(
'{') == std::string::npos)
175 return sIndexExpression;
177 std::string sParsedIndices;
181 while (sIndexExpression.length())
192 if (sIndexPairs ==
"#")
194 if (sParsedIndices.length())
195 sParsedIndices +=
",#";
197 sParsedIndices =
"#";
211 std::vector<mu::value_type> vIndices;
214 for (
size_t i = 0; i < strRes.
vResult.size(); i++)
218 if (sParsedIndices.length())
225 if (sParsedIndices.length())
226 sParsedIndices +=
", " + strRes.
vResult[0].to_string();
228 sParsedIndices = strRes.
vResult[0].to_string();
232 return sParsedIndices;
247 size_t nStartPosition = 0;
251 while ((nStartPosition =
findNextFunction(sOccurence, sLine, nStartPosition, nEndPosition,
true)) != std::string::npos)
253 size_t nStartPos = nStartPosition;
254 size_t nEndPos = nEndPosition;
258 if (nStartPosition > 4 && sLine.substr(sLine.rfind(
'(', nStartPosition) - 4, 5) ==
"norm(")
266 std::string sData = sLine.substr(nStartPos, nEndPos - nStartPos + 1);
269 if (sData.find(
"().") != std::string::npos)
276 sData = vRes.front();
284 sData.replace(nStartPosition-nStartPos+sOccurence.length(),
285 nEndPosition-nStartPosition-sOccurence.length(),
313 sLine = sLine.substr(0, nStartPos) + sData + sLine.substr(nEndPos + 1);
315 nStartPosition = nStartPos+1;
333 if (sLine.find(
'#') == std::string::npos)
337 std::string sLineToParsed = sLine +
" ";
338 std::string sLineToParsedTemp;
340 unsigned int nPos = 0;
341 unsigned int n_pos = 0;
344 while (sLineToParsed.find(
'#', nPos) != std::string::npos)
347 nPos = sLineToParsed.find(
'#', nPos);
352 std::string sPrefix =
"";
353 sLineToParsedTemp += sLineToParsed.substr(0, nPos);
354 sLineToParsed = sLineToParsed.substr(nPos + 1);
358 if (sLineToParsed[0] ==
'~')
360 for (
unsigned int i = 0; i < sLineToParsed.length(); i++)
362 if (sLineToParsed[i] !=
'~')
364 sPrefix = sLineToParsed.substr(0, i);
365 sLineToParsed = sLineToParsed.substr(i);
372 if (sLineToParsed[0] ==
'-' || sLineToParsed[0] ==
'+')
379 if (sLineToParsed[0] ==
'(' || sLineToParsed[0] ==
'{')
396 for (
size_t i = 0; i < strRes.
vResult.size(); i++)
403 sLineToParsedTemp += sExpr;
409 sLineToParsed.clear();
421 for (
size_t i = 0; i < strRes.
vResult.size(); i++)
423 sExpr += strRes.
vResult[i] +
",";
432 else if (sLineToParsed[0] ==
'"')
435 std::string sExpr = sLineToParsed.substr(1, sLineToParsed.find(
'"', 1) - 1);
438 while (sExpr.length() < sPrefix.length() + 2)
439 sExpr.insert(0, 1,
'0');
442 sLineToParsedTemp +=
"\"" + sExpr +
"\"";
443 if (sLineToParsed.find(
'"', 1) < sLineToParsed.length() - 1)
444 sLineToParsed = sLineToParsed.substr(sLineToParsed.find(
'"', 1) + 1);
446 sLineToParsed.clear();
450 else if (sLineToParsed[0] ==
'<')
453 if (sLineToParsed.find(
"<>") == 0
454 || sLineToParsed.find(
"<this>") == 0
455 || sLineToParsed.find(
"<wp>") == 0
456 || sLineToParsed.find(
"<loadpath>") == 0
457 || sLineToParsed.find(
"<savepath>") == 0
458 || sLineToParsed.find(
"<plotpath>") == 0
459 || sLineToParsed.find(
"<procpath>") == 0
460 || sLineToParsed.find(
"<scriptpath>") == 0)
463 if (sLineToParsed.find(
"<>") == 0 || sLineToParsed.find(
"<this>") == 0)
465 else if (sLineToParsed.find(
"<wp>") == 0)
467 else if (sLineToParsed.find(
"<loadpath>") == 0)
469 else if (sLineToParsed.find(
"<savepath>") == 0)
471 else if (sLineToParsed.find(
"<plotpath>") == 0)
473 else if (sLineToParsed.find(
"<procpath>") == 0)
477 sLineToParsed = sLineToParsed.substr(sLineToParsed.find(
'>') + 1);
479 else if (sLineToParsed.find(
'>') != std::string::npos)
482 sLineToParsedTemp +=
"\"" + sLineToParsed.substr(1, sLineToParsed.find(
'>') - 1) +
"\"";
483 sLineToParsed = sLineToParsed.substr(sLineToParsed.find(
'>') + 1);
506 for (
size_t i = 0; i < strRes.
vResult.size(); i++)
513 sLineToParsedTemp += sExpr;
518 sLineToParsed.clear();
527 std::vector<std::string> vResults;
528 std::string sElement =
"";
534 for (
int n = 0; n < nResults; n++)
538 while (sElement.length() < sPrefix.length() + 1)
539 sElement.insert(0, 1,
'0');
547 sLineToParsedTemp += sElement;
553 sLineToParsed.clear();
562 if (sLineToParsed.length() && sLineToParsedTemp.length())
563 sLineToParsedTemp += sLineToParsed;
566 if (sLineToParsedTemp.find(
'{') != std::string::npos)
572 if (sLineToParsedTemp.length())
573 sLineToParsed = sLineToParsedTemp;
575 sLineToParsed = sLine;
577 return sLineToParsed;
612 for (
int n = nCurrentComponent; n < (int)nStrings; n++)
614 if (!strRes.
vResult[n].length()
621 nCurrentComponent = nStrings;
629 int nthComponent = 0;
637 for (
size_t i = nCurrentComponent; i < strRes.
vResult.size(); i++)
670 for (
int j = 0; j < nResults; j++)
682 nCurrentComponent = nStrings;
690 int nthComponent = 0;
692 bool rewriteColumn =
false;
695 rewriteColumn =
true;
699 for (
size_t i = nCurrentComponent; i < strRes.
vResult.size(); i++)
713 if (i == nCurrentComponent && rewriteColumn)
730 for (
int j = 0; j < nResults; j++)
741 if (i == nCurrentComponent
757 nCurrentComponent = nStrings;
784 for (
size_t i = 0; i < _idx.
row.
size(); i++)
786 if (nCurrentComponent == nStrings)
810 if (!__sObject.length() || (nBracePos = __sObject.find_first_not_of(
' ')) == std::string::npos)
816 if (__sObject[nBracePos] ==
'{')
820 size_t nStrings = strRes.
vResult.size();
821 size_t nCurrentComponent = 0;
824 while (__sObject.length())
835 else if (sObject.find(
"string(") != std::string::npos)
844 if (sObject.find(
' ') != std::string::npos)
848 if (nCurrentComponent >= nStrings)
863 if (sObject.find(
' ') != std::string::npos)
899 for (
int n = 0; n < nResults; n++)
906 strRes.
vResult[nCurrentComponent] = sValues;
916 else if (strRes.
vNoStringVal.size() <= nCurrentComponent)
974 std::vector<bool>& vIsNoStringValue = StrRes.
vNoStringVal;
984 for (
size_t i = 0; i < vFinal.size(); i++)
985 sLine += vFinal.
getRef(i) +
",";
993 std::string sConsoleOut;
1001 for (
size_t j = 0; j < vFinal.size(); j++)
1007 if (!(parserFlags &
NO_QUOTES) && !vIsNoStringValue[j])
1008 sLine += vFinal.
getRef(j);
1010 sLine += vFinal[j].to_string();
1012 if (j < vFinal.size() - 1)
1018 if (!vIsNoStringValue[j])
1023 sLine += vFinal[j].to_string();
1025 sLine += vFinal.
getRef(j);
1034 for (
int k = 0; k < nResults-1; k++)
1038 sLine += stres +
", ";
1047 if (j + 1 == vFinal.size())
1073 std::string sConsoleOut =
"|-> ";
1074 bool bLineBreaks =
false;
1078 for (
size_t j = 0; j < strRes.
vResult.size(); j++)
1082 if (strRes.
vResult[j].find(
'\n') != std::string::npos)
1085 sConsoleOut = sConsoleOut + strRes.
vResult[j];
1094 for (
int k = 0; k < nResults-1; k++)
1097 sConsoleOut += stres +
", ";
1101 sConsoleOut += stres;
1105 if (j + 1 == strRes.
vResult.size())
1110 sConsoleOut +=
", ";
1123 std::vector<std::string> vStringResult;
1126 for (
size_t j = 0; j < strRes.
vResult.size(); j++)
1132 vStringResult.push_back(strRes.
vResult[j].to_string());
1133 replaceAll(vStringResult.back(),
"\"",
"\\\"");
1138 replaceAll(vStringResult.back(),
"\"",
"\\\"", 1, vStringResult.back().length()-1);
1141 replaceAll(vStringResult.back(),
"\n",
"\\n");
1142 replaceAll(vStringResult.back(),
"\t",
"\\t");
1151 for (
int k = 0; k < nResults-1; k++)
1178 std::vector<int> vPositions;
1187 if (vPositions.back())
1188 parserFlags |= iter->second;
1193 if (!vPositions.size())
1199 sort(vPositions.begin(), vPositions.end());
1203 for (
size_t i = 0; i < vPositions.size(); i++)
1207 sLine.erase(sLine.rfind(
'-', vPositions[i]));
1235 for (
size_t i = 0; i < sLine.size(); i++)
1237 if (sLine[i] ==
'"' && (!i || sLine[i-1] !=
'\\'))
1245 if (!(nQuotes % 2) && !isspace(sLine[i]) && sLine[i] !=
',')
1265 size_t nLength = strlen(sToken);
1267 if (sLine.length() < pos + nLength)
1270 if (sLine.substr(pos, nLength) == sToken && (sLine.length() == pos+nLength ||
isDelimiter(sLine[pos+nLength])))
1310 if (oprt ==
"==" || oprt ==
"!=" || oprt ==
"<" || oprt ==
">" || oprt ==
"<=" || oprt ==
">=")
1313 if (oprt ==
"&&" || oprt ==
"||" || oprt ==
"|||")
1330 std::stack<size_t> stIf;
1331 std::stack<size_t> stElse;
1333 bool lastIsIf =
false;
1335 for (
size_t j = 0; j < rpnStack.size(); j++)
1337 if (rpnStack[j].m_data ==
"?")
1345 if (rpnStack[j].m_data ==
":" && stIf.size())
1347 if (!lastIsIf && stElse.size())
1352 rpnStack[idx].m_val = j;
1359 rpnStack[idx].m_val = j;
1365 while (stElse.size())
1369 rpnStack[idx].m_val = rpnStack.size();
1382 static std::vector<StringStackItem>
convertToStack(
const std::vector<StringView>& vTokens)
1384 std::vector<StringStackItem> rpnStack;
1385 std::stack<StringView> operators;
1389 for (
size_t i = 0; i < vTokens.size(); i++)
1396 if (vTokens[i] ==
"?" || (vTokens[i] ==
":" && hasIf > 0))
1399 while (operators.size())
1406 hasIf += (vTokens[i] ==
"?") - (vTokens[i] ==
":");
1412 if (vTokens[i] ==
"," && !hasIf)
1415 while (operators.size())
1428 while (operators.size()
1436 operators.push(vTokens[i]);
1442 while (operators.size())
1477 std::vector<StringView> vTokens;
1489 for (
size_t i = 0; i < sExpr.
length(); i++)
1492 if (sExpr[i] ==
'"' && (!i || sExpr[i-1] !=
'\\'))
1499 if (sExpr[i] ==
'(' || sExpr[i] ==
'[' || sExpr[i] ==
'{')
1503 if (sExpr.
subview(i, 3) ==
"|||")
1510 vTokens.push_back(sToken);
1511 vTokens.push_back(sExpr.
subview(i, 3));
1517 else if (sExpr.
subview(i, 2) ==
"=="
1518 || sExpr.
subview(i, 2) ==
"!="
1519 || sExpr.
subview(i, 2) ==
"<="
1520 || sExpr.
subview(i, 2) ==
">="
1521 || sExpr.
subview(i, 2) ==
"&&"
1522 || sExpr.
subview(i, 2) ==
"||")
1529 vTokens.push_back(sToken);
1530 vTokens.push_back(sExpr.
subview(i, 2));
1536 else if (sExpr[i] ==
'+'
1543 if (sExpr[i] ==
':' && hasIf <= 0)
1545 else if (sExpr[i] ==
',' && hasIf > 0)
1547 else if (sExpr[i] ==
':')
1549 else if (sExpr[i] ==
'?')
1557 vTokens.push_back(sToken);
1558 vTokens.push_back(sExpr.
subview(i, 1));
1566 if (i+1 == sExpr.
length())
1568 vTokens.push_back(sExpr);
1578 g_logger.
warning(
"Returned from StringParser::createStack() from an unexpected statement.");
1579 return std::vector<StringStackItem>();
1595 std::stack<StringVector> valueStack;
1596 size_t nReturnValues = 1;
1598 for (
size_t i = from; i < to; i++)
1601 if (rpnStack[i].m_val < 0)
1603 std::string sValue = rpnStack[i].m_data.to_string();
1605 if (sValue.front() ==
'"')
1616 if (rpnStack[i].m_data ==
"+")
1620 valueStack.top() += op;
1622 else if (rpnStack[i].m_data ==
",")
1627 else if (rpnStack[i].m_data ==
"==")
1631 valueStack.top() = valueStack.top() == op;
1633 else if (rpnStack[i].m_data ==
"!=")
1637 valueStack.top() = valueStack.top() != op;
1639 else if (rpnStack[i].m_data ==
">=")
1643 valueStack.top() = valueStack.top() >= op;
1645 else if (rpnStack[i].m_data ==
"<=")
1649 valueStack.top() = valueStack.top() <= op;
1651 else if (rpnStack[i].m_data ==
">")
1655 valueStack.top() = valueStack.top() > op;
1657 else if (rpnStack[i].m_data ==
"<")
1661 valueStack.top() = valueStack.top() < op;
1663 else if (rpnStack[i].m_data ==
"&&")
1667 valueStack.top() = valueStack.top().
and_f(op);
1669 else if (rpnStack[i].m_data ==
"||")
1673 valueStack.top() = valueStack.top().
or_f(op);
1675 else if (rpnStack[i].m_data ==
"|||")
1679 valueStack.top() = valueStack.top().
xor_f(op);
1681 else if (rpnStack[i].m_data ==
"?")
1684 size_t nIfEnd = rpnStack[i].m_val;
1685 size_t nElseEnd = rpnStack[nIfEnd].m_val;
1688 valueStack.top().evalIfElse(valueStack.top(),
1709 if (nReturnValues > valueStack.size())
1710 throw std::out_of_range(
"Stack size (" +
toString(valueStack.size()) +
") is smaller than the requested number of return values (" +
toString(nReturnValues) +
").");
1716 while (nReturnValues)
1718 vRet.insert(vRet.begin(), valueStack.top().begin(), valueStack.top().end());
1737 std::vector<StringStackItem> rpnStack =
createStack(sExpr);
1744 for (
size_t i = 0; i < res.
vResult.size(); i++)
1768 std::vector<bool> vIsNoStringValue(vFinal.size(),
false);
1771 for (
unsigned int n = 0; n < vFinal.size(); n++)
1777 if (!vFinal[n].length())
1789 if (vFinal[n].front() ==
'"' || vFinal[n].back() ==
'"')
1794 if (vFinal[n].front() !=
'"' && vFinal[n].back() !=
'"')
1795 vIsNoStringValue[n] =
true;
1799 bReturningLogicals =
true;
1801 for (
size_t i = 0; i < vIsNoStringValue.size(); i++)
1803 if (!vIsNoStringValue[i])
1805 bReturningLogicals =
false;
1810 return vIsNoStringValue;
1828 bool bObjectContainsTablesOrClusters =
false;
1837 while (sLine.length())
1850 if (strExpr.
nEqPos && strExpr.
sLine.find(
',') != std::string::npos)
1853 std::string sStringObject = strExpr.
sLine.substr(0, strExpr.
nEqPos);
1857 if (sStringObject.substr(sStringObject.find_first_not_of(
' '), 7) ==
"string("
1859 || sStringObject[sStringObject.find_first_not_of(
' ')] ==
'{')
1863 nPos = strExpr.
sLine.find(
'=', nPos);
1866 if (nPos == std::string::npos)
1871 if (strExpr.
sLine[nPos + 1] ==
'=')
1874 sStringObject = strExpr.
sLine.substr(0, nPos + 1);
1875 strExpr.
sLine.erase(0, nPos + 1);
1878 sStringObject.clear();
1886 std::string sRecursion =
"";
1887 std::vector<std::string> vResult;
1890 while (strExpr.
sLine.length())
1899 for (
size_t n = 0; n < _res.
vResult.size(); n++)
1908 if (sStringObject.length())
1909 strExpr.
sLine = sStringObject + strExpr.
sLine;
1918 n_pos = strExpr.
nEqPos+1;
1926 if (strExpr.
sLine.find(
'(') != std::string::npos)
1943 bObjectContainsTablesOrClusters =
true;
1952 if (strExpr.
sLine.find_first_not_of(
"+-*/:?!.,;%&<>=^ ") != std::string::npos && bParseNumericals)
1992 while (strExpr.
sLine.length())
2003 if (strExpr.
sLine.find(
'(') != std::string::npos)
2008 for (
size_t i = 0; i < strExpr.
sLine.length(); i++)
2011 if (strExpr.
sLine[i] ==
'"')
2013 if (i && strExpr.
sLine[i - 1] ==
'\\')
2019 if (strExpr.
sLine[i] ==
'#' && !(nQuotes % 2))
2023 for (
size_t j = i; j < strExpr.
sLine.length(); j++)
2025 if (strExpr.
sLine[j] ==
'"')
2031 if (strExpr.
sLine[j] ==
' ' || strExpr.
sLine[j] ==
'+')
2037 if (j + 1 == strExpr.
sLine.length())
2046 if (strExpr.
sLine[i] ==
'(' && !(nQuotes % 2))
2055 if (i < 6 || strExpr.
sLine.substr(i - 6, 6) !=
"string")
2058 std::string sString = strExpr.
sLine.substr(i + 1, nPos - i - 1);
2069 if (!strvar.length())
2072 strExpr.
sLine = strExpr.
sLine.substr(0, i + 1) + strvar + strExpr.
sLine.substr(nPos);
2083 if (!strvar.length())
2086 strExpr.
sLine = strExpr.
sLine.substr(0, i) + strvar + strExpr.
sLine.substr(nPos + 1);
2095 if (strExpr.
sLine.find(
'{') != std::string::npos)
2100 for (
size_t i = 0; i < strExpr.
sLine.length(); i++)
2102 if (strExpr.
sLine[i] ==
'"' && (!i || strExpr.
sLine[i-1] !=
'\\'))
2105 if (!(nQuotes % 2) && strExpr.
sLine[i] ==
'{')
2108 std::string sVectorTemp = strExpr.
sLine.substr(i+1, nmatching-1);
2114 if (sVectorTemp.find(
':') != std::string::npos)
2126 std::vector<mu::value_type> vRes(res, res + nRes);
2145 std::vector<mu::value_type> vRes(res, res + nRes);
2163 else if (tempres.
vResult.size() == 1 && tempres.
vResult.front().find_first_of(
":,") != std::string::npos)
2171 std::vector<mu::value_type> vRes(res, res + nRes);
2177 strExpr.
sLine.replace(i, nmatching+1, sVectorTemp);
2185 if (!strExpr.
sLine.length())
2190 if (strExpr.
sLine.find(
'"') == std::string::npos
2191 && strExpr.
sLine.find(
'#') == std::string::npos
2193 && !bObjectContainsTablesOrClusters)
2237 sLine =
" " + sLine +
" ";
2254 if (bCheckAssertions)
2272 if (parserFlags &
PEEK)
2299 if (sExpression.find_first_of(
"\"#") != std::string::npos
2300 || sExpression.find(
"string(") != std::string::npos
2301 || sExpression.find(
"string_cast(") != std::string::npos
2302 || sExpression.find(
"char(") != std::string::npos
2303 || sExpression.find(
"getlasterror(") != std::string::npos
2304 || sExpression.find(
"getversioninfo(") != std::string::npos
2305 || sExpression.find(
"valtostr(") != std::string::npos
2306 || sExpression.find(
"weekday(") != std::string::npos
2307 || sExpression.find(
"to_tex(") != std::string::npos)
2313 if (sExpression.find(
'{') == std::string::npos)
2318 for (
auto iter = mClusterMap.begin(); iter != mClusterMap.end(); ++iter)
2320 if (iter->second.isMixed() || iter->second.isString())
2322 size_t pos = sExpression.find(iter->first +
"{");
2324 if (pos != std::string::npos && (!pos ||
isDelimiter(sExpression[pos-1])))
void checkAssertion(mu::value_type *v, int nNum)
Checks the return value of a muParser evaluated result.
This class is defined to abstrahize the determination of the correct data object and the calculation ...
Indices & getIndices()
Returns a reference to the stored indices.
bool isCluster() const
Determines, whether the data access references a cluster.
std::string & getDataObject()
Returns a reference to the data object identifier.
void warning(const std::string &sMessage)
Convenience member function.
This class represents the central memory managing instance. It will handle all tables and clusters,...
TableColumn::ColumnType getType(const VectorIndex &_vCol, const std::string &_sTable) const
const std::map< std::string, std::pair< size_t, size_t > > & getTableMap() const
void overwriteColumn(int col, const std::string &_sCache, TableColumn::ColumnType type)
This member function converts the selected column to the needed type, if this column shall be overwri...
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
void writeToTable(int _nLine, int _nCol, const std::string &_sCache, const mu::value_type &_dData)
bool setHeadLineElement(int _i, const std::string &_sTable, std::string _sHead)
This class represents a whole cluster. The single items are stored as pointers to the abstract cluste...
void clear()
This member function clears the internal memory buffer and frees the associated memory.
void setDouble(size_t i, const mu::value_type &value)
This member function assigns a value as data for the i-th cluster item in memory. The type of the i-t...
void push_back(ClusterItem *item)
This member function appends an arbitrary cluster item at the back of the internal cluster array buff...
void setString(size_t i, const std::string &strval)
This member function assigns a string as data for the i-th cluster item in memory....
void setDoubleArray(const std::vector< mu::value_type > &vVals)
This member function assigns values as data for the all cluster items in memory. The type of the clus...
Cluster & getCluster(StringView sCluster)
This member function returns a reference to the cluster indicated by the passed cluster identifier.
const std::map< std::string, Cluster > & getClusterMap() const
This class provides the complete function evaluation logic to the StringParser class.
std::string applyStringFuncs(std::string sLine)
This member function searches for an occurence of a known string function in the passed command line ...
std::string applySpecialStringFuncs(std::string sLine)
This member function applies special string functions in the expression, which cannot be implemented ...
size_t findNextFunction(const std::string &sFunc, StringView sLine, size_t nStartPos, size_t &nEndPosition, bool searchForMethods=false)
Finds the position of the next function occurence in the passed string including the position of the ...
StringView getFunctionArgumentList(const std::string &sFunc, StringView sLine, size_t nStartPosition, size_t nEndPosition)
Returns the contents of the argument parentheses of the function starting at nStartPosition.
void declareStringFuncs(const std::map< std::string, StringFuncHandle > &mStringFuncs)
This member function is used to fill the internal map of declared string functions with the data of t...
std::string printValue(const mu::value_type &value)
Prints a value to a string respecting possible integer optimizations.
This class handles all logical operations on string expressions.
void concatenateStrings(std::string &sExpr)
This member function performs the actual string concatenation of the passed string expression.
std::string evalStringLogic(std::string sLine, bool &bReturningLogicals)
This member function will evaluate logical string expressions in the passed command line.
bool detectStringLogicals(const std::string &sString)
This member function is may detect logical expressions in the passed string expression.
StringResult createAndEvaluateStack(StringView sExpr)
Create a stack from the expression and evaluate it.
bool isToken(const char *sToken, const std::string &sLine, size_t pos)
Determines, whether the passed token can be found at the passed position.
std::string getDataForString(std::string sLine, size_t n_pos)
This member function returns the contents of the data objects and expands them as a list.
std::string maskControlCharacters(std::string sString)
This member function masks the line break and the tabulator control characters for storing the proces...
bool isSimpleString(const std::string &sLine)
This member function determines, whether the passed string is simple, i.e. it is a string literal wit...
virtual bool isStringExpression(const std::string &sExpression) override
Returns true, if the passed expression is an expression containing strings, string variables or strin...
std::vector< bool > applyElementaryStringOperations(std::vector< std::string > &vFinal, bool &bReturningLogicals)
This member function applies some elementary string operations like concatenation to the string expre...
void storeStringToStringObject(const std::vector< std::string > &vFinal, std::string &sObject, size_t &nCurrentComponent, size_t nStrings)
This member function is a helper for StringParser::storeStringResults(). It will store the strings in...
std::string numToString(const std::string &sLine)
This member function implements the so-called value-to-string parser (called via #VAR in code).
std::map< std::string, int > m_mStringParams
std::string parseStringsInIndices(std::string sIndexExpression)
Parses the string expressions in index expressions so that they may used as numerical index expressio...
std::string createTerminalOutput(StringResult &strRes, int parserFlags)
This private member function creates the output specialized for the terminal.
void replaceDataOccurence(std::string &sLine, const std::string &sOccurence)
Replaces all occurences of the passed data access occurence in the passed string.
std::vector< StringStackItem > createStack(StringView sExpr) const
This member function creates a stack from the passed expression, which may then be evaluated more eas...
virtual StringResult eval(std::string &sLine, std::string sCache, bool bParseNumericals=true) override
This public member function provides the string parser core functionality and is the function,...
StringVector evaluateStack(const std::vector< StringStackItem > &rpnStack, size_t from, size_t to)
Evaluate the created RPN stack between the selected start and end points.
int storeStringResults(StringResult &strRes, std::string sObject)
This member function stores the processed and calculated string results in their desired targets.
void storeStringToDataObjects(StringResult &strRes, std::string &sObject, size_t &nCurrentComponent, size_t nStrings)
This member function is a helper for StringParser::storeStringResults(). It will store the strings in...
StringParserRetVal evalAndFormat(std::string &sLine, std::string &sCache, bool bSilent=false, bool bCheckAssertions=false)
This public member function evaluates the passed string expression and formats the results for the co...
StringParser(mu::Parser &parser, MemoryManager &data, Settings &option)
String parser constructor.
std::string createStringOutput(StringResult &strRes, std::string &sLine, int parserFlags, bool bSilent)
This member function converts the processed string parser results into an output string,...
int decodeStringParams(std::string &sLine)
This member function finds and decodes all passed string expression parameters and removes them from ...
StringVector evaluateStringVectors(std::string sLine)
This member function evaluates the passed string vector and returns it's evaluated components in sepa...
const StringVector & getStringVectorVar(const std::string &sVarName) const
Return a reference to the identified string vector variable or throw if it does not exist.
bool containsStringVars(const std::string &sLine) const
This public member function determines, whether the passed string line contains string variables as p...
void removeStringVectorVars()
This member function removes all internal string vector variables.
bool isStringVectorVar(const std::string &sVarName) const
Check, whether the passed string identifies a string vector variable.
bool containsStringVectorVars(const std::string &sLine)
This member function determines, whether there are string vector variables in the passed command line...
void setStringValue(const std::string &sVar, const std::string &sValue)
This public member function creates or updates a string variable and fills it with the passed value.
std::string createStringVectorVar(const std::vector< std::string > &vStringVector)
This member function is used to create a string vector variable.
void getStringValuesAsInternalVar(std::string &sLine, unsigned int nPos=0)
This public member function resolves all string variable occurences and replaces them with an interna...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
static bool bSupressAnswer
static void printPreFmt(const std::string &__sLine, bool printingEnabled=true)
This member function appends the pre- formatted string to the buffer and informs the terminal that we...
NumeRe::Cluster & getAns()
static std::string formatResultOutput(int nNum, mu::value_type *v)
This static function is used to format the result output in the terminal for numerical-only results.
This class manages the setting values of the internal (kernel) settings of this application.
std::string getLoadPath() const
Returns the current loading path.
std::string getWorkPath() const
Returns the current working path (connected to the <wp> token).
std::string getSavePath() const
Returns the current saving path.
size_t getPrecision() const
Returns the precision for displaying floating numbers in the terminal. This value determines the numb...
std::string getProcPath() const
Returns the current procedure root import path.
std::string getPlotPath() const
Returns the current plotting path (plot storing location).
std::string getExePath() const
Returns the current application root folder path.
std::string getScriptPath() const
Returns the current script import folder path.
bool writeString(const std::string &_sString, unsigned int _nthString=std::string::npos, unsigned int nCol=0)
std::string maxString(unsigned int i1=0, unsigned int i2=std::string::npos, unsigned int nCol=0)
unsigned int getStringElements(unsigned int nCol=std::string::npos) const
std::string readString(unsigned int _nthString=std::string::npos, unsigned int nCol=0)
std::string minString(unsigned int i1=0, unsigned int i2=std::string::npos, unsigned int nCol=0)
std::string sumString(unsigned int i1=0, unsigned int i2=std::string::npos, unsigned int nCol=0)
This class is an extension to the std::vector<std::string> to provide the vector-like functionalities...
std::string & getRef(size_t i)
Return a reference to the i-th element in this string.
void convert_to_string(size_t i, size_t minChars=0)
Convert the i-th element to a string.
void push_generic(const std::string &sStr)
Append a generic string value to the end of this vector. Depending on the existence of surrounding qu...
std::vector< bool > xor_f(const StringVector &sVect) const
This member function represents an XOR operator.
bool is_string(size_t i) const
Check whether the i-th element represents a string or a numeric value.
std::vector< bool > or_f(const StringVector &sVect) const
This member function represents an OR operator.
std::vector< bool > and_f(const StringVector &sVect) const
This member function represents an AND operator.
static StringVector convert_literal(const std::string &sLiteral)
Static member function to create a StringVector instance from a string literal.
void strip()
This member function shrinks the viewed section to remove all leading or trailing whitespace characte...
void trim_front(size_t len)
This member function can be used to remove characters from the front of the viewed section.
size_t length() const
This member function simply returns the length of the viewed section.
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
StringView subview(size_t pos=0, size_t len=std::string::npos) const
This member function creates a new StringView class instance using the selected position and length a...
Common exception class for all exceptions thrown in NumeRe.
static size_t invalid_position
bool isValid() const
This member function determines, whether the internal index set is valid.
VectorIndex subidx(size_t pos, size_t nLen=std::string::npos) const
This member function returns a subset of the internal stored index just like the std::string::substr(...
size_t size() const
This member function returns the size of the indices stored in this class.
bool isOpenEnd() const
This member function determines, whether the internal index set has an open end.
void setRange(int nMin, int nMax)
This member function can be used to force the indices stored internally to be in a defined interval....
bool isString() const
This member function determines, whether the internal index set referres to the table headlines.
int & back()
This member function returns a reference to the final index value stored internally.
int & front()
This member function returns a reference to the first index value stored internally.
void SetExpr(StringView a_sExpr)
Set the expression. Triggers first time calculation thus the creation of the bytecode and scanning of...
value_type Eval()
Single-value wrapper around the vectorized overload of this member function.
string_type CreateTempVectorVar(const std::vector< mu::value_type > &vVar)
This member function copies the passed vector into the internal storage referencing it with a auto-ge...
void DisableAccessCaching()
Disable the data access caching for this position.
bool ContainsVectorVars(StringView sExpr, bool ignoreSingletons)
This member function checks, whether the passed expression contains a vector.
Mathematical expressions parser.
string getDataElements(string &sLine, Parser &_parser, MemoryManager &_data, const Settings &_option, int options)
Searches the passed string for calls to any table or cluster and replaces them with internal vectors ...
void replaceDataEntities(string &sLine, const string &sEntity, MemoryManager &_data, Parser &_parser, const Settings &_option, int options)
This function replaces all calls to a single data entity with an internal vector or its value,...
bool parser_CheckMultArgFunc(const string &sLeft, const string &sRight)
This function checks, whether the argument located between sLeft and sRight is part of a multi-argume...
Indices getIndices(StringView sCmd, mu::Parser &_parser, MemoryManager &_data, const Settings &_option)
Wrapper for the new getIndices function interface.
Assertion _assertionHandler
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
static std::vector< StringStackItem > convertToStack(const std::vector< StringView > &vTokens)
Static function to convert the tokens to a RPN stack.
static void finalizeStack(std::vector< StringStackItem > &rpnStack)
Static function to finalize the if-else logic in this stack.
static size_t getOperatorPrecedence(StringView oprt)
Static function to obtain the passed operator's precedence.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
bool isreal(value_type *v, int nElem)
unsigned int getPositionOfFirstDelimiter(const string &sLine)
This function returns the position of the first delimiter in the passed string, but it jumps over par...
void convertVectorToExpression(string &sLine, const Settings &_option)
This function replaces vector expressions with their corresponding multi- expression equation.
mu::value_type * getPointerToVariable(const string &sVarName, Parser &_parser)
This function returns the pointer to the passed variable.
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
@ KEEP_MASKED_CONTROL_CHARS
static std::map< std::string, StringFuncHandle > getStringFuncHandles()
This static function is used to construct the string map.
std::string removeQuotationMarks(const std::string &sString)
This function simply removes the surrounding quotation marks.
std::string addQuotationMarks(const std::string &sString)
This function simply adds the surrounding quotation marks.
This structure is central for managing the indices of a table or cluster read or write data access....
This struct encodes a string expression. It tracks the position of an equal sign in the expression in...
void split()
Splits expression and its assignee and sets the assignment operator position to 0.
void findAssignmentOperator()
Searches for the assignment operator (the equal sign separating expression and assignee)....
This structure contains all possible return values of the central string parser in single combined st...
std::vector< bool > vNoStringVal
std::vector< mu::value_type > vNumericalValues
A simple container for a single item in the string expression RPN stack.
std::string toString(int)
Converts an integer to a string without the Settings bloat.