NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
tools.hpp File Reference
#include <string>
#include <cstdlib>
#include <vector>
#include <random>
#include "../structures.hpp"
#include "../ui/error.hpp"
#include "../settings.hpp"
#include "stringtools.hpp"
Include dependency graph for tools.hpp:

Go to the source code of this file.

Namespaces

namespace  little_endian_io
 
namespace  big_endian_io
 

Enumerations

enum  ArgExtraction {
  ARGEXTRACT_NONE = 0x0 , ARGEXTRACT_STRIPPED = 0x1 , ARGEXTRACT_PARSED = 0x2 , ARGEXTRACT_ASINT = 0x4 ,
  ARGEXTRACT_ASSTRING = 0x8
}
 

Functions

long long int intCast (double number)
 Casts doubles to integers and avoids rounding errors. More...
 
long long int intCast (const std::complex< double > &number)
 Casts the real part of the complex number to an integer and avoids rounding errors. More...
 
bool isInt (const std::complex< double > &number)
 Determines, whether the content of a complex value is actually a regular integer. More...
 
std::mt19937 & getRandGenInstance ()
 Returns a reference to the central random number generator instance, which is globally accessible by all random number functions. More...
 
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, the position of the parameter+1 is returned. More...
 
bool getStringArgument (const std::string &sCmd, std::string &sArgument)
 This function searches for the first string value in the passed expression and writes that into sArgument. If nothing was found, this function returns false, true otherwise. More...
 
std::string extractStringToken (const std::string &sCmd, size_t nPos)
 This function extracts a string token at the selected position. If the position is start of an option value, the possible equal sign is ignored. More...
 
unsigned int getMatchingParenthesis (const StringView &)
 Returns the position of the closing parenthesis. More...
 
bool isMultiValue (const std::string &sExpr, bool bIgnoreClosingParenthesis=false)
 Determines, if a string contains multiple comma-separated expressions. More...
 
std::string replaceToTeX (const std::string &sString, bool replaceForTeXFile=false)
 Replace the special tokens with their TeX counterparts, so that they can be handled by a LaTeX interpreter (like such in the plotting lib). More...
 
Match findCommand (StringView sCmd, const std::string &sCommand="")
 This function is very important for the command handler. More...
 
std::string extractCommandString (const std::string &sCmd, const Match &_mMatch)
 Extracts the whole command string from a command line (which might contain more than one). More...
 
void openExternally (const std::string &)
 Opens a file with the program, which is associated by default within the Windows shell. More...
 
void moveFile (const std::string &, const std::string &)
 Move a file from one to another location. Can be used for renaming as well. More...
 
void copyFile (const std::string &, const std::string &)
 Copy the file's contents to another file. More...
 
void writeTeXMain (const std::string &)
 
std::string getArgAtPos (const std::string &sCmd, unsigned int nPos, int extraction=ARGEXTRACT_STRIPPED)
 Extracts a options value at the selected position and applies automatic parsing, if necessary. More...
 
bool isInQuotes (StringView sExpr, unsigned int nPos, bool bIgnoreVarParser=false)
 Checks, whether the position in the passed expression is part of a string literal. More...
 
bool isToStringArg (const std::string &sExpr, unsigned int nPos)
 This function determines, whether the current position is part of an argument of the three value to string conversion functions. More...
 
bool isDelimiter (char cChar)
 This function determines, if the passed character is a delimiter character. More...
 
bool addLegends (std::string &)
 This function adds the missing legend strings to the expressions in the passed string. More...
 
bool checkDelimiter (const std::string &sToken, bool stringdelim=false)
 Checks, whether the first and the last character in the passed string is a delimiter character. More...
 
std::vector< std::string > splitIntoLines (std::string sOutput, size_t lineWidth, bool bAllowDashBreaks=true, int nFirstIndent=4, int nIndent=4)
 This function splits a string into multiple lines if the line is longer than the desired line width. More...
 
std::string outputString (std::vector< std::string > stringInLines, int nFirstIndent, int nIndent)
 This function outputs a string by adding the required prefixes and joining the various strings together. More...
 
std::string LineBreak (std::string sOutput, const Settings &_option, bool bAllowDashBreaks=true, int nFirstIndent=4, int nIndent=4)
 This function takes a string, splits it into multiple lines if it is too long and returns the result. More...
 
double Linearize (double x_0, double y_0, double x_1, double y_1)
 Determines the root of the line connecting the two passed points. More...
 
void make_hline (int nLength=-1)
 This function prints a horizontal line to the terminal using either minus or equal signs. More...
 
void make_progressBar (int nStep, int nFirstStep=1, int nFinalStep=100, const std::string &sType="std")
 Wrapper for the static member function of the kernel. More...
 
bool containsStrings (const std::string &sLine)
 This function checks, whether the passed expression contains strings or valtostring parser. More...
 
bool fileExists (const std::string &sFilename)
 This function checks, whether the file with the passed file name exists. More...
 
void reduceLogFilesize (const std::string &sFileName)
 This function is used to reduce the log file size from >= 100.000 to 20.000 lines to reduce the needed disk space. More...
 
std::string replaceToVectorname (const std::string &sExpression)
 This function replaces a data access expression (i.e. the contents of the object argument parentheses) into a vector name, which is valid for the parser. More...
 
void eraseToken (std::string &sExpr, const std::string &sToken, bool bTokenHasValue=false)
 This function erases option tokens including their possible value from a parameter string. More...
 
