Loading...
Searching...
No Matches
Qore::Reflection::Type Class Reference

The base class for Qore data types. More...

`#include <QC_Type.dox.h>`

Inheritance diagram for Qore::Reflection::Type:

## Public Member Functions

auto | acceptsValue (auto value)
| Returns the value after any conversions by the type. More...
bool | canConvertToScalar ()
| Returns True if values of this type can be converted to a scalar value. More...
| constructor (string typestr)
| Creates the type from the given string. More...
hash< string, bool > | getAcceptTypeHash ()
| Returns a hash of types accepted by this type. More...
Type | getBaseType ()
| Returns the base type for the current type; if the type is already a base type (i.e. not an "or nothing" type), then the same type is returned. More...
int | getBaseTypeCode ()
| Returns the base type code for the type or Qore::NT_ALL for those that don't have types. More...
auto | getDefaultValue ()
| Returns the default value for the type or NOTHING if the type has no default value. More...
*Type | getElementType ()
| Returns the element type for complex list and hash types, if any, otherwise returns NOTHING. More...
string | getName ()
| returns the type's name More...
Type | getOrNothingType ()
| Returns the "or nothing" type for the current type; if the type is already an "or nothing" type (i.e. it already accepts NOTHING), then the same type is returned. More...
hash< string, bool > | getReturnTypeHash ()
| Returns a hash of types returned by this type. More...
*TypedHash | getTypedHash ()
| Returns the TypedHash for the type, if the type specifies a typed hash. More...
bool | hasDefaultValue ()
| Returns True if this type has a default value. More...
bool | hasType ()
| Returns True if the type is not a wildcard type; i.e. has type restrictions. More...
bool | isAssignableFrom (Type type, reference< bool > may_not_match)
| Returns True if the output of the Type object passed as an argument is compatible with the input type if the current Type. More...
bool | isAssignableFrom (Type type)
| Returns True if the output of the Type object passed as an argument is compatible with the input type if the current Type. More...
int | isAssignableFrom (auto value)
| Returns True if the Type object can be assigned from the value given as an argument. More...
bool | isCompatible (Type type)
| Returns True if the argument type is compatible with the current type (inputs and outputs) More...
bool | isEqual (Type type)
| Returns True if the Type object passed as an argument is equal to the current object; False if not. More...
bool | isOrNothingType ()
| Returns True if the type accepts and returns NOTHING in addition to other values. More...
bool | isOutputCompatible (Type type)
| Returns True if the output of the Type object passed as an argument is compatible with the return type if the current Type. More...
bool | isTypedHash ()
| Returns True if the type is a TypedHash type, False if not. More...

## Static Public Member Functions

static Type | getOrNothingType (auto v)
| Returns the "or nothing" type object for the value. More...
static Type | getType (auto v)
| Returns the type object for the value. More...

## Detailed Description

The base class for Qore data types.

Restrictions:
  Qore::PO_NO_REFLECTION

Since
  Qore 0.9.0

## Member Function Documentation

## acceptsValue()

auto Qore::Reflection::Type::acceptsValue | ( | auto | value | ) |

Returns the value after any conversions by the type.

Example:
  auto v1 = t1.acceptsValue(v0);

Parameters

  value | the value to assign to the type

Returns
  the value to be assigned; can be converted by the type

Exceptions

  RUNTIME-TYPE-ERROR | if the value cannot be assigned to the type

## canConvertToScalar()

bool Qore::Reflection::Type::canConvertToScalar | ( |  | ) |

Returns True if values of this type can be converted to a scalar value.

Code Flags:
  CONSTANT

Example:
  bool b = t.canConvertToScalar();

Returns
  True if the output of the Type object passed as an argument is compatible with the return type if the current Type

## constructor()

Qore::Reflection::Type::constructor | ( | string | typestr | ) |

Creates the type from the given string.

Parameters

  string | the type string

Exceptions

  UNKNOWN-TYPE | cannot find the given type

## getAcceptTypeHash()

hash< string, bool > Qore::Reflection::Type::getAcceptTypeHash | ( |  | ) |

Returns a hash of types accepted by this type.

Code Flags:
  CONSTANT

Returns
  a hash of types accepted by this type

Since
  Qore 0.9.4

## getBaseType()

Type Qore::Reflection::Type::getBaseType | ( |  | ) |

Returns the base type for the current type; if the type is already a base type (i.e. not an "or nothing" type), then the same type is returned.

Code Flags:
  CONSTANT

Example:
  auto v = t.getBaseType();

Returns
  the base type for the current type; if the type is already a base type (i.e. not an "or nothing" type), then the same type is returned

See also
  getOrNothingType()

Since
  Qore 0.9.4

## getBaseTypeCode()

int Qore::Reflection::Type::getBaseTypeCode | ( |  | ) |

Returns the base type code for the type or Qore::NT_ALL for those that don't have types.

Code Flags:
  CONSTANT

Example:
  int t = t.getBaseTypeCode();

Returns
  the base type code for the type or Qore::NT_ALL for those that don't have types

Since
  Qore 0.9.4

## getDefaultValue()

auto Qore::Reflection::Type::getDefaultValue | ( |  | ) |

Returns the default value for the type or NOTHING if the type has no default value.

Code Flags:
  CONSTANT

Example:
  auto v = t.getDefaultValue();

Returns
  the default value for the type or NOTHING if the type has no default value

## getElementType()

*Type Qore::Reflection::Type::getElementType | ( |  | ) |

Returns the element type for complex list and hash types, if any, otherwise returns NOTHING.

Code Flags:
  CONSTANT

Example:
  *Type element_type = type.getElementType();

Returns
  the element type for complex list and hash types, if any, otherwise returns NOTHING

Since
  Qore 0.9.4

## getName()

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

returns the type's name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = t.getName();

Returns
  the type's name

## getOrNothingType() [1/2]

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

Returns the "or nothing" type for the current type; if the type is already an "or nothing" type (i.e. it already accepts NOTHING), then the same type is returned.

Code Flags:
  CONSTANT

Example:
  auto v = t.getOrNothingType();

Returns
  the "or nothing" type for the current type; if the type is already an "or nothing" type (i.e. it already accepts NOTHING), then the same type is returned

See also
  getBaseType()

## getOrNothingType() [2/2]

static Type Qore::Reflection::Type::getOrNothingType | ( | auto | v | ) |

static

Returns the "or nothing" type object for the value.

Code Flags:
  CONSTANT

Example:
  Type t = Type::getOrNothingType(v);

Returns
  the "or nothing" type object for the value

## getReturnTypeHash()

hash< string, bool > Qore::Reflection::Type::getReturnTypeHash | ( |  | ) |

Returns a hash of types returned by this type.

Code Flags:
  CONSTANT

Returns
  a hash of types returned by this type

Since
  Qore 0.9.4

## getType()

static Type Qore::Reflection::Type::getType | ( | auto | v | ) |

static

Returns the type object for the value.

Code Flags:
  CONSTANT

Example:
  Type t = Type::getType(v);

Parameters

  v | the value to return the type object for

Returns
  the type object for the value

## getTypedHash()

*TypedHash Qore::Reflection::Type::getTypedHash | ( |  | ) |

Returns the TypedHash for the type, if the type specifies a typed hash.

Code Flags:
  CONSTANT

Example:
  *TypedHash hd = type.getTypedHash();

Returns
  the TypedHash for the type, if the type specifies a typed hash

Since
  Qore 0.9.4

## hasDefaultValue()

bool Qore::Reflection::Type::hasDefaultValue | ( |  | ) |

Returns True if this type has a default value.

Code Flags:
  CONSTANT

Example:
  bool b = t.canConvertToScalar();

Returns
  True if this type has a default value

## hasType()

bool Qore::Reflection::Type::hasType | ( |  | ) |

Returns True if the type is not a wildcard type; i.e. has type restrictions.

Code Flags:
  CONSTANT

Example:
  bool b = type.hasType();

Returns
  True if the type is not a wildcard type; i.e. has type restrictions

Since
  Qore 0.9.4

## isAssignableFrom() [1/3]

int Qore::Reflection::Type::isAssignableFrom | ( | auto | value | ) |

Returns True if the Type object can be assigned from the value given as an argument.

Code Flags:
  CONSTANT

Example:
  int b = t.isAssignableFrom(val);

Parameters

  value | the value to check

Returns
  a match code for the assignment; see Type Match Constants for possible values

Since
  Qore 0.9.4

## isAssignableFrom() [2/3]

bool Qore::Reflection::Type::isAssignableFrom | ( | Type | type | ) |

Returns True if the output of the Type object passed as an argument is compatible with the input type if the current Type.

Code Flags:
  CONSTANT

Example:
  bool b = t1.isAssignableFrom(t2);

Parameters

  type | the type to check output value compatibility with the current type

Returns
  True if the output of the Type object passed as an argument is compatible with the input type if the current Type

Since
  Qore 0.9.4

## isAssignableFrom() [3/3]

bool Qore::Reflection::Type::isAssignableFrom | ( | Type | type,
|  | reference< bool > | may_not_match
| ) |  |

Returns True if the output of the Type object passed as an argument is compatible with the input type if the current Type.

Code Flags:
  CONSTANT

Example:
  int v = t1.isAssignableFrom(t2);

Parameters

  type | the type to check output value compatibility with the current type
  may_not_match | an output variable, if True then the assignment is not guaranteed to succeed and may fail at runtime

Returns
  True if the output of the Type object passed as an argument is compatible with the input type if the current Type

Since
  Qore 0.9.4

## isCompatible()

bool Qore::Reflection::Type::isCompatible | ( | Type | type | ) |

Returns True if the argument type is compatible with the current type (inputs and outputs)

Code Flags:
  CONSTANT

Example:
  bool b = t1.isCompatible(t2);

Parameters

  type | the type to check compatibility with the current type

Returns
  True if the argument type is compatible with the current type (inputs and outputs)

Note
  a more strict check than isOutputCompatible()

Since
  Qore 0.9.4

## isEqual()

bool Qore::Reflection::Type::isEqual | ( | Type | type | ) |

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

Code Flags:
  CONSTANT

Example:
  bool b = t1.isEqual(t2);

Parameters

  type | the type to check with the current type for equality

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

## isOrNothingType()

bool Qore::Reflection::Type::isOrNothingType | ( |  | ) |

Returns True if the type accepts and returns NOTHING in addition to other values.

Code Flags:
  CONSTANT

Example:
  bool b = type.isOrNothingType();

Returns
  True if the type accepts and returns NOTHING in addition to other values

Since
  Qore 0.9.4

## isOutputCompatible()

bool Qore::Reflection::Type::isOutputCompatible | ( | Type | type | ) |

Returns True if the output of the Type object passed as an argument is compatible with the return type if the current Type.

Code Flags:
  CONSTANT

Example:
  bool b = t1.isOutputCompatible(t2);

Parameters

  type | the type to check output value compatibility with the current type

Returns
  True if the output of the Type object passed as an argument is compatible with the return type if the current Type

See also
  isCompatible()

## isTypedHash()

bool Qore::Reflection::Type::isTypedHash | ( |  | ) |

Returns True if the type is a TypedHash type, False if not.

Code Flags:
  CONSTANT

Example:
  bool b = type.isTypedHash();

Returns
  True if the type is a TypedHash type, False if not

Since
  Qore 0.9.4

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

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