Qore DataProvider Module Reference  1.2.1
DataProvider::HashDataType Class Reference

describes a data type based on a hash More...

Inheritance diagram for DataProvider::HashDataType:

Public Member Methods

auto acceptsValue (auto value)
 Returns the value if the value can be assigned to the type. More...
 
 addField (AbstractDataField field)
 adds a field to the type
 
 constructor (string name=AutoHashType.getName(), *hash< auto > options)
 creates the object and assigns the name as the type
 
 constructor (string name=AutoHashType.getName(), hash< string, AbstractDataField > fields, *hash< auto > options)
 creates the object from the given record description and assigns the name as the type
 
 constructor (Type base_type, *string name, *hash< auto > options)
 creates the object and assigns the name as the given name or the base type's name
 
*AbstractDataField getField (string name)
 Returns the given field, if present, or NOTHING if not.
 
*hash< string, AbstractDataFieldgetFields ()
 Returns the fields of the data structure; if any.
 
string getName ()
 Returns the type name.
 
AbstractDataProviderType getOrNothingType ()
 Returns an "or nothing" type equivalent to the current type. More...
 
AbstractDataProviderType getSoftType ()
 Returns a "soft" type equivalent to the current type. More...
 
bool isAssignableFrom (AbstractDataProviderType t)
 Returns True if this type can be assigned from values of the argument type. More...
 
 setDefaultOtherFieldType (*AbstractDataProviderType default_other_field_type)
 Sets the default field type for unlisted fields.
 
- Public Member Methods inherited from DataProvider::QoreDataType
auto acceptsValue (auto value)
 returns the value if the value can be assigned to the type More...
 
 constructor (Type type, *hash< auto > options)
 creates the type
 
hash< string, bool > getAcceptTypeHash ()
 returns a hash of base types accepted by this type; keys are type names
 
*hash< string, bool > getDirectTypeHash ()
 returns a hash of native base type code where no translations are performed; keys are type codes, not names
 
*AbstractDataProviderType getElementType ()
 returns the subtype (for lists or hashes) if there is only one
 
*hash< string, AbstractDataFieldgetFields ()
 returns the fields of the data structure; if any
 
hash< DataTypeInfogetInfo ()
 returns a description of the type as a hash
 
string getName ()
 returns the type name
 
AbstractDataProviderType getOrNothingType ()
 returns an "or nothing" type equivalent to the current type More...
 
hash< string, bool > getReturnTypeHash ()
 returns a hash of base types returned by this type; keys are type names
 
AbstractDataProviderType getSoftType ()
 returns a "soft" type equivalent to the current type More...
 
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions ()
 returns supported options
 
*Type getValueType ()
 returns the base type for the type, if any
 
- Public Member Methods inherited from DataProvider::AbstractDataProviderType
 constructor ()
 creates the type
 
 constructor (hash< auto > options)
 creates the type and sets options More...
 
int getBaseTypeCode ()
 Returns the base type code for the type.
 
string getBaseTypeName ()
 Returns the base type name for the type; must be a standard Qore base type name.
 
*hash< string, bool > getDirectTypeHash ()
 Returns a hash of native base type code keys where no translations are performed; keys are type codes, not names.
 
*AbstractDataField getField (string field_name)
 Returns the given field, if present, or NOTHING if not.
 
*hash< string, hash< DataFieldInfo > > getFieldInfo ()
 Returns information on fields supported.
 
*AbstractDataProviderType getFieldType (string field_name)
 get the given field type if it exists, otherwise return NOTHING
 
hash< DataTypeInfogetInfo ()
 Returns a description of the type as a hash.
 
hash< DataTypeInfogetInputInfo ()
 Returns a description of the type as an input type. More...
 
*hash< auto > getOptions ()
 Returns options set on the type.
 
auto getOptionValue (string opt)
 Returns the value of the given option.
 
AbstractDataProviderType getOrNothingType ()
 Returns an "or nothing" type equivalent to the current type. More...
 