std::string getFileInfo (const std::string &sFilename)
 This function opens a NumeRe-Datafile file, reads its header and converts it to a human-readable string. More...
 
std::string decodeNameSpace (std::string sCommandLine, const std::string &sThisNameSpace)
 
bool isValidValue (double d)
 
bool validateParenthesisNumber (const std::string &sCmd)
 Checks, whether the number of parentheses is an even number. More...
 
void addArgumentQuotes (std::string &sToAdd, const std::string &sParam)
 This function adds quotation marks around the value of the specified parameter. More...
 
void addArgumentQuotes (std::string &sToAdd, size_t pos)
 This function adds quotation marks around the value of the specified parameter. More...
 
double intPower (double dNumber, int nExponent)
 Calculates the power of a number using an integer as exponent. More...
 
std::complex< double > intPower (const std::complex< double > &dNumber, int nExponent)
 This function calculates the power of a value with the specialization that the exponent is an integer. Function overload for complex-valued bases. More...
 
std::string getNextArgument (std::string &sArgList, bool bCut=true)
 
std::string getNextIndex (std::string &sArgList, bool bCut=true)
 
std::string getNextSemiColonSeparatedToken (std::string &sArgList, bool bCut=true)
 
StringView getNextViewedArgument (StringView &sView)
 
StringView getNextViewedIndex (StringView &sView)
 
EndlessVector< StringViewgetAllArguments (StringView sArgList)
 Splits up the complete argument list and returns them as an EndlessVector. More...
 
EndlessVector< std::string > getAllArguments (std::string sArgList)
 Splits up the complete argument list and returns them as an EndlessVector. More...
 
EndlessVector< std::string > getAllIndices (std::string sArgList)
 Splits up the complete index list and returns them as an EndlessVector. More...
 
EndlessVector< std::string > getAllSemiColonSeparatedTokens (std::string sArgList)
 Splits up the complete index list and returns them as an EndlessVector. More...
 
bool isToCmd (const std::string &sCmd, unsigned int nPos)
 Checks, whether the "to_cmd()" function was used. More...
 
unsigned int countEscapeSymbols (const std::string &sLine)
 This function counts the number of escaped dollar signs. More...
 
std::vector< std::string > getFileList (const std::string &sDirectory, const Settings &_option, int nFlags=0)
 This function returns a list of files (including their paths, if nFlags & 1). More...
 
std::vector< std::string > getFolderList (const std::string &sDirectory, const Settings &_option, int nFlags=0)
 This function returns a list of directories (including their paths, if nFlags & 1). More...
 
template<typename Word >
std::ostream & little_endian_io::write_word (std::ostream &outs, Word value, unsigned size=sizeof(Word))
 
template<typename Word >
std::istream & little_endian_io::read_word (std::istream &ins, Word &value, unsigned size=sizeof(Word))
 
template<typename Word >
std::ostream & big_endian_io::write_word (std::ostream &outs, Word value, unsigned size=sizeof(Word))
 
template<typename Word >
std::istream & big_endian_io::read_word (std::istream &ins, Word &value, unsigned size=sizeof(Word))
 
void evalRecursiveExpressions (std::string &sExpr)
 This function converts the recursive assignments like VAR += VAL into VAR = VAR + (VAL) More...
 
size_t qSortDouble (double *dArray, size_t nlength)
 This is a wrapper for the standard qsort algorithm. It returns the number of valid elements and sorts the elements in-place. More...
 
void replaceStringMethod (std::string &sLine, size_t nPos, size_t nLength, const std::string &sReplacement)
 This function searches the indicated string variable occurence for possible string methods and replaces them with the standard string function. More...
 
std::string shortenFileName (const std::string &sFullFileName)
 This function will return a shortened version of the data file name, where each "/Path/" string part is transformed to "/../". More...
 
std::string incrementVersion (std::string _sVer)
 Increments a MAJOR.MINOR.BUILD version string by one build count. More...
 

Variables

const std::string sVersion
 

Enumeration Type Documentation

◆ ArgExtraction

Enumerator
ARGEXTRACT_NONE 
ARGEXTRACT_STRIPPED 
ARGEXTRACT_PARSED 
ARGEXTRACT_ASINT 
ARGEXTRACT_ASSTRING 

Definition at line 53 of file tools.hpp.

Function Documentation

◆ addArgumentQuotes() [1/2]

void addArgumentQuotes ( string &  sToAdd,
const string &  sParam 
)

This function adds quotation marks around the value of the specified parameter.

Parameters
sToAddstring&
sParamconst string&
Returns
void

Definition at line 3560 of file tools.cpp.

References addArgumentQuotes(), and findParameter().

Referenced by addArgumentQuotes(), cmd_define(), cmd_ifndefined(), cmd_redefine(), cmd_set(), cmd_stats(), and getPathForSetting().

Here is the call graph for this function:

◆ addArgumentQuotes() [2/2]

void addArgumentQuotes ( string &  sToAdd,
size_t  pos 
)

This function adds quotation marks around the value of the specified parameter.

Parameters
sToAddstring&
possize_t
Returns
void

Definition at line 3580 of file tools.cpp.

References containsStrings(), and getArgAtPos().

Here is the call graph for this function:

◆ addLegends()

bool addLegends ( string &  sExpr)

This function adds the missing legend strings to the expressions in the passed string.

Parameters
sExprstring&
Returns
bool

Definition at line 1875 of file tools.cpp.

