1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team.
|
---|
4 | ** All rights reserved.
|
---|
5 | **
|
---|
6 | ** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
7 | ** All rights reserved.
|
---|
8 | **
|
---|
9 | ** This file may be used under the terms of the GNU Lesser General Public
|
---|
10 | ** License version 2.1 as published by the Free Software Foundation and
|
---|
11 | ** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
---|
12 | ** Please review the following information to ensure the GNU Lesser General
|
---|
13 | ** Public License version 2.1 requirements will be met:
|
---|
14 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
15 | **
|
---|
16 | ****************************************************************************/
|
---|
17 |
|
---|
18 | #ifndef QCLUCENE_GLOBAL_P_H
|
---|
19 | #define QCLUCENE_GLOBAL_P_H
|
---|
20 |
|
---|
21 | //
|
---|
22 | // W A R N I N G
|
---|
23 | // -------------
|
---|
24 | //
|
---|
25 | // This file is not part of the Qt API. It exists for the convenience
|
---|
26 | // of the help generator tools. This header file may change from version
|
---|
27 | // to version without notice, or even be removed.
|
---|
28 | //
|
---|
29 | // We mean it.
|
---|
30 | //
|
---|
31 |
|
---|
32 | #if !defined(_MSC_VER)
|
---|
33 | # include "qclucene-config_p.h"
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include <QtCore/QChar>
|
---|
37 | #include <QtCore/QString>
|
---|
38 |
|
---|
39 | #if !defined(_MSC_VER) && !defined(__MINGW32__) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T)
|
---|
40 | # if !defined(TCHAR)
|
---|
41 | # if defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) && !defined(_ASCII)
|
---|
42 | # define TCHAR wchar_t
|
---|
43 | # else
|
---|
44 | # define TCHAR char
|
---|
45 | # endif
|
---|
46 | # endif
|
---|
47 | #else
|
---|
48 | # include <windows.h>
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | QT_BEGIN_HEADER
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | #if !defined(QT_SHARED) && !defined(QT_DLL)
|
---|
56 | # define QHELP_EXPORT
|
---|
57 | #elif defined(QHELP_LIB)
|
---|
58 | # define QHELP_EXPORT Q_DECL_EXPORT
|
---|
59 | #else
|
---|
60 | # define QHELP_EXPORT Q_DECL_IMPORT
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | //
|
---|
64 | // W A R N I N G
|
---|
65 | // -------------
|
---|
66 | //
|
---|
67 | // adjustments here, need to be done in
|
---|
68 | // QTDIR/src/3rdparty/clucene/src/CLucene/StdHeader.h as well
|
---|
69 | //
|
---|
70 | #if defined(_LUCENE_DONTIMPLEMENT_NS_MACROS)
|
---|
71 |
|
---|
72 | #elif !defined(DISABLE_NAMESPACE)
|
---|
73 | # ifdef QT_NAMESPACE
|
---|
74 | # define CL_NS_DEF(sub) namespace QT_NAMESPACE { namespace lucene{ namespace sub{
|
---|
75 | # define CL_NS_DEF2(sub,sub2) namespace QT_NAMESPACE { 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 QT_NAMESPACE::lucene::sub;
|
---|
81 | # define CL_NS_USE2(sub,sub2) using namespace QT_NAMESPACE::lucene::sub::sub2;
|
---|
82 |
|
---|
83 | # define CL_NS(sub) QT_NAMESPACE::lucene::sub
|
---|
84 | # define CL_NS2(sub,sub2) QT_NAMESPACE::lucene::sub::sub2
|
---|
85 | # else
|
---|
86 | # define CL_NS_DEF(sub) namespace lucene{ namespace sub{
|
---|
87 | # define CL_NS_DEF2(sub,sub2) namespace lucene{ namespace sub{ namespace sub2 {
|
---|
88 |
|
---|
89 | # define CL_NS_END }}
|
---|
90 | # define CL_NS_END2 }}}
|
---|
91 |
|
---|
92 | # define CL_NS_USE(sub) using namespace lucene::sub;
|
---|
93 | # define CL_NS_USE2(sub,sub2) using namespace lucene::sub::sub2;
|
---|
94 |
|
---|
95 | # define CL_NS(sub) lucene::sub
|
---|
96 | # define CL_NS2(sub,sub2) lucene::sub::sub2
|
---|
97 | # endif
|
---|
98 | #else
|
---|
99 | # define CL_NS_DEF(sub)
|
---|
100 | # define CL_NS_DEF2(sub, sub2)
|
---|
101 | # define CL_NS_END
|
---|
102 | # define CL_NS_END2
|
---|
103 | # define CL_NS_USE(sub)
|
---|
104 | # define CL_NS_USE2(sub,sub2)
|
---|
105 | # define CL_NS(sub)
|
---|
106 | # define CL_NS2(sub,sub2)
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | namespace {
|
---|
110 | TCHAR* QStringToTChar(const QString &str)
|
---|
111 | {
|
---|
112 | #if (defined(UNICODE) || (defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T))) && !defined(_ASCII)
|
---|
113 | wchar_t *string = new wchar_t[(str.length() +1) * sizeof(wchar_t)];
|
---|
114 | memset(string, 0, (str.length() +1) * sizeof(wchar_t));
|
---|
115 | str.toWCharArray(string);
|
---|
116 | return string;
|
---|
117 | #else
|
---|
118 | const QByteArray ba = str.toLocal8Bit();
|
---|
119 | char *string = new char[ba.length() + 1];
|
---|
120 | strcpy(string, ba.constData());
|
---|
121 | return string;
|
---|
122 | #endif
|
---|
123 | }
|
---|
124 |
|
---|
125 | int QStringToTChar(const QString &str, TCHAR *string)
|
---|
126 | {
|
---|
127 | #if (defined(UNICODE) || (defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T))) && !defined(_ASCII)
|
---|
128 | return str.toWCharArray(string);
|
---|
129 | #else
|
---|
130 | const QByteArray ba = str.toLocal8Bit();
|
---|
131 | strncpy(string, ba.constData(), ba.length());
|
---|
132 | return ba.length();
|
---|
133 | #endif
|
---|
134 | }
|
---|
135 |
|
---|
136 | QString TCharToQString(const TCHAR *string, int size = -1)
|
---|
137 | {
|
---|
138 | #if (defined(UNICODE) || (defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T))) && !defined(_ASCII)
|
---|
139 | QString retValue = QString::fromWCharArray(string, size);
|
---|
140 | return retValue;
|
---|
141 | #else
|
---|
142 | return QString::fromLocal8Bit(string);
|
---|
143 | #endif
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | QT_END_NAMESPACE
|
---|
148 |
|
---|
149 | QT_END_HEADER
|
---|
150 |
|
---|
151 | #endif // QCLUCENE_GLOBAL_P_H
|
---|