| Qore Programming Language Reference Manual 2.2.0

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Qore::ProgramControl Class Reference

The ProgramControl class provides safe information about a Qore program. More...

`#include <QC_ProgramControl.dox.h>`

## Public Member Functions
nothing | assignBreakpoint (Breakpoint bkpt)
| Assign Breakpoint instance to Program. If breakpoint has been assigned to an program then is unassigned in the first step.
| constructor ()
| Throws an exception to prevent objects of this class being created from script.
| copy ()
| Throws an exception to prevent objects of this class from being copied.
nothing | deleteAllBreakpoints ()
| delete all breakpoints from instance
| destructor ()
| Dereferences the internal Program object and deletes the Qore object.
bool | existsFunction (string name)
| Checks if a user function exists in the program object.
int | findFunctionStatementId (string function, *list params)
| Find the first statement for function entry point.
list< hash< auto > > | findFunctionVariants (string function)
| finds all variants of a function or class method and returns a list of the results
int | findStatementId (string file, int line)
| Find statement related to position in file.
*hash< auto > | getAllDefines ()
| Retrieves all parse defines in the current Program.
list< Breakpoint > | getBreakpoints ()
| get list of breakpoint assigned to program.
auto | getDefine (string def)
| Retrieves the value of the given parse define in the current Program.
auto | getGlobalVariable (string varname, *reference< bool > rexists)
| Returns a the value of the global variable identified by the first string argument.
hash< auto > | getGlobalVars ()
| returns a hash of global variables
int | getParseOptions ()
| Returns the current binary-or'ed parse option mask for the Program object.
int | getProgramId ()
| Get program id.
*string | getScriptDir ()
| Returns the current script directory as a string or NOTHING if not set.
*string | getScriptName ()
| Returns the current script name as a string or NOTHING if not set.
*string | getScriptPath ()
| Returns the current script directory and filename if known, otherwise returns NOTHING.
hash< string, hash< string, int > > | getSourceFileNames ()
| Returns a list of file names registered to a statement when parsing source code.
hash< string, hash< string, int > > | getSourceLabels ()
| Get list of label names which has been registered to a statement when parsing source code.
hash< StatementInfo > | getStatementIdInfo (int statementId, bool listBreakpoints=False)
| get information related to statement id
list< int > | getThreadList ()
| returns a list of thread IDs active in this Program
TimeZone | getTimeZone ()
| Returns the default local time zone for the object.
bool | isDefined (string def)
| Returns True if the given parse define is defined in the current Program (does not have to have a value defined to return True), False if not.
nothing | setGlobalVarValue (string name, auto value)
| set the value of a global variable

## Static Public Member Functions
static list< ProgramControl > | getAllPrograms ()
| Get instance of all programs.
static ProgramControl | getProgram ()
| Get control for instance of current program.
static ProgramControl | resolveProgramId (int programId)
| Get instance of program id.

## Detailed Description

The ProgramControl class provides safe information about a Qore program.

Restrictions:
  MUST HAVE: Qore::PO_ALLOW_DEBUGGER

The object is never instantiated in script but returned by a API function. The class provides only safe data non breaking security model.

See also
  Program

Since
  Qore 0.8.13

## Member Function Documentation

## ◆ constructor()

Qore::ProgramControl::constructor | ( |  | ) |

Throws an exception to prevent objects of this class being created from script.

Exceptions

  PROGRAM-CREATE-ERROR | copying ProgramControl objects is currently unsupported

## ◆ copy()

Qore::ProgramControl::copy | ( |  | ) |

Throws an exception to prevent objects of this class from being copied.

Exceptions

  PROGRAM-COPY-ERROR | copying Program objects is currently unsupported

## ◆ existsFunction()

bool Qore::ProgramControl::existsFunction | ( | string | name | ) |

Checks if a user function exists in the program object.

Code Flags:
  RET_VALUE_ONLY

see Qore::Program::existsFunction "Program::existsFunction()"

## ◆ findFunctionStatementId()

int Qore::ProgramControl::findFunctionStatementId | ( | string | function,
|  | *list | params )

Find the first statement for function entry point.

Parameters

  function | name
  params | param types to resolve particular variant

See also
  ProgramControl::findStatementId()

## ◆ findFunctionVariants()

list< hash< auto > > Qore::ProgramControl::findFunctionVariants | ( | string | function | ) |

finds all variants of a function or class method and returns a list of the results

Parameters

  function | the function or class method name; may also be namespace-justified

Returns
  a list of hashes or nothing if the name cannot be resolved; when matched, each hash element has the following keys:
  - `desc:` a string description of the call which includes the name and the full text call signature
  - `params:` a list object that gives the params in a format that can be used by findFunctionStatementId

## ◆ findStatementId()

int Qore::ProgramControl::findStatementId | ( | string | file,
|  | int | line )

Find statement related to position in file.

Parameters

  file | name where is looking for. Searching is done in three steps, in the first one is looking for full name match, in the second is looking for label full match (if exists) and in the third for end suffix match. File can by empty if program contains only one file. Beware of label formating, see Qore::Program::parse
  line | to find statement. In case of multiple statements of line the first one is found

See also
  ProgramControl::findFunctionStatementId()

## ◆ getAllDefines()

*hash< auto > Qore::ProgramControl::getAllDefines | ( |  | ) |

