/* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache\@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation, and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.ibm.com . For more information * on the Apache Software Foundation, please see * . */ /** * $Log: utypes.h,v $ * Revision 1.2 2002/11/04 15:14:33 tng * C++ Namespace Support. * * Revision 1.1.1.1 2002/02/01 22:22:36 peiyongz * sane_include * * Revision 1.1 2000/02/10 18:08:28 abagchi * Initial checkin * */ #ifndef UTYPES_H #define UTYPES_H #include #include /*===========================================================================*/ /* Include platform-dependent definitions */ /* which are contained in the platform-specific file platform.h */ /*===========================================================================*/ #include "pos400.h" XERCES_CPP_NAMESPACE_BEGIN /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when using C++. It should not be defined when compiling under C. */ #ifdef __cplusplus # ifndef XP_CPLUSPLUS # define XP_CPLUSPLUS # endif #else # undef XP_CPLUSPLUS #endif /*===========================================================================*/ /* Boolean data type */ /*===========================================================================*/ #if ! HAVE_BOOL_T typedef int8_t bool_t; #endif #ifndef TRUE # define TRUE 1 #endif #ifndef FALSE # define FALSE 0 #endif /*===========================================================================*/ /* Unicode string offset */ /*===========================================================================*/ typedef int32_t UTextOffset; /*===========================================================================*/ /* Unicode character */ /*===========================================================================*/ typedef uint16_t UChar; /*===========================================================================*/ /* For C wrappers, we use the symbol U_CAPI. */ /* This works properly if the includer is C or C++. */ /* Functions are declared U_CAPI return-type U_EXPORT2 function-name() ... */ /*===========================================================================*/ #ifdef XP_CPLUSPLUS # define U_CFUNC extern "C" # define U_CDECL_BEGIN extern "C" { # define U_CDECL_END } #else # define U_CFUNC # define U_CDECL_BEGIN # define U_CDECL_END #endif #define U_CAPI U_CFUNC U_EXPORT /* Define NULL pointer value if it isn't already defined */ #ifndef NULL #ifdef XP_CPLUSPLUS #define NULL 0 #else #define NULL ((void *)0) #endif #endif /* Maximum value of a (void*) - use to indicate the limit of an 'infinite' buffer. */ #define U_MAX_PTR ((void*)-1) /*===========================================================================*/ /* UErrorCode */ /*===========================================================================*/ /** Error code to replace exception handling */ #ifdef __OS400__ enum UErrorCode1 { #else enum UErrorCode { #endif U_ERROR_INFO_START = -128, /* Start of information results (semantically successful) */ U_USING_FALLBACK_ERROR = -128, U_USING_DEFAULT_ERROR = -127, U_ERROR_INFO_LIMIT, U_ZERO_ERROR = 0, /* success */ U_ILLEGAL_ARGUMENT_ERROR = 1, /* Start of codes indicating failure */ U_MISSING_RESOURCE_ERROR = 2, U_INVALID_FORMAT_ERROR = 3, U_FILE_ACCESS_ERROR = 4, U_INTERNAL_PROGRAM_ERROR = 5, /* Indicates a bug in the library code */ U_MESSAGE_PARSE_ERROR = 6, U_MEMORY_ALLOCATION_ERROR = 7, /* Memory allocation error */ U_INDEX_OUTOFBOUNDS_ERROR = 8, U_PARSE_ERROR = 9, /* Equivalent to Java ParseException */ U_INVALID_CHAR_FOUND = 10, /* In the Character conversion routines: Invalid character or sequence was encountered*/ U_TRUNCATED_CHAR_FOUND = 11, /* In the Character conversion routines: More bytes are required to complete the conversion successfully*/ U_ILLEGAL_CHAR_FOUND = 12, /* In codeset conversion: a sequence that does NOT belong in the codepage has been encountered*/ U_INVALID_TABLE_FORMAT = 13, /* Conversion table file found, but corrupted*/ U_INVALID_TABLE_FILE = 14, /* Conversion table file not found*/ U_BUFFER_OVERFLOW_ERROR = 15, /* A result would not fit in the supplied buffer */ U_UNSUPPORTED_ERROR = 16, /* Requested operation not supported in current context */ U_ERROR_LIMIT }; #ifdef __OS400__ typedef int UErrorCode; #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) #define U_FAILURE(x) ((x)>U_ZERO_ERROR) #else #ifndef XP_CPLUSPLUS typedef enum UErrorCode UErrorCode; #endif #endif /* Use the following to determine if an UErrorCode represents */ /* operational success or failure. */ #ifndef __OS400__ #ifdef XP_CPLUSPLUS inline bool_t U_SUCCESS(UErrorCode code) { return (bool_t)(code<=U_ZERO_ERROR); } inline bool_t U_FAILURE(UErrorCode code) { return (bool_t)(code>U_ZERO_ERROR); } #else #define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) #define U_FAILURE(x) ((x)>U_ZERO_ERROR) #endif #endif /* Casting function for int32_t (backward compatibility version, here until T_INT32 is replaced) */ #define T_INT32(i) ((int32_t)i) /*===========================================================================*/ /* Debugging */ /*===========================================================================*/ /* remove this */ /* This function is useful for debugging; it returns the text name */ /* of an UErrorCode result. This is not the most efficient way of */ /* doing this but it's just for Debug builds anyway. */ /* Do not use these arrays directly: they will move to a .c file! */ static const char * _uErrorInfoName[U_ERROR_INFO_LIMIT-U_ERROR_INFO_START]={ "U_USING_FALLBACK_ERROR", "U_USING_DEFAULT_ERROR" }; static const char * _uErrorName[U_ERROR_LIMIT]={ "U_ZERO_ERROR", "U_ILLEGAL_ARGUMENT_ERROR", "U_MISSING_RESOURCE_ERROR", "U_INVALID_FORMAT_ERROR", "U_FILE_ACCESS_ERROR", "U_INTERNAL_PROGRAM_ERROR", "U_MESSAGE_PARSE_ERROR", "U_MEMORY_ALLOCATION_ERROR", "U_INDEX_OUTOFBOUNDS_ERROR", "U_PARSE_ERROR", "U_INVALID_CHAR_FOUND", "U_TRUNCATED_CHAR_FOUND", "U_ILLEGAL_CHAR_FOUND", "U_INVALID_TABLE_FORMAT", "U_INVALID_TABLE_FILE", "U_BUFFER_OVERFLOW_ERROR", "U_UNSUPPORTED_ERROR" }; #ifdef XP_CPLUSPLUS inline const char * errorName(UErrorCode code) { if(code>=0 && code=U_ERROR_INFO_START && code=0 && (code)=U_ERROR_INFO_START && (code)