NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
parser_functions.hpp File Reference
#include <string>
#include <vector>
#include "../settings.hpp"
#include "../datamanagement/memorymanager.hpp"
#include "../ParserLib/muParser.h"
#include "define.hpp"
#include "../datamanagement/dataaccess.hpp"
Include dependency graph for parser_functions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string evaluateTargetOptionInCommand (std::string &sCmd, const std::string &sDefaultTarget, Indices &_idx, mu::Parser &_parser, MemoryManager &_data, const Settings &_option)
 This function evaluates the "target=TABLE()" expression and creates the target table, if needed. More...
 
size_t findVariableInExpression (const std::string &sExpr, const std::string &sVarName, size_t nPosStart=0)
 This function searches for the selected variable in the passed string and returns the position of the first occurence or string::npos, if nothing was found. More...
 
void convertVectorToExpression (std::string &, const Settings &)
 This function replaces vector expressions with their corresponding multi- expression equation. More...
 
std::string addMissingVectorComponent (const std::string &, const std::string &, const std::string &, bool)
 This function determines the value of missing vector components (i.e. a vector contains not enough elements compared to the others used in the current expression) by applying a simple heuristic to the expression. It will either insert "1", "0" or an empty string in string expressions. More...
 
mu::value_typegetPointerToVariable (const std::string &sVarName, mu::Parser &_parser)
 This function returns the pointer to the passed variable. More...
 
std::string promptForUserInput (const std::string &__sCommand)
 This function is invoked, if a prompt operator ("??") was found in a string. More...
 
int integralFactorial (int nNumber)
 This function returns the factorial of the passed integral value. More...
 
bool evaluateIndices (const std::string &sCache, Indices &_idx, MemoryManager &_data)
 This function will evaluate the passed indices, so that they match the dimensions of the passed cache, if they are defined as open ended. More...
 
std::vector< double > readAndParseIntervals (std::string &sExpr, mu::Parser &_parser, MemoryManager &_data, FunctionDefinitionManager &_functions, const Settings &_option, bool bEraseInterval=false)
 This function will read the interval syntax in commands and return their values in a single vector. More...
 
unsigned int getPositionOfFirstDelimiter (const std::string &)
 This function returns the position of the first delimiter in the passed string, but it jumps over parentheses and braces. More...
 

Function Documentation

◆ addMissingVectorComponent()

std::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 elements compared to the others used in the current expression) by applying a simple heuristic to the expression. It will either insert "1", "0" or an empty string in string expressions.

Parameters
sVectorComponentconst string&
sLeftconst string&
sRightconst string&
bAddStringsbool
Returns
string

Definition at line 300 of file parser_functions.cpp.

Referenced by convertVectorToExpression(), and evalMatOp().

◆ convertVectorToExpression()

void convertVectorToExpression ( string &  sLine,
const Settings _option 
)

This function replaces vector expressions with their corresponding multi- expression equation.

Parameters
sLinestring&
_optionconst Settings&
Returns
void

It is used quite extensively, however, it might not be necessary everywhere, because the parser can cope with the vector syntax now.

Definition at line 82 of file parser_functions.cpp.

References addMissingVectorComponent(), containsStrings(), convertVectorToExpression(), getMatchingParenthesis(), getNextArgument(), SyntaxError::INCOMPLETE_VECTOR_SYNTAX, SyntaxError::invalid_position, isMultiValue(), isToStringArg(), and parser_CheckMultArgFunc().

Referenced by NumeRe::StringFuncHandler::argumentParser(), convertVectorToExpression(), Plot::create2dDrawing(), Plot::create3dDrawing(), evalPoints(), evaluateFittingParams(), Plot::fillData(), CommandLineParser::getExprAsMathExpression(), NumeRe::StringParser::numToString(), and NumeRe::StringParser::storeStringResults().

Here is the call graph for this function:

◆ evaluateIndices()

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, if they are defined as open ended.

Parameters
sCacheconst string&
_idxIndices&
_dataDatafile&
Returns
bool

Definition at line 625 of file parser_functions.cpp.

References Indices::col, MemoryManager::getCols(), MemoryManager::getLines(), VectorIndex::isOpenEnd(), isValidIndexSet(), Indices::row, and VectorIndex::setRange().

Referenced by evalMatOp(), and evaluateFittingParams().

Here is the call graph for this function:

◆ evaluateTargetOptionInCommand()

std::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, if needed.

Parameters
sCmdstring&
sDefaultTargetconst string&
_idxIndices&
_parserParser&
_dataDatafile&
_optionconst Settings&
Returns
string

If this option is not found, the function will create a default target cache.

Definition at line 566 of file parser_functions.cpp.

References MemoryManager::addTable(), VectorIndex::back(), Indices::col, findParameter(), VectorIndex::front(), getArgAtPos(), MemoryManager::getCols(), getIndices(), SyntaxError::INVALID_INDEX, SyntaxError::invalid_position, MemoryManager::isTable(), isValidIndexSet(), VectorIndex::OPEN_END, Indices::row, and VectorIndex::to_string().

Referenced by CommandLineParser::getTargetTable(), plugin_histogram(), plugin_random(), and plugin_statistics().

Here is the call graph for this function:

◆ findVariableInExpression()

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 first occurence or string::npos, if nothing was found.

Parameters
sExprconst std::string&
sVarNameconst std::string&
nPosStartsize_t
Returns
size_t

Definition at line 42 of file parser_functions.cpp.

◆ getPointerToVariable()

mu::value_type * getPointerToVariable ( const string &  sVarName,
Parser _parser 
)

This function returns the pointer to the passed variable.

Parameters
sVarNameconst string&
_parserParser&
Returns
double*

Definition at line 511 of file parser_functions.cpp.

References mu::ParserBase::GetVar().

Referenced by differentiate(), evalPoints(), findExtrema(), findZeroes(), FlowCtrl::prepareLocalVarsAndReplace(), NumeRe::StringParser::storeStringResults(), and taylor().

Here is the call graph for this function:

◆ getPositionOfFirstDelimiter()

unsigned int getPositionOfFirstDelimiter ( const string &  sLine)

This function returns the position of the first delimiter in the passed string, but it jumps over parentheses and braces.

Parameters
sLineconst string&
Returns
unsigned int

Definition at line 396 of file parser_functions.cpp.

References getMatchingParenthesis().

Referenced by NumeRe::StringParser::numToString().

Here is the call graph for this function:

◆ integralFactorial()

int integralFactorial ( int  nNumber)

This function returns the factorial of the passed integral value.

Parameters
nNumberint
Returns
int

Definition at line 535 of file parser_functions.cpp.

Referenced by taylor().

◆ promptForUserInput()

std::string promptForUserInput ( const string &  __sCommand)

This function is invoked, if a prompt operator ("??") was found in a string.

Parameters
__sCommandconst string&
Returns
string

It will ask the user to provide the needed value during the execution.

Definition at line 429 of file parser_functions.cpp.

References NumeReKernel::getline(), NumeReKernel::printPreFmt(), and StripSpaces().

Referenced by FlowCtrl::calc(), cmd_print(), FlowCtrl::compile(), Plot::createSubPlotSet(), CommandLineParser::getExprAsDataObject(), CommandLineParser::getExprAsMathExpression(), NumeReKernel::MainLoop(), CommandLineParser::parseExprAsString(), and Procedure::ProcCalc().

Here is the call graph for this function:

◆ readAndParseIntervals()

std::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.

Parameters
sExprstring&
_parserParser&
_dataDatafile&
_functionsDefine&
_optionconst Settings&
bEraseIntervalbool
Returns
vector<double>

Definition at line 706 of file parser_functions.cpp.

References FunctionDefinitionManager::call(), MemoryManager::containsTablesOrClusters(), mu::ParserBase::Eval(), findParameter(), SyntaxError::FUNCTION_ERROR, getAllArguments(), getAllIndices(), getDataElements(), getMatchingParenthesis(), SyntaxError::invalid_position, isInQuotes(), isNotEmptyExpression(), readAndParseLegacyIntervals(), and mu::ParserBase::SetExpr().

Referenced by evaluateFittingParams(), evaluateParameterValues(), and Odesolver::solve().

Here is the call graph for this function: