| [ < ] | [ > ] | [ << ] | [ 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 language). 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(C++, Python):mglParse (boolsetsize=false) - C function:
HMPRmgl_create_parser () Constructor initializes all values with zero and set AllowSetSize value.
- Method on
mglParse(C++, Python):~mglParse () - C function:
voidmgl_delete_parser (HMPRp) Destructor delete parser
- Method on
mglParse(C++, Python):intParse (mglGraph *gr,const char *str,longpos=0) - Method on
mglParse(C++):intParse (mglGraph *gr,const wchar_t *str,longpos=0) - C function:
intmgl_parse (HMGLgr,HMPRp,const char *str,intpos) - C function:
intmgl_parsew (HMGLgr,HMPRp,const wchar_t *str,intpos) 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(C++):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(C++):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(C++):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(C++, Python):voidExecute (mglGraph *gr,const char *text,void (*error)(int line, int kind)=NULL) - Method on
mglParse(C++):voidExecute (mglGraph *gr,const wchar_t *text,void (*error)(int line, int kind)=NULL) - C function:
voidmgl_parse_text (HMGLgr,HMPRp,const char *text) - C function:
voidmgl_parsew_text (HMGLgr,HMPRp,const wchar_t *text) 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(C++, Python):boolAddParam (intn,const char *str,boolisstr=true) - Method on
mglParse(C++):boolAddParam (intn,const wchar_t *str,boolisstr=true) - C function:
voidmgl_add_param (HMPRp,intid,const char *val) - C function:
voidmgl_add_paramw (HMPRp,intid,const wchar_t *val) Function set the value of n-th parameter as string str (n=0, 1 ... 9). It return
truefor success.
- Method on
mglParse(C++, Python):mglVar *FindVar (const char *name) - Method on
mglParse(C++):mglVar *FindVar (const wchar_t *name) - C function:
const HMDTmgl_find_var (HMPRp,const char *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(C++, Python):mglVar *AddVar (const char *name) - Method on
mglParse(C++):mglVar *AddVar (const wchar_t *name) - C function:
const HMDTmgl_add_var (HMPRp,const char *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(C++):voidDeleteVar (mglVar *v) - Method on
mglParse(C++):voidDeleteVar (const char *name) - Method on
mglParse(C++):voidDeleteVar (const wchar_t *name) Function delete the variable specified by its name or by its pointer.
- Method on
mglParse(C++, Python):inline voidRestoreOnce () - C function:
voidmgl_restore_once (HMPRp) Restore Once flag.
- Method on
mglParse(Python):voidAllowSetSize (boola) - C function:
voidmgl_parser_allow_setsize (HMPRp,inta) Allow to parse ’setsize’ command or not.
- Method on
mglParse(C++):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] | [ ? ] |
