| Qore reflection Module 1.14.0

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

The base class for Qore typed hashes (hashdecls) More...

`#include <QC_TypedHash.dox.h>`

## Public Member Functions
| constructor (string path)
| Creates the object from the typed hash (hashdecl) name or namespace-justified path as a string.
hash< auto > | doCast (hash< auto > h)
| Returns a typed hash for the given hash, if possible.
TypedHashMember | getMember (string name)
| returns the requested member or throws an exception if the member is not defined in the typed hash (hashdecl)
list< TypedHashMember > | getMembers ()
| returns a list of all declared typed hash (hashdecl) members in declaration order
*string | getModuleName ()
| Returns the module name providing the typed hash or NOTHING if the typed hash was not provided by a module.
string | getName ()
| returns the typed hash (hashdecl) name
Namespace | getNamespace ()
| Returns the namespace for the typed hash.
Type | getOrNothingType ()
| Returns the "or nothing" type object for this typed hash.
string | getPathName ()
| returns the typed hash's (hashdecl's) full namespace-justified path name
hash< SourceLocationInfo > | getSourceLocation ()
| Returns the source location of the typed hash (hashdecl) declaration.
Type | getType ()
| Returns the type object for this typed hash.
bool | isBuiltin ()
| returns True if the typed hash (hashdecl) is a builtin typed hash
bool | isEqual (TypedHash th)
| Returns True if the typed hash passed as an argument is equal to the current object; False if not.
bool | isUser ()
| returns True if the typed hash (hashdecl) is a user typed hash

## Static Public Member Functions
static list< TypedHash > | findAllRegex (string pattern, *int re_opts)
| Returns a list of typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match.
static list< TypedHash > | findAllRegex (Program pgm, string pattern, *int re_opts)
| Returns a list of typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match.
static TypedHash | forName (string path)
| Returns a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument.
static TypedHash | forName (Program pgm, string path)
| Returns a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument.

## Detailed Description

The base class for Qore typed hashes (hashdecls)

Restrictions:
  Qore::PO_NO_REFLECTION

Since
  Qore 0.9.0

## Member Function Documentation

## ◆ constructor()

Qore::Reflection::TypedHash::constructor | ( | string | path | ) |

Creates the object from the typed hash (hashdecl) name or namespace-justified path as a string.

Example:
  TypedHash th("::ARGV");

Parameters

  path | the typed hash (hashdecl) name or namespace-justified path as a string

Exceptions

  UNKNOWN-TYPED-HASH | cannot find a typed hash (hashdecl) 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

See also
  forName()

## ◆ doCast()

hash< auto > Qore::Reflection::TypedHash::doCast | ( | hash< auto > | h | ) |

Returns a typed hash for the given hash, if possible.

Parameters

  h | the hash to convert

Exceptions

  RUNTIME-TYPE-ERROR | types are not compatible

Since
  Qore 0.9.5

## ◆ findAllRegex() [1/2]

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

Returns a list of typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match.

Code Flags:
  RET_VALUE_ONLY

Example:
  # return all accessible typed hashes (hashdecls) that start with the letter "S"
  list<TypedHash> l = TypedHash::findAllRegex(pgm, "^S");

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 typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match

## ◆ findAllRegex() [2/2]

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

Returns a list of typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match.

Code Flags:
  RET_VALUE_ONLY

Example:
  # return all accessible typed hashes (hashdecls) that start with the letter "S"
  list<TypedHash> l = TypedHash::findAllRegex("^S");

Parameters

  pattern | the regular expression pattern to match
  re_opts | see Regular Expression Constants for possible values

Returns
  a list of typed hashes (hashdecls) matching the regular expression pattern argument or an empty list if no typed hashes match

## ◆ forName() [1/2]

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

Returns a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument.

Code Flags:
  RET_VALUE_ONLY

Example:
  TypedHash th = TypedHash::forName(pgm, "::ENV");

Parameters

  pgm | the Program object to search
  path | the typed hash (hashdecl) name or namespace-justified path as a string

Returns
  a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument

Exceptions

  UNKNOWN-TYPED-HASH | cannot find a typed hash (hashdecl) 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

## ◆ forName() [2/2]

static TypedHash Qore::Reflection::TypedHash::forName | ( | string | path | ) |
| static

Returns a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument.

Code Flags:
  RET_VALUE_ONLY

Example:
  TypedHash th = TypedHash::forName("::ENV");