References getAllArguments(), getMatchingParenthesis(), StripSpaces(), SyntaxError::UNMATCHED_PARENTHESIS, and validateParenthesisNumber().

Referenced by Plot::createSubPlotSet().

Here is the call graph for this function:

◆ checkDelimiter()

bool checkDelimiter ( const string &  sString,
bool  stringdelim 
)

Checks, whether the first and the last character in the passed string is a delimiter character.

Parameters
sStringconst string&
stringdelimbool
Returns
bool

Definition at line 1982 of file tools.cpp.

References isDelimiter().

Referenced by FunctionDefinitionManager::call(), FunctionDefinition::convertToValues(), NumeRe::StringParser::eval(), findCommandWithReturnValue(), Fitcontroller::getFitFunction(), FunctionDefinition::replaceArgumentOccurences(), FlowCtrl::replaceLocalVars(), replaceToTeX(), ProcedureVarFactory::resolveArguments(), ProcedureVarFactory::resolveLocalClusters(), ProcedureVarFactory::resolveLocalStrings(), ProcedureVarFactory::resolveLocalTables(), ProcedureVarFactory::resolveLocalVars(), and splitIntoLines().

Here is the call graph for this function:

◆ containsStrings()

bool containsStrings ( const string &  sLine)

This function checks, whether the passed expression contains strings or valtostring parser.

Parameters
sLineconst string&
Returns
bool

Definition at line 2470 of file tools.cpp.

References containsStringClusters().

Referenced by addArgumentQuotes(), cmd_install(), convertVectorToExpression(), NumeReDebugger::decodeType(), getStringArgument(), and taylor().

Here is the call graph for this function:

◆ copyFile()

void copyFile ( const string &  sFile,
const string &  sTarget 
)

Copy the file's contents to another file.

Parameters
sFileconst string&
sTargetconst string&
Returns
void

Definition at line 1431 of file tools.cpp.

References SyntaxError::CANNOT_OPEN_SOURCE, SyntaxError::CANNOT_OPEN_TARGET, and SyntaxError::invalid_position.

Referenced by moveFile(), and moveOrCopyFiles().

◆ countEscapeSymbols()

unsigned int countEscapeSymbols ( const string &  sLine)

This function counts the number of escaped dollar signs.

Parameters
sLineconst string&
Returns
unsigned int

Definition at line 3708 of file tools.cpp.

◆ decodeNameSpace()

std::string decodeNameSpace ( std::string  sCommandLine,
const std::string &  sThisNameSpace 
)

Definition at line 3476 of file tools.cpp.

References StripSpaces().

Referenced by Procedure::execute(), SearchController::FindNameSpaceOfProcedure(), and Dependencies::getProcedureDependencies().

Here is the call graph for this function:

◆ eraseToken()

void eraseToken ( string &  sExpr,
const string &  sToken,
bool  bTokenHasValue 
)

This function erases option tokens including their possible value from a parameter string.

Parameters
sExprstring&
sTokenconst string&
bTokenHasValuebool
Returns
void

Definition at line 2527 of file tools.cpp.

References findParameter(), getMatchingParenthesis(), and isInQuotes().

Referenced by doc_Help(), and evaluateFittingParams().

Here is the call graph for this function:

◆ evalRecursiveExpressions()

void evalRecursiveExpressions ( string &  sExpr)

This function converts the recursive assignments like VAR += VAL into VAR = VAR + (VAL)

Parameters
sExprstring&
Returns
void

Definition at line 3346 of file tools.cpp.

References getMatchingParenthesis(), handleIncAndDecOperators(), and handleRecursiveOperators().

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

Here is the call graph for this function:

◆ extractCommandString()

std::string extractCommandString ( const string &  sCmd,
const Match _mMatch 
)

Extracts the whole command string from a command line (which might contain more than one).

Parameters
sCmdconst string&
_mMatchconst Match&
Returns
string

Definition at line 1325 of file tools.cpp.

References getMatchingParenthesis(), isInQuotes(), Match::nPos, and SyntaxError::UNMATCHED_PARENTHESIS.

Referenced by cmd_get(), CommandLineParser::CommandLineParser(), and PackageManager::evalPluginCmd().

Here is the call graph for this function:

◆ extractStringToken()

std::string extractStringToken ( const string &  sCmd,
size_t  nPos 
)

This function extracts a string token at the selected position. If the position is start of an option value, the possible equal sign is ignored.

Parameters
sCmdconst string&
nPossize_t
Returns
string

Definition at line 310 of file tools.cpp.

References getMatchingParenthesis(), and isInQuotes().

Referenced by getStringArgument().

Here is the call graph for this function:

◆ fileExists()

bool fileExists ( const string &  sFilename)

This function checks, whether the file with the passed file name exists.

Parameters
sFilenameconst string&
Returns
bool

Definition at line 2500 of file tools.cpp.

◆ findCommand()

Match findCommand ( StringView  sCmd,
const std::string &  sCommand 
)

This function is very important for the command handler.

It extracts the command out of the complete command line. It is also capable of finding a command, which is not at the start of the line (i.e. commands, which are returning values).

Parameters
sCmdStringView
sCommandconst std::string&
Returns
Match

Definition at line 1275 of file tools.cpp.

References StringViewBase::find(), findCasualCommand(), findCommand(), findCommandWithReturnValue(), Match::nPos, Match::sString, StripSpaces(), and StringViewBase::to_string().

