$darkmode
Qore DataProvider Module Reference 2.7.5
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 
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 
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,
99  Type::NothingType: AbstractDataProviderType::nothingType,
100  "base64binary": Base64BinaryType,
101  "hexbinary": HexBinaryType,
102  "data": DataType,
103 
104  "softint": SoftIntType,
105  "softstring": SoftStringType,
106  "softbool": SoftBoolType,
107  "softfloat": SoftFloatType,
108  "softnumber": SoftNumberType,
109  "softdate": SoftDateType,
110 
111  "*softint": SoftIntOrNothingType,
112  "*softstring": SoftStringOrNothingType,
113  "*softbool": SoftBoolOrNothingType,
114  "*softfloat": SoftFloatOrNothingType,
115  "*softnumber": SoftNumberOrNothingType,
116  "*softdate": SoftDateOrNothingType,
117 
118  "all": AbstractDataProviderType::anyType,
119  "any": AbstractDataProviderType::anyType,
120  "auto": AbstractDataProviderType::anyType,
121 
122  "*int": IntOrNothingType,
123  "*integer": IntOrNothingType,
124  "*string": StringOrNothingType,
125  "*boolean": BoolOrNothingType,
126  "*bool": BoolOrNothingType,
127  "*double": FloatOrNothingType,
128  "*float": FloatOrNothingType,
129  "*number": NumberOrNothingType,
130  "*binary": BinaryOrNothingType,
131  "*list": AutoListOrNothingType,
132  "*hash": AutoHashOrNothingType,
133  "*object": ObjectOrNothingType,
134  "*date": DateOrNothingType,
135  "*data": DataOrNothingType,
136  "*hexbinary": HexBinaryOrNothingType,
137 };
138 
141 
142 
146  string type;
147 
149  string desc;
150 };
151 
153 public struct DataTypeInfo {
155  string name;
156 
158  string desc;
159 
161  *hash<string, hash<DataProviderTypeOptionInfo>> supported_options;
162 
164  *hash<auto> options;
165 
167  string base_type;
168 
170  bool mandatory;
171 
173  list<string> types_accepted;
174 
176  list<string> types_returned;
177 
179  hash<string, hash<DataFieldInfo>> fields;
180 
183 
185  *hash<DataTypeInfo> default_field_type_info;
186 
188  *hash<auto> tags;
189 };
190 
196 const DTT_FromFile = "from_file";
197 
199 const DTT_FromLocation = "from_location";
200 
202 const DTT_ClientOnly = "client_only";
204 
207 
208 public:
209  static Type nothingType = Reflection::NothingType;
210  static Type anyType = Reflection::AutoType;
211  // not initialized here to workaround issue #4048 (circular initializtion error)
212  static AbstractDataProviderType anyDataType;
213 
215  const DefaultDesc = "no description available";
216 
217 protected:
219  hash<auto> options;
220 
222  *hash<auto> tags;
223 
224 public:
225 
228 
229 
231 
236  constructor(hash<auto> options, *hash<auto> tags);
237 
238 
240  string getDesc();
241 
242 
244  *hash<string, hash<DataProviderTypeOptionInfo>> getSupportedOptions();
245 
246 
248 
254  hash<DataTypeInfo> getInputInfo();
255 
256 
258  hash<DataTypeInfo> getInfo();
259 
260 
262  *hash<string, hash<DataFieldInfo>> getFieldInfo();
263 
264 
267 
268 
270  bool isAssignableFrom(Type t);
271 
272 
274  bool isList();
275 
276 
278  bool isMandatory();
279 
280 
282  *AbstractDataField getField(string field_name);
283 
284 
286  bool hasType();
287 
288 
290  string getBaseTypeName();
291 
292 
295 
296 
298  *hash<string, bool> getDirectTypeHash();
299 
300 
303 
304 
307 
308 
310  auto getOptionValue(string opt);
311 
312 
314  *hash<auto> getOptions();
315 
316 
318 
323  setOption(string opt, auto value);
324 
325 
327 
331  setOptions(hash<auto> options);
332 
333 
335  auto getTag(string tag);
336 
337 
339  *hash<auto> getTags();
340 
341 
343 
349 
350 
352 
360 
361 
363  abstract string getName();
364 
366  abstract *Type getValueType();
367 
370 
372  abstract *hash<string, AbstractDataField> getFields();
373 
375  abstract hash<string, bool> getAcceptTypeHash();
376 
378  abstract hash<string, bool> getReturnTypeHash();
379 
381 
385  abstract auto acceptsValue(auto value);
386 
388  static AbstractDataProviderType get(Type type, *hash<auto> options, *hash<auto> tags);
389 
391 
394  static AbstractDataProviderType get(string typename, *hash<auto> options);
395 
397 protected:
398  setOptionIntern(string opt, auto value);
399 public:
400 
401 };
402 };
describes a data type based on a hashdecl
Definition: AbstractDataField.qc.dox.h:47
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:206
bool hasType()
Returns True if the type is not a wildcard type.
*hash< string, hash< DataFieldInfo > > getFieldInfo()
Returns information on fields supported.
int getBaseTypeCode()
Returns the base type code for the type.
*hash< auto > tags
type tags
Definition: AbstractDataProviderType.qc.dox.h:222
bool isAssignableFrom(AbstractDataProviderType t)
Returns True if this type can be assigned from values of the argument type.
*AbstractDataProviderType getFieldType(string field_name)
get the given field type if it exists, otherwise return NOTHING
hash< auto > options
type options
Definition: AbstractDataProviderType.qc.dox.h:219
hash< DataTypeInfo > getInfo()
Returns a description of the type as a hash.
bool isAssignableFrom(Type t)
Returns True if this type can be assigned from values of the argument type.
abstract *AbstractDataProviderType getElementType()
Returns the subtype (for lists or hashes) if there is only one.
*hash< string, bool > getDirectTypeHash()
Returns a hash of native base type code keys where no translations are performed; keys are type codes...
hash< DataTypeInfo > getInputInfo()
Returns a description of the type as an input type.
bool isMandatory()
Returns True if the type must have a value.
bool isList()
Returns True if this type is a list.
string getBaseTypeName()
Returns the base type name for the type; must be a standard Qore base type name.
bool isOrNothingType()
Returns True if the type also accepts NOTHING.
const DefaultDesc
Default description.
Definition: AbstractDataProviderType.qc.dox.h:215
abstract auto acceptsValue(auto value)
Returns the value if the value can be assigned to the type.
static AbstractDataProviderType get(string typename, *hash< auto > options)
Returns an appropriate object for the given type.
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions()
Returns supported options.
AbstractDataProviderType getOrNothingType()
Returns an "or nothing" type equivalent to the current type.
abstract string getName()
Returns the type name.
abstract *hash< string, AbstractDataField > getFields()
Returns the fields of the data structure; if any.
setOptionIntern(string opt, auto value)
sets the given option without any validation of the option
setOptions(hash< auto > options)
sets options on the type
abstract *Type getValueType()
Returns the base type for the type, if any.
*AbstractDataField getField(string field_name)
Returns the given field, if present, or NOTHING if not.
*hash< auto > getOptions()
Returns options set on the type.
constructor(hash< auto > options, *hash< auto > tags)
creates the type and sets options
AbstractDataProviderType getSoftType()
Returns a "soft" type equivalent to the current type.
setOption(string opt, auto value)
sets the given option on the type
abstract hash< string, bool > getReturnTypeHash()
Returns a hash of types returned by this type; keys are type names.
*hash< auto > getTags()
Returns tags set on the type.
abstract hash< string, bool > getAcceptTypeHash()
Returns a hash of types accepted by this type; keys are type names.
static AbstractDataProviderType get(Type type, *hash< auto > options, *hash< auto > tags)
Returns an appropriate object for the given type.
auto getOptionValue(string opt)
Returns the value of the given option.
auto getTag(string tag)
Returns the value of the given tag.
string getDesc()
Returns the description.
const False
const DTT_FromLocation
Tag indicates that a string value can indicate a location.
Definition: AbstractDataProviderType.qc.dox.h:199
const DTT_FromFile
Definition: AbstractDataProviderType.qc.dox.h:196
const DTT_ClientOnly
Tag indicates that the value is only applicable in client contexts.
Definition: AbstractDataProviderType.qc.dox.h:202
const NothingType
const Hash
const Number
const List
const Float
const Object
const NullType
const Date
const Binary
const String
const Boolean
const Int
const NT_DATE
const NT_BOOLEAN
const NT_INT
const NT_NUMBER
const NT_BINARY
const NT_NOTHING
const NT_STRING
const NT_ALL
const NT_FLOAT
const NT_NULL
const NT_OBJECT
const NT_LIST
const NT_HASH
string type(auto arg)
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27
const DataTypeMap
Maps Qore type name constant values to data type objects.
Definition: AbstractDataProviderType.qc.dox.h:84
const OptimalQoreDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:48
const TypeCodeMap
maps type codes to type names
Definition: AbstractDataProviderType.qc.dox.h:29
const AbstractDataProviderTypeMap
Maps Qore type name constant values to AbstractDataProviderType values.
Definition: AbstractDataProviderType.qc.dox.h:140
const OptimalQoreSoftDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:70
describes type options
Definition: AbstractDataProviderType.qc.dox.h:144
string desc
the description of the option
Definition: AbstractDataProviderType.qc.dox.h:149
string type
the option value type
Definition: AbstractDataProviderType.qc.dox.h:146
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:153
*hash< auto > options
Output: current transformation option values.
Definition: AbstractDataProviderType.qc.dox.h:164
*hash< auto > tags
Any tags set on the type.
Definition: AbstractDataProviderType.qc.dox.h:188
*hash< DataTypeInfo > default_field_type_info
Default type for fields not listed in fields.
Definition: AbstractDataProviderType.qc.dox.h:185
*hash< string, hash< DataProviderTypeOptionInfo > > supported_options
Output: transformation options supported by the type.
Definition: AbstractDataProviderType.qc.dox.h:161
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:182
bool mandatory
Output: can be null / missing?
Definition: AbstractDataProviderType.qc.dox.h:170
list< string > types_returned
Input: list of types returned.
Definition: AbstractDataProviderType.qc.dox.h:176
string desc
The description of the type.
Definition: AbstractDataProviderType.qc.dox.h:158
string base_type
Output: base type.
Definition: AbstractDataProviderType.qc.dox.h:167
list< string > types_accepted
Output: list of types accepted.
Definition: AbstractDataProviderType.qc.dox.h:173
hash< string, hash< DataFieldInfo > > fields
Any fields supported by the type.
Definition: AbstractDataProviderType.qc.dox.h:179
string name
The name of the type.
Definition: AbstractDataProviderType.qc.dox.h:155