Qore DataProvider Module Reference 3.0
Loading...
Searching...
No Matches
DataProvider::HashDataType Class Reference

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

#include <HashDataType.qc.dox.h>

Inheritance diagram for DataProvider::HashDataType:
[legend]

Public Member Methods

auto acceptsValue (auto input_value)
 Returns the value if the value can be assigned to the type.
 
HashDataType addField (AbstractDataField field)
 adds a field to the type
 
HashDataType addField (Qore::Reflection::TypedHashMember mem)
 adds a field to the type from a typed hash member
 
HashDataType addQoreFields (hash< auto > new_fields)
 Adds a set of fields from a hash.
 
 checkConvertOrNothing ()
 Convert to an "or-nothing" type if all fields are optional.
 
 constructor (Qore::Reflection::TypedHash t, *hash< auto > options, *hash< auto > tags, *hash< auto > default_value, *hash< NameDescInfo > attr)
 creates the object from the given TypedHash
 
 constructor (string name=AutoHashType.getName(), *hash< auto > options, *hash< auto > tags, *hash< auto > default_value, *hash< NameDescInfo > attr)
 creates the object and assigns the name as the type
 
 constructor (string name=AutoHashType.getName(), hash< string, AbstractDataField > fields, *hash< auto > options, *hash< auto > tags, *hash< auto > default_value, *hash< NameDescInfo > attr)
 creates the object from the given record description and assigns the name as the type
 
 constructor (Type base_type, *string name, *hash< auto > options, *hash< auto > tags, *hash< auto > default_value, *hash< NameDescInfo > attr)
 creates the object and assigns the name as the given name or the base type's name
 
 constructor (Type base_type, *string name, hash< string, AbstractDataField > fields, *hash< auto > options, *hash< auto > tags, *hash< auto > default_value, *hash< NameDescInfo > attr)
 creates the object and assigns the name as the given name or the base type's name
 
AbstractDataProviderType getDeepOrNothingType ()
 Returns an "or nothing" type equivalent to the current type as well as all fields.
 
*AbstractDataProviderType getDefaultOtherFieldType ()
 Returns the default field type for undeclared fields, if any.
 
*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.
 
hash< DataTypeInfogetInfo (*bool simple)
 returns a description of the type as a hash
 
AbstractDataProviderType getSoftType ()
 Returns a "soft" type equivalent to the current type.
 
bool hasDefaultOtherFieldType ()
 Returns True if the type has a default field type for undeclared fields.
 
bool isAssignableFrom (AbstractDataProviderType t)
 Returns True if this type can be assigned from values of the argument type.
 
 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
 
 constructor (Type type, *hash< auto > options, *hash< auto > tags, auto default_value, *hash< NameDescInfo > attr, *string path)
 creates the type
 
hash< string, bool > getAcceptTypeHash (*bool simple)
 returns a hash of base types accepted by this type; keys are type names
 
auto getDefaultValue ()
 
string getDesc ()
 Returns the description.
 
*hash< string, bool > getDirectTypeHash ()
 returns a hash of native base type code where no translations are performed; keys are type codes, not names
 
string getDisplayName ()
 Returns the type's display name.
 
*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 (*bool simple)
 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
 
hash< string, bool > getReturnTypeHash (*bool simple)
 returns a hash of base types returned by this type; keys are type names
 
string getShortDescription ()
 Returns the type's short description.
 
AbstractDataProviderType getSoftType ()
 returns a "soft" type equivalent to the current type
 
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions ()
 returns supported options
 
*Type getValueType ()
 returns the base type for the type, if any
 
bool hasDefaultValue ()
 ! Returns True if this type has a default value
 
- Public Member Methods inherited from DataProvider::AbstractDataProviderType
abstract auto acceptsValue (auto value)
 Returns the value if the value can be assigned to the type.
 
 clearPath ()
 Clears the type path for the type.
 
 constructor ()
 creates the type
 
 constructor (hash< auto > options, *hash< auto > tags, *string path)
 creates the type and sets options
 
 constructor (string path)
 creates the type
 
abstract hash< string, bool > getAcceptTypeHash (*bool simple)
 Returns a hash of types accepted by this type; keys are type names.
 
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.
 
auto getDefaultValue ()
 
string getDesc ()
 Returns the description.
 
*hash< string, bool > getDirectTypeHash ()
 Returns a hash of native base type code keys where no translations are performed; keys are type codes, not names.
 
string getDisplayName ()
 Returns the type's display name.
 
abstract *AbstractDataProviderType getElementType ()
 Returns the subtype (for lists or hashes) if there is only one.
 
