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_COMMON_H
00024
00025 #define _QORE_COMMON_H
00026
00031 #include <string.h>
00032 #include <strings.h>
00033
00034 #include <string>
00035 #include <functional>
00036 #include <list>
00037 #include <set>
00038 #include <vector>
00039 #include <algorithm>
00040
00042 typedef short qore_type_t;
00043
00045 typedef unsigned long qore_size_t;
00046
00048 typedef long qore_offset_t;
00049
00051 typedef unsigned qore_classid_t;
00052
00054 typedef std::set<int> int_set_t;
00055
00057 enum qore_license_t { QL_GPL = 0,
00058 QL_LGPL = 1
00059 };
00060
00061 #ifdef _MSC_VER
00062 #ifdef BUILDING_DLL
00063 #define DLLEXPORT __declspec(dllexport)
00064 #else
00065 #define DLLEXPORT __declspec(dllimport)
00066 #endif
00067 #define DLLLOCAL
00068 #else
00069 #ifdef HAVE_GCC_VISIBILITY
00070 #define DLLEXPORT __attribute__ ((visibility("default")))
00071 #define DLLLOCAL __attribute__ ((visibility("hidden")))
00072 #else
00073 #define DLLEXPORT
00074 #define DLLLOCAL
00075 #endif
00076 #endif
00077
00078 #define _Q_MAKE_STRING(x) #x
00079 #define MAKE_STRING_FROM_SYMBOL(x) _Q_MAKE_STRING(x)
00080
00081 class AbstractQoreNode;
00082 class QoreListNode;
00083 class ExceptionSink;
00084 class QoreObject;
00085 class AbstractPrivateData;
00086
00088 template <typename T> struct free_ptr : std::unary_function <T*, void> {
00089 void operator()(T *ptr) {
00090 free(ptr);
00091 }
00092 };
00093
00095 template <typename T> struct simple_delete {
00096 void operator()(T *ptr) {
00097 delete ptr;
00098 }
00099 };
00100
00102 template <typename T> struct simple_deref {
00103 void operator()(T *ptr) {
00104 ptr->deref();
00105 }
00106 void operator()(T *ptr, ExceptionSink *xsink) {
00107 ptr->deref(xsink);
00108 }
00109 };
00110
00112 class ltstr {
00113 public:
00114 bool operator()(const char* s1, const char* s2) const {
00115 return strcmp(s1, s2) < 0;
00116 }
00117 };
00118
00120 class ltcstrcase {
00121 public:
00122 bool operator()(const char* s1, const char* s2) const {
00123 return strcasecmp(s1, s2) < 0;
00124 }
00125 };
00126
00128 class ltstrcase {
00129 public:
00130 bool operator()(std::string s1, std::string s2) const {
00131 return strcasecmp(s1.c_str(), s2.c_str()) < 0;
00132 }
00133 };
00134
00136 class ltchar {
00137 public:
00138 bool operator()(const char s1, const char s2) const {
00139 return s1 < s2;
00140 }
00141 };
00142
00144 class cstr_vector_t : public std::vector<char *> {
00145 public:
00146 DLLLOCAL ~cstr_vector_t() {
00147 std::for_each(begin(), end(), free_ptr<char>());
00148 }
00149 };
00150
00151 #include <set>
00152 typedef std::set<char *, ltstr> strset_t;
00153
00154 typedef long long int64;
00155
00156 #include <stdarg.h>
00157
00158 class QoreMethod;
00159 class QoreBuiltinMethod;
00160 class QoreClass;
00161
00163
00167 typedef AbstractQoreNode *(*q_func_t)(const QoreListNode *args, ExceptionSink *xsink);
00168
00170
00176 typedef AbstractQoreNode *(*q_method_t)(QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00177
00179
00186 typedef AbstractQoreNode *(*q_method2_t)(const QoreMethod &method, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00187
00189
00194 typedef AbstractQoreNode *(*q_static_method2_t)(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00195
00197
00201 typedef void (*q_constructor_t)(QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00202
00204
00209 typedef void (*q_constructor2_t)(const QoreClass &thisclass, QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00210
00212
00219 typedef void (*q_system_constructor_t)(QoreObject *self, int code, va_list args);
00220
00222
00229 typedef void (*q_system_constructor2_t)(const QoreClass &thisclass, QoreObject *self, int code, va_list args);
00230
00232
00237 typedef void (*q_destructor_t)(QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00238
00240
00245 typedef void (*q_destructor2_t)(const QoreClass &thisclass, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00246
00248
00254 typedef void (*q_copy_t)(QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00255
00257
00264 typedef void (*q_copy2_t)(const QoreClass &thisclass, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00265
00267
00272 typedef bool (*q_delete_blocker_t)(QoreObject *self, AbstractPrivateData *private_data);
00273
00274 DLLEXPORT long long q_atoll(const char *str);
00275
00276 #endif // _QORE_COMMON_H