NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
NumeRe::StringVarFactory Class Reference

This class handles the creation and deletion of string vector variables. More...

#include <stringvarfactory.hpp>

Inheritance diagram for NumeRe::StringVarFactory:
Collaboration diagram for NumeRe::StringVarFactory:

Public Member Functions

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

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 StringVectorgetStringVectorVar (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

bool isNumericCandidate (const std::string &sComponent)
 This member function is used to determine, whether a string vector component is numerical parsable. More...
 
bool checkStringvarDelimiter (const std::string &sToken) const
 This private member function examines the first and the last character of the passed string and determines, whether it is a delimiter or not. More...
 
void replaceStringVectorVars (std::map< std::string, StringVector > &mVectorVarMap, std::string &currentline, size_t nCurrentComponent, bool &bHasComponents)
 Replaces all found vectors of the passed map with their nCurrentComponent component. More...
 
std::string findVectorInMap (const std::map< std::string, StringVector > &mVectorVarMap, const std::vector< std::string > &vStringVector)
 Searches for the passed string in the passed map and returns the key string from the map, if anything found, otherwise an empty string. More...
 

Private Attributes

std::map< std::string, StringVectorm_mStringVectorVars
 
std::map< std::string, StringVectorm_mTempStringVectorVars
 
std::map< std::string, std::string > m_mStringVars
 

Detailed Description

This class handles the creation and deletion of string vector variables.

Definition at line 33 of file stringvarfactory.hpp.

Member Function Documentation

◆ checkStringvarDelimiter()

bool NumeRe::StringVarFactory::checkStringvarDelimiter ( const std::string &  sToken) const
private

This private member function examines the first and the last character of the passed string and determines, whether it is a delimiter or not.

Parameters
sTokenconst string&
Returns
bool

Definition at line 359 of file stringvarfactory.cpp.

Referenced by containsStringVars(), getStringValues(), and getStringValuesAsInternalVar().

◆ containsStringVars()

bool NumeRe::StringVarFactory::containsStringVars ( const std::string &  sLine) const

This public member function determines, whether the passed string line contains string variables as part of the expression.

Parameters
_sLineconst string&
Returns
bool

Definition at line 470 of file stringvarfactory.cpp.

References checkStringvarDelimiter(), and m_mStringVars.

Referenced by NumeRe::StringParser::eval(), NumeRe::StringParser::isStringExpression(), and NumeRe::StringParser::storeStringResults().

Here is the call graph for this function:

◆ containsStringVectorVars()

bool NumeRe::StringVarFactory::containsStringVectorVars ( const std::string &  sLine)

This member function determines, whether there are string vector variables in the passed command line.

Parameters
sLineconst string&
Returns
bool

Definition at line 128 of file stringvarfactory.cpp.

References m_mStringVectorVars, and m_mTempStringVectorVars.

Referenced by NumeRe::StringParser::eval(), NumeRe::StringParser::evaluateStack(), evaluateStringVectors(), NumeRe::StringParser::isStringExpression(), NumeRe::StringParser::numToString(), and NumeRe::StringParser::replaceDataOccurence().

◆ createStringVectorVar()

string NumeRe::StringVarFactory::createStringVectorVar ( const std::vector< std::string > &  vStringVector)
protected

This member function is used to create a string vector variable.

Parameters
vStringVectorconst vector<string>&
Returns
string

Definition at line 57 of file stringvarfactory.cpp.

References SyntaxError::invalid_position, m_mStringVectorVars, SyntaxError::STRING_ERROR, and toString().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), NumeRe::StringParser::eval(), NumeRe::StringFuncHandler::evalFunction(), NumeRe::StringParser::getDataForString(), getStringValuesAsInternalVar(), and NumeRe::StringParser::numToString().

Here is the call graph for this function:

◆ createTempStringVectorVar()

string NumeRe::StringVarFactory::createTempStringVectorVar ( const std::vector< std::string > &  vStringVector)

This member function is used to create a temporary string vector variable.

Parameters
vStringVectorconst vector<string>&
Returns
string

Temporary string vector variables differ in their name and not cleared by default during an evaluation done in the parser core.

Definition at line 311 of file stringvarfactory.cpp.

References findVectorInMap(), m_mTempStringVectorVars, and toString().

