00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _QORE_PARAMS_H
00024
00025 #define _QORE_PARAMS_H
00026
00027 #include <qore/AbstractQoreNode.h>
00028
00033
00034
00037 static inline int num_params(const QoreListNode *n) {
00038 if (!n)
00039 return 0;
00040 return n->size();
00041 }
00042
00044
00049 static inline const AbstractQoreNode *get_param(const QoreListNode *n, qore_size_t i) {
00050 if (!n) return 0;
00051 const AbstractQoreNode *p = n->retrieve_entry(i);
00052 return is_nothing(p) ? 0 : p;
00053 }
00054
00056
00061 static inline qore_type_t get_param_type(const QoreListNode *n, qore_size_t i) {
00062 if (!n) return NT_NOTHING;
00063 const AbstractQoreNode *p = n->retrieve_entry(i);
00064 return p ? p->getType() : NT_NOTHING;
00065 }
00066
00068 static inline int get_int_param(const QoreListNode *n, qore_size_t i) {
00069 if (!n) return 0;
00070 const AbstractQoreNode *p = n->retrieve_entry(i);
00071 return is_nothing(p) ? 0 : p->getAsInt();
00072 }
00073
00075 static inline int64 get_bigint_param(const QoreListNode *n, qore_size_t i) {
00076 if (!n) return 0;
00077 const AbstractQoreNode *p = n->retrieve_entry(i);
00078 return is_nothing(p) ? 0 : p->getAsBigInt();
00079 }
00080
00082 static inline bool get_bool_param(const QoreListNode *n, qore_size_t i) {
00083 if (!n) return 0;
00084 const AbstractQoreNode *p = n->retrieve_entry(i);
00085 return is_nothing(p) ? false : p->getAsBool();
00086 }
00087
00089
00094 static inline const BinaryNode *test_binary_param(const QoreListNode *n, qore_size_t i) {
00095 if (!n) return 0;
00096 const AbstractQoreNode *p = n->retrieve_entry(i);
00097
00098 return p && p->getType() == NT_BINARY ? reinterpret_cast<const BinaryNode *>(p) : 0;
00099 }
00100
00102
00107 static inline const QoreStringNode *test_string_param(const QoreListNode *n, qore_size_t i) {
00108 if (!n) return 0;
00109 const AbstractQoreNode *p = n->retrieve_entry(i);
00110
00111 return p && p->getType() == NT_STRING ? reinterpret_cast<const QoreStringNode *>(p) : 0;
00112 }
00113
00115
00120 static inline QoreObject *test_object_param(const QoreListNode *n, qore_size_t i) {
00121 if (!n) return 0;
00122 const AbstractQoreNode *p = n->retrieve_entry(i);
00123
00124 return p && p->getType() == NT_OBJECT ? const_cast<QoreObject *>(reinterpret_cast<const QoreObject *>(p)) : 0;
00125 }
00126
00128
00133 static inline const DateTimeNode *test_date_param(const QoreListNode *n, qore_size_t i) {
00134 if (!n) return 0;
00135 const AbstractQoreNode *p = n->retrieve_entry(i);
00136
00137 return p && p->getType() == NT_DATE ? reinterpret_cast<const DateTimeNode *>(p) : 0;
00138 }
00139
00141
00146 static inline const QoreHashNode *test_hash_param(const QoreListNode *n, qore_size_t i) {
00147 if (!n) return 0;
00148 const AbstractQoreNode *p = n->retrieve_entry(i);
00149
00150 return p && p->getType() == NT_HASH ? reinterpret_cast<const QoreHashNode *>(p) : 0;
00151 }
00152
00154
00159 static inline const QoreListNode *test_list_param(const QoreListNode *n, qore_size_t i) {
00160 if (!n) return 0;
00161 const AbstractQoreNode *p = n->retrieve_entry(i);
00162
00163 return p && p->getType() == NT_LIST ? reinterpret_cast<const QoreListNode *>(p) : 0;
00164 }
00165
00167
00172 static inline const ResolvedCallReferenceNode *test_callref_param(const QoreListNode *n, qore_size_t i) {
00173 if (!n) return 0;
00174 const AbstractQoreNode *p = n->retrieve_entry(i);
00175
00176 return p && (p->getType() == NT_FUNCREF || p->getType() == NT_RUNTIME_CLOSURE) ? reinterpret_cast<const ResolvedCallReferenceNode *>(p) : 0;
00177 }
00178
00180
00185 static inline const ResolvedCallReferenceNode *test_funcref_param(const QoreListNode *n, qore_size_t i) {
00186 return test_callref_param(n, i);
00187 }
00188
00190
00196 static inline const ReferenceNode *test_reference_param(const QoreListNode *n, qore_size_t i) {
00197 if (!n) return 0;
00198 const AbstractQoreNode *p = n->retrieve_entry(i);
00199
00200 return p && p->getType() == NT_REFERENCE ? reinterpret_cast<const ReferenceNode *>(p) : 0;
00201 }
00202
00204
00209 static inline bool test_nothing_param(const QoreListNode *n, qore_size_t i) {
00210 if (!n) return true;
00211 return is_nothing(n->retrieve_entry(i));
00212 }
00213
00214 #endif