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 {
00090 void operator()(T *ptr)
00091 {
00092 free(ptr);
00093 }
00094 };
00095
00097 template <typename T> struct simple_delete
00098 {
00099 void operator()(T *ptr)
00100 {
00101 delete ptr;
00102 }
00103 };
00104
00106 template <typename T> struct simple_deref
00107 {
00108 void operator()(T *ptr)
00109 {
00110 ptr->deref();
00111 }
00112 void operator()(T *ptr, ExceptionSink *xsink)
00113 {
00114 ptr->deref(xsink);
00115 }
00116 };
00117
00119 class ltstr
00120 {
00121 public:
00122 bool operator()(const char* s1, const char* s2) const
00123 {
00124 return strcmp(s1, s2) < 0;
00125 }
00126 };
00127
00129 class ltcstrcase
00130 {
00131 public:
00132 bool operator()(const char* s1, const char* s2) const
00133 {
00134 return strcasecmp(s1, s2) < 0;
00135 }
00136 };
00137
00139 class ltstrcase
00140 {
00141 public:
00142 bool operator()(std::string s1, std::string s2) const
00143 {
00144 return strcasecmp(s1.c_str(), s2.c_str()) < 0;
00145 }
00146 };
00147
00149 class ltchar
00150 {
00151 public:
00152 bool operator()(const char s1, const char s2) const
00153 {
00154 return s1 < s2;
00155 }
00156 };
00157
00159 class cstr_vector_t : public std::vector<char *>
00160 {
00161 public:
00162 DLLLOCAL ~cstr_vector_t()
00163 {
00164 std::for_each(begin(), end(), free_ptr<char>());
00165 }
00166 };
00167
00168 #include <set>
00169 typedef std::set<char *, ltstr> strset_t;
00170
00171 typedef long long int64;
00172
00173 #include <stdarg.h>
00174
00176
00180 typedef AbstractQoreNode *(*q_func_t)(const QoreListNode *args, ExceptionSink *xsink);
00181
00183
00189 typedef AbstractQoreNode *(*q_method_t)(QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00190
00192
00196 typedef void (*q_constructor_t)(QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00197
00199
00206 typedef void (*q_system_constructor_t)(QoreObject *self, int code, va_list args);
00207
00209
00214 typedef void (*q_destructor_t)(QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00215
00217
00223 typedef void (*q_copy_t)(QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00224
00226
00231 typedef bool (*q_delete_blocker_t)(QoreObject *self, AbstractPrivateData *private_data);
00232
00233 DLLEXPORT long long q_atoll(const char *str);
00234
00235 #endif // _QORE_COMMON_H