Referenced by CodeAnalyzer::analyseCommands(), Procedure::applyInliningRuleset(), Assertion::assertionFail(), FlowCtrl::calc(), ProcedureVarFactory::checkArgument(), ProcedureVarFactory::checkArgumentValue(), FlowCtrl::checkParsingModeAndExpandDefinitions(), ProcedureElement::cleanCurrentLine(), cmd_clear(), cmd_get(), cmd_help(), cmd_install(), cmd_new(), cmd_plotting(), cmd_print(), cmd_redefine(), cmd_reload(), cmd_retouch(), cmd_stats(), cmd_undefine(), commandHandler(), CommandLineParser::CommandLineParser(), FlowCtrl::compile(), Plot::createSubPlotSet(), editObject(), PackageManager::evalPluginCmd(), NumeReKernel::evaluateProcedureCalls(), Plot::evaluateSubplot(), Procedure::execute(), FlowCtrl::fillJumpTableAndExpandRecursives(), findCommand(), findExtrema(), NumeRe::FindProcedureDefinition(), findShortestMatchForCommand(), fitDataSet(), FlowCtrl::for_loop(), Procedure::getInlined(), Includer::getNextLine(), Script::getNextScriptCommandFromScript(), Dependencies::getProcedureDependencies(), getVarList(), NumeReKernel::handleCommandLineSource(), NumeReKernel::handleComposeBlock(), Script::handleLocalDefinitions(), NumeReKernel::handleToCmd(), FlowCtrl::if_fork(), Includer::is_including_syntax(), Procedure::isInlineable(), PackageManager::isPluginCmd(), NumeReKernel::MainLoop(), Includer::openIncludedFile(), parseLayoutScript(), performMatrixOperation(), Plot::Plot(), plugin_histogram(), Procedure::ProcCalc(), Procedure::procedureCmdInterface(), ProcedureElement::ProcedureElement(), Procedure::procedureInterface(), FlowCtrl::range_based_for_loop(), Procedure::replaceReturnVal(), FlowCtrl::setCommand(), Odesolver::solve(), MemoryManager::sortElements(), FlowCtrl::switch_fork(), FlowCtrl::try_catch(), NumeReKernel::uninstallPlugin(), FlowCtrl::while_loop(), Script::writeProcedure(), and Procedure::writeProcedure().

Here is the call graph for this function:

◆ findParameter()

int findParameter ( const string &  sCmd,
const string &  sParam,
const char  cFollowing 
)

This function searches the passed parameter in the passed command string. If something is found, the position of the parameter+1 is returned.

Parameters
sCmdconst string&
sParamconst string&
cFollowingconst char
Returns
int

This function is one of the most important ones in the whole application as it provides the support for the defined command syntax.

Definition at line 113 of file tools.cpp.

Referenced by addArgumentQuotes(), and eraseToken().

◆ getAllArguments() [1/2]

EndlessVector< std::string > getAllArguments ( string  sArgList)

Splits up the complete argument list and returns them as an EndlessVector.

Parameters
sArgListstring
Returns
EndlessVector<string>

Definition at line 2365 of file tools.cpp.

References getNextArgument().

Here is the call graph for this function:

◆ getAllArguments() [2/2]

EndlessVector< StringView > getAllArguments ( StringView  sArgList)

Splits up the complete argument list and returns them as an EndlessVector.

Parameters
sArgListStringView
Returns
EndlessVector<StringView>

Definition at line 2346 of file tools.cpp.

References getNextViewedArgument(), and StringViewBase::length().

Referenced by Documentation::addEntry(), addLegends(), CodeAnalyzer::analysePreDefs(), mu::ParserBase::compileVectorExpansion(), SymDefManager::createSymbol(), determineWindowSize(), Plot::fillData(), Documentation::findPositionUsingIdxKeys(), Documentation::getDocIndex(), Documentation::getHelpArticle(), getIndices(), handleMafDataAccess(), IntervalSet::IntervalSet(), FlowCtrl::range_based_for_loop(), readAndParseIntervals(), NumeRe::JcampDX::readFile(), readFromFile(), and PlotData::setParams().

Here is the call graph for this function:

◆ getAllIndices()

EndlessVector< std::string > getAllIndices ( string  sArgList)

Splits up the complete index list and returns them as an EndlessVector.

Parameters
sArgListstring
Returns
EndlessVector<string>

Definition at line 2384 of file tools.cpp.

References getNextIndex().

Referenced by Plot::createDataLegends(), evalPoints(), findExtrema(), findZeroes(), readAndParseIntervals(), readAndParseLegacyIntervals(), and Interval::refresh().

Here is the call graph for this function:

◆ getAllSemiColonSeparatedTokens()

EndlessVector< std::string > getAllSemiColonSeparatedTokens ( string  sArgList)

Splits up the complete index list and returns them as an EndlessVector.

Parameters
sArgListstring
Returns
EndlessVector<string>

Definition at line 2403 of file tools.cpp.

References getNextSemiColonSeparatedToken().

Referenced by cmd_reload(), Procedure::execute(), NumeReKernel::getLineFromCommandCache(), and NumeReSyntax::splitDefs().

Here is the call graph for this function:

◆ getArgAtPos()

std::string getArgAtPos ( const string &  sCmd,
unsigned int  nPos,
int  extraction 
)

Extracts a options value at the selected position and applies automatic parsing, if necessary.

Parameters
sCmdconst string&
nPosunsigned int
extractionint
Returns
string

Definition at line 1598 of file tools.cpp.

