NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
parser_functions.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2014 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20#include "parser_functions.hpp"
21#include "../../kernel.hpp"
22
23
25extern mglGraph _fontData;
26
27using namespace std;
28
29
42size_t findVariableInExpression(const std::string& sExpr, const std::string& sVarName, size_t nPosStart)
43{
44 size_t nMatch = nPosStart;
45 const static std::string sOperators = "+-*/,^!%&|?:#<>='; ";
46 const static std::string sDelimiterLeft = sOperators + "([{";
47#warning TODO (numere#1#12/05/21): Cannot detect variables with methods (if that is needed)
48 const static std::string sDelimiterRight = sOperators + ")]}";
49
50 // search the first match of the token, which is surrounded by the
51 // defined separator characters
52 while ((nMatch = sExpr.find(sVarName, nMatch)) != string::npos)
53 {
54 if ((!nMatch || sDelimiterLeft.find(sExpr[nMatch-1]) != string::npos)
55 && (nMatch + sVarName.length() >= sExpr.length() || sDelimiterRight.find(sExpr[nMatch+sVarName.length()]) != string::npos)
56 && !isInQuotes(sExpr, nMatch))
57 {
58 return nMatch;
59 }
60
61 nMatch++;
62 }
63
64 return std::string::npos;
65}
66
67
82void convertVectorToExpression(string& sLine, const Settings& _option)
83{
84 vector<string> vVectors(1, "");
85 vector<string> vScalars(1, "");
86
87 string sTemp = sLine;
88 string sDelim = "+-*/^&|!%";
89 int nDim = 0;
90 int nDim_vec = 0;
91 unsigned int nPos = 0;
92 size_t nQuotes = 0;
93 bool bIsStringExpression = containsStrings(sLine);
94
95 // Handle multi-expression expressions first
96 if (isMultiValue(sLine))
97 {
98 string sBuffer;
99
100 // Use the getNextArgument function to
101 // obtain the next single expression part
102 // of the current string
103 while (sLine.length())
104 {
105 sTemp = getNextArgument(sLine, true);
106
107 // Evaluate the single expression part using a recursion
108 convertVectorToExpression(sTemp, _option);
109
110 sBuffer += sTemp + ",";
111 }
112
113 sLine = sBuffer.substr(0, sBuffer.length()-1);
114 sTemp = sLine;
115 }
116
117 // Reset the positions
118 nPos = 0;
119 nQuotes = 0;
120
121 // Separate the expression in scalars and vectors
122 for (nPos = 0; nPos < sTemp.length(); nPos++)
123 {
124 // Count the quotation marks to ensure that
125 // we're only focussing on actual operators
126 if (sTemp[nPos] == '"')
127 {
128 if (!nPos || (nPos && sTemp[nPos - 1] != '\\'))
129 nQuotes++;
130 }
131
132 // If we're in quotation marks, then continue
133 if (sTemp[nPos] != '{' || (nQuotes % 2))
134 continue;
135
136 if (isToStringArg(sTemp, nPos))
137 continue;
138
139 if (nPos && (isalnum(sTemp[nPos-1]) || sTemp[nPos-1] == '_'))
140 {
141 // Ensure that there's a matching parenthesis
142 if (getMatchingParenthesis(sTemp.substr(nPos)) == string::npos)
144
145 nPos += getMatchingParenthesis(sTemp.substr(nPos));
146 continue;
147 }
148
149 nDim_vec = 0;
150
151 // Ensure that there's a matching parenthesis
152 if (getMatchingParenthesis(sTemp.substr(nPos)) == string::npos)
154
155 // Extract the current vector
156 vVectors.back() = sTemp.substr(nPos + 1, getMatchingParenthesis(sTemp.substr(nPos)) - 1);
157
158 // If there's a part of the expression before the vector
159 // copy this as the first scalar value
160 if (sTemp.find('{', nPos) != 0)
161 vScalars.back() += sTemp.substr(0, sTemp.find('{', nPos));
162
163 // Ensure that the legacy syntax "{{VECTOR}}" is handled correctly
164 if (vVectors.back()[0] == '{')
165 {
166 vVectors.back().erase(0, 1);
167
168 if (vVectors.back().back() == '}')
169 vVectors.back().pop_back();
170 }
171
172 // Ensure that we didn't copy the argument of a multi-argument function
173 if (parser_CheckMultArgFunc(vScalars.back(), sTemp.substr(sTemp.find('}', nPos) + 1)))
174 {
175 vScalars.back() += vVectors.back();
176 sTemp.erase(0, getMatchingParenthesis(sTemp.substr(nPos)) + nPos + 1);
177 continue;
178 }
179
180 // Remove the part of the already copied part of the expressions
181 sTemp.erase(0, getMatchingParenthesis(sTemp.substr(nPos)) + nPos + 1);
182 nPos = 0;
183
184 // Get the dimensions of the current vector
185 if (vVectors.back().length())
186 {
187 string sTempCopy = vVectors.back();
188
189 while (sTempCopy.length())
190 {
191 // Get-cut the next argument
192 if (getNextArgument(sTempCopy, true).length())
193 nDim_vec++;
194 }
195 }
196
197 // Save the largest dimension
198 if (nDim_vec > nDim)
199 nDim = nDim_vec;
200
201 // Add new empty vector and scalar storages
202 vVectors.push_back("");
203 vScalars.push_back("");
204
205 // Break, if the expression was handled completely
206 if (!sTemp.length())
207 break;
208 }
209
210 // If the command line is not empty, add this line to the
211 // last scalar in the expression
212 if (sTemp.length())
213 {
214 vScalars.back() += sTemp;
215 vScalars.push_back("");
216 }
217
218 // Clear the lines and the temporary copy
219 sTemp.clear();
220 sLine.clear();
221
222 // Expand the vectors and copy them back to the
223 // command line
224 if (!nDim)
225 {
226 // This was only a scalar value
227 for (size_t i = 0; i < vScalars.size(); i++)
228 sLine += vScalars[i];
229 }
230 else
231 {
232 // For the largest dimension of all vectors
233 for (int i = 0; i < nDim; i++)
234 {
235 // For the number of vectors
236 for (size_t j = 0; j < vVectors.size()-1; j++)
237 {
238 // Copy first the scalar part
239 sLine += vScalars[j];
240 sTemp.clear();
241
242 // Get the next vector component or replace them by an empty one
243 if (vVectors[j].length())
244 sTemp = getNextArgument(vVectors[j], true);
245 else
246 {
247 sTemp = addMissingVectorComponent(vVectors[j], vScalars[j], vScalars[j + 1], bIsStringExpression);
248 }
249
250 // If we're currently handling a string expression
251 if (!bIsStringExpression)
252 {
253 // Search for string delimiters in the current vector component
254 // (a.k.a concatentation operators)
255 for (unsigned int n = 0; n < sDelim.length(); n++)
256 {
257 // If there's a delimiter, enclose the current
258 // vector component in parentheses
259 if (sTemp.find(sDelim[n]) != string::npos)
260 {
261 sTemp = "(" + sTemp + ")";
262 break;
263 }
264 }
265 }
266
267 // Append the vector component to the command line
268 sLine += sTemp;
269 }
270
271 // Append the last scalar and a comma, if it is needed
272 if (vScalars.size() > vVectors.size())
273 sLine += vScalars[vScalars.size()-2];
274
275 if (i < nDim - 1)
276 sLine += ",";
277 }
278 }
279
280 return;
281}
282
283
300string addMissingVectorComponent(const string& sVectorComponent, const string& sLeft, const string& sRight, bool bAddStrings)
301{
302 bool bOneLeft = false;
303 bool bOneRight = false;
304
305 // Examine some basic border cases
306 if (sVectorComponent.length())
307 {
308 // Do nothing because the vector component
309 // id already defined
310 return sVectorComponent;
311 }
312 else if (bAddStrings)
313 {
314 // No vector component defined, but strings
315 // are required, therefore simply return an
316 // empty string
317 return "\"\"";
318 }
319 else if (!sLeft.length() && !sRight.length())
320 {
321 // No surrounding elements are available
322 // return a zero
323 return "0";
324 }
325
326 // If the user surrounds the current vector
327 // with extra parentheses, then the heuristic
328 // will require a non-zero element.
329 //
330 // There's also a special case for the left
331 // side: if a division operator was found
332 // then we will return a one direclty.
333 for (int i = sLeft.length() - 1; i >= 0; i--)
334 {
335 if (sLeft[i] != ' ')
336 {
337 if (sLeft[i] == '(')
338 {
339 for (int j = i - 1; j >= 0; j--)
340 {
341 if (sLeft[j] == '(')
342 {
343 bOneLeft = true;
344 break;
345 }
346 if (sLeft[j] == '/')
347 return "1";
348 }
349 }
350 else if (sLeft[i] == '/')
351 return "1";
352 break;
353 }
354 }
355
356 // Now examine the right side. Only parentheses
357 // are important in this case.
358 for (unsigned int i = 0; i < sRight.length(); i++)
359 {
360 if (sRight[i] != ' ')
361 {
362 if (sRight[i] == ')')
363 {
364 for (unsigned int j = i + 1; j < sRight.length(); j++)
365 {
366 if (sRight[j] == ')')
367 {
368 bOneRight = true;
369 break;
370 }
371 }
372 }
373 break;
374 }
375 }
376
377 // If both heuristics are requiring non-zero
378 // elements, return a one
379 if ((bOneLeft && bOneRight))
380 return "1";
381
382 // Fallback: return zero
383 return "0";
384}
385
386
396unsigned int getPositionOfFirstDelimiter(const string& sLine)
397{
398 static string sDelimiter = "+-*/ =^&|!<>,\n";
399
400 // Go through the current line
401 for (unsigned int i = 0; i < sLine.length(); i++)
402 {
403 // Jump over parentheses and braces
404 if (sLine[i] == '(' || sLine[i] == '{')
405 i += getMatchingParenthesis(sLine.substr(i));
406
407 // Try to find the current character in
408 // the defined list of delimiters
409 if (sDelimiter.find(sLine[i]) != string::npos)
410 return i;
411 }
412
413 // Nothing was found: return the largest possible
414 // number
415 return string::npos;
416}
417
418
429string promptForUserInput(const string& __sCommand)
430{
431 string sReturn = ""; // Variable fuer Rueckgabe-String
432 string sInput = ""; // Variable fuer die erwartete Eingabe
433 bool bHasDefaultValue = false; // Boolean; TRUE, wenn der String einen Default-Value hat
434 unsigned int nPos = 0; // Index-Variable
435
436 if (__sCommand.find("??") == string::npos) // Wenn's "??" gar nicht gibt, koennen wir sofort zurueck
437 return __sCommand;
438 sReturn = __sCommand; // Kopieren wir den Uebergebenen String in sReturn
439
440 // --> do...while-Schleife, so lange "??" im String gefunden wird <--
441 do
442 {
443 /* --> Fuer jeden "??" muessen wir eine Eingabe abfragen, daher muessen
444 * wir zuerst alle Variablen zuruecksetzen <--
445 */
446 sInput = "";
447 bHasDefaultValue = false;
448
449 // --> Speichern der naechsten Position von "??" in nPos <--
450 nPos = sReturn.find("??");
451
452 // --> Pruefen wir, ob es die Default-Value-Klammer ("??[DEFAULT]") gibt <--
453 if (sReturn.find("[", nPos) != string::npos)
454 {
455 // --> Es gibt drei moegliche Faelle, wie eine eckige Klammer auftreten kann <--
456 if (sReturn.find("??", nPos + 2) != string::npos && sReturn.find("[", nPos) < sReturn.find("??", nPos + 2))
457 bHasDefaultValue = true;
458 else if (sReturn.find("??", nPos + 2) == string::npos)
459 bHasDefaultValue = true;
460 else
461 bHasDefaultValue = false;
462 }
463
464 /* --> Eingabe in einer do...while abfragen. Wenn ein Defaultwert vorhanden ist,
465 * braucht diese Schleife nicht loopen, auch wenn nichts eingegeben wird <--
466 */
467 do
468 {
469 string sComp = sReturn.substr(0, nPos);
470 // --> Zur Orientierung geben wir den Teil des Strings vor "??" aus <--
471 NumeReKernel::printPreFmt("|-\?\?> " + sComp);
472 NumeReKernel::getline(sInput);
473 StripSpaces(sComp);
474 if (sComp.length() && sInput.find(sComp) != string::npos)
475 sInput.erase(0, sInput.find(sComp) + sComp.length());
476 StripSpaces(sInput);
477 }
478 while (!bHasDefaultValue && !sInput.length());
479
480 // --> Eingabe in den String einsetzen <--
481 if (bHasDefaultValue && !sInput.length())
482 {
483 sReturn = sReturn.substr(0, nPos) + sReturn.substr(sReturn.find("[", nPos) + 1, sReturn.find("]", nPos) - sReturn.find("[", nPos) - 1) + sReturn.substr(sReturn.find("]", nPos) + 1);
484 }
485 else if (bHasDefaultValue && sInput.length())
486 {
487 sReturn = sReturn.substr(0, nPos) + sInput + sReturn.substr(sReturn.find("]", nPos) + 1);
488 }
489 else
490 {
491 sReturn = sReturn.substr(0, nPos) + sInput + sReturn.substr(nPos + 2);
492 }
493 }
494 while (sReturn.find("??") != string::npos);
495
496 GetAsyncKeyState(VK_ESCAPE);
497 // --> Jetzt enthaelt der String sReturn "??" an keiner Stelle mehr und kann zurueckgegeben werden <--
498 return sReturn;
499}
500
501
511mu::value_type* getPointerToVariable(const string& sVarName, Parser& _parser)
512{
513 // Get the map of declared variables
514 mu::varmap_type Vars = _parser.GetVar();
515
516 // Try to find the selected variable in the map
517 auto iter = Vars.find(sVarName);
518 if (iter != Vars.end())
519 return iter->second;
520
521 // return a null pointer, if nothing
522 // was found
523 return nullptr;
524}
525
526
535int integralFactorial(int nNumber)
536{
537 if (nNumber < 0)
538 nNumber *= -1;
539
540 if (nNumber == 0)
541 return 1;
542
543 for (int i = nNumber - 1; i > 0; i--)
544 nNumber *= i;
545
546 return nNumber;
547}
548
549
566string evaluateTargetOptionInCommand(string& sCmd, const string& sDefaultTarget, Indices& _idx, Parser& _parser, MemoryManager& _data, const Settings& _option)
567{
568 string sTargetTable;
569
570 // search for the target option in the command string
571 if (findParameter(sCmd, "target", '='))
572 {
573 // Extract the table name
574 sTargetTable = getArgAtPos(sCmd, findParameter(sCmd, "target", '=') + 6);
575
576 // Create the target table, if it doesn't exist
577 if (!_data.isTable(sTargetTable.substr(0, sTargetTable.find('(')) + "()"))
578 _data.addTable(sTargetTable.substr(0, sTargetTable.find('(')), _option);
579
580 // Read the target indices
581 getIndices(sTargetTable, _idx, _parser, _data, _option);
582 sTargetTable.erase(sTargetTable.find('('));
583
584 // check the indices
585 if (!isValidIndexSet(_idx))
587
588 // remove the target option and its value from the command line
589 sCmd.erase(sCmd.find(getArgAtPos(sCmd, findParameter(sCmd, "target", '=') + 6), findParameter(sCmd, "target", '=') - 1), getArgAtPos(sCmd, findParameter(sCmd, "target", '=') + 6).length());
590 sCmd.erase(findParameter(sCmd, "target", '=') - 1, 7);
591 }
592 else if (sDefaultTarget.length())
593 {
594 // If not found, create a default index set
596 _idx.col.front() = 0;
597
598 // Create cache, if needed. Otherwise get first empty column
599 if (_data.isTable(sDefaultTarget + "()"))
600 _idx.col.front() += _data.getCols(sDefaultTarget, false);
601 else
602 _data.addTable(sDefaultTarget, _option);
603
605 sTargetTable = sDefaultTarget;
606 }
607
608 // return the target table name
609 return sTargetTable;
610}
611
612
625bool evaluateIndices(const string& sCache, Indices& _idx, MemoryManager& _data)
626{
627 // Check the initial indices
628 if (!isValidIndexSet(_idx))
629 return false;
630
631 // Evaluate the case for an open end index
632 if (_idx.row.isOpenEnd())
633 _idx.row.setRange(0, _data.getLines(sCache.substr(0, sCache.find('(')), false)-1);
634
635 if (_idx.col.isOpenEnd())
636 _idx.col.setRange(0, _data.getCols(sCache.substr(0, sCache.find('(')), false)-1);
637
638 // Signal success
639 return true;
640}
641
642
657static void readAndParseLegacyIntervals(string& sExpr, const string& sLegacyIntervalIdentifier, Parser& _parser, vector<double>& vInterval, size_t nMinSize, bool bEraseInterval)
658{
659 string sInterval = getArgAtPos(sExpr, findParameter(sExpr, sLegacyIntervalIdentifier, '=') + 1);
660 EndlessVector<string> indices;
661
662 // Erase the interval definition, if needed
663 if (bEraseInterval)
664 {
665 sExpr.erase(sExpr.find(sInterval), sInterval.length());
666 size_t pos = sExpr.rfind(sLegacyIntervalIdentifier, findParameter(sExpr, sLegacyIntervalIdentifier, '='));
667 sExpr.erase(pos, findParameter(sExpr, sLegacyIntervalIdentifier, '=') + 1 - pos);
668 }
669
670 // If the intervall contains a colon, split it there
671 if (sInterval.find(':') != string::npos)
672 indices = getAllIndices(sInterval);
673 else
674 indices.push_back(sInterval);
675
676 while (vInterval.size() < nMinSize)
677 vInterval.push_back(NAN);
678
679 for (size_t i = 0; i < 2; i++)
680 {
681 if (isNotEmptyExpression(indices[i]))
682 {
683 _parser.SetExpr(indices[i]);
684 vInterval.push_back(_parser.Eval().real());
685 }
686 else
687 vInterval.push_back(NAN);
688 }
689}
690
691
706vector<double> readAndParseIntervals(string& sExpr, Parser& _parser, MemoryManager& _data, FunctionDefinitionManager& _functions, const Settings& _option, bool bEraseInterval)
707{
708 vector<double> vInterval;
709
710 // Get user defined functions
711 if (!_functions.call(sExpr))
713
714 // If the expression contains data elements, get their contents here
715 if (_data.containsTablesOrClusters(sExpr))
716 getDataElements(sExpr, _parser, _data, _option);
717
718 // Get the interval for x
719 if (findParameter(sExpr, "x", '='))
720 readAndParseLegacyIntervals(sExpr, "x", _parser, vInterval, 0, bEraseInterval);
721
722 // Get the interval for y
723 if (findParameter(sExpr, "y", '='))
724 readAndParseLegacyIntervals(sExpr, "y", _parser, vInterval, 2, bEraseInterval);
725
726 // Get the interval for z
727 if (findParameter(sExpr, "z", '='))
728 readAndParseLegacyIntervals(sExpr, "z", _parser, vInterval, 4, bEraseInterval);
729
730 // Read the interval syntax
731 if (sExpr.find('[') != string::npos
732 && sExpr.find(']', sExpr.find('[')) != string::npos
733 && sExpr.find(':', sExpr.find('[')) != string::npos)
734 {
735 size_t nPos = 0;
736 size_t nMatchingParens = 0;
737
738 // Find the correct interval bracket
739 do
740 {
741 nPos = sExpr.find('[', nPos);
742
743 if (nPos == string::npos || (nMatchingParens = getMatchingParenthesis(sExpr.substr(nPos))) == string::npos)
744 break;
745
746 nMatchingParens += nPos;
747 nPos++;
748 }
749 while (isInQuotes(sExpr, nPos) || sExpr.substr(nPos, nMatchingParens - nPos).find(':') == string::npos);
750
751 // If an interval bracket was found
752 if (nPos != string::npos && nMatchingParens != string::npos)
753 {
754 string sRanges = sExpr.substr(nPos, nMatchingParens - nPos);
755
756 // Erase the interval part from the expression, if needed
757 if (bEraseInterval)
758 sExpr.erase(nPos - 1, nMatchingParens - nPos + 2);
759
760 // Split the whole argument list
761 auto args = getAllArguments(sRanges);
762
763 // Try to split the indices in every argument
764 for (size_t i = 0; i < args.size(); i++)
765 {
766 if (args[i].find(':') == string::npos)
767 continue;
768
769 auto indices = getAllIndices(args[i]);
770
771 // Set the intervals and parse them
772 for (size_t j = 0; j < 2; j++)
773 {
774 if (isNotEmptyExpression(indices[j]))
775 {
776 _parser.SetExpr(indices[j]);
777 vInterval.push_back(_parser.Eval().real());
778 }
779 else
780 vInterval.push_back(NAN);
781 }
782 }
783 }
784 }
785
786 // Return the calculated interval part
787 return vInterval;
788}
789
This class extends the std::vector for endlessness.
Definition: structures.hpp:838
This class implements the function definition managing instance.
Definition: define.hpp:74
bool call(std::string &sExpr, int nRecursion=0)
This function searches for known custom definitions in the passed expression and replaces them with t...
Definition: define.cpp:801
This class represents the central memory managing instance. It will handle all tables and clusters,...
int getLines(StringView sTable, bool _bFull=false) const
bool isTable(const std::string &sTable) const
This member function returns, whether the passed table name corresponds to a known table.
bool addTable(const std::string &sCache, const Settings &_option)
This member function creates a new table. It is checked, whether its name is valid and not already us...
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
int getCols(StringView sTable, bool _bFull=false) const
static void getline(std::string &sLine)
This function is an implementation replacing the std::getline() function.
Definition: kernel.cpp:3621
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...
Definition: kernel.cpp:2683
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32
@ FUNCTION_ERROR
Definition: error.hpp:110
@ INCOMPLETE_VECTOR_SYNTAX
Definition: error.hpp:118
@ INVALID_INDEX
Definition: error.hpp:129
static size_t invalid_position
Definition: error.hpp:235
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
Definition: structures.hpp:42
bool isOpenEnd() const
This member function determines, whether the internal index set has an open end.
Definition: structures.hpp:614
void setRange(int nMin, int nMax)
This member function can be used to force the indices stored internally to be in a defined interval....
Definition: structures.hpp:712
std::string to_string() const
This member function converts the vector indexes contents into a human-readable string representation...
Definition: structures.hpp:770
int & back()
This member function returns a reference to the final index value stored internally.
Definition: structures.hpp:653
int & front()
This member function returns a reference to the first index value stored internally.
Definition: structures.hpp:640
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.
const varmap_type & GetVar() const
Return a map containing the used variables only.
Mathematical expressions parser.
Definition: muParser.h:51
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 ...
Definition: dataaccess.cpp:276
bool isNotEmptyExpression(const string &sExpr)
This function checks, whether the passed expression is non-empty (i.e. it contains more than white sp...
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.
Definition: indices.cpp:49
bool isValidIndexSet(const Indices &_idx)
Definition: dataaccess.hpp:81
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
Definition: tools.cpp:414
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
std::map< string_type, value_type * > varmap_type
Type used for storing variables.
Definition: muParserDef.h:273
unsigned int getPositionOfFirstDelimiter(const string &sLine)
This function returns the position of the first delimiter in the passed string, but it jumps over par...
string addMissingVectorComponent(const string &sVectorComponent, const string &sLeft, const string &sRight, bool bAddStrings)
This function determines the value of missing vector components (i.e. a vector contains not enough el...
string promptForUserInput(const string &__sCommand)
This function is invoked, if a prompt operator ("??") was found in a string.
bool evaluateIndices(const string &sCache, Indices &_idx, MemoryManager &_data)
This function will evaluate the passed indices, so that they match the dimensions of the passed cache...
mglGraph _fontData
Definition: kernel.cpp:40
size_t findVariableInExpression(const std::string &sExpr, const std::string &sVarName, size_t nPosStart)
This function searches for the selected variable in the passed string and returns the position of the...
string evaluateTargetOptionInCommand(string &sCmd, const string &sDefaultTarget, Indices &_idx, Parser &_parser, MemoryManager &_data, const Settings &_option)
This function evaluates the "target=TABLE()" expression and creates the target table,...
void convertVectorToExpression(string &sLine, const Settings &_option)
This function replaces vector expressions with their corresponding multi- expression equation.
int integralFactorial(int nNumber)
This function returns the factorial of the passed integral value.
vector< double > readAndParseIntervals(string &sExpr, Parser &_parser, MemoryManager &_data, FunctionDefinitionManager &_functions, const Settings &_option, bool bEraseInterval)
This function will read the interval syntax in commands and return their values in a single vector.
mu::value_type vAns
static void readAndParseLegacyIntervals(string &sExpr, const string &sLegacyIntervalIdentifier, Parser &_parser, vector< double > &vInterval, size_t nMinSize, bool bEraseInterval)
This static function handles a single legacy interval. It's a helper for readAndParseIntervals().
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,...
Definition: tools.cpp:113
std::string getNextArgument(std::string &sArgList, bool bCut)
Definition: tools.cpp:2294
This structure is central for managing the indices of a table or cluster read or write data access....
VectorIndex col
VectorIndex row
bool containsStrings(const string &sLine)
This function checks, whether the passed expression contains strings or valtostring parser.
Definition: tools.cpp:2470
string getArgAtPos(const string &sCmd, unsigned int nPos, int extraction)
Extracts a options value at the selected position and applies automatic parsing, if necessary.
Definition: tools.cpp:1598
bool isInQuotes(StringView sExpr, unsigned int nPos, bool bIgnoreVarParser)
Checks, whether the position in the passed expression is part of a string literal.
Definition: tools.cpp:1672
bool isToStringArg(const string &sExpr, unsigned int nPos)
This function determines, whether the current position is part of an argument of the three value to s...
Definition: tools.cpp:1766
bool isMultiValue(const string &sExpr, bool bIgnoreClosingParenthesis)
Determines, if a string contains multiple comma-separated expressions.
Definition: tools.cpp:484
EndlessVector< string > getAllIndices(string sArgList)
Splits up the complete index list and returns them as an EndlessVector.
Definition: tools.cpp:2384
EndlessVector< StringView > getAllArguments(StringView sArgList)
Splits up the complete argument list and returns them as an EndlessVector.
Definition: tools.cpp:2346