| Qore reflection Module 1.14.0

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

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

`#include <QC_Constant.dox.h>`

Inheritance diagram for Qore::Reflection::Constant:

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

## Static Public Member Functions
static list< Constant > | findAllRegex (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.
static list< Constant > | findAllRegex (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.
static Constant | forName (string path)
| Returns a Constant object from the constant name or namespace-justified path as a string.
static Constant | forName (Program pgm, string path)
| Returns a Constant object from the constant name or namespace-justified path as a string.

## 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

  path | the constant name or namespace-justified path as a string

Exceptions

  UNKNOWN-CONSTANT | cannot find a constant with the given name or path
  ENCODING-CONVERSION-ERROR | this 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

  pgm | the Program object to search
  pattern | the regular expression pattern to match
  re_opts | see Regular Expression 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

  pattern | the regular expression pattern to match
  re_opts | see Regular Expression 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

  pgm | the Program object to search
  path | the 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-CONSTANT | cannot find a constant with the given name or path
  ENCODING-CONVERSION-ERROR | this 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

  path | the 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-CONSTANT | cannot find a constant with the given name or path
  ENCODING-CONVERSION-ERROR | this 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:

- modules/reflection/src/QC_Constant.dox.h