References ARGEXTRACT_PARSED, ARGEXTRACT_STRIPPED, NumeReKernel::getInstance(), getMatchingParenthesis(), NumeReKernel::getStringParser(), isStringContinuation(), NumeRe::StringParser::isStringExpression(), parseArg(), and StripSpaces().

Referenced by addArgumentQuotes(), FunctionDefinition::appendComment(), FlowCtrl::calc(), cmd_list(), cmd_rename(), cmd_set(), FlowCtrl::compile(), FunctionDefinition::convertToValues(), PackageManager::declareNewPackage(), FunctionDefinition::decodeDefinition(), FunctionDefinitionManager::defineFunc(), dialogCommand(), evaluateFittingParams(), Script::evaluateInstallInformation(), Plot::evaluateSubplot(), evaluateTargetOptionInCommand(), NumeRe::OpenDocumentSpreadSheet::expandLine(), FlowCtrl::extractFlagsAndIndexVariables(), findExtrema(), findZeroes(), CommandLineParser::getFileParameterValue(), getIntervalDef(), getIntervalForSearchFunctions(), getItemId(), Package::getOptionValue(), getParametersFromWindow(), getParameterValue(), CommandLineParser::getParameterValue(), CommandLineParser::getParameterValueAsNumericalValue(), CommandLineParser::getParameterValueAsString(), getTagValue(), getTargetTable(), NumeReKernel::handleComposeBlock(), Script::handleInstallInformation(), FunctionDefinition::importFunction(), IntervalSet::IntervalSet(), listDirectory(), listFiles(), loadDocumentationArticle(), parseEventOpt(), MemoryManager::parseEvery(), parseLayoutCommand(), parseLayoutScript(), parseNumOpt(), parseStringOpt(), Plot::Plot(), plugin_histogram(), plugin_random(), plugin_statistics(), ProcedureElement::ProcedureElement(), readAndParseLegacyIntervals(), setParametersInWindow(), PlotData::setParams(), Odesolver::solve(), MemoryManager::sortElements(), Memory::sortElements(), StringInternalMemory::sortElements(), strfnc_getopt(), swapTables(), NumeReKernel::uninstallPlugin(), windowCommand(), and Script::writeLayout().

Here is the call graph for this function:

◆ getFileInfo()

std::string getFileInfo ( const string &  sFileName)

This function opens a NumeRe-Datafile file, reads its header and converts it to a human-readable string.

Parameters
sFileNameconst string&
Returns
string

Definition at line 3446 of file tools.cpp.

References NumeRe::FileHeaderInfo::fileVersion, NumeRe::NumeReDataFile::getFileHeaderInformation(), NumeRe::FileHeaderInfo::nCols, NumeRe::FileHeaderInfo::nRows, NumeRe::NumeReDataFile::readFileInformation(), NumeRe::FileHeaderInfo::sComment, NumeRe::FileHeaderInfo::sTableName, NumeRe::FileHeaderInfo::timeStamp, and toString().

Referenced by NumeReWindow::getFileDetails(), and listDirectory().

Here is the call graph for this function:

◆ getFileList()

std::vector< std::string > getFileList ( const string &  sDirectory,
const Settings _option,
int  nFlags 
)

This function returns a list of files (including their paths, if nFlags & 1).

Parameters
sDirectoryconst string&
_optionconst Settings&
nFlagsint
Returns
vector<string>

Definition at line 2853 of file tools.cpp.

References initializeFileHandle(), replacePathSeparator(), and resolveChooseTokens().

Referenced by append_data(), cmd_load(), Documentation::createDocumentationIndex(), NumeReWindow::CreateProcedureTree(), moveOrCopyFiles(), Archive::pack(), removeFile(), and strfnc_getfilelist().

Here is the call graph for this function:

◆ getFolderList()

std::vector< std::string > getFolderList ( const string &  sDirectory,
const Settings _option,
int  nFlags 
)

This function returns a list of directories (including their paths, if nFlags & 1).

Parameters
sDirectoryconst string&
_optionconst Settings&
nFlagsint
Returns
vector<string>

Definition at line 2925 of file tools.cpp.

References initializeFileHandle(), replacePathSeparator(), and resolveChooseTokens().

Referenced by NumeReWindow::CreateProcedureTree(), Archive::pack(), resolveChooseTokens(), and strfnc_getfolderlist().

Here is the call graph for this function:

◆ getMatchingParenthesis()

unsigned int getMatchingParenthesis ( const StringView sLine)

Returns the position of the closing parenthesis.

Parameters
sLineStringView
Returns
unsigned int The position of the closing parenthesis

This function determines the type of the desired parenthesis by itself by using the first parenthesis-like character that might be found in the passed string. This function also considers quotation marks, so that parentheses in strings are not considered as matching. If the function does not find the matching parenthesis, it returns string::npos

Definition at line 414 of file tools.cpp.

Referenced by addLegends(), eraseToken(), evalRecursiveExpressions(), extractCommandString(), extractStringToken(), getArgAtPos(), getNextCommandLineToken(), handleRecursiveOperators(), isInQuotes(), isMultiValue(), isToCmd(), isToStringArg(), replaceStringMethod(), and replaceToTeX().

◆ getNextArgument()

std::string getNextArgument ( std::string &  sArgList,
bool  bCut = true 
)

Definition at line 2294 of file tools.cpp.

Referenced by getAllArguments(), and replaceSearchMethods().

◆ getNextIndex()

std::string getNextIndex ( std::string &  sArgList,
bool  bCut = true 
)

Definition at line 2305 of file tools.cpp.