Parameters

  path | the typed hash (hashdecl) name or namespace-justified path as a string

Returns
  a typed hash (hashdecl) object corresponding to the name or namespace-justified path provided as an argument

Exceptions

  UNKNOWN-TYPED-HASH | cannot find a typed hash (hashdecl) 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

## ◆ getMember()

TypedHashMember Qore::Reflection::TypedHash::getMember | ( | string | name | ) |

returns the requested member or throws an exception if the member is not defined in the typed hash (hashdecl)

Code Flags:
  RET_VALUE_ONLY

Example:
  TypedHashMember m = th.getMember(name);

Returns
  the requested member or throws an exception if the member is not defined in the typed hash (hashdecl)

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed
  UNKNOWN-MEMBER | if the requested member is not defined in the typed hash (hashdecl)
  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

## ◆ getMembers()

list< TypedHashMember > Qore::Reflection::TypedHash::getMembers | ( |  | ) |

returns a list of all declared typed hash (hashdecl) members in declaration order

Code Flags:
  RET_VALUE_ONLY

Example:
  list<TypedHashMember> l = th.getMembers();

Returns
  a list of all declared typed hash (hashdecl) members in declaration order

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## ◆ getModuleName()

*string Qore::Reflection::TypedHash::getModuleName | ( |  | ) |

Returns the module name providing the typed hash or NOTHING if the typed hash was not provided by a module.

Code Flags:
  RET_VALUE_ONLY

Example:
  *string str = th.getModuleName();

Returns
  the module name providing the typed hash or NOTHING if the typed hash was not provided by a module

## ◆ getName()

string Qore::Reflection::TypedHash::getName | ( |  | ) |

returns the typed hash (hashdecl) name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = th.getName();

Returns
  the typed hash (hashdecl) name

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

See also
  getPathName()

## ◆ getNamespace()

Namespace Qore::Reflection::TypedHash::getNamespace | ( |  | ) |

Returns the namespace for the typed hash.

Code Flags:
  CONSTANT

Example:
  Namespace ns = th.getNamespace();

Returns
  the namespace for the typed hash

## ◆ getOrNothingType()

Type Qore::Reflection::TypedHash::getOrNothingType | ( |  | ) |

Returns the "or nothing" type object for this typed hash.

Code Flags:
  RET_VALUE_ONLY

Example:
  Type t = th.getOrNothingType();

Returns
  the "or nothing" type object for this typed hash

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash has been destroyed

See also
  getType()

## ◆ getPathName()

string Qore::Reflection::TypedHash::getPathName | ( |  | ) |

returns the typed hash's (hashdecl's) full namespace-justified path name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = th.getPathName();

Returns
  the typed hash's (hashdecl's) full namespace-justified path name

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

See also
  getName()

## ◆ getSourceLocation()

hash< SourceLocationInfo > Qore::Reflection::TypedHash::getSourceLocation | ( |  | ) |

Returns the source location of the typed hash (hashdecl) declaration.

Code Flags:
  RET_VALUE_ONLY

Example:
  hash<SourceLocationInfo> loc = th.getSourceLocation();

Returns
  the source location of the typed hash (hashdecl) declaration

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

## ◆ getType()

Type Qore::Reflection::TypedHash::getType | ( |  | ) |

Returns the type object for this typed hash.

Code Flags:
  RET_VALUE_ONLY

Example:
  Type t = th.getType();

Returns
  the type object for this typed hash

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

See also
  getOrNothingType()

## ◆ isBuiltin()

bool Qore::Reflection::TypedHash::isBuiltin | ( |  | ) |

returns True if the typed hash (hashdecl) is a builtin typed hash

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = th.isBuiltin();

Returns
  True if the typed hash (hashdecl) is a builtin typed hash

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

Note
  complementary to isUser()

## ◆ isEqual()

bool Qore::Reflection::TypedHash::isEqual | ( | TypedHash | th | ) |

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

Code Flags:
  CONSTANT

Example:
  bool b = th1.isEqual(th2);

Parameters

  th | the typed hash (hashdecl) 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 typed hashes (hashdecls) created from the same source code but in different Program containers, it will return False

## ◆ isUser()

bool Qore::Reflection::TypedHash::isUser | ( |  | ) |

returns True if the typed hash (hashdecl) is a user typed hash

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = th.isUser();

Returns
  True if the typed hash (hashdecl) is a user typed hash

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the typed hash (hashdecl) has been destroyed

Note
  complementary to isBuiltin()

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

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