1/*------------------------------------------------------------------------------
2* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
3*
4* Distributable under the terms of either the Apache License (Version 2.0) or
5* the GNU Lesser General Public License, as specified in the COPYING file.
6------------------------------------------------------------------------------*/
7#ifndef lucene_sharedheader_h
8#define lucene_sharedheader_h
9
10/**
11* This header contains definitions and macros for helping create cross-platform code.
12* It is primarily for use by the clucene-core library, but is split off so that
13* other applications such as the demo, test, benchmarks, etc can benefit from the
14* cross platform code. Cross platform code is not distributed with the clucene-core
15* and is not available through the shared library.
16*/
17
18#include "CLucene/clucene-config.h"
19
20//some early definitions
21#if defined(_MSC_VER) || defined(__BORLANDC__)
22 #define _LUCENE_PRAGMA_WARNINGS //tell lucene to display warnings using pragmas instead of #warning
23#endif
24
25
26////////////////////////////////////////////////////////
27//Are we in unicode mode?
28////////////////////////////////////////////////////////
29#if defined(_MBCS) || defined(_ASCII)
30 #undef _ASCII
31 #undef _UCS2
32 #define _ASCII
33#elif defined(_UNICODE)
34 #ifndef _UCS2
35 #define _UCS2
36 #endif
37#elif !defined(_UCS2)
38 #define _UCS2
39#endif
40
41//msvc needs unicode define so that it uses unicode library
42#ifdef _UCS2
43 #undef _UNICODE
44 #define _UNICODE
45 #undef _ASCII
46#else
47 #undef _UNICODE
48 #undef _UCS2
49#endif
50////////////////////////////////////////////////////////
51
52
53
54////////////////////////////////////////////////////////
55//platform includes that MUST be included for the public headers to work...
56////////////////////////////////////////////////////////
57#include <cstddef> //need this for wchar_t, size_t, NULL
58#ifdef _CL_HAVE_STDINT_H
59 #include <stdint.h> //need this for int32_t, etc
60#endif
61#include <math.h> //required for float_t
62#include <string> //need to include this really early...
63
64#ifdef _CL_HAVE_TCHAR_H
65 #include <tchar.h> //required for _T and TCHAR
66#endif
67
68////////////////////////////////////////////////////////
69//namespace helper
70////////////////////////////////////////////////////////
71#if defined(_LUCENE_DONTIMPLEMENT_NS_MACROS)
72 //do nothing
73#elif !defined(DISABLE_NAMESPACE) && defined(_CL_HAVE_NAMESPACES)
74 #define CL_NS_DEF(sub) namespace lucene{ namespace sub{
75 #define CL_NS_DEF2(sub,sub2) namespace lucene{ namespace sub{ namespace sub2 {
76
77 #define CL_NS_END }}
78 #define CL_NS_END2 }}}
79
80 #define CL_NS_USE(sub) using namespace lucene::sub;
81 #define CL_NS_USE2(sub,sub2) using namespace lucene::sub::sub2;
82
83 #define CL_NS(sub) lucene::sub
84 #define CL_NS2(sub,sub2) lucene::sub::sub2
85
86 #define CL_STRUCT_DEF(sub,clazz) namespace lucene { namespace sub{ struct clazz; } }
87 #define CL_CLASS_DEF(sub,clazz) namespace lucene { namespace sub{ class clazz; } }
88 #define CL_CLASS_DEF2(sub,sub2, clazz) namespace lucene { namespace sub{ namespace sub2{ class clazz; } } }
89
90 #define CL_TEMPATE_DEF(sub, clazz, typedefs) namespace lucene { namespace sub{ template<typedefs> class clazz; }}
91 #define CL_TYPE_DEF(sub, clazz, def) namespace lucene { namespace sub{ typedef def clazz; }}
92#else
93 #define CL_NS_DEF(sub)
94 #define CL_NS_DEF2(sub, sub2)
95 #define CL_NS_END
96 #define CL_NS_END2
97 #define CL_NS_USE(sub)
98 #define CL_NS_USE2(sub,sub2)
99 #define CL_NS(sub)
100 #define CL_NS2(sub,sub2)
101 #define CL_CLASS_DEF(sub,clazz) class clazz;
102 #define CL_CLASS_DEF2(sub,sub2, clazz) class clazz;
103#endif
104
105#if defined(LUCENE_NO_STDC_NAMESPACE)
106 //todo: haven't actually tested this on a non-stdc compliant compiler
107 #define CL_NS_STD(func) ::func
108#else
109 #define CL_NS_STD(func) std::func
110#endif
111//
112////////////////////////////////////////////////////////
113
114////////////////////////////////////////////////////////
115// EXPORTS definition
116////////////////////////////////////////////////////////
117#if defined(_WIN32) || defined(_WIN64)
118 #define CLUCENE_EXPORT_DECL __declspec(dllexport)
119 #define CLUCENE_IMPORT_DECL __declspec(dllimport)
120 #define CLUCENE_LOCAL_DECL
121#elif defined(_CL_HAVE_GCCVISIBILITYPATCH)
122 #define CLUCENE_EXPORT_DECL __attribute__ ((visibility("default")))
123 #define CLUCENE_LOCAL_DECL __attribute__ ((visibility("hidden")))
124 #define CLUCENE_IMPORT_DECL
125#else
126 #define CLUCENE_EXPORT_DECL
127 #define CLUCENE_IMPORT_DECL
128 #define CLUCENE_LOCAL_DECL
129#endif
130
131//define for the libraries
132#if defined(clucene_shared_EXPORTS)
133 #define CLUCENE_SHARED_EXPORT CLUCENE_EXPORT_DECL
134 #define CLUCENE_LOCAL CLUCENE_LOCAL_DECL
135#elif defined(MAKE_CLUCENE_SHARED_LIB)
136 #define CLUCENE_SHARED_EXPORT //don't export if we are building a static library
137#else
138 #define CLUCENE_SHARED_EXPORT CLUCENE_IMPORT_DECL
139#endif
140#if defined(clucene_core_EXPORTS)
141 #define CLUCENE_EXPORT CLUCENE_EXPORT_DECL
142 #define CLUCENE_LOCAL CLUCENE_LOCAL_DECL
143#elif defined(MAKE_CLUCENE_CORE_LIB)
144 #define CLUCENE_EXPORT
145#else
146 #define CLUCENE_EXPORT CLUCENE_IMPORT_DECL
147#endif
148#if defined(clucene_contribs_lib_EXPORTS)
149 #define CLUCENE_CONTRIBS_EXPORT CLUCENE_EXPORT_DECL
150 #define CLUCENE_LOCAL CLUCENE_LOCAL_DECL
151#elif defined(MAKE_CLUCENE_CONTRIBS_LIB)
152 #define CLUCENE_CONTRIBS_EXPORT
153#else
154 #define CLUCENE_CONTRIBS_EXPORT CLUCENE_IMPORT_DECL
155#endif
156#ifndef CLUCENE_LOCAL
157 #define CLUCENE_LOCAL
158#endif
159
160//inline definitions
161#if defined(__MINGW32__) || defined(_MSC_VER)
162 #define CLUCENE_SHARED_INLINE_EXPORT
163 #define CLUCENE_INLINE_EXPORT
164 #define CLUCENE_CONTRIBS_INLINE_EXPORT
165#else
166 #define CLUCENE_SHARED_INLINE_EXPORT CLUCENE_SHARED_EXPORT
167 #define CLUCENE_INLINE_EXPORT CLUCENE_EXPORT
168 #define CLUCENE_CONTRIBS_INLINE_EXPORT CLUCENE_CONTRIBS_EXPORT
169#endif
170////////////////////////////////////////////////////////
171
172
173//todo: put this logic in cmake
174#if defined(_MSC_VER)
175 #if _MSC_FULL_VER >= 140050320
176 #define _CL_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
177 #elif _MSC_VER >= 1300
178 #define _CL_DEPRECATE_TEXT(_Text) __declspec(deprecated)
179 #else
180 #define _CL_DEPRECATE_TEXT(_Text)
181 #endif
182#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
183 #define _CL_DEPRECATE_TEXT(_Text) __attribute__((__deprecated__))
184#else
185 #define _CL_DEPRECATE_TEXT(_Text)
186#endif
187#define _CL_DEPRECATED(_NewItem) _CL_DEPRECATE_TEXT("This function or variable has been superceded by newer library or operating system functionality. Consider using " #_NewItem " instead. See online help for details.")
188//
189////////////////////////////////////////////////////////
190
191////////////////////////////////////////////////////////
192// boost stuff
193////////////////////////////////////////////////////////
194#if defined(_MSC_VER)
195# pragma warning (disable : 4251) // disable exported dll function
196# endif
197
198////////////////////////////////////////////////////////
199//Class interfaces
200////////////////////////////////////////////////////////
201#include "CLucene/debug/lucenebase.h"
202////////////////////////////////////////////////////////
203
204//memory handling macros/functions
205#include "CLucene/debug/mem.h"
206
207#ifdef DMALLOC
208 #include <stdlib.h>
209 #include <string.h>
210 #include <dmalloc.h>
211#endif
212
213#endif //lucene_sharedheader_h
214