Qore Programming Language - C/C++ Library  0.8.13.8
QoreType.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreType.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2018 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QORETYPE_H
33 
34 #define _QORE_QORETYPE_H
35 
36 #include <qore/common.h>
37 #include <qore/node_types.h>
38 
39 #include <map>
40 
41 // global default values
42 DLLEXPORT extern QoreListNode* emptyList;
43 DLLEXPORT extern QoreHashNode* emptyHash;
44 DLLEXPORT extern QoreStringNode* NullString;
45 DLLEXPORT extern DateTimeNode* ZeroDate;
46 DLLEXPORT extern QoreBigIntNode* Zero;
47 DLLEXPORT extern QoreFloatNode* ZeroFloat;
48 DLLEXPORT extern QoreNumberNode* ZeroNumber, * InfinityNumber, * NaNumber, * piNumber;
49 
50 DLLEXPORT extern QoreString NothingTypeString, NullTypeString, TrueString,
51  FalseString, EmptyHashString, EmptyListString;
52 
53 DLLEXPORT extern const QoreTypeInfo* anyTypeInfo,
54  *autoTypeInfo,
55  *bigIntTypeInfo,
56  *floatTypeInfo,
57  *boolTypeInfo,
58  *stringTypeInfo,
59  *binaryTypeInfo,
60  *dateTypeInfo,
61  *objectTypeInfo,
62  *hashTypeInfo,
63  *emptyHashTypeInfo,
64  *autoHashTypeInfo,
65  *listTypeInfo,
66  *autoListTypeInfo,
67  *emptyListTypeInfo,
68  *nothingTypeInfo,
69  *nullTypeInfo,
70  *numberTypeInfo,
71  *runTimeClosureTypeInfo,
72  *callReferenceTypeInfo,
73  *referenceTypeInfo,
74  *codeTypeInfo, // either closure or callref
75  *softBigIntTypeInfo, // converts to int from float, string, bool, number, and null
76  *softFloatTypeInfo, // converts to float from int, string, bool, number, and null
77  *softNumberTypeInfo, // converts to number from int, string, bool, float, and null
78  *softBoolTypeInfo, // converts to bool from int, float, string, number, and null
79  *softStringTypeInfo, // converts to string from int, float, bool, number, and null
80  *softDateTypeInfo, // converts to date from int, float, bool, string, number, and null
81  *softListTypeInfo, // converts NOTHING -> empty list, list -> the same list, and everything else: list(arg)
82  *softAutoListTypeInfo,
83  *dataTypeInfo, // either string or binary
84  *timeoutTypeInfo, // accepts int or date and returns int giving timeout in milliseconds
85  *bigIntOrFloatTypeInfo, // accepts int or float and returns the same
86  *bigIntFloatOrNumberTypeInfo, // accepts int or float and returns the same
87  *floatOrNumberTypeInfo, // accepts float or number and returns the same
88 
89  *bigIntOrNothingTypeInfo,
90  *floatOrNothingTypeInfo,
91  *numberOrNothingTypeInfo,
92  *stringOrNothingTypeInfo,
93  *boolOrNothingTypeInfo,
94  *binaryOrNothingTypeInfo,
95  *objectOrNothingTypeInfo,
96  *dateOrNothingTypeInfo,
97  *hashOrNothingTypeInfo,
98  *autoHashOrNothingTypeInfo,
99  *listOrNothingTypeInfo,
100  *autoListOrNothingTypeInfo,
101  *nullOrNothingTypeInfo,
102  *codeOrNothingTypeInfo,
103  *dataOrNothingTypeInfo,
104  *referenceOrNothingTypeInfo,
105 
106  *softBigIntOrNothingTypeInfo,
107  *softFloatOrNothingTypeInfo,
108  *softNumberOrNothingTypeInfo,
109  *softBoolOrNothingTypeInfo,
110  *softStringOrNothingTypeInfo,
111  *softDateOrNothingTypeInfo,
112  *softListOrNothingTypeInfo,
113  *softAutoListOrNothingTypeInfo,
114  *timeoutOrNothingTypeInfo;
115 
116 DLLEXPORT qore_type_t get_next_type_id();
117 
119 DLLEXPORT bool compareHard(const AbstractQoreNode* l, const AbstractQoreNode* r, ExceptionSink* xsink);
121 DLLEXPORT bool compareSoft(const AbstractQoreNode* l, const AbstractQoreNode* r, ExceptionSink* xsink);
123 DLLEXPORT bool q_compare_soft(const QoreValue l, const QoreValue r, ExceptionSink* xsink);
124 
125 static inline AbstractQoreNode* boolean_false() {
126  return &False;
127 }
128 
129 static inline AbstractQoreNode* boolean_true() {
130  return &True;
131 }
132 
133 static inline QoreBigIntNode* zero() {
134  Zero->ref();
135  return Zero;
136 }
137 
138 static inline QoreFloatNode* zero_float() {
139  ZeroFloat->ref();
140  return ZeroFloat;
141 }
142 
143 static inline QoreNumberNode* zero_number() {
144  ZeroNumber->ref();
145  return ZeroNumber;
146 }
147 
148 static inline DateTimeNode* zero_date() {
149  ZeroDate->ref();
150  return ZeroDate;
151 }
152 
153 static inline class QoreStringNode* null_string() {
154  NullString->ref();
155  return NullString;
156 }
157 
158 static inline QoreListNode* empty_list() {
159  emptyList->ref();
160  return emptyList;
161 }
162 
163 static inline QoreHashNode* empty_hash() {
164  emptyHash->ref();
165  return emptyHash;
166 }
167 
168 static inline QoreNumberNode* pi_number() {
169  piNumber->ref();
170  return piNumber;
171 }
172 
174 enum qore_type_result_e {
175  QTI_IGNORE = -2,
176  QTI_UNASSIGNED = -1,
177 
178  QTI_NOT_EQUAL = 0,
179  QTI_WILDCARD = 1,
180  QTI_AMBIGUOUS = 2,
181  QTI_NEAR = 3,
182  QTI_IDENT = 4
183 };
184 
185 DLLEXPORT int testObjectClassAccess(const QoreObject* obj, const QoreClass* classtoaccess);
186 
187 DLLEXPORT const QoreClass* typeInfoGetUniqueReturnClass(const QoreTypeInfo* typeInfo);
188 DLLEXPORT bool typeInfoHasType(const QoreTypeInfo* typeInfo);
189 DLLEXPORT const char* typeInfoGetName(const QoreTypeInfo* typeInfo);
190 DLLEXPORT qore_type_result_e typeInfoAcceptsType(const QoreTypeInfo* typeInfo, const QoreTypeInfo* otherTypeInfo);
191 DLLEXPORT qore_type_result_e typeInfoReturnsType(const QoreTypeInfo* typeInfo, const QoreTypeInfo* otherTypeInfo);
192 
193 DLLEXPORT const QoreTypeInfo* qore_get_or_nothing_type(const QoreTypeInfo* typeInfo);
194 
195 // @since %Qore 0.8.13
196 DLLEXPORT const QoreTypeInfo* qore_get_complex_hash_type(const QoreTypeInfo* valueTypeInfo);
197 // @since %Qore 0.8.13
198 DLLEXPORT const QoreTypeInfo* qore_get_complex_hash_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
199 // @since %Qore 0.8.13
200 DLLEXPORT const QoreTypeInfo* qore_get_complex_list_type(const QoreTypeInfo* valueTypeInfo);
201 // @since %Qore 0.8.13
202 DLLEXPORT const QoreTypeInfo* qore_get_complex_list_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
203 // @since %Qore 0.8.13
204 DLLEXPORT const QoreTypeInfo* qore_get_complex_softlist_type(const QoreTypeInfo* valueTypeInfo);
205 // @since %Qore 0.8.13
206 DLLEXPORT const QoreTypeInfo* qore_get_complex_softlist_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
207 // @since %Qore 0.8.13
208 DLLEXPORT const QoreTypeInfo* qore_get_complex_reference_type(const QoreTypeInfo* valueTypeInfo);
209 // @since %Qore 0.8.13
210 DLLEXPORT const QoreTypeInfo* qore_get_complex_reference_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
211 
212 // @since %Qore 0.8.13.1
213 DLLEXPORT const QoreTypeInfo* qore_get_type_from_string(const char* str);
214 
215 #endif // _QORE_QORETYPE_H
Qore&#39;s arbitrary-precision number value type, dynamically-allocated only, reference counted...
Definition: QoreNumberNode.h:51
Qore&#39;s floating-point value type, dynamically-allocated only, reference counted.
Definition: QoreFloatNode.h:39
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
DLLEXPORT QoreBoolFalseNode False
Qore&#39;s boolean false value.
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:82
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
DLLEXPORT QoreBoolTrueNode True
Qore&#39;s boolean true value.
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
Qore&#39;s parse tree/value type for date-time values, reference-counted, dynamically-allocated only...
Definition: DateTimeNode.h:45
defines a Qore-language class
Definition: QoreClass.h:214
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:112
the implementation of Qore&#39;s object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:62
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:47
DLLEXPORT void ref() const
increments the reference count
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:71
this class implements Qore&#39;s 64-bit integer data type, reference-counted, dynamically-allocated only ...
Definition: QoreBigIntNode.h:41