2
2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
4
* Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
6
6
* The contents of this file are subject to the terms of either the GNU Lesser
7
7
* General Public License Version 2.1 only ("LGPL") or the Common Development and
8
8
* Distribution License ("CDDL")(collectively, the "License"). You may not use this
9
9
* file except in compliance with the License. You can obtain a copy of the CDDL at
10
10
* http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at
11
* http://www.opensource.org/licenses/lgpl-license.php. See the License for the
11
* http://www.opensource.org/licenses/lgpl-license.php. See the License for the
12
12
* specific language governing permissions and limitations under the License. When
13
13
* distributing the software, include this License Header Notice in each file and
14
14
* include the full text of the License in the License file as well as the
15
15
* following notice:
17
17
* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
19
19
* For Covered Software in this distribution, this License shall be governed by the
21
21
* Any litigation relating to this License shall be subject to the jurisdiction of
22
22
* the Federal Courts of the Northern District of California and the state courts
23
23
* of the State of California, with venue lying in Santa Clara County, California.
27
27
* If you wish your version of this file to be governed by only the CDDL or only
28
28
* the LGPL Version 2.1, indicate your decision by adding "[Contributor]" elects to
29
29
* include this software in this distribution under the [CDDL or LGPL Version 2.1]
32
32
* Version 2.1, or to extend the choice of license to its licensees as provided
33
33
* above. However, if you add LGPL Version 2.1 code and therefore, elected the LGPL
34
34
* Version 2 license, then the option applies only if the new code is made subject
35
* to such option by the copyright holder.
35
* to such option by the copyright holder.
38
38
#ifndef ___SUN_SLM_PORTABILITY_H___
62
63
#else // HOST_OS_GNUC_2
63
64
#if defined(DEBUG) && !defined(NDEBUG)
64
#define DEBUG_print(fmt, a...) fprintf(stderr, fmt, a...)
65
#define DEBUG_print(fmt, a ...) fprintf(stderr, fmt, a ...)
66
#define DEBUG_print(fmt, a...) (int(0))
67
#define DEBUG_print(fmt, a ...) (int(0))
68
69
#endif // !HOST_OS_GNUC_2
116
114
TLongExpFloat(const TLongExpFloat& b) : m_base(b.m_base), m_exp(b.m_exp) { }
118
TLongExpFloat(int exp = 0, double base=0.0) : m_base(base), m_exp(exp) { }
116
TLongExpFloat(int exp = 0, double base = 0.0) : m_base(base), m_exp(exp) { }
120
118
TLongExpFloat(double d);
123
operator* (const TLongExpFloat& b) const;
121
operator*(const TLongExpFloat& b) const;
126
operator/ (const TLongExpFloat& b) const;
124
operator/(const TLongExpFloat& b) const;
129
operator< (const TLongExpFloat& b) const;
127
operator<(const TLongExpFloat& b) const;
132
130
operator<=(const TLongExpFloat& b) const;
138
136
toString(std::string& str) const;
141
toString(char* buf) const
142
{if (buf) sprintf(buf, "%10lf*2^%d", m_base, m_exp);}
138
void toString(char* buf) const
139
{ if (buf) sprintf(buf, "%10lf*2^%d", m_base, m_exp); }
145
log2() const { return ::log2(m_base) + m_exp; }
141
double log2() const { return ::log2(m_base) + m_exp; }
153
* UCS4 wide character type, system dependent
154
* Multibytes string in this program is UTF-8 only
156
typedef unsigned int TWCHAR;
149
* UCS4 wide character type, system dependent
150
* Multibytes string in this program is UTF-8 only
152
typedef unsigned int TWCHAR;
158
154
#if !defined(WORDS_BIGENDIAN)
159
155
#define TWCHAR_ICONV_NAME "UCS-4LE"
161
157
#define TWCHAR_ICONV_NAME "UCS-4BE"
164
typedef TWCHAR TSIMWordId;
166
const TSIMWordId SIM_ID_NOT_WORD = (0x0);
167
const TSIMWordId SIM_ID_UNKNOWN_CN = (2);
168
const TSIMWordId SIM_ID_SEN_TOKEN = (10);
169
const TSIMWordId SIM_ID_DIGIT = (20);
170
const TSIMWordId SIM_ID_SIMBOL = (21);
171
const TSIMWordId SIM_ID_DUMMY_WORD = (69);
172
const TSIMWordId SIM_ID_NONWORD = (69);
173
const TSIMWordId SIM_ID_ALLWORD = (69);
174
const TSIMWordId SIM_ID_REALWORD_START = (70);
175
const TSIMWordId SIM_ID_CNWORD_START = (100);
177
const TWCHAR WCH_NULL = 0;
178
const TWCHAR WCH_RETURN = '\n';
179
const TWCHAR WCH_TAB = '\t';
180
const TWCHAR WCH_SPACE = ' ';
181
const TWCHAR WCH_LESSTHAN = '<';
182
const TWCHAR WCH_GREATERTHAN = '>';
184
const TWCHAR WCH_DOUBLESPACE = 0x3000;
185
const TWCHAR WCH_JUHAO = 0x3002;
186
const TWCHAR WCH_WENHAO = 0xFF1F;
187
const TWCHAR WCH_TANHAO = 0xFF01;
188
const TWCHAR WCH_FENHAO = 0xFF1B;
189
const TWCHAR WCH_MAOHAO = 0xFF1A;
190
const TWCHAR WCH_DOUHAO = 0xFF0C;
191
const TWCHAR WCH_ZUOKUOHAO = 0x201C;
192
const TWCHAR WCH_YOUKUOHAO = 0x201D;
193
const TWCHAR WCH_SHENGLUEHAO = 0x2026;
160
typedef TWCHAR TSIMWordId;
162
const TSIMWordId SIM_ID_NOT_WORD = (0x0);
163
const TSIMWordId SIM_ID_UNKNOWN_CN = (2);
164
const TSIMWordId SIM_ID_SEN_TOKEN = (10);
165
const TSIMWordId SIM_ID_DIGIT = (20);
166
const TSIMWordId SIM_ID_SIMBOL = (21);
167
const TSIMWordId SIM_ID_DUMMY_WORD = (69);
168
const TSIMWordId SIM_ID_NONWORD = (69);
169
const TSIMWordId SIM_ID_ALLWORD = (69);
170
const TSIMWordId SIM_ID_REALWORD_START = (70);
171
const TSIMWordId SIM_ID_CNWORD_START = (100);
173
const TWCHAR WCH_NULL = 0;
174
const TWCHAR WCH_RETURN = '\n';
175
const TWCHAR WCH_TAB = '\t';
176
const TWCHAR WCH_SPACE = ' ';
177
const TWCHAR WCH_LESSTHAN = '<';
178
const TWCHAR WCH_GREATERTHAN = '>';
180
const TWCHAR WCH_DOUBLESPACE = 0x3000;
181
const TWCHAR WCH_JUHAO = 0x3002;
182
const TWCHAR WCH_WENHAO = 0xFF1F;
183
const TWCHAR WCH_TANHAO = 0xFF01;
184
const TWCHAR WCH_FENHAO = 0xFF1B;
185
const TWCHAR WCH_MAOHAO = 0xFF1A;
186
const TWCHAR WCH_DOUHAO = 0xFF0C;
187
const TWCHAR WCH_ZUOKUOHAO = 0x201C;
188
const TWCHAR WCH_YOUKUOHAO = 0x201D;
189
const TWCHAR WCH_SHENGLUEHAO = 0x2026;
196
192
size_t MBSTOWCS(TWCHAR *pwcs, const char* s, size_t n);
208
203
struct char_traits<TWCHAR>
209
204
#endif // HOST_OS_GNUC_2
211
typedef TWCHAR char_type;
212
typedef unsigned int int_type;
206
typedef TWCHAR char_type;
207
typedef unsigned int int_type;
213
208
#ifndef HOST_OS_GNUC_2
214
typedef streamoff off_type;
215
typedef wstreampos pos_type;
216
typedef mbstate_t state_type;
209
typedef streamoff off_type;
210
typedef wstreampos pos_type;
211
typedef mbstate_t state_type;
217
212
#endif // !HOST_OS_GNUC_2
220
assign(char_type& __c1, const char_type& __c2)
214
static void assign(char_type& __c1, const char_type& __c2)
224
eq(const char_type& __c1, const char_type& __c2)
217
static bool eq(const char_type& __c1, const char_type& __c2)
225
218
{ return __c1 == __c2; }
228
lt(const char_type& __c1, const char_type& __c2)
220
static bool lt(const char_type& __c1, const char_type& __c2)
229
221
{ return __c1 < __c2; }
232
compare(const char_type* __s1, const char_type* __s2, size_t __n)
234
for (size_t i=0; i < __n; ++i) {
223
static int compare(const char_type* __s1, const char_type* __s2,
225
for (size_t i = 0; i < __n; ++i) {
235
226
if (*__s1 < *__s2)
237
228
else if (*__s1++ == *__s2++)
246
length(const char_type* __s)
236
static size_t length(const char_type* __s)
247
237
{ return WCSLEN(__s); }
250
copy(char_type* __s1, const char_type* __s2, size_t __n)
252
return static_cast<char_type*>(memcpy(__s1, __s2, __n*sizeof(char_type)));
239
static char_type*copy(char_type* __s1, const char_type* __s2,
241
return static_cast<char_type*>(memcpy(__s1, __s2, __n *
256
move(char_type* __s1, const char_type* __s2, int_type __n)
258
return static_cast<char_type*>(memmove(__s1, __s2, __n*sizeof(char_type)));
245
static char_type*move(char_type* __s1, const char_type* __s2,
247
return static_cast<char_type*>(memmove(__s1, __s2, __n *
261
251
#ifndef HOST_OS_GNUC_2
262
static const char_type*
263
find(const char_type* __s, size_t __n, const char_type& __a)
252
static const char_type*find(const char_type* __s,
254
const char_type& __a) {
266
256
if (*__s++ == __a)
273
to_char_type(const int_type& __c) { return char_type(__c); }
276
to_int_type(const char_type& __c) { return int_type(__c); }
279
eq_int_type(const int_type& __c1, const int_type& __c2)
262
static char_type to_char_type(const int_type& __c) { return char_type(__c); }
264
static int_type to_int_type(const char_type& __c) { return int_type(__c); }
266
static bool eq_int_type(const int_type& __c1, const int_type& __c2)
280
267
{ return __c1 == __c2; }
283
eof() { return static_cast<int_type>(WEOF); }
269
static int_type eof() { return static_cast<int_type>(WEOF); }
286
not_eof(const int_type& __c)
271
static int_type not_eof(const int_type& __c)
287
272
{ return eq_int_type(__c, eof()) ? 0 : __c; }
290
assign(char_type* __s, size_t __n, char_type __a)
292
for (char_type *p = __s; __n--;)
274
static char_type*assign(char_type* __s, size_t __n,
276
for (char_type *p = __s; __n--; )
303
287
static bool is_del(char_type a)
304
288
{ return a == WCH_SPACE; }
306
static char_type* set(char_type* __s, char_type __a, size_t __n)
308
for (char_type *p = __s; __n--;)
290
static char_type* set(char_type* __s, char_type __a, size_t __n){
291
for (char_type *p = __s; __n--; )
312
295
#endif // !HOST_OS_GNUC_2
315
297
}; // namespace std
317
299
#ifndef HOST_OS_GNUC_2
318
typedef std::basic_string<TWCHAR> wstring;
300
typedef std::basic_string<TWCHAR> wstring;
319
301
#else // HOST_OS_GNUC_2
320
class wstring : public std::basic_string<TWCHAR>
323
inline wstring() : std::basic_string<TWCHAR>((TWCHAR)0) {}
324
inline wstring(const TWCHAR* c) : std::basic_string<TWCHAR>(c) {}
325
inline wstring(const TWCHAR* c, size_t n) : std::basic_string<TWCHAR>(c, n) {}
326
inline void push_back(TWCHAR c) { this->append(1, c); }
327
inline void clear(void) { this->resize(0); }
328
inline const TWCHAR* c_str(void) const
330
static TWCHAR null_s = 0;
331
if (this->length() == 0) return &null_s;
332
*(const_cast<TWCHAR*>(this->data()) + this->length()) = 0;
302
class wstring : public std::basic_string<TWCHAR>
305
inline wstring() : std::basic_string<TWCHAR>((TWCHAR) 0) {}
306
inline wstring(const TWCHAR* c) : std::basic_string<TWCHAR>(c) {}
307
inline wstring(const TWCHAR* c, size_t n) : std::basic_string<TWCHAR>(c,
309
inline void push_back(TWCHAR c) { this->append(1, c); }
310
inline void clear(void) { this->resize(0); }
311
inline const TWCHAR* c_str(void) const {
312
static TWCHAR null_s = 0;
313
if (this->length() == 0) return &null_s;
314
*(const_cast<TWCHAR*>(this->data()) + this->length()) = 0;
336
318
#endif // !HOST_OS_GNUC_2
338
320
#ifdef _RW_STD_STL
339
321
template <class Iterator>
340
inline long distance (Iterator pos1, Iterator pos2)
343
distance (pos1, pos2, d);
322
inline long distance(Iterator pos1, Iterator pos2){
324
distance(pos1, pos2, d);
348
#if !defined (HAVE_STRNDUP)
349
extern "C" char *strndup( const char *s, size_t n );
350
#endif //HAVE_STRNDUP