Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

utypes.h

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2000,2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00033 #ifndef UTYPES_H 00034 #define UTYPES_H 00035 #include <wchar.h> 00036 #include <stdlib.h> 00037 00038 /*===========================================================================*/ 00039 /* Include platform-dependent definitions */ 00040 /* which are contained in the platform-specific file platform.h */ 00041 /*===========================================================================*/ 00042 00043 #include "pos400.h" 00044 00045 XERCES_CPP_NAMESPACE_BEGIN 00046 00047 /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when 00048 using C++. It should not be defined when compiling under C. */ 00049 #ifdef __cplusplus 00050 # ifndef XP_CPLUSPLUS 00051 # define XP_CPLUSPLUS 00052 # endif 00053 #else 00054 # undef XP_CPLUSPLUS 00055 #endif 00056 00057 /*===========================================================================*/ 00058 /* Boolean data type */ 00059 /*===========================================================================*/ 00060 00061 #if ! HAVE_BOOL_T 00062 typedef int8_t bool_t; 00063 #endif 00064 00065 #ifndef TRUE 00066 # define TRUE 1 00067 #endif 00068 #ifndef FALSE 00069 # define FALSE 0 00070 #endif 00071 00072 /*===========================================================================*/ 00073 /* Unicode string offset */ 00074 /*===========================================================================*/ 00075 typedef int32_t UTextOffset; 00076 00077 /*===========================================================================*/ 00078 /* Unicode character */ 00079 /*===========================================================================*/ 00080 typedef uint16_t UChar; 00081 00082 00083 /*===========================================================================*/ 00084 /* For C wrappers, we use the symbol U_CAPI. */ 00085 /* This works properly if the includer is C or C++. */ 00086 /* Functions are declared U_CAPI return-type U_EXPORT2 function-name() ... */ 00087 /*===========================================================================*/ 00088 00089 #ifdef XP_CPLUSPLUS 00090 # define U_CFUNC extern "C" 00091 # define U_CDECL_BEGIN extern "C" { 00092 # define U_CDECL_END } 00093 #else 00094 # define U_CFUNC 00095 # define U_CDECL_BEGIN 00096 # define U_CDECL_END 00097 #endif 00098 #define U_CAPI U_CFUNC U_EXPORT 00099 00100 00101 /* Define NULL pointer value if it isn't already defined */ 00102 00103 #ifndef NULL 00104 #ifdef XP_CPLUSPLUS 00105 #define NULL 0 00106 #else 00107 #define NULL ((void *)0) 00108 #endif 00109 #endif 00110 00111 /* Maximum value of a (void*) - use to indicate the limit of 00112 an 'infinite' buffer. */ 00113 #define U_MAX_PTR ((void*)-1) 00114 00115 00116 00117 /*===========================================================================*/ 00118 /* UErrorCode */ 00119 /*===========================================================================*/ 00120 00122 #ifdef __OS400__ 00123 enum UErrorCode1 { 00124 #else 00125 enum UErrorCode { 00126 #endif 00127 U_ERROR_INFO_START = -128, /* Start of information results (semantically successful) */ 00128 U_USING_FALLBACK_ERROR = -128, 00129 U_USING_DEFAULT_ERROR = -127, 00130 U_ERROR_INFO_LIMIT, 00131 00132 U_ZERO_ERROR = 0, /* success */ 00133 00134 U_ILLEGAL_ARGUMENT_ERROR = 1, /* Start of codes indicating failure */ 00135 U_MISSING_RESOURCE_ERROR = 2, 00136 U_INVALID_FORMAT_ERROR = 3, 00137 U_FILE_ACCESS_ERROR = 4, 00138 U_INTERNAL_PROGRAM_ERROR = 5, /* Indicates a bug in the library code */ 00139 U_MESSAGE_PARSE_ERROR = 6, 00140 U_MEMORY_ALLOCATION_ERROR = 7, /* Memory allocation error */ 00141 U_INDEX_OUTOFBOUNDS_ERROR = 8, 00142 U_PARSE_ERROR = 9, /* Equivalent to Java ParseException */ 00143 U_INVALID_CHAR_FOUND = 10, /* In the Character conversion routines: Invalid character or sequence was encountered*/ 00144 U_TRUNCATED_CHAR_FOUND = 11, /* In the Character conversion routines: More bytes are required to complete the conversion successfully*/ 00145 U_ILLEGAL_CHAR_FOUND = 12, /* In codeset conversion: a sequence that does NOT belong in the codepage has been encountered*/ 00146 U_INVALID_TABLE_FORMAT = 13, /* Conversion table file found, but corrupted*/ 00147 U_INVALID_TABLE_FILE = 14, /* Conversion table file not found*/ 00148 U_BUFFER_OVERFLOW_ERROR = 15, /* A result would not fit in the supplied buffer */ 00149 U_UNSUPPORTED_ERROR = 16, /* Requested operation not supported in current context */ 00150 U_ERROR_LIMIT 00151 }; 00152 #ifdef __OS400__ 00153 typedef int UErrorCode; 00154 #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) 00155 #define U_FAILURE(x) ((x)>U_ZERO_ERROR) 00156 #else 00157 #ifndef XP_CPLUSPLUS 00158 typedef enum UErrorCode UErrorCode; 00159 #endif 00160 #endif 00161 00162 00163 /* Use the following to determine if an UErrorCode represents */ 00164 /* operational success or failure. */ 00165 #ifndef __OS400__ 00166 #ifdef XP_CPLUSPLUS 00167 inline bool_t U_SUCCESS(UErrorCode code) { return (bool_t)(code<=U_ZERO_ERROR); } 00168 inline bool_t U_FAILURE(UErrorCode code) { return (bool_t)(code>U_ZERO_ERROR); } 00169 #else 00170 #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) 00171 #define U_FAILURE(x) ((x)>U_ZERO_ERROR) 00172 #endif 00173 #endif 00174 00175 /* Casting function for int32_t (backward compatibility version, here until 00176 T_INT32 is replaced) */ 00177 #define T_INT32(i) ((int32_t)i) 00178 00179 00180 /*===========================================================================*/ 00181 /* Debugging */ 00182 /*===========================================================================*/ 00183 00184 /* remove this */ 00185 00186 /* This function is useful for debugging; it returns the text name */ 00187 /* of an UErrorCode result. This is not the most efficient way of */ 00188 /* doing this but it's just for Debug builds anyway. */ 00189 00190 /* Do not use these arrays directly: they will move to a .c file! */ 00191 static const char * 00192 _uErrorInfoName[U_ERROR_INFO_LIMIT-U_ERROR_INFO_START]={ 00193 "U_USING_FALLBACK_ERROR", 00194 "U_USING_DEFAULT_ERROR" 00195 }; 00196 00197 static const char * 00198 _uErrorName[U_ERROR_LIMIT]={ 00199 "U_ZERO_ERROR", 00200 00201 "U_ILLEGAL_ARGUMENT_ERROR", 00202 "U_MISSING_RESOURCE_ERROR", 00203 "U_INVALID_FORMAT_ERROR", 00204 "U_FILE_ACCESS_ERROR", 00205 "U_INTERNAL_PROGRAM_ERROR", 00206 "U_MESSAGE_PARSE_ERROR", 00207 "U_MEMORY_ALLOCATION_ERROR", 00208 "U_INDEX_OUTOFBOUNDS_ERROR", 00209 "U_PARSE_ERROR", 00210 "U_INVALID_CHAR_FOUND", 00211 "U_TRUNCATED_CHAR_FOUND", 00212 "U_ILLEGAL_CHAR_FOUND", 00213 "U_INVALID_TABLE_FORMAT", 00214 "U_INVALID_TABLE_FILE", 00215 "U_BUFFER_OVERFLOW_ERROR", 00216 "U_UNSUPPORTED_ERROR" 00217 }; 00218 00219 #ifdef XP_CPLUSPLUS 00220 inline const char * 00221 errorName(UErrorCode code) 00222 { 00223 if(code>=0 && code<U_ERROR_LIMIT) { 00224 return _uErrorName[code]; 00225 } else if(code>=U_ERROR_INFO_START && code<U_ERROR_INFO_LIMIT) { 00226 return _uErrorInfoName[code-U_ERROR_INFO_START]; 00227 } else { 00228 return "[BOGUS UErrorCode]"; 00229 } 00230 } 00231 #else 00232 # define errorName(code) \ 00233 ((code)>=0 && (code)<U_ERROR_LIMIT) ? \ 00234 _uErrorName[code] : \ 00235 ((code)>=U_ERROR_INFO_START && (code)<U_ERROR_INFO_LIMIT) ? \ 00236 _uErrorInfoName[code-U_ERROR_INFO_START] : \ 00237 "[BOGUS UErrorCode]" 00238 #endif 00239 00240 XERCES_CPP_NAMESPACE_END 00241 00242 #endif /* _UTYPES */

Generated on Thu Apr 30 02:30:52 2009 for ACS C++ API by doxygen 1.3.8