References getNextCommandLineToken(), and StringViewBase::to_string().

Referenced by evaluateParameterValues(), and getAllIndices().

Here is the call graph for this function:

◆ getNextSemiColonSeparatedToken()

std::string getNextSemiColonSeparatedToken ( std::string &  sArgList,
bool  bCut = true 
)

Definition at line 2316 of file tools.cpp.

References getNextCommandLineToken(), and StringViewBase::to_string().

Referenced by getAllSemiColonSeparatedTokens().

Here is the call graph for this function:

◆ getNextViewedArgument()

StringView getNextViewedArgument ( StringView sView)

Definition at line 2327 of file tools.cpp.

References getNextCommandLineToken().

Referenced by NumeRe::StringFuncHandler::argumentParser(), mu::ExpressionTarget::create(), extractIndexList(), and getAllArguments().

Here is the call graph for this function:

◆ getNextViewedIndex()

StringView getNextViewedIndex ( StringView sView)

Definition at line 2332 of file tools.cpp.

References getNextCommandLineToken().

Referenced by extractIndexList().

Here is the call graph for this function:

◆ getRandGenInstance()

std::mt19937 & getRandGenInstance ( )

Returns a reference to the central random number generator instance, which is globally accessible by all random number functions.

Returns
std::mt19937&

Definition at line 91 of file tools.cpp.

◆ getStringArgument()

bool getStringArgument ( const string &  sCmd,
string &  sArgument 
)

This function searches for the first string value in the passed expression and writes that into sArgument. If nothing was found, this function returns false, true otherwise.

Parameters
sCmdconst string&
sArgumentstring&
Returns
bool

Definition at line 250 of file tools.cpp.

References containsStrings(), and extractStringToken().

Referenced by evaluateParameterValues(), extractFirstParameterStringValue(), and Procedure::ProcCalc().

Here is the call graph for this function:

◆ incrementVersion()

std::string incrementVersion ( std::string  _sVer)

Increments a MAJOR.MINOR.BUILD version string by one build count.

Parameters
_sVerstd::string
Returns
std::string

Definition at line 3991 of file tools.cpp.

References intToVersion(), and versionToInt().

Referenced by PackageDialog::loadProjectFile().

Here is the call graph for this function:

◆ intCast() [1/2]

long long int intCast ( const std::complex< double > &  number)

Casts the real part of the complex number to an integer and avoids rounding errors.

Parameters
numberconst std::complex<double>&
Returns
long long int

Definition at line 1824 of file tools.cpp.

◆ intCast() [2/2]

long long int intCast ( double  number)

Casts doubles to integers and avoids rounding errors.

Parameters
numberdouble
Returns
long long int

Definition at line 1805 of file tools.cpp.

References mu::rint().

Referenced by intCast(), and parseArg().

Here is the call graph for this function:

◆ intPower() [1/2]

std::complex< double > intPower ( const std::complex< double > &  dNumber,
int  nExponent 
)

This function calculates the power of a value with the specialization that the exponent is an integer. Function overload for complex-valued bases.

Parameters
dNumberconst std::complex<double>&
nExponentint
Returns
std::complex<double>

Definition at line 3640 of file tools.cpp.

◆ intPower() [2/2]

double intPower ( double  dNumber,
int  nExponent 
)

Calculates the power of a number using an integer as exponent.

Parameters
dNumberdouble
nExponentint
Returns
double

Calculates the power of a number using an integer as exponent.

Parameters
dNumberdouble
nExponentint
Returns
double

Definition at line 3607 of file tools.cpp.

Referenced by intPower().

◆ isDelimiter()

◆ isInQuotes()

bool isInQuotes ( StringView  sExpr,
unsigned int  nPos,
bool  bIgnoreVarParser 
)

Checks, whether the position in the passed expression is part of a string literal.

Parameters
sExprStringView
nPosunsigned int
boolbIgnoreVarParser = false
Returns
bool

Definition at line 1672 of file tools.cpp.

References getMatchingParenthesis(), isInQuotes(), StringViewBase::length(), StringViewBase::rfind(), and StringView::subview().

Referenced by FlowCtrl::calc(), FunctionDefinitionManager::call(), FlowCtrl::compile(), CodeAnalyzer::containsAssignment(), Procedure::countProceduresInLine(), ProcedureVarFactory::countVarListElements(), Plot::create2dDrawing(), Plot::create3dDrawing(), Plot::createSubPlotSet(), eraseToken(), NumeRe::StringLogicParser::evalStringLogic(), NumeRe::StringLogicParser::evalStringTernary(), evaluateParameterValues(), NumeReKernel::evaluateProcedureCalls(), NumeRe::StringVarFactory::evaluateStringVectors(), Procedure::expandInlineProcedures(), extractCommandString(), extractStringToken(), findCasualCommand(), findCommandWithReturnValue(), NumeRe::StringFuncHandler::findNextFunction(), findShortestMatchForCommand(), findVariableInExpression(), CommandLineParser::getAllParametersWithValues(), NumeRe::StringVarFactory::getStringValues(), NumeRe::StringVarFactory::getStringValuesAsInternalVar(), handleMafDataAccess(), NumeReKernel::handleToCmd(), IntervalSet::IntervalSet(), Procedure::isInline(), isInQuotes(), isToCmd(), NumeRe::StringParser::numToString(), Plot::Plot(), Procedure::ProcCalc(), Procedure::procedureInterface(), readAndParseIntervals(), replaceDataEntities(), FlowCtrl::replaceLocalVars(), ProcedureVarFactory::resolveArguments(), ProcedureVarFactory::resolveLocalClusters(), ProcedureVarFactory::resolveLocalStrings(), ProcedureVarFactory::resolveLocalTables(), ProcedureVarFactory::resolveLocalVars(), Dependencies::resolveProcedureCalls(), PlotData::setParams(), and Procedure::writeProcedure().

Here is the call graph for this function:

◆ isInt()

bool isInt ( const std::complex< double > &  number)

Determines, whether the content of a complex value is actually a regular integer.

Parameters
numberconst std::complex<double>&
Returns
bool

Definition at line 1838 of file tools.cpp.

References mu::rint().

Referenced by CategoricalColumn::setValue().

Here is the call graph for this function:

◆ isMultiValue()

bool isMultiValue ( const string &  sExpr,
bool  bIgnoreClosingParenthesis 
)

Determines, if a string contains multiple comma-separated expressions.

Parameters
sExprconst string&
bIgnoreClosingParenthesisbool
Returns
bool

Definition at line 484 of file tools.cpp.

References getMatchingParenthesis(), and isMultiValue().

Referenced by convertVectorToExpression(), FunctionDefinition::decodeDefinition(), Procedure::getInlined(), and isMultiValue().

Here is the call graph for this function:

◆ isToCmd()

bool isToCmd ( const string &  sCmd,
unsigned int  nPos 
)

Checks, whether the "to_cmd()" function was used.

Parameters
sCmdconst string&
nPosunsigned int
Returns
bool

Checks, whether the "to_cmd()" function was used.

Parameters
sCmdconst string&
nPosunsigned int
Returns
bool

Definition at line 3675 of file tools.cpp.

References getMatchingParenthesis(), and isInQuotes().

Referenced by ProcedureVarFactory::resolveArguments(), ProcedureVarFactory::resolveLocalClusters(), ProcedureVarFactory::resolveLocalStrings(), ProcedureVarFactory::resolveLocalTables(), and ProcedureVarFactory::resolveLocalVars().

Here is the call graph for this function:

◆ isToStringArg()

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 string conversion functions.

Parameters
sExprconst string&
nPosunsigned int
Returns
bool

Definition at line 1766 of file tools.cpp.

References getMatchingParenthesis(), and isDelimiter().

Referenced by convertVectorToExpression().

Here is the call graph for this function:

◆ isValidValue()

bool isValidValue ( double  d)
inline

Definition at line 84 of file tools.hpp.

References mu::isinf(), and mu::isnan().

Referenced by getDataForFit().

Here is the call graph for this function:

◆ Linearize()

double Linearize ( double  x_0,
double  y_0,
double  x_1,
double  y_1 
)

Determines the root of the line connecting the two passed points.

Parameters
x_0double
y_0double
x_1double
y_1double
Returns
double

Definition at line 2222 of file tools.cpp.

Referenced by findZeroesInMultiResult(), localizeExtremum(), and localizeZero().

◆ LineBreak()

std::string LineBreak ( std::string  sOutput,
const Settings _option,
bool  bAllowDashBreaks,
int  nFirstIndent,
int  nIndent 
)

◆ make_hline()

void make_hline ( int  nLength)

This function prints a horizontal line to the terminal using either minus or equal signs.

Parameters
nLengthint
Returns
void

Definition at line 3720 of file kernel.cpp.

References NumeReKernel::nLINE_LENGTH, NumeReKernel::printPreFmt(), and strfill().

Referenced by analyzePulse(), cmd_credits(), cmd_hline(), createOutputForHist1D(), createOutputForHist2D(), createStatsOutput(), doc_Help(), doc_SearchFct(), fitDataSet(), listCommands(), listConstants(), listDeclaredVariables(), listDefinitions(), listFiles(), listFunctions(), listInstalledPlugins(), listLogicalOperators(), listUnitConversions(), NumeReKernel::MainLoop(), NumeReKernel::printVersionInfo(), and show_data().

Here is the call graph for this function:

◆ make_progressBar()

void make_progressBar ( int  nStep,
int  nFirstStep,
int  nFinalStep,
const string &  sType 
)

Wrapper for the static member function of the kernel.

Parameters
nStepint
nFirstStepint
nFinalStepint
sTypeconst string&
Returns
void

Definition at line 2425 of file tools.cpp.

References NumeReKernel::progressBar().

Referenced by FlowCtrl::calc(), cmd_progress(), and FlowCtrl::compile().

Here is the call graph for this function:

◆ moveFile()

void moveFile ( const string &  sFile,
const string &  sNewFileName 
)

Move a file from one to another location. Can be used for renaming as well.

Parameters
sFileconst string&
sNewFileNameconst string&
Returns
void

Definition at line 1412 of file tools.cpp.

References copyFile().

Referenced by moveOrCopyFiles().

Here is the call graph for this function:

◆ openExternally()

void openExternally ( const string &  sFile)

Opens a file with the program, which is associated by default within the Windows shell.

Parameters
sFileconst string&
Returns
void

Definition at line 1375 of file tools.cpp.

References SyntaxError::CANNOT_READ_FILE, SyntaxError::EXTERNAL_PROGRAM_NOT_FOUND, SyntaxError::invalid_position, and replaceAll().

Referenced by editObject().

Here is the call graph for this function:

◆ outputString()

std::string outputString ( std::vector< std::string >  stringInLines,
int  nFirstIndent,
int  nIndent 
)

This function outputs a string by adding the required prefixes and joining the various strings together.

Parameters
stringInLinesstd::vector<std::string>
nFirstIndentint
nIndentint
Returns
std::string

Definition at line 2164 of file tools.cpp.

Referenced by LineBreak().

◆ qSortDouble()

size_t qSortDouble ( double *  dArray,
size_t  nlength 
)

This is a wrapper for the standard qsort algorithm. It returns the number of valid elements and sorts the elements in-place.

Parameters
dArraydouble*
nlengthsize_t
Returns
size_t

Definition at line 3762 of file tools.cpp.

References compareDouble(), mu::isinf(), and mu::isnan().

Referenced by PlotAsset::getWeightedRanges(), NumeRe::Cluster::med(), Memory::med(), Memory::pct(), and NumeRe::Cluster::pct().

Here is the call graph for this function:

◆ reduceLogFilesize()

void reduceLogFilesize ( const string &  sFileName)

This function is used to reduce the log file size from >= 100.000 to 20.000 lines to reduce the needed disk space.

Parameters
sFileNameconst string&
Returns
void

Definition at line 2998 of file tools.cpp.

References date::detail::trunc().

Referenced by fitDataSet(), and NumeReKernel::StartUp().

Here is the call graph for this function:

◆ replaceStringMethod()

void replaceStringMethod ( string &  sLine,
size_t  nPos,
size_t  nLength,
const string &  sReplacement 
)

This function searches the indicated string variable occurence for possible string methods and replaces them with the standard string function.

Parameters
sLinestring&
nPossize_t
nLengthsize_t
sReplacementconst string&
Returns
void

Definition at line 3875 of file tools.cpp.

References getMatchingParenthesis(), replaceAccessMethods(), and replaceSearchMethods().

Referenced by NumeRe::StringVarFactory::getStringValues(), NumeRe::StringVarFactory::getStringValuesAsInternalVar(), and ProcedureVarFactory::resolveLocalStrings().

Here is the call graph for this function:

◆ replaceToTeX()

std::string replaceToTeX ( const std::string &  sString,
bool  replaceForTeXFile 
)

Replace the special tokens with their TeX counterparts, so that they can be handled by a LaTeX interpreter (like such in the plotting lib).

Parameters
sStringconst std::string&
replaceForTeXFilebool true for TeX files. Will replace fewer characters.
Returns
std::string

Definition at line 753 of file tools.cpp.

References checkDelimiter(), getMatchingParenthesis(), getTeXCodePage(), getTeXCodePageSpecial(), handleTeXIndicesAndExponents(), isDelimiter(), and StripSpaces().

Referenced by calculateHist1dData(), Plot::create2dPlot(), Plot::createStd3dPlot(), Plot::createStdPlot(), createTeXExport(), and PlotData::getAxisLabel().

Here is the call graph for this function:

◆ replaceToVectorname()

std::string replaceToVectorname ( const string &  sExpression)

This function replaces a data access expression (i.e. the contents of the object argument parentheses) into a vector name, which is valid for the parser.

Parameters
sExpressionconst string&
Returns
string

Definition at line 3108 of file tools.cpp.

References OprtRplc_setup().

Referenced by NumeRe::StringFuncHandler::applySpecialStringFuncs(), createMafVectorName(), and replaceDataEntities().

Here is the call graph for this function:

◆ shortenFileName()

std::string shortenFileName ( const std::string &  sFullFileName)

This function will return a shortened version of the data file name, where each "/Path/" string part is transformed to "/../".

Parameters
sFullFileNameconst std::string&
Returns
std::string

Definition at line 3953 of file tools.cpp.

References replacePathSeparator().

Referenced by NumeRe::FileAdapter::getDataFileNameShort(), and EditorNotebook::SetTabText().

Here is the call graph for this function:

◆ splitIntoLines()

std::vector< std::string > splitIntoLines ( std::string  sOutput,
size_t  lineWidth,
bool  bAllowDashBreaks,
int  nFirstIndent,
int  nIndent 
)

This function splits a string into multiple lines if the line is longer than the desired line width.

Parameters
sOutputstd::string
lineWidthsize_t
bAllowDashBreaksbool
nFirstIndentint
nIndentint
Returns
std::vector<std::string>

Definition at line 2002 of file tools.cpp.

References checkDelimiter(), and toSystemCodePage().

Referenced by LineBreak(), and plotTableBySize().

Here is the call graph for this function:

◆ validateParenthesisNumber()

bool validateParenthesisNumber ( const string &  sCmd)

Checks, whether the number of parentheses is an even number.

Parameters
sCmdconst string&
Returns
bool

Doesn't check, whether the parentheses are ordered reasonable

Checks, whether the number of parentheses is an even number.

Parameters
sCmdconst string&
Returns
bool

Definition at line 3512 of file tools.cpp.

Referenced by addLegends(), applyValueHeuristics(), ProcedureVarFactory::createProcedureArguments(), getDataElements(), NumeReKernel::handleCommandLineSource(), ProcedureElement::ProcedureElement(), and FlowCtrl::setCommand().

◆ writeTeXMain()

void writeTeXMain ( const std::string &  sTeXFile)

Definition at line 1449 of file tools.cpp.

References SyntaxError::CANNOT_OPEN_TARGET, and SyntaxError::invalid_position.

Referenced by Plot::Plot().

Variable Documentation

◆ sVersion

const std::string sVersion
extern

Definition at line 123 of file NumeReWindow.cpp.