Retrieves all parse defines in the current Program.

see Qore::Program::getAllDefines "Program::getAllDefines()"

## ◆ getAllPrograms()

static list< ProgramControl > Qore::ProgramControl::getAllPrograms | ( |  | ) |
| static

Get instance of all programs.

Restrictions:
  MUST HAVE: Qore::PO_ALLOW_DEBUGGER

Code Flags:
  RET_VALUE_ONLY

Use ProgramControl::resolveProgramId() to get instance

## ◆ getDefine()

auto Qore::ProgramControl::getDefine | ( | string | def | ) |

Retrieves the value of the given parse define in the current Program.

see Qore::Program::getDefine "Program::getDefine()"

## ◆ getGlobalVariable()

auto Qore::ProgramControl::getGlobalVariable | ( | string | varname,
|  | *reference< bool > | rexists )

Returns a the value of the global variable identified by the first string argument.

see Qore::Program::getGlobalVariable "Program::getGlobalVariable()"

## ◆ getGlobalVars()

hash< auto > Qore::ProgramControl::getGlobalVars | ( |  | ) |

returns a hash of global variables

Code Flags:
  CONSTANT

see Qore::Program::getGlobalVars "Program::getGlobalVars()"

## ◆ getParseOptions()

int Qore::ProgramControl::getParseOptions | ( |  | ) |

Returns the current binary-or'ed parse option mask for the Program object.

see Qore::Program::getParseOptions "Program::getParseOptions()"

## ◆ getProgram()

static ProgramControl Qore::ProgramControl::getProgram | ( |  | ) |
| static

Get control for instance of current program.

Restrictions:
  MUST HAVE: Qore::PO_ALLOW_DEBUGGER

Code Flags:
  RET_VALUE_ONLY

## ◆ getProgramId()

int Qore::ProgramControl::getProgramId | ( |  | ) |

Get program id.

Code Flags:
  RET_VALUE_ONLY

see Qore::Program::getProgramId "Program::getProgramId()"

## ◆ getScriptDir()

*string Qore::ProgramControl::getScriptDir | ( |  | ) |

Returns the current script directory as a string or NOTHING if not set.

see Qore::Program::getScriptDir "Program::getScriptDir()"

## ◆ getScriptName()

*string Qore::ProgramControl::getScriptName | ( |  | ) |

Returns the current script name as a string or NOTHING if not set.

see Qore::Program::getScriptPath "Program::getScriptPath()"

## ◆ getScriptPath()

*string Qore::ProgramControl::getScriptPath | ( |  | ) |

Returns the current script directory and filename if known, otherwise returns NOTHING.

see Qore::Program::getScriptPath "Program::getScriptPath()"

## ◆ getSourceFileNames()

hash< string, hash< string, int > > Qore::ProgramControl::getSourceFileNames | ( |  | ) |

Returns a list of file names registered to a statement when parsing source code.

See also
  ProgramControl::getSourceLabels()

Returns
  a hash where keys are file names and the value is hash of labels, in this hash, the keys are label names and values are the label's section offset in the file.

Since
  Qore 0.8.13.3

## ◆ getSourceLabels()

hash< string, hash< string, int > > Qore::ProgramControl::getSourceLabels | ( |  | ) |

Get list of label names which has been registered to a statement when parsing source code.

See also
  ProgramControl::getSourceFileNames()

Returns
  a hash where keys are file names and the value is hash of labels, in this hash, the keys are label names and values are the label's section offset in the file.

Since
  Qore 0.8.13.3

## ◆ getStatementIdInfo()

hash< StatementInfo > Qore::ProgramControl::getStatementIdInfo | ( | int | statementId,
|  | bool | listBreakpoints = False )

get information related to statement id

Parameters

  statementId |
  listBreakpoints | list also breakpoints assigned to statement, no effect if %no-debugging (since 0.9)

Returns
  a hash of statement info

See also
  ProgramControl::findStatementId() ProgramControl::findFunctionStatementId()

## ◆ getThreadList()

list< int > Qore::ProgramControl::getThreadList | ( |  | ) |

returns a list of thread IDs active in this Program

Code Flags:
  CONSTANT

see Qore::Program::getThreadList "Program::getThreadList()"

## ◆ getTimeZone()

TimeZone Qore::ProgramControl::getTimeZone | ( |  | ) |

Returns the default local time zone for the object.

see Qore::Program::getTimeZone "Program::getTimeZone()"

## ◆ isDefined()

bool Qore::ProgramControl::isDefined | ( | string | def | ) |

Returns True if the given parse define is defined in the current Program (does not have to have a value defined to return True), False if not.

see Qore::Program::isDefined "Program::isDefined()"

## ◆ resolveProgramId()

static ProgramControl Qore::ProgramControl::resolveProgramId | ( | int | programId | ) |
| static

Get instance of program id.

Restrictions:
  MUST HAVE: Qore::PO_ALLOW_DEBUGGER

See also
  ProgramControl::resolveProgramId()

Exceptions

  PROGRAM-ERROR | if the programId cannot identify ProgramControl instance

## ◆ setGlobalVarValue()

nothing Qore::ProgramControl::setGlobalVarValue | ( | string | name,
|  | auto | value )

set the value of a global variable

see Qore::Program::setGlobalVars "Program::setGlobalVars()"