• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

utypes.h

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

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0