Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ucnv_cnv.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1999, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 **********************************************************************
00006 *
00007 *   uconv_cnv.h:
00008 *   defines all the low level conversion functions
00009 *   T_UnicodeConverter_{to,from}Unicode_$ConversionType
00010 *
00011 * Modification History:
00012 *
00013 *   Date        Name        Description
00014 *   05/09/00    helena      Added implementation to handle fallback mappings.
00015 *   06/29/2000  helena      Major rewrite of the callback APIs.
00016 */
00017 
00018 #ifndef UCNV_CNV_H
00019 #define UCNV_CNV_H
00020 
00021 #include "unicode/utypes.h"
00022 #include "unicode/ucnv_err.h"
00023 #include "ucnv_bld.h"
00024 #include "ucnvmbcs.h"
00025 #include "ucmp8.h"
00026 #include "ucmp16.h"
00027 
00028 /*Table Node Definitions */
00029 typedef struct
00030   {
00031     UChar *toUnicode;  /* [256]; */
00032     CompactByteArray fromUnicode;
00033     UChar *toUnicodeFallback;
00034     CompactByteArray fromUnicodeFallback;
00035   }
00036 UConverterSBCSTable;
00037 
00038 typedef struct
00039   {
00040     CompactShortArray toUnicode;
00041     CompactShortArray fromUnicode;
00042     CompactShortArray toUnicodeFallback;
00043     CompactShortArray fromUnicodeFallback;
00044   }
00045 UConverterDBCSTable;
00046 
00047 union UConverterTable
00048   {
00049     UConverterSBCSTable sbcs;
00050     UConverterDBCSTable dbcs;
00051     UConverterMBCSTable mbcs;
00052   };
00053 
00054 
00055 U_CDECL_BEGIN
00056 
00057 /* this is used in fromUnicode DBCS tables as an "unassigned" marker */
00058 #define missingCharMarker 0xFFFF
00059 
00060 /*
00061  * #define missingUCharMarker 0xfffe
00062  *
00063  * there are actually two values used in toUnicode tables:
00064  * U+fffe "unassigned"
00065  * U+ffff "illegal"
00066  */
00067 
00068 #define FromU_CALLBACK_MACRO(context, args, codeUnits, length, codePoint, reason, err) \
00069                 { \
00070                   /*copies current values for the ErrorFunctor to update */ \
00071                   /*Calls the ErrorFunctor */ \
00072                   args->converter->fromUCharErrorBehaviour ( context, \
00073                                                   args, \
00074                                                   codeUnits, \
00075                                                   length, \
00076                                                   codePoint, \
00077                                                   reason, \
00078                                                   err); \
00079                  myTargetIndex = args->target - (char*)myTarget; \
00080                  mySourceIndex = args->source - mySource; \
00081                 }
00082 /*
00083 */
00084 #define ToU_CALLBACK_MACRO(context, args, codePoints, length, reason, err) \
00085                 { \
00086                   /*Calls the ErrorFunctor */ \
00087                   args->converter->fromCharErrorBehaviour ( \
00088                                                  context, \
00089                                                  args, \
00090                                                  codePoints, \
00091                                                  length, \
00092                                                  reason, \
00093                                                  err); \
00094                  myTargetIndex = args->target - myTarget; \
00095                  mySourceIndex = args->source - (const char*)mySource; \
00096                 }
00097 /*
00098 */
00099 #define FromU_CALLBACK_OFFSETS_LOGIC_MACRO(context, args, codeUnits, length, codePoint, reason, err) \
00100                 { \
00101                  int32_t My_i = myTargetIndex; \
00102                   /*copies current values for the ErrorFunctor to update */ \
00103                   /*Calls the ErrorFunctor */ \
00104                   args->converter->fromUCharErrorBehaviour ( \
00105                                                  context, \
00106                                                  args, \
00107                                                  codeUnits, \
00108                                                  length, \
00109                                                  codePoint, \
00110                                                  reason, \
00111                                                  err); \
00112                   /*Update the local Indexes so that the conversion can restart at the right points */ \
00113                  myTargetIndex = args->target - (char*)myTarget; \
00114                  mySourceIndex = args->source - mySource; \
00115                  args->offsets = saveOffsets; \
00116                   for (;My_i < myTargetIndex;My_i++) args->offsets[My_i] += currentOffset; \
00117                 }
00118 /*
00119 */
00120 #define ToU_CALLBACK_OFFSETS_LOGIC_MACRO(context, args, codePoints, length, reason, err) \
00121                 { \
00122                       args->converter->fromCharErrorBehaviour ( \
00123                                                  context, \
00124                                                  args, \
00125                                                  codePoints, \
00126                                                  length, \
00127                                                  reason, \
00128                                                  err); \
00129                   /*Update the local Indexes so that the conversion can restart at the right points */ \
00130                  myTargetIndex = args->target - myTarget; \
00131                  mySourceIndex = args->source - (const char*)mySource; \
00132                  args->offsets = saveOffsets; \
00133                   for (;My_i < myTargetIndex;My_i++) {args->offsets[My_i] += currentOffset;} \
00134                 }
00135 
00136 
00137 typedef void (*UConverterLoad) (UConverterSharedData *sharedData, const uint8_t *raw, UErrorCode *pErrorCode);
00138 typedef void (*UConverterUnload) (UConverterSharedData *sharedData);
00139 
00140 typedef void (*UConverterOpen) (UConverter *cnv, const char *name, const char *locale,uint32_t options, UErrorCode *pErrorCode);
00141 typedef void (*UConverterClose) (UConverter *cnv);
00142 
00143 typedef void (*UConverterReset) (UConverter *cnv);
00144 
00145 typedef void (*T_ToUnicodeFunction) (UConverterToUnicodeArgs *, UErrorCode *);
00146 
00147 typedef void (*T_FromUnicodeFunction) (UConverterFromUnicodeArgs *, UErrorCode *);
00148 
00149 typedef UChar32 (*T_GetNextUCharFunction) (UConverterToUnicodeArgs *, UErrorCode *);
00150 
00151 typedef void (*UConverterGetStarters)(const UConverter* converter,
00152                                       UBool starters[256],
00153                                       UErrorCode *pErrorCode);
00154 /* If this function pointer is null or if the function returns null
00155  * the name field in static data struct should be returned by 
00156  * ucnv_getName() API function
00157  */
00158 typedef const char * (*UConverterGetName) (const UConverter *cnv);
00159 
00160 UBool CONVERSION_U_SUCCESS (UErrorCode err);
00161 
00162 void flushInternalUnicodeBuffer (UConverter * _this,
00163                                  UChar * myTarget,
00164                                  int32_t * myTargetIndex,
00165                                  int32_t targetLength,
00166                                  int32_t** offsets,
00167                                  UErrorCode * err);
00168 
00169 void flushInternalCharBuffer (UConverter * _this,
00170                               char *myTarget,
00171                               int32_t * myTargetIndex,
00172                               int32_t targetLength,
00173                               int32_t** offsets,
00174                               UErrorCode * err);
00175 
00192 struct UConverterImpl {
00193     UConverterType type;
00194 
00195     UConverterLoad load;
00196     UConverterUnload unload;
00197 
00198     UConverterOpen open;
00199     UConverterClose close;
00200     UConverterReset reset;
00201 
00202     T_ToUnicodeFunction toUnicode;
00203     T_ToUnicodeFunction toUnicodeWithOffsets;
00204     T_FromUnicodeFunction fromUnicode;
00205     T_FromUnicodeFunction fromUnicodeWithOffsets;
00206     T_GetNextUCharFunction getNextUChar;
00207 
00208     UConverterGetStarters getStarters;
00209     UConverterGetName getName;
00210 };
00211 
00212 extern const UConverterSharedData
00213     _SBCSData, _DBCSData, _MBCSData, _Latin1Data,
00214     _UTF8Data, _UTF16BEData, _UTF16LEData, _UTF32BEData, _UTF32LEData,
00215     _EBCDICStatefulData, _ISO2022Data, 
00216     _LMBCSData1,_LMBCSData2, _LMBCSData3, _LMBCSData4, _LMBCSData5, _LMBCSData6,
00217     _LMBCSData8,_LMBCSData11,_LMBCSData16,_LMBCSData17,_LMBCSData18,_LMBCSData19,_HZData;
00218 
00219 U_CDECL_END
00220 
00237 U_CFUNC UChar32
00238 ucnv_getUChar32KeepOverflow(UConverter *cnv, const UChar *buffer, int32_t length);
00239 
00252 U_CFUNC int32_t *
00253 ucnv_updateCallbackOffsets(int32_t *offsets, int32_t length, int32_t sourceIndex);
00254 
00256 #define TO_U_USE_FALLBACK(useFallback) TRUE
00257 #define UCNV_TO_U_USE_FALLBACK(cnv) TRUE
00258 
00260 #define FROM_U_USE_FALLBACK(useFallback, c) ((useFallback) || (uint32_t)((c)-0xe000)<0x1900 || (uint32_t)((c)-0xf0000)<0x20000)
00261 #define UCNV_FROM_U_USE_FALLBACK(cnv, c) FROM_U_USE_FALLBACK((cnv)->useFallback, c)
00262 
00263 #endif /* UCNV_CNV */

Generated at Tue Dec 5 17:55:34 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000