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

ucmp8.h

Go to the documentation of this file.
00001 /*
00002  ********************************************************************
00003  * COPYRIGHT: 
00004  * Copyright (c) 1996-1999, International Business Machines Corporation and
00005  * others. All Rights Reserved.
00006  ********************************************************************
00007  */
00008 
00009 
00010 
00011 #ifndef UCMP8_H
00012 #define UCMP8_H
00013 
00014 /* 32-bits.
00015   Bump this whenever the internal structure changes.
00016 */
00017 #define ICU_UCMP8_VERSION 0x01260000
00018 
00019 #include "umemstrm.h"
00020 #include "unicode/utypes.h"
00021 
00022 /*====================================*/
00023 /* class CompactByteArray
00024  * Provides a compact way to store information that is indexed by Unicode values,
00025  * such as character properties, types, keyboard values, etc.
00026  * The ATypes are used by value, so should be small, integers or pointers.
00027  *====================================
00028  */
00029 
00030 U_CAPI int32_t U_EXPORT2 ucmp8_getkUnicodeCount(void);
00031 U_CAPI int32_t U_EXPORT2 ucmp8_getkBlockCount(void);
00032 
00033 typedef struct CompactByteArray {
00034   uint32_t fStructSize;
00035   int8_t* fArray;
00036   uint16_t* fIndex;
00037   int32_t fCount;
00038   UBool fCompact;
00039   UBool fBogus;
00040   UBool fAlias;
00041   UBool fIAmOwned; /* don't free CBA on close */
00042 } CompactByteArray;
00043 
00044 #define UCMP8_kUnicodeCount 65536
00045 #define UCMP8_kBlockShift 7
00046 #define UCMP8_kBlockCount (1<<UCMP8_kBlockShift)
00047 #define UCMP8_kIndexShift (16-UCMP8_kBlockShift)
00048 #define UCMP8_kIndexCount (1<<UCMP8_kIndexShift)
00049 #define UCMP8_kBlockMask (UCMP8_kBlockCount-1)
00050 
00051 
00052 U_CAPI  CompactByteArray* U_EXPORT2 ucmp8_open(int8_t defaultValue);
00053 
00054 U_CAPI  void U_EXPORT2 ucmp8_init(CompactByteArray* array, int8_t defaultValue);
00055 U_CAPI  void U_EXPORT2 ucmp8_initBogus(CompactByteArray* array);
00056 
00068 U_CAPI  CompactByteArray* U_EXPORT2 ucmp8_openAdopt(uint16_t* indexArray, 
00069                                int8_t* newValues,
00070                                int32_t count);
00071 U_CAPI  CompactByteArray* U_EXPORT2 ucmp8_openAlias(uint16_t* indexArray, 
00072                                int8_t* newValues,
00073                                int32_t count);
00074 
00086 U_CAPI  CompactByteArray* U_EXPORT2 ucmp8_initAdopt(CompactByteArray *this_obj,
00087                                uint16_t* indexArray, 
00088                                int8_t* newValues,
00089                                int32_t count);
00090 U_CAPI  CompactByteArray* U_EXPORT2 ucmp8_initAlias(CompactByteArray *this_obj,
00091                                uint16_t* indexArray, 
00092                                int8_t* newValues,
00093                                int32_t count);
00094 
00095 U_CAPI  void U_EXPORT2 ucmp8_close(CompactByteArray* array);
00096 U_CAPI  UBool U_EXPORT2 ucmp8_isBogus(const CompactByteArray* array);
00097 
00098 #define ucmp8_get(array, index)  (array->fArray[(array->fIndex[index >> UCMP8_kBlockShift] & 0xFFFF) + (index & UCMP8_kBlockMask)])
00099 
00100 #define ucmp8_getu(array,index) (uint8_t)ucmp8_get(array,index)
00101 
00102 
00103 U_CAPI  void U_EXPORT2 ucmp8_set(CompactByteArray* array,
00104                  UChar character,
00105                  int8_t value);
00106 
00107 U_CAPI  void U_EXPORT2 ucmp8_setRange(CompactByteArray* array, 
00108                   UChar start,
00109                   UChar end, 
00110                   int8_t value);
00111 
00112 U_CAPI  int32_t U_EXPORT2 ucmp8_getCount(const CompactByteArray* array);
00113 U_CAPI  const int8_t* U_EXPORT2 ucmp8_getArray(const CompactByteArray* array);
00114 U_CAPI  const uint16_t* U_EXPORT2 ucmp8_getIndex(const CompactByteArray* array);
00115 
00116 /* Compact the array.
00117    The value of cycle determines how large the overlap can be.
00118    A cycle of 1 is the most compacted, but takes the most time to do.
00119    If values stored in the array tend to repeat in cycles of, say, 16,
00120    then using that will be faster than cycle = 1, and get almost the
00121    same compression.
00122 */
00123 U_CAPI  void U_EXPORT2 ucmp8_compact(CompactByteArray* array, 
00124                  uint32_t cycle);
00125 
00126 /* Expanded takes the array back to a 65536 element array*/
00127 U_CAPI  void U_EXPORT2 ucmp8_expand(CompactByteArray* array);
00128 
00130 U_CAPI  uint32_t U_EXPORT2 ucmp8_flattenMem (const CompactByteArray* array, UMemoryStream *MS);
00131 /* initializes an existing CBA from memory.  Will cause ucmp8_close() to not deallocate anything. */
00132 U_CAPI  void U_EXPORT2 ucmp8_initFromData(CompactByteArray* array, const uint8_t **source, UErrorCode *status);
00133 
00134 #endif
00135 
00136 
00137 

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