Referenced by handleMafDataAccess(), replaceDataEntities(), Procedure::replaceReturnVal(), and CommandLineParser::setReturnValue().

Here is the call graph for this function:

◆ evaluateStringVectors()

StringVector NumeRe::StringVarFactory::evaluateStringVectors ( std::string  sLine)
protected

This member function evaluates the passed string vector and returns it's evaluated components in separate vector components.

Parameters
sLinestring
Returns
StringVector

For each contained vector, the complete command line is evaluated and returned as a separate vector component.

Definition at line 167 of file stringvarfactory.cpp.

References containsStringVectorVars(), g_logger, NumeReKernel::getInstance(), getNextArgument(), NumeReKernel::getParser(), mu::ParserBase::GetVectors(), DetachedLogger::info(), isDelimiter(), isInQuotes(), m_mStringVectorVars, m_mTempStringVectorVars, StringVector::push_generic(), replaceStringVectorVars(), toCmdString(), and toString().

Referenced by NumeRe::StringParser::evaluateStack(), and NumeRe::StringParser::replaceDataOccurence().

Here is the call graph for this function:

◆ expandStringVectorComponents()

StringVector NumeRe::StringVarFactory::expandStringVectorComponents ( std::vector< StringVector > &  vStringVector)
protected

This member function expands the internal multi-expressions in the veector into separate components by enlarging the dimension of the vector.

Parameters
vStringVectorstd::vector<StringVector>&
Returns
StringVector

The components are evaluated and inserted into the original vector, replacing the original component with the calculated vector n components, which will enlarge the original vector by n-1 new components.

Definition at line 264 of file stringvarfactory.cpp.

Referenced by NumeRe::StringFuncHandler::evalFunction().

◆ findVectorInMap()

string NumeRe::StringVarFactory::findVectorInMap ( const std::map< std::string, StringVector > &  mVectorVarMap,
const std::vector< std::string > &  vStringVector 
)
private

Searches for the passed string in the passed map and returns the key string from the map, if anything found, otherwise an empty string.

Parameters
mVectorVarMapmap<string,StringVector>&
vStringVectorconst vector<string>&
Returns
string

Definition at line 432 of file stringvarfactory.cpp.

Referenced by createTempStringVectorVar().

◆ getStringValue()

std::string NumeRe::StringVarFactory::getStringValue ( const std::string &  sVar) const

Returns the value of the selected string variable.

Parameters
sVarconst std::string&
Returns
std::string

Definition at line 683 of file stringvarfactory.cpp.

References m_mStringVars.

Referenced by NumeReDebugger::gatherLoopBasedInformations().

◆ getStringValues()

void NumeRe::StringVarFactory::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.

Parameters
sLinestd::string&
Returns
void

Definition at line 609 of file stringvarfactory.cpp.

References checkStringvarDelimiter(), isInQuotes(), m_mStringVars, and replaceStringMethod().

Referenced by FlowCtrl::calc(), cmd_define(), cmd_ifndefined(), cmd_install(), cmd_redefine(), cmd_set(), cmd_stats(), FlowCtrl::compile(), Plot::createSubPlotSet(), evaluateParameterValues(), Procedure::execute(), extractFirstParameterStringValue(), CommandLineParser::getExprAsFileName(), CommandLineParser::getFileParameterValue(), Procedure::ProcCalc(), and saveDataObject().

Here is the call graph for this function:

◆ getStringValuesAsInternalVar()

void NumeRe::StringVarFactory::getStringValuesAsInternalVar ( std::string &  sLine,
unsigned int  nPos = 0 
)
protected

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.

Parameters
sLinestd::string&
nPosunsigned int
Returns
void

Definition at line 531 of file stringvarfactory.cpp.

References checkStringvarDelimiter(), createStringVectorVar(), isInQuotes(), m_mStringVars, and replaceStringMethod().

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

Here is the call graph for this function:

◆ getStringVars()

const std::map< std::string, std::string > & NumeRe::StringVarFactory::getStringVars ( ) const
inline

◆ getStringVectorVar()

const StringVector & NumeRe::StringVarFactory::getStringVectorVar ( const std::string &  sVarName) const
protected

Return a reference to the identified string vector variable or throw if it does not exist.

