$darkmode

| Qore DataProvider Module Reference 2.7.1

AbstractDataProviderType.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
27 namespace DataProvider {
29 const TypeCodeMap = {
30 NT_INT: "int",
31 NT_STRING: "string",
32 NT_BOOLEAN: "bool",
33 NT_FLOAT: "float",
34 NT_NUMBER: "number",
35 NT_BINARY: "binary",
36 NT_LIST: "list",
37 NT_HASH: "hash",
38 NT_OBJECT: "object",
39 NT_ALL: "any",
40 NT_DATE: "date",
41 NT_NULL: "null",
42 NT_NOTHING: "nothing",
43};
44
46
48 const OptimalQoreDataTypeMap = {
49 "int": "int",
50 Type::Int: "int",
51 Type::String: "string",
52 "boolean": "bool",
53 Type::Boolean: "bool",
54 "double": "float",
55 Type::Float: "float",
56 Type::Number: "number",
57 Type::Binary: "binary",
58 Type::List: "list<auto>",
59 Type::Hash: "hash<auto>",
60 Type::Object: "object",
61 Type::Date: "date",
62 Type::NullType: "null",
63 Type::NothingType: "nothing",
64 "all": "any",
65};
66
68
70 const OptimalQoreSoftDataTypeMap = OptimalQoreDataTypeMap + {
71 "int": "softint",
72 Type::Int: "softint",
73 Type::String: "softstring",
74 "boolean": "softbool",
75 Type::Boolean: "softbool",
76 "double": "softfloat",
77 Type::Float: "softfloat",
78 Type::Number: "softnumber",
79 Type::List: "softlist<auto>",
80 Type::Date: "softdate",
81};
82
84 const DataTypeMap = {
85 "int": IntType,
86 Type::Int: IntType,
87 Type::String: StringType,
88 "boolean": BoolType,
89 Type::Boolean: BoolType,
90 "double": FloatType,
91 Type::Float: FloatType,
92 Type::Number: NumberType,
93 Type::Binary: BinaryType,
94 Type::List: AutoListType,
95 Type::Hash: AutoHashType,
96 Type::Object: ObjectType,
97 Type::Date: DateType,
98 Type::NullType: Reflection::NullType,
99 Type::NothingType: AbstractDataProviderType::nothingType,
100 "data": DataType,
101 "all": AbstractDataProviderType::anyType,
102 "any": AbstractDataProviderType::anyType,
103 "auto": AbstractDataProviderType::anyType,
104 "*int": IntOrNothingType,
105 "*integer": IntOrNothingType,
106 "*string": StringOrNothingType,
107 "*boolean": BoolOrNothingType,
108 "*bool": BoolOrNothingType,
109 "*double": FloatOrNothingType,
110 "*float": FloatOrNothingType,
111 "*number": NumberOrNothingType,
112 "*binary": BinaryOrNothingType,
113 "*list": AutoListOrNothingType,
114 "*hash": AutoHashOrNothingType,
115 "*object": ObjectOrNothingType,
116 "*date": DateOrNothingType,
117 "*data": DataOrNothingType,
118};
119
121 const AbstractDataProviderTypeMap = ...;
122
123
125 public struct DataProviderTypeOptionInfo {
127 string type;
128
130 string desc;
131};
132
134 public struct DataTypeInfo {
136 string name;
137
139 string desc;
140
142 *hash<string, hash<DataProviderTypeOptionInfo>> supported_options;
143
145 *hash<auto> options;
146
148 string base_type;
149
151 bool mandatory;
152
154 list<string> types_accepted;
155
157 list<string> types_returned;
158
160 hash<string, hash<DataFieldInfo>> fields;
161
163 bool can_manage_fields = False;
164
166 *hash<DataTypeInfo> default_field_type_info;
167
169 *hash<auto> tags;
170};
171
177 const DTT_FromFile = "from_file";
178
180 const DTT_FromLocation = "from_location";
181
183 const DTT_ClientOnly = "client_only";
185
187 class AbstractDataProviderType : public Qore::Serializable {
188
189 public:
190 static Type nothingType = Reflection::NothingType;
191 static Type anyType = Reflection::AutoType;
192 // not initialized here to workaround issue #4048 (circular initializtion error)
193 static AbstractDataProviderType anyDataType;
194
196 const DefaultDesc = "no description available";
197
198 protected:
200 hash<auto> options;
201
203 *hash<auto> tags;
204
205 public:
206
208 constructor();
209
210
212
217 constructor(hash<auto> options, *hash<auto> tags);
218
219
221 string getDesc();
222
223
225 *hash<string, hash<DataProviderTypeOptionInfo>> getSupportedOptions();
226
227
229
235 hash<DataTypeInfo> getInputInfo();
236
237
239 hash<DataTypeInfo> getInfo();
240
241
243 *hash<string, hash<DataFieldInfo>> getFieldInfo();
244
245
247 bool isAssignableFrom(AbstractDataProviderType t);
248
249
251 bool isAssignableFrom(Type t);
252
253
255 bool isList();
256
257
259 bool isMandatory();
260
261
263 *AbstractDataField getField(string field_name);
264
265
267 bool hasType();
268
269
271 string getBaseTypeName();
272
273
275 int getBaseTypeCode();
276
277
279 *hash<string, bool> getDirectTypeHash();
280
281
283 bool isOrNothingType();
284
285
287 *AbstractDataProviderType getFieldType(string field_name);
288
289
291 auto getOptionValue(string opt);
292
293
295 *hash<auto> getOptions();
296
297
299
304 setOption(string opt, auto value);
305
306
308
312 setOptions(hash<auto> options);
313
314
316 auto getTag(string tag);
317
318
320 *hash<auto> getTags();
321
322
324
329 AbstractDataProviderType getSoftType();
330
331
333
340 AbstractDataProviderType getOrNothingType();
341
342
344 abstract string getName();
345
347 abstract *Type getValueType();
348
350 abstract *AbstractDataProviderType getElementType();
351
353 abstract *hash<string, AbstractDataField> getFields();
354
356 abstract hash<string, bool> getAcceptTypeHash();
357
359 abstract hash<string, bool> getReturnTypeHash();
360
362
366 abstract auto acceptsValue(auto value);
367
369 static AbstractDataProviderType get(Type type, *hash<auto> options, *hash<auto> tags);
370
372
375 static AbstractDataProviderType get(string typename, *hash<auto> options);
376
378 protected:
379 setOptionIntern(string opt, auto value);
380 public:
381
382};
383};
DataProvider::AbstractDataField
describes a data type based on a hashdecl
Definition: AbstractDataField.qc.dox.h:47
DataProvider::AbstractDataProviderType
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:187
DataProvider::AbstractDataProviderType::hasType
bool hasType()
Returns True if the type is not a wildcard type.
DataProvider::AbstractDataProviderType::getBaseTypeCode
int getBaseTypeCode()
Returns the base type code for the type.
DataProvider::AbstractDataProviderType::tags
*hash< auto > tags
type tags
Definition: AbstractDataProviderType.qc.dox.h:203
DataProvider::AbstractDataProviderType::getSupportedOptions
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions()
Returns supported options.
DataProvider::AbstractDataProviderType::isAssignableFrom
bool isAssignableFrom(AbstractDataProviderType t)
Returns True if this type can be assigned from values of the argument type.
DataProvider::AbstractDataProviderType::getFieldType
*AbstractDataProviderType getFieldType(string field_name)
get the given field type if it exists, otherwise return NOTHING
DataProvider::AbstractDataProviderType::options
hash< auto > options
type options
Definition: AbstractDataProviderType.qc.dox.h:200
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...
DataProvider::AbstractDataProviderType::isAssignableFrom
bool isAssignableFrom(Type t)
Returns True if this type can be assigned from values of the argument type.
DataProvider::AbstractDataProviderType::getElementType
abstract *AbstractDataProviderType getElementType()
Returns the subtype (for lists or hashes) if there is only one.
DataProvider::AbstractDataProviderType::getReturnTypeHash
abstract hash< string, bool > getReturnTypeHash()
Returns a hash of types returned by this type; keys are type names.
DataProvider::AbstractDataProviderType::getInfo
hash< DataTypeInfo > getInfo()
Returns a description of the type as a hash.
DataProvider::AbstractDataProviderType::isMandatory
bool isMandatory()
Returns True if the type must have a value.
DataProvider::AbstractDataProviderType::getFields
abstract *hash< string, AbstractDataField > getFields()
Returns the fields of the data structure; if any.
DataProvider::AbstractDataProviderType::isList
bool isList()
Returns True if this type is a list.
DataProvider::AbstractDataProviderType::getBaseTypeName
string getBaseTypeName()
Returns the base type name for the type; must be a standard Qore base type name.
DataProvider::AbstractDataProviderType::isOrNothingType
bool isOrNothingType()
Returns True if the type also accepts NOTHING.
DataProvider::AbstractDataProviderType::getTags
*hash< auto > getTags()
Returns tags set on the type.
DataProvider::AbstractDataProviderType::DefaultDesc
const DefaultDesc
Default description.
Definition: AbstractDataProviderType.qc.dox.h:196
DataProvider::AbstractDataProviderType::acceptsValue
abstract auto acceptsValue(auto value)
Returns the value if the value can be assigned to the type.
DataProvider::AbstractDataProviderType::get
static AbstractDataProviderType get(string typename, *hash< auto > options)
Returns an appropriate object for the given type.
DataProvider::AbstractDataProviderType::getOrNothingType
AbstractDataProviderType getOrNothingType()
Returns an "or nothing" type equivalent to the current type.
DataProvider::AbstractDataProviderType::getName
abstract string getName()
Returns the type name.
DataProvider::AbstractDataProviderType::setOptionIntern
setOptionIntern(string opt, auto value)
sets the given option without any validation of the option
DataProvider::AbstractDataProviderType::setOptions
setOptions(hash< auto > options)
sets options on the type
DataProvider::AbstractDataProviderType::getValueType
abstract *Type getValueType()
Returns the base type for the type, if any.
DataProvider::AbstractDataProviderType::getFieldInfo
*hash< string, hash< DataFieldInfo > > getFieldInfo()
Returns information on fields supported.
DataProvider::AbstractDataProviderType::getField
*AbstractDataField getField(string field_name)
Returns the given field, if present, or NOTHING if not.
DataProvider::AbstractDataProviderType::constructor
constructor(hash< auto > options, *hash< auto > tags)
creates the type and sets options
DataProvider::AbstractDataProviderType::getAcceptTypeHash
abstract hash< string, bool > getAcceptTypeHash()
Returns a hash of types accepted by this type; keys are type names.
DataProvider::AbstractDataProviderType::getInputInfo
hash< DataTypeInfo > getInputInfo()
Returns a description of the type as an input type.
DataProvider::AbstractDataProviderType::getOptions
*hash< auto > getOptions()
Returns options set on the type.
DataProvider::AbstractDataProviderType::constructor
constructor()
creates the type
DataProvider::AbstractDataProviderType::getSoftType
AbstractDataProviderType getSoftType()
Returns a "soft" type equivalent to the current type.
DataProvider::AbstractDataProviderType::setOption
setOption(string opt, auto value)
sets the given option on the type
DataProvider::AbstractDataProviderType::get
static AbstractDataProviderType get(Type type, *hash< auto > options, *hash< auto > tags)
Returns an appropriate object for the given type.
DataProvider::AbstractDataProviderType::getOptionValue
auto getOptionValue(string opt)
Returns the value of the given option.
DataProvider::AbstractDataProviderType::getTag
auto getTag(string tag)
Returns the value of the given tag.
DataProvider::AbstractDataProviderType::getDesc
string getDesc()
Returns the description.
Qore::Serializable
False
const False
DataProvider::DTT_FromLocation
const DTT_FromLocation
Tag indicates that a string value can indicate a location.
Definition: AbstractDataProviderType.qc.dox.h:180
DataProvider::DTT_FromFile
const DTT_FromFile
Definition: AbstractDataProviderType.qc.dox.h:177
DataProvider::DTT_ClientOnly
const DTT_ClientOnly
Tag indicates that the value is only applicable in client contexts.
Definition: AbstractDataProviderType.qc.dox.h:183
NothingType
const NothingType
Hash
const Hash
Number
const Number
List
const List
Float
const Float
Object
const Object
NullType
const NullType
Date
const Date
Binary
const Binary
String
const String
Boolean
const Boolean
Int
const Int
NT_DATE
const NT_DATE
NT_BOOLEAN
const NT_BOOLEAN
NT_INT
const NT_INT
NT_NUMBER
const NT_NUMBER
NT_BINARY
const NT_BINARY
NT_NOTHING
const NT_NOTHING
NT_STRING
const NT_STRING
NT_ALL
const NT_ALL
NT_FLOAT
const NT_FLOAT
NT_NULL
const NT_NULL
NT_OBJECT
const NT_OBJECT
NT_LIST
const NT_LIST
NT_HASH
const NT_HASH
type
string type(auto arg)
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27
DataProvider::DataTypeMap
const DataTypeMap
Maps Qore type name constant values to data type objects.
Definition: AbstractDataProviderType.qc.dox.h:84
DataProvider::OptimalQoreDataTypeMap
const OptimalQoreDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:48
DataProvider::TypeCodeMap
const TypeCodeMap
maps type codes to type names
Definition: AbstractDataProviderType.qc.dox.h:29
DataProvider::AbstractDataProviderTypeMap
const AbstractDataProviderTypeMap
Maps Qore type name constant values to AbstractDataProviderType values.
Definition: AbstractDataProviderType.qc.dox.h:121
DataProvider::OptimalQoreSoftDataTypeMap
const OptimalQoreSoftDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:70
DataProvider::DataProviderTypeOptionInfo
describes type options
Definition: AbstractDataProviderType.qc.dox.h:125
DataProvider::DataProviderTypeOptionInfo::desc
string desc
the description of the option
Definition: AbstractDataProviderType.qc.dox.h:130
DataProvider::DataProviderTypeOptionInfo::type
string type
the option value type
Definition: AbstractDataProviderType.qc.dox.h:127
DataProvider::DataTypeInfo
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:134
DataProvider::DataTypeInfo::options
*hash< auto > options
Output: current transformation option values.
Definition: AbstractDataProviderType.qc.dox.h:145
DataProvider::DataTypeInfo::tags
*hash< auto > tags
Any tags set on the type.
Definition: AbstractDataProviderType.qc.dox.h:169
DataProvider::DataTypeInfo::default_field_type_info
*hash< DataTypeInfo > default_field_type_info
Default type for fields not listed in fields.
Definition: AbstractDataProviderType.qc.dox.h:166
DataProvider::DataTypeInfo::supported_options
*hash< string, hash< DataProviderTypeOptionInfo > > supported_options
Output: transformation options supported by the type.
Definition: AbstractDataProviderType.qc.dox.h:142
DataProvider::DataTypeInfo::can_manage_fields
bool can_manage_fields
If fields can be added dynamically to the type and if the type will accept any field at runtime.
Definition: AbstractDataProviderType.qc.dox.h:163
DataProvider::DataTypeInfo::mandatory
bool mandatory
Output: can be null / missing?
Definition: AbstractDataProviderType.qc.dox.h:151
DataProvider::DataTypeInfo::types_returned
list< string > types_returned
Input: list of types returned.
Definition: AbstractDataProviderType.qc.dox.h:157
DataProvider::DataTypeInfo::desc
string desc
The description of the type.
Definition: AbstractDataProviderType.qc.dox.h:139
DataProvider::DataTypeInfo::base_type
string base_type
Output: base type.
Definition: AbstractDataProviderType.qc.dox.h:148
DataProvider::DataTypeInfo::types_accepted
list< string > types_accepted
Output: list of types accepted.
Definition: AbstractDataProviderType.qc.dox.h:154
DataProvider::DataTypeInfo::fields
hash< string, hash< DataFieldInfo > > fields
Any fields supported by the type.
Definition: AbstractDataProviderType.qc.dox.h:160
DataProvider::DataTypeInfo::name
string name
The name of the type.
Definition: AbstractDataProviderType.qc.dox.h:136