20#include "../kernel.hpp"
100 m_parlist = sCommandString.substr(sCommandString.find(
'-'));
111 for (
size_t i = 0; i <
m_expr.length(); i++)
127 if ((
m_expr[i] ==
',' ||
m_expr[i] ==
' ' ||
m_expr[i] ==
'+') &&
m_expr.find_first_not_of(
",+ ", i) != std::string::npos)
128 i =
m_expr.find_first_not_of(
",+ ", i);
158 for (
size_t i = 0; i <
m_expr.length(); i++)
170 if (
m_expr.substr(i, 2) ==
"--" ||
m_expr.substr(i, 5) ==
"-set ")
203 if (sBasePath.length()
204 && sFileName.find(
"\\\\") == std::string::npos
205 && sFileName.find(
"//") == std::string::npos
206 && sFileName.find(
':') == std::string::npos
207 && sFileName.find(
'<') == std::string::npos)
208 sFileName.insert(0, sBasePath +
"/");
211 if (sFileName.find(
'.') != std::string::npos)
213 size_t nPos = sFileName.find_last_of(
"/\\");
215 if (sFileName.find(
'.', nPos) != std::string::npos)
216 sFileExt = sFileName.substr(sFileName.rfind(
'.'));
220 if (sFileExt ==
".exe" || sFileExt ==
".dll" || sFileExt ==
".sys")
225 if (!sFileExt.length())
293 std::string sFileName =
m_expr;
308 if (!sFileName.length())
336 std::string sExpr =
m_expr;
342 if (sExpr.find(
"??") != std::string::npos)
363 std::string sExpr =
m_expr;
369 if (sExpr.find(
"??") != std::string::npos)
396 std::string sExpr =
m_expr;
404 if (sExpr.find(
"??") != std::string::npos)
430 std::string sValue =
m_expr;
439 std::string sDummy =
"";
453 std::vector<mu::value_type> vVals(v, v+nRes);
505 std::vector<std::string> vParams;
507 while ((pos =
m_parlist.find(
'=', pos)) != std::string::npos)
511 size_t lastChar =
m_parlist.find_last_not_of(
" =", pos);
515 size_t firstChar =
m_parlist.find_last_of(
" -", lastChar) + 1;
516 vParams.push_back(
m_parlist.substr(firstChar, lastChar + 1 - firstChar));
577 if (!nParPos && sDefaultName.length())
595 if (sFileName.length())
597 else if (sDefaultName.length())
642 return sDefaultValue;
645 nParPos+sParameter.length(),
649 if (!stripAlways && arg.find(
",") != std::string::npos && arg.find(
"\"") != std::string::npos)
651 else if (arg.front() ==
'"' && arg.back() ==
'"')
673 return std::vector<mu::value_type>();
676 std::vector<mu::value_type> vArgs;
std::vector< mu::value_type > parseExprAsNumericalValues() const
Parses the expression into numerical values, returned as a vector of doubles.
void parse(const std::string &sCommandString, CommandSignature signature)
Private helper member function used for parsing the command line as specified by the command line sig...
std::string m_returnValueStatement
DataAccessParser getExprAsDataObject() const
Parses the expression to a DataAccessParser, which will extract the needed information for the curren...
std::string m_commandLine
std::string getFileParameterValue(std::string sFileExt, const std::string &sBaseFolder="", const std::string &sDefaultName="") const
Parses the value of the common "file" command line parameter and returns a valid filename.
std::string getExprAsMathExpression(bool parseDataObjects=false) const
Prepares the expression by calling custom function definitions and resolving vector braces so that th...
std::vector< mu::value_type > getParameterValueAsNumericalValue(const std::string &sParameter) const
Parses the selected parameter as (one or more) numerical value(s) and returns them as a vector of dou...
std::string getParameterValueAsString(const std::string &sParameter, const std::string &sDefaultValue, bool stripAlways=false, bool onlyStringEvaluation=false) const
Parses the selected parameter value as a string and returns it. If the parameter is not found,...
std::string getFileParameterValueForSaving(std::string sFileExt, const std::string &sBaseFolder="", const std::string &sDefaultName="") const
Parses the value of the common "file" command line parameter and returns a valid filename....
std::string getTargetTable(Indices &_targetIndices, const std::string &sDefaultTableName)
Evaluates any target=TABLE() statements in the parameter list and returns the needed information....
void setReturnValue(const std::string &sRetVal)
Sets the return value of the current command by simply appending it to the return value statement.
std::string parseExprAsString() const
Prepares the expression by handling all string operations and removing the surrounding quotation mark...
std::string getParameterValue(const std::string &sParameter) const
Simply returns the parameter value or an empty string. Does not do any parsing steps.
@ CMD_PAR
Command-parameter sequence.
@ CMD_DAT_PAR
Command-dataobject-parameter sequence (e.g. fit)
@ CMD_EXPR_set_PAR
Command-expression-set-parameter sequence.
std::vector< std::string > getAllParametersWithValues() const
Returns a vector containing all parameters with values in the current parameter list....
CommandLineParser(const std::string &sCommandLine, CommandSignature signature)
CommandLineParser constructor from a command line and the command signature. Will use the standard fi...
std::string parseFileName(std::string &sFileName, std::string &sFileExt, const std::string &sBasePath) const
Common method to convert a prepared string into a valid file or folder name.
std::string getExprAsFileName(std::string sFileExt, const std::string &sBasePath="") const
Converts the expression to a file name and removes the surrounding quotation marks,...
bool exprContainsDataObjects() const
Simply returns, whether the expression contains any data objects.
IntervalSet parseIntervals(bool bErase=false)
Parses intervals in the parameter list and returns them as a vector. The interval may be deleted,...
bool hasParam(const std::string &sParameter) const
Simple wrapper around findParameter(), if used as a boolean flag.
This class is defined to abstrahize the determination of the correct data object and the calculation ...
This class implements the basic input/ output file system and provides functionalities to work with f...
std::string ValidFolderName(std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
This member function evaluates, whether the passed foldername is a valid foldername.
std::string ValidizeAndPrepareName(const std::string &_sFileName, const std::string &sExtension=".dat") const
This member function validizes the passed file name and creates the needed folders on-the-fly.
void initializeFromKernel()
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up...
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
void declareFileType(const std::string &sFileType)
bool call(std::string &sExpr, int nRecursion=0)
This function searches for known custom definitions in the passed expression and replaces them with t...
bool containsTablesOrClusters(const std::string &sCmdLine)
This member function evaluates, whether the passed command line contains tables or clusters.
virtual bool isStringExpression(const std::string &sExpression) override
Returns true, if the passed expression is an expression containing strings, string variables or strin...
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...
void getStringValues(std::string &sLine)
This public member function resolves all string variable occurences and replaces them with their valu...
std::string createTempStringVectorVar(const std::vector< std::string > &vStringVector)
This member function is used to create a temporary string vector variable.
This class provides the interface to the core of NumeRe. It provides all functionalities,...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
NumeRe::StringParser & getStringParser()
MemoryManager & getMemoryManager()
FunctionDefinitionManager & getDefinitions()
Common exception class for all exceptions thrown in NumeRe.
@ FILETYPE_MAY_NOT_BE_WRITTEN
static size_t invalid_position
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...
std::string removeQuotationMarks(const std::string &sString)
This function simply removes the surrounding quotation marks.
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 ...
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
string promptForUserInput(const string &__sCommand)
This function is invoked, if a prompt operator ("??") was found in a string.
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.
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,...
This structure is central for managing the indices of a table or cluster read or write data access....
This class represents a set of intervals used together for calculations and simulations.
Structure for the findCommand function.