QoreType.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreType.h
Qore Programming Language
Copyright (C) 2003 - 2021 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_QORETYPE_H
#define _QORE_QORETYPE_H
#include <qore/common.h>
#include <qore/node_types.h>
#include <map>
// global default values
DLLEXPORT extern QoreListNode* emptyList;
DLLEXPORT extern QoreHashNode* emptyHash;
DLLEXPORT extern QoreStringNode* NullString;
DLLEXPORT extern DateTimeNode* ZeroDate;
DLLEXPORT extern QoreNumberNode* ZeroNumber, * InfinityNumber, * NaNumber, * piNumber;
DLLEXPORT extern QoreString NothingTypeString, NullTypeString, TrueString,
FalseString, EmptyHashString, EmptyListString;
DLLEXPORT extern const QoreTypeInfo* anyTypeInfo,
*autoTypeInfo,
*bigIntTypeInfo,
*floatTypeInfo,
*boolTypeInfo,
*stringTypeInfo,
*binaryTypeInfo,
*dateTypeInfo,
*objectTypeInfo,
*hashTypeInfo,
*emptyHashTypeInfo,
*autoHashTypeInfo,
*listTypeInfo,
*autoListTypeInfo,
*emptyListTypeInfo,
*nothingTypeInfo,
*nullTypeInfo,
*numberTypeInfo,
*runTimeClosureTypeInfo,
*callReferenceTypeInfo,
*referenceTypeInfo,
*codeTypeInfo, // either closure or callref
*softBinaryTypeInfo, // converts to binary from string and null
*softBigIntTypeInfo, // converts to int from float, string, bool, number, and null
*softFloatTypeInfo, // converts to float from int, string, bool, number, and null
*softNumberTypeInfo, // converts to number from int, string, bool, float, and null
*softBoolTypeInfo, // converts to bool from int, float, string, number, and null
*softStringTypeInfo, // converts to string from int, float, bool, number, and null
*softDateTypeInfo, // converts to date from int, float, bool, string, number, and null
*softListTypeInfo, // converts NOTHING -> empty list, list -> the same list, and everything else: list(arg)
*softAutoListTypeInfo,
*dataTypeInfo, // either string or binary
*timeoutTypeInfo, // accepts int or date and returns int giving timeout in milliseconds
*bigIntOrFloatTypeInfo, // accepts int or float and returns the same
*bigIntFloatOrNumberTypeInfo, // accepts int or float and returns the same
*floatOrNumberTypeInfo, // accepts float or number and returns the same
*bigIntOrNothingTypeInfo,
*floatOrNothingTypeInfo,
*numberOrNothingTypeInfo,
*stringOrNothingTypeInfo,
*boolOrNothingTypeInfo,
*binaryOrNothingTypeInfo,
*objectOrNothingTypeInfo,
*dateOrNothingTypeInfo,
*hashOrNothingTypeInfo,
*autoHashOrNothingTypeInfo,
*listOrNothingTypeInfo,
*autoListOrNothingTypeInfo,
*nullOrNothingTypeInfo,
*codeOrNothingTypeInfo,
*dataOrNothingTypeInfo,
*referenceOrNothingTypeInfo,
*softBinaryOrNothingTypeInfo,
*softBigIntOrNothingTypeInfo,
*softFloatOrNothingTypeInfo,
*softNumberOrNothingTypeInfo,
*softBoolOrNothingTypeInfo,
*softStringOrNothingTypeInfo,
*softDateOrNothingTypeInfo,
*softListOrNothingTypeInfo,
*softAutoListOrNothingTypeInfo,
*timeoutOrNothingTypeInfo;
DLLEXPORT qore_type_t get_next_type_id();
DLLEXPORT bool compareHard(const AbstractQoreNode* l, const AbstractQoreNode* r, ExceptionSink* xsink);
DLLEXPORT bool compareSoft(const AbstractQoreNode* l, const AbstractQoreNode* r, ExceptionSink* xsink);
DLLEXPORT bool q_compare_soft(const QoreValue l, const QoreValue r, ExceptionSink* xsink);
static inline QoreNumberNode* zero_number() {
ZeroNumber->ref();
return ZeroNumber;
}
static inline DateTimeNode* zero_date() {
ZeroDate->ref();
return ZeroDate;
}
static inline class QoreStringNode* null_string() {
NullString->ref();
return NullString;
}
static inline QoreListNode* empty_list() {
emptyList->ref();
return emptyList;
}
static inline QoreHashNode* empty_hash() {
emptyHash->ref();
return emptyHash;
}
static inline QoreNumberNode* pi_number() {
piNumber->ref();
return piNumber;
}
enum qore_type_result_e {
QTI_IGNORE = -2,
QTI_UNASSIGNED = -1,
QTI_NOT_EQUAL = 0,
QTI_WILDCARD = 1,
QTI_AMBIGUOUS = 2,
QTI_NEAR = 3,
QTI_IDENT = 4
};
DLLEXPORT int testObjectClassAccess(const QoreObject* obj, const QoreClass* classtoaccess);
DLLEXPORT const QoreClass* typeInfoGetUniqueReturnClass(const QoreTypeInfo* typeInfo);
DLLEXPORT bool typeInfoHasType(const QoreTypeInfo* typeInfo);
DLLEXPORT const char* typeInfoGetName(const QoreTypeInfo* typeInfo);
DLLEXPORT const QoreTypeInfo* typeInfoGetElementType(const QoreTypeInfo* typeInfo);
DLLEXPORT const TypedHashDecl* typeInfoGetTypedHash(const QoreTypeInfo* typeInfo);
DLLEXPORT qore_type_result_e typeInfoAcceptsType(const QoreTypeInfo* typeInfo, const QoreTypeInfo* otherTypeInfo);
DLLEXPORT qore_type_result_e typeInfoReturnsType(const QoreTypeInfo* typeInfo, const QoreTypeInfo* otherTypeInfo);
// Returns a non "or nothing" type for the given "or nothing" type
DLLEXPORT const QoreTypeInfo* qore_get_value_type(const QoreTypeInfo* typeInfo);
DLLEXPORT const QoreTypeInfo* qore_get_or_nothing_type(const QoreTypeInfo* typeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_hash_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_hash_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_list_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_list_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_softlist_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_softlist_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_reference_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.8.13
DLLEXPORT const QoreTypeInfo* qore_get_complex_reference_or_nothing_type(const QoreTypeInfo* valueTypeInfo);
// @since %Qore 0.9.4
DLLEXPORT const QoreTypeInfo* qore_get_type_from_string(const char* str, ExceptionSink& xsink);
// @since %Qore 1.0
DLLEXPORT const QoreClass* type_info_get_return_class(const QoreTypeInfo* typeInfo);
#endif // _QORE_QORETYPE_H
QoreNumberNode
Qore&#39;s arbitrary-precision number value type, dynamically-allocated only, reference counted...
Definition: QoreNumberNode.h:51
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:81
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
DateTimeNode
Qore&#39;s parse tree/value type for date-time values, reference-counted, dynamically-allocated only...
Definition: DateTimeNode.h:45
QoreClass
defines a Qore-language class
Definition: QoreClass.h:239
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:267
QoreObject
the implementation of Qore&#39;s object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:60
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
TypedHashDecl
typed hash declaration
Definition: TypedHashDecl.h:44
AbstractQoreNode::ref
DLLEXPORT void ref() const
increments the reference count
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:70
common.h
node_types.h