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 {
00039 if (!n)
00040 return 0;
00041 return n->size();
00042 }
00043
00045
00050 static inline const AbstractQoreNode *get_param(const QoreListNode *n, qore_size_t i) {
00051 if (!n) return 0;
00052 const AbstractQoreNode *p = n->retrieve_entry(i);
00053 return is_nothing(p) ? 0 : p;
00054 }
00055
00057 static inline int get_int_param(const QoreListNode *n, qore_size_t i) {
00058 if (!n) return 0;
00059 const AbstractQoreNode *p = n->retrieve_entry(i);
00060 return is_nothing(p) ? 0 : p->getAsInt();
00061 }
00062
00064 static inline int64 get_bitint_param(const QoreListNode *n, qore_size_t i) {
00065 if (!n) return 0;
00066 const AbstractQoreNode *p = n->retrieve_entry(i);
00067 return is_nothing(p) ? 0 : p->getAsBigInt();
00068 }
00069
00071 static inline bool get_bool_param(const QoreListNode *n, qore_size_t i) {
00072 if (!n) return 0;
00073 const AbstractQoreNode *p = n->retrieve_entry(i);
00074 return is_nothing(p) ? false : p->getAsBool();
00075 }
00076
00078
00083 static inline const BinaryNode *test_binary_param(const QoreListNode *n, qore_size_t i)
00084 {
00085 if (!n) return 0;
00086 const AbstractQoreNode *p = n->retrieve_entry(i);
00087
00088 return p && p->getType() == NT_BINARY ? reinterpret_cast<const BinaryNode *>(p) : 0;
00089 }
00090
00092
00097 static inline const QoreStringNode *test_string_param(const QoreListNode *n, qore_size_t i)
00098 {
00099 if (!n) return 0;
00100 const AbstractQoreNode *p = n->retrieve_entry(i);
00101
00102 return p && p->getType() == NT_STRING ? reinterpret_cast<const QoreStringNode *>(p) : 0;
00103 }
00104
00106
00111 static inline QoreObject *test_object_param(const QoreListNode *n, qore_size_t i)
00112 {
00113 if (!n) return 0;
00114 const AbstractQoreNode *p = n->retrieve_entry(i);
00115
00116 return p && p->getType() == NT_OBJECT ? const_cast<QoreObject *>(reinterpret_cast<const QoreObject *>(p)) : 0;
00117 }
00118
00120
00125 static inline const DateTimeNode *test_date_param(const QoreListNode *n, qore_size_t i)
00126 {
00127 if (!n) return 0;
00128 const AbstractQoreNode *p = n->retrieve_entry(i);
00129
00130 return p && p->getType() == NT_DATE ? reinterpret_cast<const DateTimeNode *>(p) : 0;
00131 }
00132
00134
00139 static inline const QoreHashNode *test_hash_param(const QoreListNode *n, qore_size_t i)
00140 {
00141 if (!n) return 0;
00142 const AbstractQoreNode *p = n->retrieve_entry(i);
00143
00144 return p && p->getType() == NT_HASH ? reinterpret_cast<const QoreHashNode *>(p) : 0;
00145 }
00146
00148
00153 static inline const QoreListNode *test_list_param(const QoreListNode *n, qore_size_t i)
00154 {
00155 if (!n) return 0;
00156 const AbstractQoreNode *p = n->retrieve_entry(i);
00157
00158 return p && p->getType() == NT_LIST ? reinterpret_cast<const QoreListNode *>(p) : 0;
00159 }
00160
00162
00167 static inline const ResolvedCallReferenceNode *test_funcref_param(const QoreListNode *n, qore_size_t i)
00168 {
00169 if (!n) return 0;
00170 const AbstractQoreNode *p = n->retrieve_entry(i);
00171
00172 return p && p->getType() == NT_FUNCREF ? reinterpret_cast<const ResolvedCallReferenceNode *>(p) : 0;
00173 }
00174
00176
00181 static inline const ReferenceNode *test_reference_param(const QoreListNode *n, qore_size_t i)
00182 {
00183 if (!n) return 0;
00184 const AbstractQoreNode *p = n->retrieve_entry(i);
00185
00186 return p && p->getType() == NT_REFERENCE ? reinterpret_cast<const ReferenceNode *>(p) : 0;
00187 }
00188
00190
00195 static inline bool test_nothing_param(const QoreListNode *n, qore_size_t i)
00196 {
00197 if (!n) return true;
00198 return is_nothing(n->retrieve_entry(i));
00199 }
00200
00201 #endif