Class for parsing and executing MGL script. This class is defined in #include <mgl2/mgl.h>
.
The main function of mglParse class is Execute()
. Exactly this function parses and executes the script string-by-string. Also there are subservient functions for the finding and creation of a variable (object derived from mglDataA
). These functions can be useful for displaying values of variables (arrays) in some external object (like, window) or for providing access to internal data. Function AllowSetSize()
allows one to prevent changing the size of the picture inside the script (forbids the MGL command setsize
).
mglParse
:
mglParse (bool
setsize=false
)
¶mglParse
:
mglParse (HMPR
pr)
¶mglParse
:
mglParse (mglParse &
pr)
¶HMPR
mgl_create_parser ()
¶Constructor initializes all values with zero and set AllowSetSize value.
mglParse
:
~mglParse ()
¶void
mgl_delete_parser (HMPR
p)
¶Destructor delete parser
mglParse
: HMPR
Self ()
¶Returns the pointer to internal object of type HMPR
.
mglParse
: void
Execute (mglGraph &
gr, const char *
text)
¶mglParse
: void
Execute (mglGraph &
gr, const wchar_t *
text)
¶void
mgl_parse_text (HMGL
gr, HMPR
p, const char *
text)
¶void
mgl_parse_textw (HMGL
gr, HMPR
p, const wchar_t *
text)
¶Main function in the class. Function parse and execute line-by-line MGL script in array text. Lines are separated by newline symbol ‘\n’ as usual.
mglParse
: void
Execute (mglGraph &
gr, FILE *
fp, bool
print=false
)
¶void
mgl_parse_file (HMGL
gr, HMPR
p, FILE *
fp, int
print)
¶The same as previous but read script from the file fp. If print=true
then all warnings and information will be printed in stdout.
mglParse
: int
Parse (mglGraph &
gr, const char *
str, long
pos=0
)
¶mglParse
: int
Parse (mglGraph &
gr, const wchar_t *
str, long
pos=0
)
¶int
mgl_parse_line (HMGL
gr, HMPR
p, const char *
str, int
pos)
¶int
mgl_parse_linew (HMGL
gr, HMPR
p, const wchar_t *
str, int
pos)
¶Function 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, 4 – strings is not closed. Optional argument pos allows one to save the string position in the document (or file) for using for|next
command.
mglParse
: mglData
Calc (const char *
formula)
¶mglParse
: mglData
Calc (const wchar_t *
formula)
¶HMDT
mgl_parser_calc (HMPR
p, const char *
formula)
¶HMDT
mgl_parser_calcw (HMPR
p, const wchar_t *
formula)
¶Function parses the string formula and return resulting data array. In difference to AddVar()
or FindVar()
, it is usual data array which should be deleted after usage.
mglParse
: mglDataC
CalcComplex (const char *
formula)
¶mglParse
: mglDataC
CalcComplex (const wchar_t *
formula)
¶HADT
mgl_parser_calc_complex (HMPR
p, const char *
formula)
¶HADT
mgl_parser_calc_complexw (HMPR
p, const wchar_t *
formula)
¶Function parses the string formula and return resulting data array with complex values. In difference to AddVar()
or FindVar()
, it is usual data array which should be deleted after usage.
mglParse
: void
AddParam (int
n, const char *
str)
¶mglParse
: void
AddParam (int
n, const wchar_t *
str)
¶void
mgl_parser_add_param (HMPR
p, int
id, const char *
val)
¶void
mgl_parser_add_paramw (HMPR
p, int
id, const wchar_t *
val)
¶Function set the value of n-th parameter as string str (n=0, 1 ... ’z’-’a’+10). String str shouldn’t contain ‘$’ symbol.
mglParse
: mglVar *
FindVar (const char *
name)
¶mglParse
: mglVar *
FindVar (const wchar_t *
name)
¶HMDT
mgl_parser_find_var (HMPR
p, const char *
name)
¶HMDT
mgl_parser_find_varw (HMPR
p, 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. You must not delete obtained data arrays!
mglParse
: mglVar *
AddVar (const char *
name)
¶mglParse
: mglVar *
AddVar (const wchar_t *
name)
¶HMDT
mgl_parser_add_var (HMPR
p, const char *
name)
¶HMDT
mgl_parser_add_varw (HMPR
p, 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. You must not delete obtained data arrays!
mglParse
: void
OpenHDF (const char *
fname)
¶void
mgl_parser_openhdf (HMPR
pr, const char *
fname)
¶Reads all data array from HDF5 file fname and create MGL variables with names of data names in HDF file. Complex variables will be created if data name starts with ‘!’.
mglParse
(C++): void
DeleteVar (const char *
name)
¶mglParse
(C++): void
DeleteVar (const wchar_t *
name)
¶void
mgl_parser_del_var (HMPR
p, const char *
name)
¶void
mgl_parser_del_varw (HMPR
p, const wchar_t *
name)
¶Function delete the variable with given name.
mglParse
(C++): void
DeleteAll ()
¶void
mgl_parser_del_all (HMPR
p)
¶Function delete all variables and reset list of commands to default one in this parser.
mglParse
: void
RestoreOnce ()
¶void
mgl_parser_restore_once (HMPR
p)
¶Restore Once flag.
mglParse
: void
AllowSetSize (bool
a)
¶void
mgl_parser_allow_setsize (HMPR
p, int
a)
¶allow one to parse setsize command or not.
mglParse
: void
AllowFileIO (bool
a)
¶void
mgl_parser_allow_file_io (HMPR
p, int
a)
¶Allow reading/saving files or not.
mglParse
: void
AllowDllCall (bool
a)
¶void
mgl_parser_allow_dll_call (HMPR
p, int
a)
¶allow one to parse load command or not.
mglParse
: void
Stop ()
¶void
mgl_parser_stop (HMPR
p)
¶Sends stop signal which terminate execution at next command.
mglParse
: void
SetVariant (int
var=0
)
¶void
mgl_parser_variant (HMPR
p, int
var)
¶Sets variant of argument(s) separated by ‘?’ symbol to be used in further commands.
mglParse
: void
StartID (int
id=0
)
¶void
mgl_parser_start_id (HMPR
p, int
id)
¶Sets id (like, line number) of first line in further script parsing.
mglParse
: long
GetCmdNum ()
¶long
mgl_parser_cmd_num (HMPR
p)
¶Return the number of registered MGL commands.
mglParse
: const char *
GetCmdName (long
id)
¶const char *
mgl_parser_cmd_name (HMPR
p, long
id)
¶Return the name of command with given id.
mglParse
: int
CmdType (const char *
name)
¶int
mgl_parser_cmd_type (HMPR
p, const char *
name)
¶Return the type of MGL command name. Type of commands are: 0 – not the command, 1 - data plot, 2 - other plot, 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program, 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot, 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform.
mglParse
: const char *
CmdFormat (const char *
name)
¶const char *
mgl_parser_cmd_frmt (HMPR
p, const char *
name)
¶Return the format of arguments for MGL command name.
mglParse
: const char *
CmdDesc (const char *
name)
¶const char *
mgl_parser_cmd_desc (HMPR
p, const char *
name)
¶Return the description of MGL command name.
mglParse
: void
RK_Step (const char *
eqs, const char *
vars, mreal
dt=1
)
¶mglParse
: void
RK_Step (const wchar_t *
eqs, const wchar_t *
vars, mreal
dt=1
)
¶void
mgl_rk_step (HMPR
p, const char *
eqs, const char *
vars, mreal
dt)
¶void
mgl_rk_step_w (HMPR
p, const wchar_t *
eqs, const wchar_t *
vars, mreal
dt)
¶Make one step for ordinary differential equation(s) {var1’ = eq1, ... } with time-step dt. Here strings eqs and vars contain the equations and variable names separated by symbol ‘;’. The variable(s) ‘var1’, ... are the ones, defined in MGL script previously. The Runge-Kutta 4-th order method is used.