Qore Programming Language  0.8.3
include/qore/common.h (4311)
Go to the documentation of this file.
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   common.h
00004 
00005   Qore Programming Language
00006 
00007   Copyright 2003 - 2011 David Nichols
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #ifndef _QORE_COMMON_H
00025 
00026 #define _QORE_COMMON_H
00027 
00032 #include <string.h>
00033 #include <strings.h>
00034 #include <stdarg.h>
00035 
00036 #include <string>
00037 #include <functional>
00038 #include <list>
00039 #include <set>
00040 #include <vector>
00041 #include <algorithm>
00042 #include <set>
00043 
00045 #define Q_AF_UNSPEC -1
00046 
00048 #define Q_AF_INET -2
00049 
00051 #define Q_AF_INET6 -3
00052 
00054 #define Q_SOCK_STREAM -1
00055 
00057 typedef signed short qore_type_t;
00058 
00060 typedef unsigned long qore_size_t;
00061 
00063 typedef long qore_offset_t;
00064 
00066 typedef unsigned qore_classid_t;
00067 
00069 typedef std::set<int> int_set_t;
00070 
00072 enum qore_license_t { QL_GPL = 0,         
00073                       QL_LGPL = 1         
00074 };
00075 
00076 #if defined _MSC_VER || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
00077   #ifdef BUILDING_DLL
00078     #define DLLEXPORT __declspec(dllexport)
00079   #else
00080     #define DLLEXPORT __declspec(dllimport)
00081   #endif
00082   #define DLLLOCAL
00083 #else
00084   #ifdef HAVE_GCC_VISIBILITY
00085     #define DLLEXPORT __attribute__ ((visibility("default")))
00086     #define DLLLOCAL __attribute__ ((visibility("hidden")))
00087   #else
00088     #define DLLEXPORT
00089     #define DLLLOCAL
00090   #endif
00091 #endif
00092 
00093 #define _Q_MAKE_STRING(x) #x
00094 #define MAKE_STRING_FROM_SYMBOL(x) _Q_MAKE_STRING(x)
00095 
00096 class AbstractQoreNode;
00097 class QoreListNode;
00098 class ExceptionSink;
00099 class QoreObject;
00100 class AbstractPrivateData;
00101 class QoreMethod;
00102 class QoreBuiltinMethod;
00103 class QoreClass;
00104 class QoreTypeInfo;
00105 
00107 template <typename T> struct free_ptr : std::unary_function <T*, void> {
00108       void operator()(T *ptr) {
00109          free(ptr);
00110       }
00111 };
00112 
00114 template <typename T> struct simple_delete {
00115       void operator()(T *ptr) {
00116          delete ptr;
00117       }
00118 };
00119 
00121 template <typename T> struct simple_deref {
00122       void operator()(T *ptr) {
00123          ptr->deref();
00124       }
00125       void operator()(T *ptr, ExceptionSink *xsink) {
00126          ptr->deref(xsink);
00127       }
00128 };
00129 
00131 class ltstr {
00132   public:
00133    bool operator()(const char* s1, const char* s2) const {
00134       return strcmp(s1, s2) < 0;
00135    }
00136 };
00137 
00139 class ltcstrcase {
00140    public:
00141       bool operator()(const char* s1, const char* s2) const {
00142          return strcasecmp(s1, s2) < 0;
00143       }
00144 };
00145 
00147 class ltstrcase {
00148    public:
00149       bool operator()(std::string s1, std::string s2) const {
00150          return strcasecmp(s1.c_str(), s2.c_str()) < 0;
00151       }
00152 };
00153 
00155 class ltchar {
00156    public:
00157       bool operator()(const char s1, const char s2) const {
00158          return s1 < s2;
00159       }
00160 };
00161 
00163 class cstr_vector_t : public std::vector<char *> {
00164   public:
00165    DLLLOCAL ~cstr_vector_t() {
00166       std::for_each(begin(), end(), free_ptr<char>());
00167    }
00168 };
00169 
00171 typedef std::vector<const QoreTypeInfo *> type_vec_t;
00172 
00174 typedef std::vector<AbstractQoreNode *> arg_vec_t;
00175 
00176 typedef long long int64;
00177 
00179 
00183 typedef AbstractQoreNode *(*q_func_t)(const QoreListNode *args, ExceptionSink *xsink);
00184 
00186 
00192 typedef AbstractQoreNode *(*q_method_t)(QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00193 
00195 
00202 typedef AbstractQoreNode *(*q_method2_t)(const QoreMethod &method, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00203 
00205 
00214 typedef AbstractQoreNode *(*q_method3_t)(const QoreMethod &method, const type_vec_t &typeList, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00215 
00217 
00222 typedef AbstractQoreNode *(*q_static_method2_t)(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00223 
00225 
00232 typedef AbstractQoreNode *(*q_static_method3_t)(const QoreMethod &method, const type_vec_t &typeList, const void *ptr, const QoreListNode *args, ExceptionSink *xsink);
00233 
00235 
00239 typedef void (*q_constructor_t)(QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00240 
00242 
00247 typedef void (*q_constructor2_t)(const QoreClass &thisclass, QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00248 
00250 
00257 typedef void (*q_constructor3_t)(const QoreClass &thisclass, const type_vec_t &typeList, const void *ptr, QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00258 
00260 
00267 typedef void (*q_system_constructor_t)(QoreObject *self, int code, va_list args);
00268 
00270 
00277 typedef void (*q_system_constructor2_t)(const QoreClass &thisclass, QoreObject *self, int code, va_list args);
00278 
00280 
00285 typedef void (*q_destructor_t)(QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00286 
00288 
00294 typedef void (*q_destructor2_t)(const QoreClass &thisclass, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00295 
00297 
00304 typedef void (*q_destructor3_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00305 
00307 
00313 typedef void (*q_copy_t)(QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00314 
00316 
00323 typedef void (*q_copy2_t)(const QoreClass &thisclass, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00324 
00326 
00334 typedef void (*q_copy3_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00335 
00337 
00342 typedef bool (*q_delete_blocker_t)(QoreObject *self, AbstractPrivateData *private_data);
00343 
00345 
00347 typedef unsigned q_trid_t;
00348 
00349 DLLEXPORT long long q_atoll(const char *str);
00350 
00351 #endif // _QORE_COMMON_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines