20#include "../utils/tinyxml2.h"
21#include "../io/styledtextfile.hpp"
22#include "../../kernel.hpp"
23#include "../procedure/includer.hpp"
40static std::string
parseNumOpt(
const std::string& sCmd,
size_t pos)
60 if (arg.find(
",") != std::string::npos && arg.find(
"\"") != std::string::npos)
62 else if (arg.front() ==
'"' && arg.back() ==
'"')
63 return arg.substr(1, arg.length()-2);
79static std::string
parseEventOpt(
const std::string& sCmd,
size_t pos,
const std::string& sFolderName)
84 if (sFolderName.substr(0, sProcBase.length()) == sProcBase)
86 sProcBase = sFolderName.substr(sProcBase.length());
89 while (sProcBase.front() ==
'~')
90 sProcBase.erase(0, 1);
92 if (sProcBase.length() && sProcBase.back() !=
'~')
98 if (option.front() ==
'$' && option.substr(option.length()-2) ==
"()")
99 option.erase(option.length()-2);
101 if (option.substr(0, 6) ==
"$this~")
102 option =
"$" + sProcBase + option.substr(6);
121 if (sExpr.find_first_not_of(
' ') == std::string::npos)
149 for (
int i = 0; i < results; i++)
171 std::string sExpr = sLayoutCommand.substr(0,
std::min(sLayoutCommand.find(
"-set"), sLayoutCommand.find(
"--")));
173 replaceAll(sExpr,
"<this>", sFolderName.c_str());
179 layoutElement->
SetText(sExpr.c_str());
242 std::unique_ptr<Includer> _includer;
244 std::string sFolderName = sLayoutScript.substr(0, sLayoutScript.rfind(
'/'));
245 std::string sOnOpenEvent;
251 std::stack<tinyxml2::XMLElement*> currentGroup;
262 if (_includer && _includer->is_open())
264 line = _includer->getNextLine();
284 _includer.reset(
new Includer(line, sLayoutScript.substr(0, sLayoutScript.rfind(
'/'))));
299 if (_mMatch.
sString ==
"declare")
306 if (_mMatch.
sString ==
"layout")
309 currentGroup.push(layout->
NewElement(
"layout"));
311 replaceAll(line,
"<this>", sFolderName.c_str());
328 else if (_mMatch.
sString ==
"endlayout")
330 else if (_mMatch.
sString ==
"group")
335 currentGroup.push(newgroup);
350 else if (_mMatch.
sString ==
"endgroup")
354 if (currentGroup.empty())
359 if (currentGroup.empty())
365 std::string sLayoutCommand = line.substr(_mMatch.
nPos+_mMatch.
sString.length());
366 std::string sExpr = sLayoutCommand.substr(0,
std::min(sLayoutCommand.find(
"-set"), sLayoutCommand.find(
"--")));
367 replaceAll(sExpr,
"<this>", sFolderName.c_str());
369 currentChild->
SetText(sExpr.c_str());
374 if (currentGroup.empty())
429 std::string sCurExpr = sExpr;
474 if (val.
type !=
"tablegrid")
577 std::string sExpr = cmdParser.
getExpr();
601 if (sItemType ==
"prop")
613 std::vector<mu::value_type> vRes;
616 for (
auto items : vItems)
617 vRes.push_back(items);
646 std::string sOnOpenEvent;
662 size_t millisecs = 0;
664 while (millisecs < 3000)
676 if (sOnOpenEvent.length())
677 cmdParser.
setReturnValue(
" " + sOnOpenEvent +
"(" +
toString(
id) +
", -1, {\"event\",\"onopen\",\"object\",\"window\",\"value\",nan,\"state\",\"enabled\"})");
695 for (
size_t i = 0; i < sProc.length(); i++)
699 if (sProc.length() > 5 && i >= 4 && sProc.substr(i - 4, 5) ==
"main~")
700 sProc = sProc.substr(0, i - 4) + sProc.substr(i + 1);
726 std::string sFolderName = sLayoutFile.substr(0, sLayoutFile.rfind(
'/'));
727 std::vector<std::string> vProcedures;
729 for (
size_t i = 0; i < (size_t)layoutFile.
getLinesCount(); i++)
737 if (sEvent.front() ==
'$')
745 if (sEvent.front() ==
'$')
753 if (sEvent.front() ==
'$')
773 std::string sMessage;
774 std::string sTitle =
"NumeRe: Window";
775 std::string sExpression;
793 if (sType ==
"filedialog")
795 else if (sType ==
"dirdialog")
797 else if (sType ==
"listdialog")
799 else if (sType ==
"selectiondialog")
801 else if (sType ==
"messagebox")
803 else if (sType ==
"textentry")
815 if (sButtons ==
"ok")
817 else if (sButtons ==
"okcancel")
819 else if (sButtons ==
"yesno")
829 if (sIcon ==
"erroricon")
831 else if (sIcon ==
"warnicon")
833 else if (sIcon ==
"infoicon")
835 else if (sIcon ==
"questionicon")
840 sExpression = cmdParser.
getExpr();
874 std::string sTemp = sExpression;
879 sExpression +=
"," + sTemp;
This class provides the functionality to extract the different components of a command line into the ...
const std::string & getCommandLine() const
Returns the command line used for constructing this instance (e.g. for errors).
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,...
const std::string & getExpr() const
Returns the expression as plain value.
const std::string & getParameterList() const
Returns the parameter list.
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.
This class is defined to abstrahize the determination of the correct data object and the calculation ...
Indices & getIndices()
Returns a reference to the stored indices.
std::string & getDataObject()
Returns a reference to the data object identifier.
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 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...
bool call(std::string &sExpr, int nRecursion=0)
This function searches for known custom definitions in the passed expression and replaces them with t...
This class represents a file, which can be included into other files using the @ syntax.
static bool is_including_syntax(const std::string &sLine)
Static member function which determines, whether the passed line is actually a including syntax.
This class represents the central memory managing instance. It will handle all tables and clusters,...
NumeRe::Table extractTable(const std::string &_sTable, const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
void importTable(NumeRe::Table _table, const std::string &_sTable, const VectorIndex &lines=VectorIndex(0, VectorIndex::OPEN_END), const VectorIndex &cols=VectorIndex(0, VectorIndex::OPEN_END))
bool containsTables(const std::string &sExpression)
This member function detects, whether a table is used in the current expression.
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...
std::string getItemColor(int windowItemID) const
Returns the color of the selected window item as a string.
bool setItemState(const std::string &_state, int windowItemID)
Enables changing the state of the selected window item to the passed state.
WinItemValue getItemValue(int windowItemID) const
Returns the value of the selected window item as a string.
std::vector< int > getWindowItems(const std::string &_selection) const
Returns a vector of item ids corresponding to the available window items of this window.
std::string getItemLabel(int windowItemID) const
Returns the label of the selected window item as a string.
bool setItemColor(const std::string &_color, int windowItemID)
Enables changing the color of the selected window item to the passed color.
std::string getItemState(int windowItemID) const
Returns the state of the selected window item as a string.
std::string getProperties() const
Returns a list of all available window properties (comp. prop) in this window.
bool setItemValue(const WinItemValue &_value, int windowItemID)
Enables changing the value of the selected window item to the passed value.
bool setPropValue(const std::string &_value, const std::string &varName)
This function sets the value of the selected window property.
bool closeWindow()
Closes the current window.
std::string getPropValue(const std::string &varName) const
Returns the value of the selected property as a string.
bool setItemLabel(const std::string &_label, int windowItemID)
Enables changing the label of the selected window item to the passed label.
This is the window manager of the kernel. All windows opened by the kernel will be registered here.
WindowInformation getWindowInformationModal(size_t windowId)
This public member function will return the window information stored in the internal map....
WindowInformation getWindowInformation(size_t windowId)
This public member function will return the window information stored in the internal map....
size_t createWindow(GraphHelper *graph)
This public member function will create a window object containing the passed graph.
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()
NumeRe::WindowManager & getWindowManager()
MemoryManager & getMemoryManager()
FunctionDefinitionManager & getDefinitions()
Procedure & getProcedureInterpreter()
std::string getProcPath() const
Returns the current procedure root import path.
This class represents a text file in memory (e.g. a code file). This class will try to lex the loaded...
std::string getStrippedLine(size_t line) const
Returns the selected line (without the line termination characters and without any comments).
int getLinesCount() const
Returns the number of lines in the current loaded file.
This class handles the file-static constants, which are more or less macros similar to #define in C/C...
void resolveSymbols(std::string &sCommandLine) const
Resolve all file-static constant declarations in the current line.
void createSymbol(const std::string &sCommandLine)
Create one or more new file-static constant declarations for the current file.
Common exception class for all exceptions thrown in NumeRe.
@ NO_DEFAULTVALUE_FOR_DIALOG
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...
Mathematical expressions parser.
XMLElement * NewElement(const char *name)
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
void SetText(const char *inText)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
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 ...
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int StrToInt(const std::string &)
Converts a string into an integer.
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....
Structure for the findCommand function.
Kernel representation of the WindowItemValue structure of the CustomWindow class.
This class contains the window information to create the dialog in the GUI.
long long int intCast(const std::complex< double > &)
Casts the real part of the complex number to an integer and avoids rounding errors.
std::string toString(int)
Converts an integer to a string without the Settings bloat.
static void getParametersFromWindow(CommandLineParser &cmdParser, const std::string &sExpr)
This static function handles property reads from windows.
static void evaluateExpression(std::string &sExpr)
This static function evaluates the expression part of each window layout command.
static int getItemId(const std::string &sCmd)
This static function returns the item id from the user command string. It is also handled if the user...
static std::string parseEventOpt(const std::string &sCmd, size_t pos, const std::string &sFolderName)
This static function parses a event argument.
static std::string parseStringOpt(const std::string &sCmd, size_t pos)
This static function parses a string option.
std::vector< std::string > getEventProcedures(const std::string &sLayoutFile)
Examines a window layout file and searches for all event handler procedures. Returns their correspond...
static NumeRe::WindowInformation getWindow(const std::string &sExpr)
This static function returns the window information describing the window with the selected ID.
std::string removeQuotationMarks(const std::string &sString)
This function simply removes the surrounding quotation marks.
static std::string parseLayoutScript(std::string &sLayoutScript, tinyxml2::XMLDocument *layout)
This static function parses a layout script into a xml data container usable by the GUI....
static void parseLayoutCommand(const std::string &sLayoutCommand, tinyxml2::XMLElement *layoutElement, const std::string &sFolderName)
This static function parses a single layout command into a usable XML element.
static std::string getProcedureFileName(std::string sProc)
Converts a full-qualified procedure name into the corresponding file name.
static std::string parseNumOpt(const std::string &sCmd, size_t pos)
This static function parses a numerical argument.
void dialogCommand(CommandLineParser &cmdParser)
This function is the actual implementation of the dialog command.
void windowCommand(CommandLineParser &cmdParser)
This function is the actual implementation of the window command.
static void setParametersInWindow(CommandLineParser &cmdParser, const std::string &sExpr)
This static function handles property writes in windows.