Loading...
Searching...
No Matches
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. More...
Namespace | getNamespace ()
| Returns the namespace for the constant. More...
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. 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 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. More...
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. 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

  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