#ifdef UCPTRIE_DEBUG
# include <stdio.h>
#endif
#include "unicode/utypes.h"
#include "unicode/ucptrie.h"
#include "unicode/utf.h"
#include "unicode/utf8.h"
#include "unicode/utf16.h"
#include "cmemory.h"
#include "uassert.h"
#include "ucptrie_impl.h"
U_CAPI UCPTrie * U_EXPORT2
ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth,
const void *data, int32_t length, int32_t *pActualLength,
UErrorCode *pErrorCode) { … }
U_CAPI void U_EXPORT2
ucptrie_close(UCPTrie *trie) { … }
U_CAPI UCPTrieType U_EXPORT2
ucptrie_getType(const UCPTrie *trie) { … }
U_CAPI UCPTrieValueWidth U_EXPORT2
ucptrie_getValueWidth(const UCPTrie *trie) { … }
U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallIndex(const UCPTrie *trie, UChar32 c) { … }
U_CAPI int32_t U_EXPORT2
ucptrie_internalSmallU8Index(const UCPTrie *trie, int32_t lt1, uint8_t t2, uint8_t t3) { … }
U_CAPI int32_t U_EXPORT2
ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c,
const uint8_t *start, const uint8_t *src) { … }
namespace {
inline uint32_t getValue(UCPTrieData data, UCPTrieValueWidth valueWidth, int32_t dataIndex) { … }
}
U_CAPI uint32_t U_EXPORT2
ucptrie_get(const UCPTrie *trie, UChar32 c) { … }
namespace {
constexpr int32_t MAX_UNICODE = …;
inline uint32_t maybeFilterValue(uint32_t value, uint32_t trieNullValue, uint32_t nullValue,
UCPMapValueFilter *filter, const void *context) { … }
UChar32 getRange(const void *t, UChar32 start,
UCPMapValueFilter *filter, const void *context, uint32_t *pValue) { … }
}
U_CFUNC UChar32
ucptrie_internalGetRange(UCPTrieGetRange *getRange,
const void *trie, UChar32 start,
UCPMapRangeOption option, uint32_t surrogateValue,
UCPMapValueFilter *filter, const void *context, uint32_t *pValue) { … }
U_CAPI UChar32 U_EXPORT2
ucptrie_getRange(const UCPTrie *trie, UChar32 start,
UCPMapRangeOption option, uint32_t surrogateValue,
UCPMapValueFilter *filter, const void *context, uint32_t *pValue) { … }
U_CAPI int32_t U_EXPORT2
ucptrie_toBinary(const UCPTrie *trie,
void *data, int32_t capacity,
UErrorCode *pErrorCode) { … }
namespace {
#ifdef UCPTRIE_DEBUG
long countNull(const UCPTrie *trie) {
uint32_t nullValue=trie->nullValue;
int32_t length=trie->dataLength;
long count=0;
switch (trie->valueWidth) {
case UCPTRIE_VALUE_BITS_16:
for(int32_t i=0; i<length; ++i) {
if(trie->data.ptr16[i]==nullValue) { ++count; }
}
break;
case UCPTRIE_VALUE_BITS_32:
for(int32_t i=0; i<length; ++i) {
if(trie->data.ptr32[i]==nullValue) { ++count; }
}
break;
case UCPTRIE_VALUE_BITS_8:
for(int32_t i=0; i<length; ++i) {
if(trie->data.ptr8[i]==nullValue) { ++count; }
}
break;
default:
break;
}
return count;
}
U_CFUNC void
ucptrie_printLengths(const UCPTrie *trie, const char *which) {
long indexLength=trie->indexLength;
long dataLength=(long)trie->dataLength;
long totalLength=(long)sizeof(UCPTrieHeader)+indexLength*2+
dataLength*(trie->valueWidth==UCPTRIE_VALUE_BITS_16 ? 2 :
trie->valueWidth==UCPTRIE_VALUE_BITS_32 ? 4 : 1);
printf("**UCPTrieLengths(%s %s)** index:%6ld data:%6ld countNull:%6ld serialized:%6ld\n",
which, trie->name, indexLength, dataLength, countNull(trie), totalLength);
}
#endif
}
U_CAPI uint32_t U_EXPORT2
ucpmap_get(const UCPMap *map, UChar32 c) { … }
U_CAPI UChar32 U_EXPORT2
ucpmap_getRange(const UCPMap *map, UChar32 start,
UCPMapRangeOption option, uint32_t surrogateValue,
UCPMapValueFilter *filter, const void *context, uint32_t *pValue) { … }