Parameters
sVarNameconst std::string&
Returns
const StringVector&

Definition at line 103 of file stringvarfactory.cpp.

References m_mStringVectorVars, and m_mTempStringVectorVars.

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

◆ isNumericCandidate()

bool NumeRe::StringVarFactory::isNumericCandidate ( const std::string &  sComponent)
private

This member function is used to determine, whether a string vector component is numerical parsable.

Parameters
sComponentconst string&
Returns
bool

Definition at line 35 of file stringvarfactory.cpp.

References getMatchingParenthesis().

Here is the call graph for this function:

◆ isStringVar()

bool NumeRe::StringVarFactory::isStringVar ( const std::string &  sVarName) const

Determine, whether the passed string is the identifier of a string variable.

Parameters
sVarNameconst std::string&
Returns
bool

Definition at line 512 of file stringvarfactory.cpp.

References m_mStringVars.

Referenced by NumeReDebugger::gatherLoopBasedInformations(), and FlowCtrl::range_based_for_loop().

◆ isStringVectorVar()

bool NumeRe::StringVarFactory::isStringVectorVar ( const std::string &  sVarName) const
protected

Check, whether the passed string identifies a string vector variable.

Parameters
sVarNameconst std::string&
Returns
bool

Definition at line 87 of file stringvarfactory.cpp.

References m_mStringVectorVars, and m_mTempStringVectorVars.

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

◆ removeStringVar()

void NumeRe::StringVarFactory::removeStringVar ( const std::string &  sVar)

This public member function removes the selected string variable from memory.

Parameters
sVarconst string&
Returns
void

Definition at line 737 of file stringvarfactory.cpp.

References m_mStringVars.

Referenced by FlowCtrl::reset(), and ProcedureVarFactory::reset().

◆ removeStringVectorVars()

void NumeRe::StringVarFactory::removeStringVectorVars ( )
protected

This member function removes all internal string vector variables.

Returns
void

This member function is called automatically from the parser.

Definition at line 293 of file stringvarfactory.cpp.

References m_mStringVectorVars.

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

◆ removeTempStringVectorVars()

void NumeRe::StringVarFactory::removeTempStringVectorVars ( )

This member function removes all temporary string vector variables.

Returns
void

This member function is not called automatically by the parser. It has to be used from the outside.

Definition at line 342 of file stringvarfactory.cpp.

References m_mTempStringVectorVars.

Referenced by FlowCtrl::calc(), FlowCtrl::compile(), NumeReKernel::MainLoop(), Procedure::ProcCalc(), and NumeReKernel::resetAfterError().

◆ replaceStringVectorVars()

void NumeRe::StringVarFactory::replaceStringVectorVars ( std::map< std::string, StringVector > &  mVectorVarMap,
std::string &  currentline,
size_t  nCurrentComponent,
bool &  bHasComponents 
)
private

Replaces all found vectors of the passed map with their nCurrentComponent component.

Parameters
mVectorVarMapmap<string,StringVector>&
currentlinestring&
nCurrentComponentsize_t
bHasComponentsbool&
Returns
void

Definition at line 387 of file stringvarfactory.cpp.

Referenced by evaluateStringVectors().

◆ setStringValue()

void NumeRe::StringVarFactory::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.

Parameters
sVarconst string&
sValueconst string&
Returns
void

Definition at line 704 of file stringvarfactory.cpp.

References SyntaxError::invalid_position, m_mStringVars, SyntaxError::STRINGVARS_MUSTNT_BEGIN_WITH_A_NUMBER, and SyntaxError::STRINGVARS_MUSTNT_CONTAIN.

Referenced by ProcedureVarFactory::createLocalStrings(), ProcedureVarFactory::evaluateProcedureArguments(), FlowCtrl::range_based_for_loop(), and NumeRe::StringParser::storeStringResults().

Member Data Documentation

◆ m_mStringVars

std::map<std::string,std::string> NumeRe::StringVarFactory::m_mStringVars
private

◆ m_mStringVectorVars

std::map<std::string,StringVector> NumeRe::StringVarFactory::m_mStringVectorVars
private

◆ m_mTempStringVectorVars

std::map<std::string,StringVector> NumeRe::StringVarFactory::m_mTempStringVectorVars
private

The documentation for this class was generated from the following files: