1999-08-16 21:50:52 +00:00
|
|
|
/*
|
|
|
|
********************************************************************
|
|
|
|
* COPYRIGHT:
|
1999-11-22 20:56:34 +00:00
|
|
|
* Copyright (c) 1996-1999, International Business Machines Corporation and
|
|
|
|
* others. All Rights Reserved.
|
1999-08-16 21:50:52 +00:00
|
|
|
********************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UCMP8_H
|
|
|
|
#define UCMP8_H
|
|
|
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/*====================================*/
|
|
|
|
/* class CompactByteArray
|
|
|
|
* Provides a compact way to store information that is indexed by Unicode values,
|
|
|
|
* such as character properties, types, keyboard values, etc.
|
|
|
|
* The ATypes are used by value, so should be small, integers or pointers.
|
|
|
|
*====================================
|
|
|
|
*/
|
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI int32_t U_EXPORT2 ucmp8_getkUnicodeCount(void);
|
|
|
|
U_CAPI int32_t U_EXPORT2 ucmp8_getkBlockCount(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
typedef struct CompactByteArray {
|
1999-12-04 02:31:40 +00:00
|
|
|
uint32_t fStructSize;
|
1999-08-16 21:50:52 +00:00
|
|
|
int8_t* fArray;
|
|
|
|
uint16_t* fIndex;
|
|
|
|
int32_t fCount;
|
1999-12-04 02:31:40 +00:00
|
|
|
bool_t fCompact;
|
1999-08-16 21:50:52 +00:00
|
|
|
bool_t fBogus;
|
1999-12-04 02:31:40 +00:00
|
|
|
bool_t fAlias;
|
1999-08-16 21:50:52 +00:00
|
|
|
} CompactByteArray;
|
|
|
|
|
1999-11-22 20:56:34 +00:00
|
|
|
#define UCMP8_kUnicodeCount 65536
|
|
|
|
#define UCMP8_kBlockShift 7
|
|
|
|
#define UCMP8_kBlockCount (1<<UCMP8_kBlockShift)
|
|
|
|
#define UCMP8_kIndexShift (16-UCMP8_kBlockShift)
|
|
|
|
#define UCMP8_kIndexCount (1<<UCMP8_kIndexShift)
|
|
|
|
#define UCMP8_kBlockMask (UCMP8_kBlockCount-1)
|
|
|
|
|
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI CompactByteArray* U_EXPORT2 ucmp8_open(int8_t defaultValue);
|
|
|
|
U_CAPI CompactByteArray* U_EXPORT2 ucmp8_openAdopt(uint16_t* indexArray,
|
1999-08-16 21:50:52 +00:00
|
|
|
int8_t* newValues,
|
|
|
|
int32_t count);
|
1999-12-10 21:56:55 +00:00
|
|
|
U_CAPI CompactByteArray* U_EXPORT2 ucmp8_openAlias(uint16_t* indexArray,
|
|
|
|
int8_t* newValues,
|
|
|
|
int32_t count);
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucmp8_close(CompactByteArray* array);
|
|
|
|
U_CAPI bool_t U_EXPORT2 isBogus(const CompactByteArray* array);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-11-22 20:56:34 +00:00
|
|
|
#define ucmp8_get(array, index) (array->fArray[(array->fIndex[index >> UCMP8_kBlockShift] & 0xFFFF) + (index & UCMP8_kBlockMask)])
|
|
|
|
|
|
|
|
#define ucmp8_getu(array,index) (uint8_t)ucmp8_get(array,index)
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucmp8_set(CompactByteArray* array,
|
2000-04-14 05:22:29 +00:00
|
|
|
UChar character,
|
1999-08-16 21:50:52 +00:00
|
|
|
int8_t value);
|
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucmp8_setRange(CompactByteArray* array,
|
1999-08-16 21:50:52 +00:00
|
|
|
UChar start,
|
|
|
|
UChar end,
|
|
|
|
int8_t value);
|
|
|
|
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI int32_t U_EXPORT2 ucmp8_getCount(const CompactByteArray* array);
|
|
|
|
U_CAPI const int8_t* U_EXPORT2 ucmp8_getArray(const CompactByteArray* array);
|
|
|
|
U_CAPI const uint16_t* U_EXPORT2 ucmp8_getIndex(const CompactByteArray* array);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/* Compact the array.
|
|
|
|
The value of cycle determines how large the overlap can be.
|
|
|
|
A cycle of 1 is the most compacted, but takes the most time to do.
|
|
|
|
If values stored in the array tend to repeat in cycles of, say, 16,
|
|
|
|
then using that will be faster than cycle = 1, and get almost the
|
|
|
|
same compression.
|
|
|
|
*/
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucmp8_compact(CompactByteArray* array,
|
1999-08-16 21:50:52 +00:00
|
|
|
uint32_t cycle);
|
|
|
|
|
|
|
|
/* Expanded takes the array back to a 65536 element array*/
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 ucmp8_expand(CompactByteArray* array);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-12-04 02:31:40 +00:00
|
|
|
/** INTERNAL USE ONLY **/
|
|
|
|
U_CAPI CompactByteArray * U_EXPORT2 ucmp8_cloneFromData(const uint8_t **source, UErrorCode *status);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|