Qore DataProvider Module Reference  1.0.1
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 
161 class AbstractDataProviderType : public Serializable {
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 
292 
293 
295  abstract string getName();
296 
298  abstract *Type getValueType();
299 
302 
304  abstract *hash<string, AbstractDataField> getFields();
305 
307  abstract hash<string, bool> getAcceptTypeHash();
308 
310  abstract hash<string, bool> getReturnTypeHash();
311 
313 
317  abstract auto acceptsValue(auto value);
318 
320  static AbstractDataProviderType get(Type type, *hash<auto> options);
321 
323 
326  static AbstractDataProviderType get(string typename, *hash<auto> options);
327 
329 protected:
330  setOptionIntern(string opt, auto value);
331 public:
332 
333 };
334 }
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