1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * $Log: utypes.h,v $
|
---|
59 | * Revision 1.2 2002/11/04 15:14:33 tng
|
---|
60 | * C++ Namespace Support.
|
---|
61 | *
|
---|
62 | * Revision 1.1.1.1 2002/02/01 22:22:36 peiyongz
|
---|
63 | * sane_include
|
---|
64 | *
|
---|
65 | * Revision 1.1 2000/02/10 18:08:28 abagchi
|
---|
66 | * Initial checkin
|
---|
67 | *
|
---|
68 | */
|
---|
69 |
|
---|
70 | #ifndef UTYPES_H
|
---|
71 | #define UTYPES_H
|
---|
72 | #include <wchar.h>
|
---|
73 | #include <stdlib.h>
|
---|
74 |
|
---|
75 | /*===========================================================================*/
|
---|
76 | /* Include platform-dependent definitions */
|
---|
77 | /* which are contained in the platform-specific file platform.h */
|
---|
78 | /*===========================================================================*/
|
---|
79 |
|
---|
80 | #include "pos400.h"
|
---|
81 |
|
---|
82 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
83 |
|
---|
84 | /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when
|
---|
85 | using C++. It should not be defined when compiling under C. */
|
---|
86 | #ifdef __cplusplus
|
---|
87 | # ifndef XP_CPLUSPLUS
|
---|
88 | # define XP_CPLUSPLUS
|
---|
89 | # endif
|
---|
90 | #else
|
---|
91 | # undef XP_CPLUSPLUS
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | /*===========================================================================*/
|
---|
95 | /* Boolean data type */
|
---|
96 | /*===========================================================================*/
|
---|
97 |
|
---|
98 | #if ! HAVE_BOOL_T
|
---|
99 | typedef int8_t bool_t;
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | #ifndef TRUE
|
---|
103 | # define TRUE 1
|
---|
104 | #endif
|
---|
105 | #ifndef FALSE
|
---|
106 | # define FALSE 0
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /*===========================================================================*/
|
---|
110 | /* Unicode string offset */
|
---|
111 | /*===========================================================================*/
|
---|
112 | typedef int32_t UTextOffset;
|
---|
113 |
|
---|
114 | /*===========================================================================*/
|
---|
115 | /* Unicode character */
|
---|
116 | /*===========================================================================*/
|
---|
117 | typedef uint16_t UChar;
|
---|
118 |
|
---|
119 |
|
---|
120 | /*===========================================================================*/
|
---|
121 | /* For C wrappers, we use the symbol U_CAPI. */
|
---|
122 | /* This works properly if the includer is C or C++. */
|
---|
123 | /* Functions are declared U_CAPI return-type U_EXPORT2 function-name() ... */
|
---|
124 | /*===========================================================================*/
|
---|
125 |
|
---|
126 | #ifdef XP_CPLUSPLUS
|
---|
127 | # define U_CFUNC extern "C"
|
---|
128 | # define U_CDECL_BEGIN extern "C" {
|
---|
129 | # define U_CDECL_END }
|
---|
130 | #else
|
---|
131 | # define U_CFUNC
|
---|
132 | # define U_CDECL_BEGIN
|
---|
133 | # define U_CDECL_END
|
---|
134 | #endif
|
---|
135 | #define U_CAPI U_CFUNC U_EXPORT
|
---|
136 |
|
---|
137 |
|
---|
138 | /* Define NULL pointer value if it isn't already defined */
|
---|
139 |
|
---|
140 | #ifndef NULL
|
---|
141 | #ifdef XP_CPLUSPLUS
|
---|
142 | #define NULL 0
|
---|
143 | #else
|
---|
144 | #define NULL ((void *)0)
|
---|
145 | #endif
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | /* Maximum value of a (void*) - use to indicate the limit of
|
---|
149 | an 'infinite' buffer. */
|
---|
150 | #define U_MAX_PTR ((void*)-1)
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | /*===========================================================================*/
|
---|
155 | /* UErrorCode */
|
---|
156 | /*===========================================================================*/
|
---|
157 |
|
---|
158 | /** Error code to replace exception handling */
|
---|
159 | #ifdef __OS400__
|
---|
160 | enum UErrorCode1 {
|
---|
161 | #else
|
---|
162 | enum UErrorCode {
|
---|
163 | #endif
|
---|
164 | U_ERROR_INFO_START = -128, /* Start of information results (semantically successful) */
|
---|
165 | U_USING_FALLBACK_ERROR = -128,
|
---|
166 | U_USING_DEFAULT_ERROR = -127,
|
---|
167 | U_ERROR_INFO_LIMIT,
|
---|
168 |
|
---|
169 | U_ZERO_ERROR = 0, /* success */
|
---|
170 |
|
---|
171 | U_ILLEGAL_ARGUMENT_ERROR = 1, /* Start of codes indicating failure */
|
---|
172 | U_MISSING_RESOURCE_ERROR = 2,
|
---|
173 | U_INVALID_FORMAT_ERROR = 3,
|
---|
174 | U_FILE_ACCESS_ERROR = 4,
|
---|
175 | U_INTERNAL_PROGRAM_ERROR = 5, /* Indicates a bug in the library code */
|
---|
176 | U_MESSAGE_PARSE_ERROR = 6,
|
---|
177 | U_MEMORY_ALLOCATION_ERROR = 7, /* Memory allocation error */
|
---|
178 | U_INDEX_OUTOFBOUNDS_ERROR = 8,
|
---|
179 | U_PARSE_ERROR = 9, /* Equivalent to Java ParseException */
|
---|
180 | U_INVALID_CHAR_FOUND = 10, /* In the Character conversion routines: Invalid character or sequence was encountered*/
|
---|
181 | U_TRUNCATED_CHAR_FOUND = 11, /* In the Character conversion routines: More bytes are required to complete the conversion successfully*/
|
---|
182 | U_ILLEGAL_CHAR_FOUND = 12, /* In codeset conversion: a sequence that does NOT belong in the codepage has been encountered*/
|
---|
183 | U_INVALID_TABLE_FORMAT = 13, /* Conversion table file found, but corrupted*/
|
---|
184 | U_INVALID_TABLE_FILE = 14, /* Conversion table file not found*/
|
---|
185 | U_BUFFER_OVERFLOW_ERROR = 15, /* A result would not fit in the supplied buffer */
|
---|
186 | U_UNSUPPORTED_ERROR = 16, /* Requested operation not supported in current context */
|
---|
187 | U_ERROR_LIMIT
|
---|
188 | };
|
---|
189 | #ifdef __OS400__
|
---|
190 | typedef int UErrorCode;
|
---|
191 | #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
|
---|
192 | #define U_FAILURE(x) ((x)>U_ZERO_ERROR)
|
---|
193 | #else
|
---|
194 | #ifndef XP_CPLUSPLUS
|
---|
195 | typedef enum UErrorCode UErrorCode;
|
---|
196 | #endif
|
---|
197 | #endif
|
---|
198 |
|
---|
199 |
|
---|
200 | /* Use the following to determine if an UErrorCode represents */
|
---|
201 | /* operational success or failure. */
|
---|
202 | #ifndef __OS400__
|
---|
203 | #ifdef XP_CPLUSPLUS
|
---|
204 | inline bool_t U_SUCCESS(UErrorCode code) { return (bool_t)(code<=U_ZERO_ERROR); }
|
---|
205 | inline bool_t U_FAILURE(UErrorCode code) { return (bool_t)(code>U_ZERO_ERROR); }
|
---|
206 | #else
|
---|
207 | #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
|
---|
208 | #define U_FAILURE(x) ((x)>U_ZERO_ERROR)
|
---|
209 | #endif
|
---|
210 | #endif
|
---|
211 |
|
---|
212 | /* Casting function for int32_t (backward compatibility version, here until
|
---|
213 | T_INT32 is replaced) */
|
---|
214 | #define T_INT32(i) ((int32_t)i)
|
---|
215 |
|
---|
216 |
|
---|
217 | /*===========================================================================*/
|
---|
218 | /* Debugging */
|
---|
219 | /*===========================================================================*/
|
---|
220 |
|
---|
221 | /* remove this */
|
---|
222 |
|
---|
223 | /* This function is useful for debugging; it returns the text name */
|
---|
224 | /* of an UErrorCode result. This is not the most efficient way of */
|
---|
225 | /* doing this but it's just for Debug builds anyway. */
|
---|
226 |
|
---|
227 | /* Do not use these arrays directly: they will move to a .c file! */
|
---|
228 | static const char *
|
---|
229 | _uErrorInfoName[U_ERROR_INFO_LIMIT-U_ERROR_INFO_START]={
|
---|
230 | "U_USING_FALLBACK_ERROR",
|
---|
231 | "U_USING_DEFAULT_ERROR"
|
---|
232 | };
|
---|
233 |
|
---|
234 | static const char *
|
---|
235 | _uErrorName[U_ERROR_LIMIT]={
|
---|
236 | "U_ZERO_ERROR",
|
---|
237 |
|
---|
238 | "U_ILLEGAL_ARGUMENT_ERROR",
|
---|
239 | "U_MISSING_RESOURCE_ERROR",
|
---|
240 | "U_INVALID_FORMAT_ERROR",
|
---|
241 | "U_FILE_ACCESS_ERROR",
|
---|
242 | "U_INTERNAL_PROGRAM_ERROR",
|
---|
243 | "U_MESSAGE_PARSE_ERROR",
|
---|
244 | "U_MEMORY_ALLOCATION_ERROR",
|
---|
245 | "U_INDEX_OUTOFBOUNDS_ERROR",
|
---|
246 | "U_PARSE_ERROR",
|
---|
247 | "U_INVALID_CHAR_FOUND",
|
---|
248 | "U_TRUNCATED_CHAR_FOUND",
|
---|
249 | "U_ILLEGAL_CHAR_FOUND",
|
---|
250 | "U_INVALID_TABLE_FORMAT",
|
---|
251 | "U_INVALID_TABLE_FILE",
|
---|
252 | "U_BUFFER_OVERFLOW_ERROR",
|
---|
253 | "U_UNSUPPORTED_ERROR"
|
---|
254 | };
|
---|
255 |
|
---|
256 | #ifdef XP_CPLUSPLUS
|
---|
257 | inline const char *
|
---|
258 | errorName(UErrorCode code)
|
---|
259 | {
|
---|
260 | if(code>=0 && code<U_ERROR_LIMIT) {
|
---|
261 | return _uErrorName[code];
|
---|
262 | } else if(code>=U_ERROR_INFO_START && code<U_ERROR_INFO_LIMIT) {
|
---|
263 | return _uErrorInfoName[code-U_ERROR_INFO_START];
|
---|
264 | } else {
|
---|
265 | return "[BOGUS UErrorCode]";
|
---|
266 | }
|
---|
267 | }
|
---|
268 | #else
|
---|
269 | # define errorName(code) \
|
---|
270 | ((code)>=0 && (code)<U_ERROR_LIMIT) ? \
|
---|
271 | _uErrorName[code] : \
|
---|
272 | ((code)>=U_ERROR_INFO_START && (code)<U_ERROR_INFO_LIMIT) ? \
|
---|
273 | _uErrorInfoName[code-U_ERROR_INFO_START] : \
|
---|
274 | "[BOGUS UErrorCode]"
|
---|
275 | #endif
|
---|
276 |
|
---|
277 | XERCES_CPP_NAMESPACE_END
|
---|
278 |
|
---|
279 | #endif /* _UTYPES */
|
---|