AbstractDataProviderType getSoftType ()
 Returns a "soft" type equivalent to the current type. More...
 
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions ()
 Returns supported options.
 
bool hasType ()
 Returns True if the type is not a wildcard type.
 
bool isAssignableFrom (AbstractDataProviderType t)
 Returns True if this type can be assigned from values of the argument type.
 
bool isAssignableFrom (Type t)
 Returns True if this type can be assigned from values of the argument type.
 
bool isList ()
 Returns True if this type is a list.
 
bool isMandatory ()
 Returns True if the type must have a value.
 
bool isOrNothingType ()
 Returns True if the type also accepts NOTHING.
 
 setOption (string opt, auto value)
 sets the given option on the type More...
 
 setOptions (hash< auto > options)
 sets options on the type More...
 

Private Attributes

*AbstractDataProviderType default_other_field_type = AbstractDataProviderType::get(AbstractDataProviderType::anyType)
 allow other fields
 
hash< string, AbstractDataFieldfields
 fields
 
bool has_default_other_field_type = False
 if the type requires validation
 
string name
 the name of the type
 
- Private Attributes inherited from DataProvider::QoreDataType
*hash< string, bool > accept_type_hash
 hash of base types accepted by this type; keys are type names
 
hash< string, bool > base_type_hash
 hash of base types where no translations are performed; keys are type codes, not names More...
 
hash< string, bool > blacklist_type_hash
 hash of type codes accepted by the base type but not accepted by this type: code -> True
 
bool or_nothing_type
 flag for "or nothing" types
 
*hash< string, bool > return_type_hash
 hash of base types returned by this type; keys are type names
 
bool soft_type
 flag for soft types
 
const SoftTypeMap = ...
 map from normal types to soft types
 
const SupportedOptions = ...
 supported options
 
Type type
 the Qore type
 
- Private Attributes inherited from DataProvider::AbstractDataProviderType
hash< auto > options
 type options
 

Additional Inherited Members

- Static Public Member Methods inherited from DataProvider::AbstractDataProviderType
static AbstractDataProviderType get (string typename, *hash< auto > options)
 Returns an appropriate object for the given type. More...
 
static AbstractDataProviderType get (Type type, *hash< auto > options)
 Returns an appropriate object for the given type.
 
- Private Member Methods inherited from DataProvider::AbstractDataProviderType
 setOptionIntern (string opt, auto value)
 sets the given option without any validation of the option
 

Detailed Description

describes a data type based on a hash

Note
objects of this type are only compatible if their fields are compatible; non-matching fields of other types are automatically considered compatible; change the default "other field type" by calling setDefaultOtherFieldType() to change this; calling setDefaultOtherFieldType() with no argument removes compatibility with non-matching fields in other types

Member Function Documentation

◆ acceptsValue()

auto DataProvider::HashDataType::acceptsValue ( auto  value)
virtual

Returns the value if the value can be assigned to the type.

Parameters
valuethe value to assign to the type
Returns
the value to be assigned; can be converted by the type
Exceptions
RUNTIME-TYPE-ERRORvalue cannot be assigned to type

Implements DataProvider::AbstractDataProviderType.

◆ getOrNothingType()

AbstractDataProviderType DataProvider::HashDataType::getOrNothingType ( )

Returns an "or nothing" type equivalent to the current type.

Returns
an "or nothing" type equivalent to the current type

◆ getSoftType()

AbstractDataProviderType DataProvider::HashDataType::getSoftType ( )

Returns a "soft" type equivalent to the current type.

Returns
a "soft" type equivalent to the current type

◆ isAssignableFrom()

bool DataProvider::HashDataType::isAssignableFrom ( AbstractDataProviderType  t)

Returns True if this type can be assigned from values of the argument type.

Note
objects of this type are only compatible if their fields are compatible; if either side is a hash without declared fields, then they are compatible