AbstractDataProviderType.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// assume local scope for variables, do not use "$" signs
// require type definitions everywhere
// enable all warnings
namespace DataProvider {
const TypeCodeMap = {
NT_INT: "int",
NT_STRING: "string",
NT_BOOLEAN: "bool",
NT_FLOAT: "float",
NT_NUMBER: "number",
NT_BINARY: "binary",
NT_LIST: "list",
NT_HASH: "hash",
NT_OBJECT: "object",
NT_ALL: "any",
NT_DATE: "date",
NT_NULL: "null",
NT_NOTHING: "nothing",
};
const OptimalQoreDataTypeMap = {
"int": "int",
Type::Int: "int",
Type::String: "string",
"boolean": "bool",
Type::Boolean: "bool",
"double": "float",
Type::Float: "float",
Type::Number: "number",
Type::Binary: "binary",
Type::List: "list<auto>",
Type::Hash: "hash<auto>",
Type::Object: "object",
Type::Date: "date",
Type::NullType: "null",
Type::NothingType: "nothing",
"all": "any",
};
const OptimalQoreSoftDataTypeMap = OptimalQoreDataTypeMap + {
"int": "softint",
Type::Int: "softint",
Type::String: "softstring",
"boolean": "softbool",
Type::Boolean: "softbool",
"double": "softfloat",
Type::Float: "softfloat",
Type::Number: "softnumber",
Type::List: "softlist<auto>",
Type::Date: "softdate",
};
const DataTypeMap = {
"int": IntType,
Type::Int: IntType,
Type::String: StringType,
"boolean": BoolType,
Type::Boolean: BoolType,
"double": FloatType,
Type::Float: FloatType,
Type::Number: NumberType,
Type::Binary: BinaryType,
Type::List: AutoListType,
Type::Hash: AutoHashType,
Type::Object: ObjectType,
Type::Date: DateType,
Type::NullType: Reflection::NullType,
Type::NothingType: AbstractDataProviderType::nothingType,
"all": AbstractDataProviderType::anyType,
"*int": IntOrNothingType,
"*integer": IntOrNothingType,
"*string": StringOrNothingType,
"*boolean": BoolOrNothingType,
"*bool": BoolOrNothingType,
"*double": FloatOrNothingType,
"*float": FloatOrNothingType,
"*number": NumberOrNothingType,
"*binary": BinaryOrNothingType,
"*list": AutoListOrNothingType,
"*hash": AutoHashOrNothingType,
"*object": ObjectOrNothingType,
"*date": DateOrNothingType,
};
public struct DataProviderTypeOptionInfo {
string type;
string desc;
};
public struct DataTypeInfo {
string name;
*hash<string, hash<DataProviderTypeOptionInfo>> supported_options;
*hash<auto> options;
string base_type;
bool mandatory;
list<string> types_accepted;
list<string> types_returned;
hash<string, hash<DataFieldInfo>> fields;
bool can_manage_fields = False;
};
class AbstractDataProviderType : public Serializable {
public:
static Type nothingType("nothing");
static Type anyType("auto");
protected:
hash<auto> options;
public:
constructor();
constructor(hash<auto> options);
*hash<string, hash<DataProviderTypeOptionInfo>> getSupportedOptions();
hash<DataTypeInfo> getInputInfo();
hash<DataTypeInfo> getInfo();
*hash<string, hash<DataFieldInfo>> getFieldInfo();
bool isAssignableFrom(AbstractDataProviderType t);
bool isAssignableFrom(Type t);
bool isList();
bool isMandatory();
*AbstractDataField getField(string field_name);
bool hasType();
string getBaseTypeName();
int getBaseTypeCode();
*hash<string, bool> getDirectTypeHash();
bool isOrNothingType();
*AbstractDataProviderType getFieldType(string field_name);
auto getOptionValue(string opt);
*hash<auto> getOptions();
setOption(string opt, auto value);
setOptions(hash<auto> options);
AbstractDataProviderType getSoftType();
AbstractDataProviderType getOrNothingType();
abstract string getName();
abstract *Type getValueType();
abstract *AbstractDataProviderType getElementType();
abstract *hash<string, AbstractDataField> getFields();
abstract hash<string, bool> getAcceptTypeHash();
abstract hash<string, bool> getReturnTypeHash();
abstract auto acceptsValue(auto value);
static AbstractDataProviderType get(Type type, *hash<auto> options);
static AbstractDataProviderType get(string typename, *hash<auto> options);
protected:
setOptionIntern(string opt, auto value);
public:
};
}
DataProvider::AbstractDataProviderType::getReturnTypeHash
abstract hash< string, bool > getReturnTypeHash()
returns a hash of types returned by this type; keys are type names
List
const List
DataProvider::DataProviderTypeOptionInfo::type
string type
the option value type
Definition: AbstractDataProviderType.qc.dox.h:124
NT_BINARY
const NT_BINARY
DataProvider::DataTypeInfo::base_type
string base_type
output: base type
Definition: AbstractDataProviderType.qc.dox.h:142
NT_NOTHING
const NT_NOTHING
NT_ALL
const NT_ALL
DataProvider::AbstractDataProviderType::getSoftType
AbstractDataProviderType getSoftType()
returns a "soft" type equivalent to the current type
NT_LIST
const NT_LIST
DataProvider::AbstractDataProviderType
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:161
DataProvider::AbstractDataProviderType::getBaseTypeName
string getBaseTypeName()
returns the base type name for the type; must be a standard Qore base type name
NT_NUMBER
const NT_NUMBER
DataProvider::AbstractDataProviderType::setOption
setOption(string opt, auto value)
sets the given option on the type
DataProvider::AbstractDataProviderType::hasType
bool hasType()
returns True if the type is not a wildcard type
DataProvider::DataTypeInfo::can_manage_fields
bool can_manage_fields
if fields can be added dynamically to the type
Definition: AbstractDataProviderType.qc.dox.h:157
type
string type(auto arg)
NT_NULL
const NT_NULL
Binary
const Binary
NullType
const NullType
DataProvider::AbstractDataProviderType::getInfo
hash< DataTypeInfo > getInfo()
returns a description of the type as a hash
NT_INT
const NT_INT
DataProvider::AbstractDataProviderType::acceptsValue
abstract auto acceptsValue(auto value)
returns the value if the value can be assigned to the type
Number
const Number
DataProvider::AbstractDataProviderType::get
static AbstractDataProviderType get(Type type, *hash< auto > options)
returns an appropriate object for the given type
DataProvider::AbstractDataProviderType::getInputInfo
hash< DataTypeInfo > getInputInfo()
returns a description of the type as an input type
DataProvider::AbstractDataField
describes a data type based on a hashdecl
Definition: AbstractDataField.qc.dox.h:49
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:32
DataProvider::AbstractDataProviderType::isAssignableFrom
bool isAssignableFrom(AbstractDataProviderType t)
returns True if this type can be assigned from values of the argument type
NT_OBJECT
const NT_OBJECT
NT_DATE
const NT_DATE
DataProvider::DataTypeInfo::options
*hash< auto > options
output: current transformation option values
Definition: AbstractDataProviderType.qc.dox.h:139
Object
const Object
DataProvider::DataTypeInfo::types_returned
list< string > types_returned
input: list of types returned
Definition: AbstractDataProviderType.qc.dox.h:151
DataProvider::DataProviderTypeOptionInfo::desc
string desc
the description of the option
Definition: AbstractDataProviderType.qc.dox.h:127
NT_HASH
const NT_HASH
DataProvider::AbstractDataProviderType::getElementType
abstract *AbstractDataProviderType getElementType()
returns the subtype (for lists or hashes) if there is only one
Float
const Float
DataProvider::DataProviderTypeOptionInfo
describes type options
Definition: AbstractDataProviderType.qc.dox.h:122
DataProvider::AbstractDataProviderType::getFields
abstract *hash< string, AbstractDataField > getFields()
returns the fields of the data structure; if any
DataProvider::AbstractDataProviderType::getBaseTypeCode
int getBaseTypeCode()
returns the base type code for the type
String
const String
DataProvider::AbstractDataProviderType::getOptionValue
auto getOptionValue(string opt)
returns the value of the given option
DataProvider::DataTypeInfo::name
string name
the name of the type
Definition: AbstractDataProviderType.qc.dox.h:133
DataProvider::AbstractDataProviderType::getFieldType
*AbstractDataProviderType getFieldType(string field_name)
get the given field type if it exists, otherwise return NOTHING
DataProvider::AbstractDataProviderType::getOrNothingType
AbstractDataProviderType getOrNothingType()
returns an "or nothing" type equivalent to the current type
NT_BOOLEAN
const NT_BOOLEAN
DataProvider::AbstractDataProviderType::setOptions
setOptions(hash< auto > options)
sets options on the type
DataProvider::AbstractDataProviderType::getSupportedOptions
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions()
returns supported options
NothingType
const NothingType
Date
const Date
DataProvider::AbstractDataProviderType::getFieldInfo
*hash< string, hash< DataFieldInfo > > getFieldInfo()
Returns information on fields supported.
DataProvider::OptimalQoreSoftDataTypeMap
const OptimalQoreSoftDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:75
DataProvider::DataTypeInfo
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:131
DataProvider::AbstractDataProviderType::getOptions
*hash< auto > getOptions()
returns options set on the type
False
const False
DataProvider::DataTypeInfo::mandatory
bool mandatory
output: can be null / missing?
Definition: AbstractDataProviderType.qc.dox.h:145
DataProvider::TypeCodeMap
const TypeCodeMap
maps type codes to type names
Definition: AbstractDataProviderType.qc.dox.h:34
DataProvider::AbstractDataProviderType::options
hash< auto > options
type options
Definition: AbstractDataProviderType.qc.dox.h:169
DataProvider::AbstractDataProviderType::getName
abstract string getName()
returns the type name
DataProvider::DataTypeInfo::fields
hash< string, hash< DataFieldInfo > > fields
any fields supported by the type
Definition: AbstractDataProviderType.qc.dox.h:154
DataProvider::AbstractDataProviderType::getValueType
abstract *Type getValueType()
returns the base type for the type, if any
DataProvider::DataTypeInfo::types_accepted
list< string > types_accepted
output: list of types accepted
Definition: AbstractDataProviderType.qc.dox.h:148
DataProvider::OptimalQoreDataTypeMap
const OptimalQoreDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:53
DataProvider::AbstractDataProviderType::isList
bool isList()
returns True if this type is a list
NT_FLOAT
const NT_FLOAT
DataProvider::AbstractDataProviderType::isMandatory
bool isMandatory()
returns True if the type must have a value
DataProvider::AbstractDataProviderType::getField
*AbstractDataField getField(string field_name)
returns the given field, if present, or NOTHING if not
DataProvider::AbstractDataProviderType::constructor
constructor()
creates the type
DataProvider::AbstractDataProviderType::getAcceptTypeHash
abstract hash< string, bool > getAcceptTypeHash()
returns a hash of types accepted by this type; keys are type names
Hash
const Hash
DataProvider::AbstractDataProviderType::setOptionIntern
setOptionIntern(string opt, auto value)
sets the given option without any validation of the option
DataProvider::AbstractDataProviderType::isOrNothingType
bool isOrNothingType()
returns True if the type also accepts NOTHING
DataProvider::AbstractDataProviderType::getDirectTypeHash
*hash< string, bool > getDirectTypeHash()
returns a hash of native base type code keys where no translations are performed; keys are type codes...
Int
const Int
Boolean
const Boolean
DataProvider::DataTypeMap
const DataTypeMap
maps Qore type name constant values to data type objects
Definition: AbstractDataProviderType.qc.dox.h:89
NT_STRING
const NT_STRING
DataProvider::DataTypeInfo::supported_options
*hash< string, hash< DataProviderTypeOptionInfo > > supported_options
output: transformation options supported by the type
Definition: AbstractDataProviderType.qc.dox.h:136