mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 14:31:31 +00:00
ICU-392 added API declarations and dummy implementations for state handling functions. Carved data structures some more.
X-SVN-Rev: 5195
This commit is contained in:
parent
e52983285d
commit
ac95eb8654
3 changed files with 93 additions and 9 deletions
|
@ -318,6 +318,31 @@ ucol_openVersion(const char *loc,
|
|||
return collator;
|
||||
}
|
||||
|
||||
int32_t ucol_getState(const UCollator *coll, UColStateEnum contents,
|
||||
uint8_t *buffer, const int32_t buflen,
|
||||
UErrorCode *status) {
|
||||
if(U_FAILURE(*status) || coll == NULL) {
|
||||
return -1;
|
||||
}
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ucol_checkState (const uint8_t *state, UErrorCode *status) {
|
||||
if(U_FAILURE(*status) || state == NULL) {
|
||||
return;
|
||||
}
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
}
|
||||
|
||||
UCollator *ucol_openState(const uint8_t *state, UErrorCode *status) {
|
||||
if(U_FAILURE(*status) || state == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U_CAPI void
|
||||
ucol_close(UCollator *coll)
|
||||
{
|
||||
|
|
|
@ -492,6 +492,9 @@ typedef struct {
|
|||
uint8_t reserved[64]; /* for future use */
|
||||
} UCATableHeader;
|
||||
|
||||
#define U_UNKNOWN_STATE 0
|
||||
#define U_COLLATOR_STATE 0x01
|
||||
#define U_STATE_LIMIT 0x02
|
||||
|
||||
/* This is the first structure in a state */
|
||||
/* it should be machine independent */
|
||||
|
@ -506,6 +509,10 @@ typedef struct {
|
|||
uint8_t charsetFamily;
|
||||
/* version of ICU this state structure comes from */
|
||||
uint8_t icuVersion[4];
|
||||
/* What is the data following this state */
|
||||
uint8_t type;
|
||||
/* more stuff to come, keep it on 16 byte boundary */
|
||||
uint8_t reserved[7];
|
||||
} UStatusStruct;
|
||||
|
||||
/* This structure follows UStatusStruct */
|
||||
|
@ -516,16 +523,36 @@ typedef struct {
|
|||
/* size of this structure */
|
||||
uint8_t sizeLo;
|
||||
uint8_t sizeHi;
|
||||
uint8_t reserved[2];
|
||||
char charsetName[32]; /* for charset CEs */
|
||||
char locale[32]; /* this is the resolved locale name*/
|
||||
/* This state is followed by the frozen tailoring */
|
||||
uint8_t containsTailoring;
|
||||
/* This state is followed by the frozen UCA */
|
||||
uint8_t containsUCA;
|
||||
/* Version info - the same one */
|
||||
uint8_t versionInfo[4];
|
||||
|
||||
/* for charset CEs */
|
||||
uint8_t charsetName[32];
|
||||
/* this is the resolved locale name*/
|
||||
uint8_t locale[32];
|
||||
|
||||
/* Attributes. Open ended */
|
||||
/* all the following will be moved to uint32_t because of portability */
|
||||
/* variable top value */
|
||||
uint32_t variableTopValue;
|
||||
UColAttributeValue frenchCollation;
|
||||
UColAttributeValue alternateHandling; /* attribute for handling variable elements*/
|
||||
UColAttributeValue caseFirst; /* who goes first, lower case or uppercase */
|
||||
UColAttributeValue caseLevel; /* do we have an extra case level */
|
||||
UColAttributeValue normalizationMode; /* attribute for normalization */
|
||||
UColAttributeValue strength; /* attribute for strength */
|
||||
/* attribute for handling variable elements*/
|
||||
uint32_t /*UColAttributeValue*/ alternateHandling;
|
||||
/* how to handle secondary weights */
|
||||
uint32_t /*UColAttributeValue*/ frenchCollation;
|
||||
/* who goes first, lower case or uppercase */
|
||||
uint32_t /*UColAttributeValue*/ caseFirst;
|
||||
/* do we have an extra case level */
|
||||
uint32_t /*UColAttributeValue*/ caseLevel;
|
||||
/* attribute for normalization */
|
||||
uint32_t /*UColAttributeValue*/ normalizationMode;
|
||||
/* attribute for strength */
|
||||
uint32_t /*UColAttributeValue*/ strength;
|
||||
/* to be immediately 16 byte aligned */
|
||||
uint8_t reserved[12];
|
||||
} UColStatusStruct;
|
||||
|
||||
#define UCOL_INV_SIZEMASK 0xFFF00000
|
||||
|
|
|
@ -627,4 +627,36 @@ U_CAPI int32_t ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UCha
|
|||
/* include backward compatibility */
|
||||
#include "unicode/ucoleitr.h"
|
||||
|
||||
typedef enum {
|
||||
UCOL_JUST_STATE = 0,
|
||||
UCOL_INCLUDE_TAILORING,
|
||||
UCOL_INCLUDE_TAILORING_AND_UCA
|
||||
} UColStateEnum;
|
||||
|
||||
/**
|
||||
* This API would save (freeze) the current state of a collator so that a collator with same functionality
|
||||
* can be later constructed according to this data. The state blob can optionally contain binary tailoring
|
||||
* data as well as the binary version of the UCA, in order to facilitate independence from ICU data.
|
||||
* @draft
|
||||
*/
|
||||
int32_t ucol_getState(const UCollator *coll, UColStateEnum contents,
|
||||
uint8_t *buffer, const int32_t buflen,
|
||||
UErrorCode *status);
|
||||
|
||||
/**
|
||||
* This API would compare the frozen state with the current implementation of ICU and will set status to one of four values:
|
||||
* U_ZERO_ERROR - most desirable result, meaning that the frozen collator in entirety matches the current ICU implementation, and that the same results would be obtained with simple opening of a collator (with a caveat: opening from state resurrects the attributes, while simple opening doesn't).
|
||||
* U_COLLATOR_OLD_WARN - this is a warning. This collator can be constructed - however, the current implementation would not give the same results, so compatibility layer is used. This fact can affect performance and memory usage of collation. Also, it means that eventually this collator will not be available. It is users responsibility to consider regenerating the data that depends on the collator while it is 'old'.
|
||||
* U_MISSING_RESOURCE_ERROR - this is an error that means that the data required to construct a collator is missing. If the user supplies the required data, it will be able to construct the collator, either in regular OR compatibility mode.
|
||||
* U_COLLATOR_VERSION_TOO_OLD_ERROR - This is an error and means that this collator cannot be instantiated because this version is no longer supported by ICU. The user needs either to regenerate the data OR install an older version of ICU.
|
||||
* @draft
|
||||
*/
|
||||
void ucol_checkState (const uint8_t *state, UErrorCode *status);
|
||||
|
||||
/**
|
||||
* This API tries to construct a collator based on a state blob passed.
|
||||
* @draft
|
||||
*/
|
||||
UCollator *ucol_openState(const uint8_t *state, UErrorCode *status);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue