![]() |
NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class provides the complete function evaluation logic to the StringParser class. More...
#include <stringfunchandler.hpp>
Public Member Functions | |
virtual | ~StringFuncHandler () |
virtual bool | isStringExpression (const std::string &sExpression)=0 |
![]() | |
bool | containsStringVectorVars (const std::string &sLine) |
This member function determines, whether there are string vector variables in the passed command line. More... | |
std::string | createTempStringVectorVar (const std::vector< std::string > &vStringVector) |
This member function is used to create a temporary string vector variable. More... | |
void | removeTempStringVectorVars () |
This member function removes all temporary string vector variables. More... | |
bool | containsStringVars (const std::string &sLine) const |
This public member function determines, whether the passed string line contains string variables as part of the expression. More... | |
bool | isStringVar (const std::string &sVarName) const |
Determine, whether the passed string is the identifier of a string variable. More... | |
void | getStringValues (std::string &sLine) |
This public member function resolves all string variable occurences and replaces them with their value or the standard string function signature, if the string variable is connected to a method. More... | |
std::string | getStringValue (const std::string &sVar) const |
Returns the value of the selected string variable. More... | |
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. More... | |
void | removeStringVar (const std::string &sVar) |
This public member function removes the selected string variable from memory. More... | |
const std::map< std::string, std::string > & | getStringVars () const |
Protected Member Functions | |
std::string | applySpecialStringFuncs (std::string sLine) |
This member function applies special string functions in the expression, which cannot be implemented as standard string functions. More... | |
std::string | applyStringFuncs (std::string sLine) |
This member function searches for an occurence of a known string function in the passed command line and passes the control to StringFuncHandler::evalFunction() member function for evaluation. More... | |
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 the passed one. More... | |
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 closing parenthesis. More... | |
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. More... | |
std::string | printValue (const mu::value_type &value) |
Prints a value to a string respecting possible integer optimizations. More... | |
size_t | getStringFuncMapSize () const |
virtual StringResult | eval (std::string &sLine, std::string sCache, bool bParseNumericals=true)=0 |
![]() | |
StringVector | evaluateStringVectors (std::string sLine) |
This member function evaluates the passed string vector and returns it's evaluated components in separate vector components. More... | |
StringVector | expandStringVectorComponents (std::vector< StringVector > &vStringVector) |
This member function expands the internal multi-expressions in the veector into separate components by enlarging the dimension of the vector. More... | |
void | removeStringVectorVars () |
This member function removes all internal string vector variables. More... | |
std::string | createStringVectorVar (const std::vector< std::string > &vStringVector) |
This member function is used to create a string vector variable. More... | |
bool | isStringVectorVar (const std::string &sVarName) const |
Check, whether the passed string identifies a string vector variable. More... | |
const StringVector & | getStringVectorVar (const std::string &sVarName) const |
Return a reference to the identified string vector variable or throw if it does not exist. More... | |
void | getStringValuesAsInternalVar (std::string &sLine, unsigned int nPos=0) |
This public member function resolves all string variable occurences and replaces them with an internal string vector variable or the standard string function signature, if the string variable is connected to a method. More... | |
Private Member Functions | |
std::string | addMaskedStrings (const std::string &sString) |
This member function adds escape characters into the passed string and transforms the newstring character into a comma. More... | |
void | evalFunction (std::string &sLine, const std::string &sFuncName, StringFuncHandle) |
This member function evaluates the passed call sequence to the string function. More... | |
size_t | argumentParser (StringView, n_vect &) |
This member function is the string function argument parser for numerical arguments. More... | |
size_t | argumentParser (StringView, d_vect &) |
This member function is the string function argument parser for numerical arguments. More... | |
size_t | argumentParser (StringView, d_vect &, n_vect &) |
This member function is the string function argument parser for double and numeric values. More... | |
size_t | argumentParser (StringView, s_vect &, bool &bLogicalOnly) |
This member function is the string function argument parser for string arguments. More... | |
size_t | argumentParser (StringView, s_vect &, d_vect &) |
This member function is the string function argument parser for one string and one (optional) numerical argument. More... | |
size_t | argumentParser (StringView, s_vect &, n_vect &, n_vect &) |
This member function is the string function argument parser for one string and two (optional) numerical arguments. More... | |
size_t | argumentParser (StringView, s_vect &, n_vect &, n_vect &, s_vect &) |
This member function is the string function argument parser for two string and two numerical values, where the second string is the last argument. Every argument except of the first one is optional. More... | |
size_t | argumentParser (StringView, s_vect &, s_vect &, n_vect &, n_vect &) |
This member function is the string function argument parser for two string and two numerical values. Every argument except of the first one is optional. More... | |
size_t | argumentParser (StringView, s_vect &, s_vect &, s_vect &, n_vect &, n_vect &) |
This member function is the string function argument parser for three string and two numerical values. Every argument except of the first one is optional. More... | |
std::vector< s_vect > | callFunction (StringFuncHandle, s_vect &, s_vect &, s_vect &, n_vect &, n_vect &, d_vect &, size_t) |
Calls the selected string function using the passed string function arguments sequentially. More... | |
std::vector< s_vect > | callFunctionParallel (StringFuncHandle, s_vect &, s_vect &, s_vect &, n_vect &, n_vect &, d_vect &, size_t) |
Calls the selected string function using the passed string function arguments parallel using OpenMP. More... | |
std::vector< s_vect > | callMultiFunction (StringFuncHandle, s_vect &, s_vect &, s_vect &, n_vect &, n_vect &, d_vect &, size_t) |
Calls the selected string function accepting multiple values as first argument using the passed string function arguments sequentially. More... | |
std::vector< s_vect > | callMultiFunctionParallel (StringFuncHandle, s_vect &, s_vect &, s_vect &, n_vect &, n_vect &, d_vect &, size_t) |
Calls the selected string function accepting multiple values as first argument using the passed string function arguments parallel using OpenMP. More... | |
Private Attributes | |
std::map< std::string, StringFuncHandle > | m_mStringFuncs |
This class provides the complete function evaluation logic to the StringParser class.
Definition at line 37 of file stringfunchandler.hpp.
|
inlinevirtual |
Definition at line 73 of file stringfunchandler.hpp.
|
private |
This member function adds escape characters into the passed string and transforms the newstring character into a comma.
sString | const string& |
Definition at line 43 of file stringfunchandler.cpp.
References NEWSTRING.
|
protected |
This member function applies special string functions in the expression, which cannot be implemented as standard string functions.
sLine | string |
Definition at line 1036 of file stringfunchandler.cpp.
References VectorIndex::back(), Indices::col, MemoryManager::containsTablesOrClusters(), StringVector::convert_to_string(), NumeRe::StringVarFactory::createStringVectorVar(), mu::ParserBase::DisableAccessCaching(), mu::ParserBase::Eval(), eval(), findNextFunction(), VectorIndex::front(), NumeRe::ClusterManager::getCluster(), MemoryManager::getCols(), getDataElements(), DataAccessParser::getDataObject(), getFunctionArgumentList(), MemoryManager::getHeadLineElement(), DataAccessParser::getIndices(), NumeReKernel::getInstance(), MemoryManager::getLines(), NumeReKernel::getMemoryManager(), getNextArgument(), NumeReKernel::getParser(), StringVector::getRef(), NumeReKernel::getSettings(), StringMemory::getStringCols(), StringMemory::getStringElements(), intCast(), VectorIndex::INVALID, SyntaxError::invalid_position, StringVector::is_string(), DataAccessParser::isCluster(), NumeRe::ClusterManager::isCluster(), VectorIndex::isOpenEnd(), isStringExpression(), MemoryManager::isTable(), isValidIndexSet(), VectorIndex::last(), VectorIndex::linearize(), printValue(), StringVector::push_back(), removeQuotationMarks(), replaceToVectorname(), Indices::row, mu::ParserBase::SetExpr(), VectorIndex::setRange(), mu::ParserBase::SetVectorVar(), NumeRe::Cluster::size(), VectorIndex::size(), SyntaxError::STRING_ERROR, StripSpaces(), StringViewBase::to_string(), toString(), and StringResult::vResult.
Referenced by NumeRe::StringParser::eval().
|
protected |
This member function searches for an occurence of a known string function in the passed command line and passes the control to StringFuncHandler::evalFunction() member function for evaluation.
sLine | string |
Definition at line 1534 of file stringfunchandler.cpp.
References evalFunction(), and m_mStringFuncs.
Referenced by NumeRe::StringParser::eval().
|
private |
This member function is the string function argument parser for numerical arguments.
__sFuncArgument | StringView |
dArg | d_vect& a vector of numerical values as return value |
It is one of the two basic argument parser functions, which are called by all others depending on the signatures of their functions.
Definition at line 289 of file stringfunchandler.cpp.
References NumeRe::ClusterManager::containsClusters(), MemoryManager::containsTablesOrClusters(), mu::ParserBase::Eval(), eval(), getDataElements(), NumeReKernel::getInstance(), NumeReKernel::getMemoryManager(), NumeReKernel::getParser(), NumeReKernel::getSettings(), isStringExpression(), mu::ParserBase::SetExpr(), StringViewBase::to_string(), StringResult::vNumericalValues, and StringResult::vResult.
|
private |
This member function is the string function argument parser for double and numeric values.
__sFuncArgument | StringView |
dArg | d_vect& a vector of numerical values as return value |
nArg | n_vect& a vector of numerical values as return value |
It is one of the two basic argument parser functions, which are called by all others depending on the signatures of their functions.
Definition at line 353 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
This member function is the string function argument parser for numerical arguments.
__sFuncArgument | StringView |
nArg | n_vect& a vector of numerical values as return value |
It is one of the two basic argument parser functions, which are called by all others depending on the signatures of their functions.
Definition at line 220 of file stringfunchandler.cpp.
References NumeRe::ClusterManager::containsClusters(), MemoryManager::containsTablesOrClusters(), mu::ParserBase::Eval(), eval(), getDataElements(), NumeReKernel::getInstance(), NumeReKernel::getMemoryManager(), NumeReKernel::getParser(), NumeReKernel::getSettings(), intCast(), isStringExpression(), mu::ParserBase::SetExpr(), StringViewBase::to_string(), StringResult::vNumericalValues, and StringResult::vResult.
Referenced by argumentParser(), and evalFunction().
|
private |
This member function is the string function argument parser for string arguments.
__sFuncArgument | StringView |
sArg | s_vect& a vector of string values as return value |
bLogicalOnly | bool& |
It is one of the two basic argument parser functions, which are called by all others depending on the signatures of their functions.
Definition at line 398 of file stringfunchandler.cpp.
References StringResult::bOnlyLogicals, NumeRe::ClusterManager::containsClusters(), MemoryManager::containsTablesOrClusters(), convertVectorToExpression(), eval(), getDataElements(), NumeReKernel::getInstance(), NumeReKernel::getMemoryManager(), getNextArgument(), NumeReKernel::getParser(), NumeReKernel::getSettings(), isStringExpression(), StringVector::push_generic(), removeQuotationMarks(), StringViewBase::to_string(), and StringResult::vResult.
|
private |
This member function is the string function argument parser for one string and one (optional) numerical argument.
__sFuncArgument | StringView |
sArg1 | s_vect& |
dArg1 | d_vect& |
Definition at line 467 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
This member function is the string function argument parser for one string and two (optional) numerical arguments.
__sFuncArgument | StringView |
sArg1 | s_vect& |
nArg1 | n_vect& |
nArg2 | n_vect& |
Definition at line 510 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
This member function is the string function argument parser for two string and two numerical values, where the second string is the last argument. Every argument except of the first one is optional.
__sFuncArgument | StringView |
sArg1 | s_vect& |
nArg1 | n_vect& |
nArg2 | n_vect& |
sArg2 | s_vect& |
Definition at line 570 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
This member function is the string function argument parser for two string and two numerical values. Every argument except of the first one is optional.
__sFuncArgument | StringView |
sArg1 | s_vect& |
sArg2 | s_vect& |
nArg1 | n_vect& |
nArg2 | n_vect& |
Definition at line 643 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
This member function is the string function argument parser for three string and two numerical values. Every argument except of the first one is optional.
__sFuncArgument | StringView |
sArg1 | s_vect& |
sArg2 | s_vect& |
sArg3 | s_vect& |
nArg1 | n_vect& |
nArg2 | n_vect& |
Definition at line 717 of file stringfunchandler.cpp.
References argumentParser(), getNextViewedArgument(), and StringViewBase::length().
|
private |
Calls the selected string function using the passed string function arguments sequentially.
funcHandle | StringFuncHandle |
sStringArg1 | s_vect& |
sStringArg2 | s_vect& |
sStringArg3 | s_vect& |
nIntArg1 | n_vect& |
nIntArg2 | n_vect& |
dValArg | d_vect& |
nMaxArgs | size_t |
Definition at line 806 of file stringfunchandler.cpp.
References StringFuncArgs::dArg1, DEFAULT_NUM_ARG, StringFuncHandle::fHandle, StringVector::getArg(), NumeReKernel::getInstance(), NumeReKernel::getSettings(), StringFuncArgs::nArg1, StringFuncArgs::nArg2, StringFuncArgs::opt, StringFuncArgs::sArg1, StringFuncArgs::sArg2, and StringFuncArgs::sArg3.
Referenced by evalFunction().
|
private |
Calls the selected string function using the passed string function arguments parallel using OpenMP.
funcHandle | StringFuncHandle |
sStringArg1 | s_vect& |
sStringArg2 | s_vect& |
sStringArg3 | s_vect& |
nIntArg1 | n_vect& |
nIntArg2 | n_vect& |
dValArg | d_vect& |
nMaxArgs | size_t |
Definition at line 867 of file stringfunchandler.cpp.
References StringFuncArgs::dArg1, DEFAULT_NUM_ARG, StringFuncHandle::fHandle, StringVector::getArg(), NumeReKernel::getInstance(), NumeReKernel::getSettings(), StringFuncArgs::nArg1, StringFuncArgs::nArg2, StringFuncArgs::opt, StringFuncArgs::sArg1, StringFuncArgs::sArg2, and StringFuncArgs::sArg3.
Referenced by evalFunction().
|
private |
Calls the selected string function accepting multiple values as first argument using the passed string function arguments sequentially.
funcHandle | StringFuncHandle |
sStringArg1 | s_vect& |
sStringArg2 | s_vect& |
sStringArg3 | s_vect& |
nIntArg1 | n_vect& |
nIntArg2 | n_vect& |
dValArg | d_vect& |
nMaxArgs | size_t |
Definition at line 926 of file stringfunchandler.cpp.
References StringFuncArgs::dArg1, DEFAULT_NUM_ARG, StringFuncHandle::fHandle, StringVector::getArg(), NumeReKernel::getInstance(), NumeReKernel::getSettings(), StringFuncArgs::nArg1, StringFuncArgs::nArg2, StringFuncArgs::opt, StringFuncArgs::sArg2, StringFuncArgs::sArg3, and StringFuncArgs::sMultiArg.
Referenced by evalFunction().
|
private |
Calls the selected string function accepting multiple values as first argument using the passed string function arguments parallel using OpenMP.
funcHandle | StringFuncHandle |
sStringArg1 | s_vect& |
sStringArg2 | s_vect& |
sStringArg3 | s_vect& |
nIntArg1 | n_vect& |
nIntArg2 | n_vect& |
dValArg | d_vect& |
nMaxArgs | size_t |
Definition at line 984 of file stringfunchandler.cpp.
References StringFuncArgs::dArg1, DEFAULT_NUM_ARG, StringFuncHandle::fHandle, StringVector::getArg(), NumeReKernel::getInstance(), NumeReKernel::getSettings(), StringFuncArgs::nArg1, StringFuncArgs::nArg2, StringFuncArgs::opt, StringFuncArgs::sArg2, StringFuncArgs::sArg3, and StringFuncArgs::sMultiArg.
Referenced by evalFunction().
|
protected |
This member function is used to fill the internal map of declared string functions with the data of the passed one.
mStringFuncs | const map<string,StringFuncHandle>& |
Definition at line 1561 of file stringfunchandler.cpp.
References m_mStringFuncs.
Referenced by NumeRe::StringParser::StringParser().
|
protectedpure virtual |
Implemented in NumeRe::StringParser.
Referenced by applySpecialStringFuncs(), and argumentParser().
|
private |
This member function evaluates the passed call sequence to the string function.
sLine | std::string& |
sFuncName | const std::string& |
funcHandle | StringFuncHandle |
The arguments of the string function are evaluated depending on the defined signature of the called string function and passed to the linked implementation of the string function. The return value of the string function is transformed back into a usual string expression afterwards and stored in a string vector, which replaces the selected call to the string function.
Definition at line 104 of file stringfunchandler.cpp.
References argumentParser(), StringFuncHandle::bTakesMultiArguments, callFunction(), callFunctionParallel(), callMultiFunction(), callMultiFunctionParallel(), NumeRe::StringVarFactory::createStringVectorVar(), NumeRe::StringVarFactory::expandStringVectorComponents(), StringFuncHandle::fHandle, findNextFunction(), StringFuncHandle::fType, getFunctionArgumentList(), NumeReKernel::getInstance(), NumeReKernel::getSettings(), SyntaxError::invalid_position, isStringExpression(), max, StringFuncArgs::nMultiArg, NOARGS, StringFuncArgs::opt, PARSER_DOUBLE, PARSER_INT, PARSER_STRING, PARSER_STRING_DOUBLE, PARSER_STRING_INT_INT, PARSER_STRING_INT_INT_STRING, PARSER_STRING_STRING_INT_INT, PARSER_STRING_STRING_STRING_INT_INT, StringVector::push_generic(), SyntaxError::STRING_ERROR, and StringViewBase::to_string().
Referenced by applyStringFuncs().
|
protected |
Finds the position of the next function occurence in the passed string including the position of the closing parenthesis.
sFunc | const string& |
sLine | StringView |
nStartPos | size_t |
nEndPosition | size_t& |
searchForMethods | bool |
Definition at line 1581 of file stringfunchandler.cpp.
References StringViewBase::find(), getMatchingParenthesis(), isDelimiter(), isInQuotes(), StringViewBase::length(), StringView::subview(), StringViewBase::to_string(), and SyntaxError::UNMATCHED_PARENTHESIS.
Referenced by applySpecialStringFuncs(), evalFunction(), NumeRe::StringParser::getDataForString(), and NumeRe::StringParser::replaceDataOccurence().
|
protected |
Returns the contents of the argument parentheses of the function starting at nStartPosition.
sFunc | const std::string& |
sLine | StringView |
nStartPosition | size_t First character of the function |
nEndPosition | size_t Position of the closing parenthesis |
Definition at line 1646 of file stringfunchandler.cpp.
References StringView::subview().
Referenced by applySpecialStringFuncs(), evalFunction(), NumeRe::StringParser::getDataForString(), and NumeRe::StringParser::replaceDataOccurence().
|
inlineprotected |
Definition at line 66 of file stringfunchandler.hpp.
References m_mStringFuncs.
|
pure virtual |
Implemented in NumeRe::StringParser.
Referenced by applySpecialStringFuncs(), argumentParser(), and evalFunction().
|
protected |
Prints a value to a string respecting possible integer optimizations.
value | const mu::value_type& |
Definition at line 1661 of file stringfunchandler.cpp.
References NumeReKernel::getInstance(), intCast(), mu::rint(), and toString().
Referenced by applySpecialStringFuncs(), and NumeRe::StringParser::numToString().
|
private |
Definition at line 40 of file stringfunchandler.hpp.
Referenced by applyStringFuncs(), declareStringFuncs(), and getStringFuncMapSize().