auto getExampleValue ()
 Returns any example value for type, if any.
 
*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.
 
abstract *hash< string, AbstractDataFieldgetFields ()
 Returns the fields of the data structure; if any.
 
*AbstractDataProviderType getFieldType (string field_name)
 get the given field type if it exists, otherwise return NOTHING
 
hash< DataTypeInfogetInfo (*bool simple)
 Returns a description of the type as a hash.
 
hash< DataTypeInfogetInputInfo (*bool simple)
 Returns a description of the type as an input type.
 
abstract string getName ()
 Returns the type name.
 
*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.
 
*string getPath ()
 Returns the type path in the type cache, if any.
 
abstract hash< string, bool > getReturnTypeHash (*bool simple)
 Returns a hash of types returned by this type; keys are type names.
 
string getShortDescription ()
 Returns the type's short description.
 
AbstractDataProviderType getSoftType ()
 Returns a "soft" type equivalent to the current type.
 
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions ()
 Returns supported options.
 
auto getTag (string tag)
 Returns the value of the given tag.
 
*hash< auto > getTags ()
 Returns tags set on the type.
 
abstract *Type getValueType ()
 Returns the base type for the type, if any.
 
bool hasDefaultValue ()
 ! Returns True if this type has a default value
 
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
 
 setOptions (hash< auto > options)
 sets options on the type
 
 setPath (string path)
 Sets the type path for the type.
 

Private Member Methods

 postProcessAddedField (AbstractDataField field)
 Post process added fields.
 
- Private Member Methods inherited from DataProvider::AbstractDataProviderType
 setOptionIntern (string opt, auto value)
 sets the given option without any validation of the option
 

Private Attributes

*AbstractDataProviderType default_other_field_type
 allow other fields
 
hash< string, AbstractDataFieldfields
 fields
 
bool has_default_other_field_type = False
 if the type requires validation
 
bool manual_default_other_field_type = False
 default other field type set mamnually?
 
- 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 > accept_type_hash_simple
 hash of base types accepted by this type; keys are simple type names
 
hash< string, bool > base_type_hash
 hash of base types where no translations are performed; keys are type codes, not names
 
hash< string, bool > blacklist_type_hash
 hash of type codes accepted by the base type but not accepted by this type: code -> True
 
auto default_value
 Default value for type.
 
string desc
 The long description for the type in markdown.
 
string display_name
 The display name for the type.
 
string name
 The name of the type; if not set then the name of "type" is used instead.
 
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
 
*hash< string, bool > return_type_hash_simple
 hash of base types returned by this type; keys are simple type names
 
string short_desc
 The short plain-text description for the type.
 
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
 
*string path
 The type path, if any.
 
*hash< auto > tags
 type tags
 

Additional Inherited Members

- Static Public Member Methods inherited from DataProvider::AbstractDataProviderType
static AbstractDataProviderType get (hash< DataTypeInfo > info)
 Returns an appropriate object for the given type description.
 
static AbstractDataProviderType get (string typename, *hash< auto > options)
 Returns an appropriate object for the given type.
 
static AbstractDataProviderType get (Type type, *hash< auto > options, *hash< auto > tags, auto default_value, *hash< NameDescInfo > attr)
 Returns an appropriate object for the given type.
 
- Public Attributes inherited from DataProvider::AbstractDataProviderType
const DefaultDesc = "no description available"
 Default description.
 

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.

Additionally, adding any fields before calling setDefaultOtherFieldType() will also remove compatibility with unknown fields

Member Function Documentation

◆ acceptsValue()

auto DataProvider::HashDataType::acceptsValue ( auto  input_value)

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

Parameters
input_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

◆ addQoreFields()

HashDataType DataProvider::HashDataType::addQoreFields ( hash< auto >  new_fields)

Adds a set of fields from a hash.

Parameters
new_fieldsa hash keyed by field name where values are hashes that can be processed by QoreDataField::constructor(hash<auto>)
Since
DataProvider 3.0

◆ getDeepOrNothingType()

AbstractDataProviderType DataProvider::HashDataType::getDeepOrNothingType ( )

Returns an "or nothing" type equivalent to the current type as well as all fields.

Returns
an "or nothing" type equivalent to the current type as well as all fields

◆ 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

◆ postProcessAddedField()

DataProvider::HashDataType::postProcessAddedField ( AbstractDataField  field)
private

Post process added fields.

do not allow unnamed fields if any fields are added manually and no default other field type has been set manually

Since
DataProvider 3.0