| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.1 mglParse class
Class for parsing and executing MGL script. This class is defined in #include <mgl/mgl_parse.h>.
Class mglParse is the interpreter for MGL scripts (see section MGL interface). The main function of mglParse class is Parse(). Exactly this function parses and executes the script string-by-string. Also there are two subservient functions for the finding and creation of a variable. These functions can be useful for displaying values of variables (arrays) in some external program (in window, for example). The variable DataList contains full list of variables in script. Flag AllowSetSize allows one to prevent changing the size of the picture inside the script (forbids the MGL command setsize).
Note an important feature – if user defines function func in variable then it will be called before the destroying of this variable (see section mglVar class).
- Method on mglParse:
mglParse (boolsetsize=false) Constructor initializes all values with zero and set AllowSetSize value.
- Method on mglParse:
intParse (mglGraph *gr,const char *str,longpos=0) - Method on mglParse:
intParse (mglGraph *gr,const wchar_t *str,longpos=0) Main function in the class. It parses the string str and executes it by using gr as a graphics plotter. Returns the value depending on an error presence in the string str: 0 – no error, 1 – wrong command argument(s), 2 – unknown command, 3 – string is too long. Optional argument pos allows to save the string position in the document (or file) for using
for|nextcommand.
- Method on mglParse:
intExport (wchar_tcpp_out[1024],mglGraph *gr,const wchar_t *str) Function parses the string str, executes it by using gr as a graphics plotter and exports it to C++ code. Returns the value depending on an error presence in the string str: 0 – no error, 1 – wrong command argument(s), 2 – unknown command, 3 – string is too long. Output C++ text will be placed in out variable. If string str have options (defined after ';' symbol) then the corresponding C++ texts are placed in variables op1, op2.
- Method on mglParse:
voidExecute (mglGraph *gr,FILE *fp,boolprint=false) Function parse and execute line-by-line MGL script in file fp. If print=
truethen all warnings and information will be printed in stdout. Also this function support thefor|nextMGL commands.
- Method on mglParse:
voidExecute (mglGraph *gr,intnum,const wchar_t **text,void (*error)(int line, int kind)=NULL) Function parse and execute line-by-line MGL script in array text. If error is not
NULLthen this function will be called for all warnings, information and other messages. Also this function support thefor|nextMGL commands.
- Method on mglParse:
voidExecute (mglGraph *gr,const char *text,void (*error)(int line, int kind)=NULL) - Method on mglParse:
voidExecute (mglGraph *gr,const wchar_t *text,void (*error)(int line, int kind)=NULL) Function parse and execute line-by-line MGL script in string text. Lines are separated by ‘\n’ symbol as usual. If error is not
NULLthen this function will be called for all warnings, information and other messages. Also this function support thefor|nextMGL commands.
- Method on mglParse:
boolAddParam (intn,const char *str,boolisstr=true) - Method on mglParse:
boolAddParam (intn,const wchar_t *str,boolisstr=true) Function set the value of n-th parameter as string str (n=0, 1 ... 9). It return
truefor success.
- Method on mglParse:
mglVar *FindVar (const char *name) - Method on mglParse:
mglVar *FindVar (const wchar_t *name) Function returns the pointer to variable with name name or zero if variable is absent. Use this function to put external data array to the script or get the data from the script.
- Method on mglParse:
mglVar *AddVar (const char *name) - Method on mglParse:
mglVar *AddVar (const wchar_t *name) Function returns the pointer to variable with name name. If variable is absent then new variable is created with name name. Use this function to put external data array to the script or get the data from the script.
- Method on mglParse:
voidDeleteVar (mglVar *v) - Method on mglParse:
voidDeleteVar (const char *name) - Method on mglParse:
voidDeleteVar (const wchar_t *name) Function delete the variable specified by its name or by its pointer.
- Method on mglParse:
voidAddCommand (mglCommand *cmd,intnum=0) Add num commands cmd to the defined MGL commands list. Parameter cmd is array of
mglCommandstructures. If parameter num=0 then it will be determined automatically. At this, array cmd must have last element withname=L""
- Option of mglParse:
mglCommand *Cmd Table (array) of recognizable MGL commands (can be changed by user). Items in the table MUST be sorted by name field !!! Last items must have empty name (i.e.
L"").
- Option of mglParse:
wchar_t *op1 These strings contain command options and should be placed before the command. These variables are used for MGL->C++ (or other language) conversion.
- Option of mglParse:
wchar_t *op2 These strings contain command options and should be placed after the command. These variables are used for MGL->C++ (or other language) conversion.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
