Qore supports the use of parse directives in order to set parsing options, load modules, control warnings, and include other files. Parse directives that set parsing options can be used any time parse options have not been locked on a Program object. They are used most often when it's not possible or desirable to set the parse options in the qore command-line.
Table 6.1. Parse Directives
Directive | Description |
---|---|
Turns off all warnings | |
| Disables the named warning until |
Turns on all warnings | |
| Enables the named warning. |
| Instantiates the named class as the application class. Also turns on |
| Starts parsing |
Prohibits further changes to parse options (equivalent to the | |
Prohibits further changes to the warning mask (equivalent to the | |
Disallows class definitions. Equivalent to | |
Allows child program objects to have parse option restrictions that are not a strict subset of the parents'. Equivalent to parse option | |
Disallows constant definitions. Equivalent to parse option | |
Disallows access to database functionality (for example the Datasource class. Equivalent to parse option | |
Disallows any access to external processes (see | |
Disallows access to the local filesystem. Equivalent to parse option | |
Disallows the use of global variables. Equivalent to parse option | |
Disallows functionality that draws graphics to the display. Equivalent to parse option | |
Disallows new namespace definitions. Equivalent to | |
Disallows access to the network. Equivalent to parse option | |
Disallows use of the new operator. Equivalent to parse option | |
Disallows access to functions that would affect the current process (see | |
Disallows subroutine (function) definitions. Equivalent to parse option | |
Disallows access to terminal I/O (see | |
Disallows access to thread classes (see | |
Disallows access to thread control operations (see | |
Disallows access to all thread control operations and thread classes (equivalent to | |
Disallows top level code. Equivalent to parse option | |
Requires global variables to be declared with our prior to use (like perl's | |
| If the named feature is not already present in Qore, then the |
%disable-all-warnings
none, warnings are disabled by default
n/a
Disables all warnings while parsing. See Warnings for more information.
%disable-warning
none, warnings are disabled by default
n/a
Disables the named warning while parsing. See Warnings for more information.
%enable-all-warnings
--enable-all-warnings, -W
n/a
Enables all warnings while parsing. See Warnings for more information.
%enable-warning
--enable-warning, -w
n/a
Enables the named warning while parsing. See Warnings for more information.
%exec-class
--exec-class, -x
n/a
Executes the named class as the application class and turns on no-top-level
as well.
%include
n/a from the command-line
n/a
Includes a file to be parsed. If the path is not absolute (i.e. starting with '/'), then files are searched first in the directory of the currently-executing script (if known), then in each path in the environment variable QORE_INCLUDE_DIR
.
%lock-options
--lock-options, -K
n/a
Prohibits further changes to parse options.
%lock-warnings
--lock-warnings, -A
PO_LOCK_WARNINGS
Prohibits further changes to the warning mask.
%no-child-restrictions
--no-child-restrictions, -I
PO_NO_CHILD_PO_RESTRICTIONS
Allows child program objects to have parse option restrictions that are not a strict subset of the parents'.
%no-class-defs
--no-class-defs
PO_NO_CLASS_DEFS
Disallows new class definitions. Any use of the reserved word class will result in a parse exception.
%no-constant-defs
--no-constant-defs
PO_NO_CONSTANT_DEFS
Disallows new constant definitions. Any use of the reserved word const will result in a parse exception.
%no-database
--no-database, -D
PO_NO_DATABASE
Disallows access to database functionality. Currently this means that access to the Datasource and DatasourcePool classes is restricted.
%no-external-process
--no-external-process, -E
PO_NO_EXTERNAL_PROCESS
Disallows any access to external processes.
Table 6.2. Unavailable Features with no-external-process
Feature/Function | Description |
---|---|
The backquote operator (``) is not available. | |
The system() function is not available. | |
The kill() function is not available. | |
The exec() function is not available. | |
The backquote() function is not available. |
%no-filesystem
--no-filesystem, -F
PO_NO_FILESYSTEM
Disallows any access to the external filesystem.
Table 6.3. Unavailable Features with no-filesystem
Feature/Function | Description |
---|---|
Dir class | The Dir class is not available. |
File class | The File class is not available. |
The chdir() function is not available. | |
The chmod() function is not available. | |
The chown() function is not available. | |
The glob() function is not available. | |
The hlstat() function is not available. | |
The hstat() function is not available. | |
The is_cdev() function is not available. | |
The is_bdev() function is not available. | |
The is_dev() function is not available. | |
The is_executable() function is not available. | |
The is_dir() function is not available. | |
The is_file() function is not available. | |
The is_pipe() function is not available. | |
The is_link() function is not available. | |
The is_readable() function is not available. | |
The is_socket() function is not available. | |
The is_writeable() function is not available. | |
The lstat() function is not available. | |
The mkdir() function is not available. | |
The mkfifo() function is not available. | |
The rmdir() function is not available. | |
The stat() function is not available. | |
The umask() function is not available. | |
The unlink() function is not available. |
%no-global-vars
--no-global-vars, -G
PO_NO_GLOBAL_VARS
Disallows the use of global variables.
%no-gui
--no-gui, --set-parse-option=no-gui, -pno-gui
PO_NO_GUI
Disallows the use of functionality that draws graphics to the display (this functionality is not implemented in the qore library; only implemented in modules).
%no-namespace-defs
--no-namespace-defs, -M
PO_NO_NAMESPACE_DEFS
Disallows new namespace definitions.
%no-network
--no-network, -Y
PO_NO_NETWORK
Disallows any access to the network.
Table 6.4. Unavailable Features with no-network
Feature/Function | Description |
---|---|
FtpClient class | The FtpClient class is not available. |
HTTPClient class | The HTTPClient class is not available. |
XmlRpcClient class | The XmlRpcClient class is not available. |
JsonRpcClient class | The JsonRpcClient class is not available. |
Socket class | The Socket class is not available. |
%no-new
--no-new, -N
PO_NO_NEW
Disallows use of the new operator.
%no-process-control
--no-process-control, -P
PO_NO_PROCESS_CONTROL
Disallows access to functions that would affect the current process.
Table 6.5. Unavailable Features with no-process-control
Feature/Function | Description |
---|---|
The abort() function is not available. | |
The fork() function is not available. | |
The exec() function is not available. | |
The exit() function is not available. | |
The remove_signal_handler() function is not available. | |
The set_signal_handler() function is not available. | |
The setegid() function is not available. | |
The seteuid() function is not available. | |
The setgid() function is not available. | |
The setuid() function is not available. | |
The sleep() function is not available. | |
The usleep() function is not available. |
%no-subroutine-defs
--no-subroutine-defs, -S
PO_NO_SUBROUTINE_DEFS
Disallows subroutine (function) definitions.
%no-terminal-io
--no-terminal-io, --set-parse-option=no-terminal-io, -pno-terminal-io
PO_NO_TERMINAL_IO
Disallows access to terminal input and output.
Table 6.6. Unavailable Features with no-terminal-io
Feature/Function | Description |
---|---|
The flush() function is not available. | |
The f_printf() function is not available. | |
The print() function is not available. | |
The printf() function is not available. | |
The vprintf() function is not available. | |
The stdin constant is not accessible. | |
The stdout constant is not accessible. | |
The stderr constant is not accessible. |
%no-thread-classes
--no-thread-classes
PO_NO_THREAD_CLASSES
Disallows access to thread classes.
Table 6.7. Unavailable Features with no-thread-classes
Feature/Function | Description |
---|---|
AutoGate class | The AutoGate class is not available. |
AutoLock class | The AutoLock class is not available. |
AutoReadLock class | The AutoReadLock class is not available. |
AutoWriteLock class | The AutoWriteLock class is not available. |
Condition class | The Condition class is not available. |
Counter class | The Counter class is not available. |
Mutex class | The Mutex class is not available. |
Queue class | The Queue class is not available. |
RWLock class | The RWLock class is not available. |
%no-thread-control
--no-thread-control, -R
PO_NO_THREAD_CONTROL
Disallows access to thread control operations.
Table 6.8. Unavailable Features with no-thread-control
Feature/Function | Description |
---|---|
background operator | The background operator is not available. |
thread_exit statement | The thread_exit statement is not available. |
The get_thread_data() function is not available. | |
The get_all_thread_data() function is not available. | |
The save_thread_data() function is not available. | |
The delete_thread_data() function is not available. | |
The delete_all_thread_data() function is not available. | |
The getAllThreadCallStacks() function is not available (this function is deprecated and will be removed from a future release). | |
The throwThreadResourceExceptions() function is not available. |
%no-threads
--no-threads, -T
PO_NO_THREADS
Disallows access to all thread control operations and thread classes (equivalent to no-thread-control
and no-thread-classes
together).
%no-top-level
--no-top-level, -L
PO_NO_TOP_LEVEL_STATEMENTS
Disallows top level code.
%require-our
--require-our, -O
PO_REQUIRE_OUR
Requires global variables to be declared with our prior to use (recommended to use for all larger scripts/programs).
%requires
--load, -l
n/a
Loads a Qore module immediately. The parse directive can be used to load a module during parsing, and the command-line version can be used to load a module before parsing.
From Qore 0.7.1, you can specify a comparison operator (one of < <=, =, >=, or >) and version information after the module name as well. Version numbers are compared via integer comparisons of each element, where elements are separated by a '.'. If one of the versions does not have as many elements as another, the missing elements are assumed to be '0' (i.e. version "1.0" compared with version "1.0.1" will be exteneded to "1.0.0").
For example:
%requires oracle >= 1.0.1
This will load the oracle module if it is at least version 1.0.1.
Note that there is one special feature name: "qore". This pseudo-feature can be used to check the minimum qore version; if this feature is requested with version information, then the Qore library's version information is used for the version number comparison.