Qore reflection Module  1.8.0
Qore::Reflection::Constant Class Reference

This class provides information about Qore constants defined in Qore namespaces. More...

Inheritance diagram for Qore::Reflection::Constant:
Qore::Reflection::AbstractConstant

Public Member Methods

 constructor (string path)
 Creates the object from the constant name or namespace-justified path as a string. More...
 
Namespace getNamespace ()
 Returns the namespace for the constant. More...
 
- Public Member Methods inherited from Qore::Reflection::AbstractConstant
 constructor ()
 Throws an exception; this class cannot be created directly or used in a user class hierarchy. More...
 
list< string > getModifierList ()
 returns a list of strings of modifiers describing the constant More...
 
int getModifiers ()
 returns a bitfield of modifiers describing the constant More...
 
*string getModuleName ()
 Returns the module name providing the constant or nothing if the constant was not provided by a module. More...
 
string getName ()
 returns the constant's name More...
 
hash< SourceLocationInfo > getSourceLocation ()
 Returns the source location of the contant declaration. More...
 
Type getType ()
 Returns the type object for this constant. More...
 
auto getValue ()
 Returns the value of the constant. More...
 
bool isBuiltin ()
 returns True if the constant is builtin More...
 
bool isClassConstant ()
 returns True if the constant is a class constant More...
 
bool isEqual (AbstractConstant con)
 Returns True if the AbstractConstant object passed as an argument is equal to the current object; False if not. More...
 
bool isUser ()
 returns True if the constant is a user constant More...
 

Static Public Member Methods

static list< ConstantfindAllRegex (string pattern, *int re_opts)
 Returns a list of constants matching the regular expression pattern argument or an empty list if no namespace constants match. More...
 
static list< ConstantfindAllRegex (Program pgm, string pattern, *int re_opts)
 Returns a list of constants matching the regular expression pattern argument or an empty list if no namespace constants match. More...
 
static Constant forName (string path)
 Returns a Constant object from the constant name or namespace-justified path as a string. More...
 
static Constant forName (Program pgm, string path)
 Returns a Constant object from the constant name or namespace-justified path as a string. More...
 

Detailed Description

This class provides information about Qore constants defined in Qore namespaces.

Restrictions:
Qore::PO_NO_REFLECTION
See also
ClassConstant
Since
Qore 0.9.0

Member Function Documentation

◆ constructor()

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

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

Example:
Constant con("::ARGV");
Parameters
paththe constant name or namespace-justified path as a string
Exceptions
UNKNOWN-CONSTANTcannot find a constant 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
Note
searches namespace constants only; does not search class constants
See also
forName()

◆ findAllRegex() [1/2]

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

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

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible constants that start with the letter "T"
list<Constant> l = Constant::findAllRegex(pgm, "^T");
Parameters
pgmthe Program object to search
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of constants matching the regular expression pattern argument or an empty list if no constants match
Note
searches namespace constants only; does not search class constants

◆ findAllRegex() [2/2]

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

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

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible constants that start with the letter "T"
list<Constant> l = Constant::findAllRegex("^T");
Parameters
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of constants matching the regular expression pattern argument or an empty list if no constants match
Note
searches namespace constants only; does not search class constants

◆ forName() [1/2]

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

Returns a Constant object from the constant name or namespace-justified path as a string.

Code Flags:
RET_VALUE_ONLY
Example:
Constant con = Constant::forName(pgm, "Option::HAVE_FORK");
Parameters
pgmthe Program object to search
paththe constant name or namespace-justified path as a string
Returns
a constant object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-CONSTANTcannot find a constant 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
Note
searches namespace constants only; does not search class constants

◆ forName() [2/2]

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

Returns a Constant object from the constant name or namespace-justified path as a string.

Code Flags:
RET_VALUE_ONLY
Example:
Constant con = Constant::forName("Option::HAVE_FORK");
Parameters
paththe constant name or namespace-justified path as a string
Returns
a constant object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-CONSTANTcannot find a constant 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
Note
searches namespace constants only; does not search class constants

◆ getNamespace()

Namespace Qore::Reflection::Constant::getNamespace ( )

Returns the namespace for the constant.

Code Flags:
CONSTANT
Example:
Namespace ns = con.getNamespace();
Returns
the namespace for the constant

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