Qore DataProvider Module Reference  1.0
AbstractDataProviderType.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
25 // assume local scope for variables, do not use "$" signs
26 // require type definitions everywhere
28 // enable all warnings
29 
30 
32 namespace DataProvider {
34 const TypeCodeMap = {
35  NT_INT: "int",
36  NT_STRING: "string",
37  NT_BOOLEAN: "bool",
38  NT_FLOAT: "float",
39  NT_NUMBER: "number",
40  NT_BINARY: "binary",
41  NT_LIST: "list",
42  NT_HASH: "hash",
43  NT_OBJECT: "object",
44  NT_ALL: "any",
45  NT_DATE: "date",
46  NT_NULL: "null",
47  NT_NOTHING: "nothing",
48 };
49 
51 
54  "int": "int",
55  Type::Int: "int",
56  Type::String: "string",
57  "boolean": "bool",
58  Type::Boolean: "bool",
59  "double": "float",
60  Type::Float: "float",
61  Type::Number: "number",
62  Type::Binary: "binary",
63  Type::List: "list<auto>",
64  Type::Hash: "hash<auto>",
65  Type::Object: "object",
66  Type::Date: "date",
67  Type::NullType: "null",
68  Type::NothingType: "nothing",
69  "all": "any",
70 };
71 
73 
76  "int": "softint",
77  Type::Int: "softint",
78  Type::String: "softstring",
79  "boolean": "softbool",
80  Type::Boolean: "softbool",
81  "double": "softfloat",
82  Type::Float: "softfloat",
83  Type::Number: "softnumber",
84  Type::List: "softlist<auto>",
85  Type::Date: "softdate",
86 };
87 
89 const DataTypeMap = {
90  "int": IntType,
91  Type::Int: IntType,
92  Type::String: StringType,
93  "boolean": BoolType,
94  Type::Boolean: BoolType,
95  "double": FloatType,
96  Type::Float: FloatType,
97  Type::Number: NumberType,
98  Type::Binary: BinaryType,
99  Type::List: AutoListType,
100  Type::Hash: AutoHashType,
101  Type::Object: ObjectType,
102  Type::Date: DateType,
104  Type::NothingType: AbstractDataProviderType::nothingType,
105  "all": AbstractDataProviderType::anyType,
106  "*int": IntOrNothingType,
107  "*integer": IntOrNothingType,
108  "*string": StringOrNothingType,
109  "*boolean": BoolOrNothingType,
110  "*bool": BoolOrNothingType,
111  "*double": FloatOrNothingType,
112  "*float": FloatOrNothingType,
113  "*number": NumberOrNothingType,
114  "*binary": BinaryOrNothingType,
115  "*list": AutoListOrNothingType,
116  "*hash": AutoHashOrNothingType,
117  "*object": ObjectOrNothingType,
118  "*date": DateOrNothingType,
119 };
120 
124  string type;
125 
127  string desc;
128 };
129 
131 public struct DataTypeInfo {
133  string name;
134 
136  *hash<string, hash<DataProviderTypeOptionInfo>> supported_options;
137 
139  *hash<auto> options;
140 
142  string base_type;
143 
145  bool mandatory;
146 
148  list<string> types_accepted;
149 
151  list<string> types_returned;
152 
154  hash<string, hash<DataFieldInfo>> fields;
155 
158 };
159 
162 
163 public:
164  static Type nothingType("nothing");
165  static Type anyType("auto");
166 
167 protected:
169  hash<auto> options;
170 
171 public:
172 
174  constructor();
175 
176 
178 
182  constructor(hash<auto> options);
183 
184 
186  *hash<string, hash<DataProviderTypeOptionInfo>> getSupportedOptions();
187 
188 
190 
194  hash<DataTypeInfo> getInputInfo();
195 
196 
198  hash<DataTypeInfo> getInfo();
199 
200 
202  *hash<string, hash<DataFieldInfo>> getFieldInfo();
203 
204 
207 
208 
210  bool isAssignableFrom(Type t);
211 
212 
214  bool isList();
215 
216 
218  bool isMandatory();
219 
220 
222  *AbstractDataField getField(string field_name);
223 
224 
226  bool hasType();
227 
228 
230  string getBaseTypeName();
231 
232 
234  int getBaseTypeCode();
235 
236 
238  *hash<string, bool> getDirectTypeHash();
239 
240 
242  bool isOrNothingType();
243 
244 
246  *AbstractDataProviderType getFieldType(string field_name);
247 
248 
250  auto getOptionValue(string opt);
251 
252 
254  *hash<auto> getOptions();
255 
256 
258 
263  setOption(string opt, auto value);
264 
265 
267 
271  setOptions(hash<auto> options);
272 
273 
275 
281 
282 
284  abstract string getName();
285 
287  abstract *Type getValueType();
288 
291 
293  abstract *hash<string, AbstractDataField> getFields();
294 
296  abstract hash<string, bool> getAcceptTypeHash();
297 
299  abstract hash<string, bool> getReturnTypeHash();
300 
302 
306  abstract auto acceptsValue(auto value);
307 
309  static AbstractDataProviderType get(Type type, *hash<auto> options);
310 
312  static AbstractDataProviderType get(string typename, *hash<auto> options);
313 
315 protected:
316  setOptionIntern(string opt, auto value);
317 public:
318 
319 };
320 }
const Date
const TypeCodeMap
maps type codes to type names
Definition: AbstractDataProviderType.qc.dox.h:34
*AbstractDataField getField(string field_name)
returns the given field, if present, or NOTHING if not
const Hash
string name
the name of the type
Definition: AbstractDataProviderType.qc.dox.h:133
const String
*hash< auto > getOptions()
returns options set on the type
const NT_NOTHING
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:131
setOption(string opt, auto value)
sets the given option on the type
const OptimalQoreSoftDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:75
const NullType
hash< DataTypeInfo > getInfo()
returns a description of the type as a hash
*hash< auto > options
output: current transformation option values
Definition: AbstractDataProviderType.qc.dox.h:139
bool isMandatory()
returns True if the type must have a value
abstract auto acceptsValue(auto value)
returns the value if the value can be assigned to the type
abstract *hash< string, AbstractDataField > getFields()
returns the fields of the data structure; if any
static AbstractDataProviderType get(Type type, *hash< auto > options)
returns an appropriate object for the given type
const NT_FLOAT
hash< string, hash< DataFieldInfo > > fields
any fields supported by the type
Definition: AbstractDataProviderType.qc.dox.h:154
*hash< string, hash< DataProviderTypeOptionInfo > > getSupportedOptions()
returns supported options
const NT_LIST
string base_type
output: base type
Definition: AbstractDataProviderType.qc.dox.h:142
const List
const NT_STRING
*hash< string, hash< DataProviderTypeOptionInfo > > supported_options
output: transformation options supported by the type
Definition: AbstractDataProviderType.qc.dox.h:136
const False
describes type options
Definition: AbstractDataProviderType.qc.dox.h:122
const NothingType
bool hasType()
returns True if the type is not a wildcard type
bool mandatory
output: can be null / missing?
Definition: AbstractDataProviderType.qc.dox.h:145
const Float
AbstractDataProviderType getSoftType()
returns a "soft" type equivalent to the current type
string type
the option value type
Definition: AbstractDataProviderType.qc.dox.h:124
const NT_ALL
const Boolean
const NT_DATE
const Binary
list< string > types_accepted
output: list of types accepted
Definition: AbstractDataProviderType.qc.dox.h:148
setOptions(hash< auto > options)
sets options on the type
const OptimalQoreDataTypeMap
maps Qore type name constant values from the Type namespace to optimal Qore types names
Definition: AbstractDataProviderType.qc.dox.h:53
const NT_INT
const NT_BOOLEAN
abstract *Type getValueType()
returns the base type for the type, if any
const NT_NULL
bool isAssignableFrom(AbstractDataProviderType t)
returns True if this type can be assigned from values of the argument type
hash< auto > options
type options
Definition: AbstractDataProviderType.qc.dox.h:169
const NT_BINARY
abstract hash< string, bool > getReturnTypeHash()
returns a hash of types returned by this type; keys are type names
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:161
string desc
the description of the option
Definition: AbstractDataProviderType.qc.dox.h:127
string type(auto arg)
abstract hash< string, bool > getAcceptTypeHash()
returns a hash of types accepted by this type; keys are type names
const Int
describes a data type based on a hashdecl
Definition: AbstractDataField.qc.dox.h:49
const NT_NUMBER
list< string > types_returned
input: list of types returned
Definition: AbstractDataProviderType.qc.dox.h:151
const NT_HASH
int getBaseTypeCode()
returns the base type code for the type
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:32
const DataTypeMap
maps Qore type name constant values to data type objects
Definition: AbstractDataProviderType.qc.dox.h:89
*hash< string, hash< DataFieldInfo > > getFieldInfo()
Returns information on fields supported.
abstract *AbstractDataProviderType getElementType()
returns the subtype (for lists or hashes) if there is only one
const NT_OBJECT
string getBaseTypeName()
returns the base type name for the type; must be a standard Qore base type name
*AbstractDataProviderType getFieldType(string field_name)
get the given field type if it exists, otherwise return NOTHING
const Object
bool can_manage_fields
if fields can be added dynamically to the type
Definition: AbstractDataProviderType.qc.dox.h:157
bool isList()
returns True if this type is a list
abstract string getName()
returns the type name
hash< DataTypeInfo > getInputInfo()
returns a description of the type as an input type
auto getOptionValue(string opt)
returns the value of the given option
const Number
setOptionIntern(string opt, auto value)
sets the given option without any validation of the option
*hash< string, bool > getDirectTypeHash()
returns a hash of native base type code keys where no translations are performed; keys are type codes...
bool isOrNothingType()
returns True if the type also accepts NOTHING