Qore reflection Module  1.12.0
Qore::Reflection::GlobalVar Class Reference

The abstract base class for Qore global variables. More...

Public Member Methods

 constructor (string path)
 Creates the object from the global variable name or namespace-justified path as a string. More...
 
string getName ()
 returns the global variable name More...
 
Namespace getNamespace ()
 Returns the namespace for the global variable. More...
 
hash< SourceLocationInfo > getSourceLocation ()
 Returns the source location of the global variable declaration. More...
 
Type getType ()
 Returns the type object for this global variable. More...
 
auto getValue ()
 Returns the value of the global variable. More...
 
bool isBuiltin ()
 returns True if the global variable is a builtin global variable More...
 
bool isEqual (GlobalVar var)
 Returns True if the global variable passed as an argument is equal to the current object; False if not. More...
 
bool isModulePublic ()
 returns True if the global variable has the module public flag set More...
 
bool isUser ()
 returns True if the global variable is a user global variable More...
 
nothing setValue (auto val)
 Sets the value of the global variable. More...
 

Static Public Member Methods

static list< GlobalVarfindAllRegex (string pattern, *int re_opts)
 Returns a list of global variables matching the regular expression pattern argument or an empty list if no global variables match. More...
 
static list< GlobalVarfindAllRegex (Program pgm, string pattern, *int re_opts)
 Returns a list of global variables matching the regular expression pattern argument or an empty list if no global variables match. More...
 
static GlobalVar forName (string path)
 Returns a global variable object corresponding to the name or namespace-justified path provided as an argument. More...
 
static GlobalVar forName (Program pgm, string path)
 Returns a global variable object corresponding to the name or namespace-justified path provided as an argument. More...
 

Detailed Description

The abstract base class for Qore global variables.

Restrictions:
Qore::PO_NO_REFLECTION
Since
Qore 0.9.0

Member Function Documentation

◆ constructor()

Qore::Reflection::GlobalVar::constructor ( string  path)

Creates the object from the global variable name or namespace-justified path as a string.

Example:
GlobalVar var("::ARGV");
Parameters
paththe global variable name or namespace-justified path as a string
Exceptions
UNKNOWN-GLOBAL-VARcannot find a global variable with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion
See also
forName()

◆ findAllRegex() [1/2]

static list<GlobalVar> Qore::Reflection::GlobalVar::findAllRegex ( Program  pgm,
string  pattern,
*int  re_opts 
)
static

Returns a list of global variables matching the regular expression pattern argument or an empty list if no global variables match.

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible global variables that start with the letter "E"
list<GlobalVar> l = GlobalVar::findAllRegex(pgm, "^E");
Parameters
pgmthe Program object to search
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of global variables matching the regular expression pattern argument or an empty list if no global variables match

◆ findAllRegex() [2/2]

static list<GlobalVar> Qore::Reflection::GlobalVar::findAllRegex ( string  pattern,
*int  re_opts 
)
static

Returns a list of global variables matching the regular expression pattern argument or an empty list if no global variables match.

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible global variables that start with the letter "E"
list<GlobalVar> l = GlobalVar::findAllRegex("^E");
Parameters
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of global variables matching the regular expression pattern argument or an empty list if no global variables match

◆ forName() [1/2]

static GlobalVar Qore::Reflection::GlobalVar::forName ( Program  pgm,
string  path 
)
static

Returns a global variable object corresponding to the name or namespace-justified path provided as an argument.

Code Flags:
RET_VALUE_ONLY
Example:
GlobalVar var = GlobalVar::forName(pgm, "::ENV");
Parameters
pgmthe Program object to search
paththe global variable name or namespace-justified path as a string
Returns
a global variable object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-GLOBAL-VARcannot find a global variable with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default characterencoding" and an error occurs during encoding conversion

◆ forName() [2/2]

static GlobalVar Qore::Reflection::GlobalVar::forName ( string  path)
static

Returns a global variable object corresponding to the name or namespace-justified path provided as an argument.

Code Flags:
RET_VALUE_ONLY
Example:
GlobalVar var = GlobalVar::forName("::ENV");
Parameters
paththe global variable name or namespace-justified path as a string
Returns
a global variable object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-GLOBAL-VARcannot find a global variable with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default characterencoding" and an error occurs during encoding conversion

◆ getName()

string Qore::Reflection::GlobalVar::getName ( )

returns the global variable name

Code Flags:
RET_VALUE_ONLY
Example:
string name = var.getName();
Returns
the global variable name
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed

◆ getNamespace()

Namespace Qore::Reflection::GlobalVar::getNamespace ( )

Returns the namespace for the global variable.

Code Flags:
CONSTANT
Example:
Namespace ns = var.getNamespace();
Returns
the namespace for the global variable

◆ getSourceLocation()

hash<SourceLocationInfo> Qore::Reflection::GlobalVar::getSourceLocation ( )

Returns the source location of the global variable declaration.

Code Flags:
RET_VALUE_ONLY
Example:
hash<SourceLocationInfo> loc = var.getSourceLocation();
Returns
the source location of the global variable declaration
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed

◆ getType()

Type Qore::Reflection::GlobalVar::getType ( )

Returns the type object for this global variable.

Code Flags:
RET_VALUE_ONLY
Example:
Type t = var.getType();
Returns
the type object for this global variable
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed

◆ getValue()

auto Qore::Reflection::GlobalVar::getValue ( )

Returns the value of the global variable.

Code Flags:
RET_VALUE_ONLY
Example:
auto val = var.getValue();
Returns
the value of the global variable
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed

◆ isBuiltin()

bool Qore::Reflection::GlobalVar::isBuiltin ( )

returns True if the global variable is a builtin global variable

Code Flags:
RET_VALUE_ONLY
Example:
bool b = var.isBuiltin();
Returns
True if the global variable is a builtin global variable
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed
Note
complementary to isUser()

◆ isEqual()

bool Qore::Reflection::GlobalVar::isEqual ( GlobalVar  var)

Returns True if the global variable passed as an argument is equal to the current object; False if not.

Code Flags:
CONSTANT
Example:
bool b = var1.isEqual(var2);
Parameters
varthe global variable to check with the current object for equality
Returns
True if the object passed as an argument is equal to the current object; False if not
Note
if this method is called on user global variables created from the same source code but in different Program containers, it will return False

◆ isModulePublic()

bool Qore::Reflection::GlobalVar::isModulePublic ( )

returns True if the global variable has the module public flag set

Code Flags:
RET_VALUE_ONLY
Example:
bool b = var.isModulePublic();
Returns
True if the global variable has the module public flag set
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed

◆ isUser()

bool Qore::Reflection::GlobalVar::isUser ( )

returns True if the global variable is a user global variable

Code Flags:
RET_VALUE_ONLY
Example:
bool b = var.isUser();
Returns
True if the global variable is a user global variable
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed
Note
complementary to isBuiltin()

◆ setValue()

nothing Qore::Reflection::GlobalVar::setValue ( auto  val)

Sets the value of the global variable.

Example:
var.setValue(val);
Parameters
valthe new value of the global variable
Exceptions
PROGRAM-ERRORthrown if the Program object holding the global variable has been destroyed
RUNTIME-TYPE-ERRORvalue type is not compatible with the global variable's type

The documentation for this class was generated from the following file: