// These functions for swapping different generations of ICU code point tries are here // so that their implementation files need not depend on swapper code, // need not depend on each other, and so that other swapper code // need not depend on other trie code.
/* swap the index */ const uint16_t *inIndex=reinterpret_cast<const uint16_t *>(inTrie+1);
uint16_t *outIndex=reinterpret_cast<uint16_t *>(outTrie+1);
ds->swapArray16(ds, inIndex, trie.indexLength*2, outIndex, pErrorCode);
/* swap the data */ const uint16_t *inData=inIndex+trie.indexLength;
uint16_t *outData=outIndex+trie.indexLength; switch(valueWidth) { case UCPTRIE_VALUE_BITS_16:
ds->swapArray16(ds, inData, dataLength*2, outData, pErrorCode); break; case UCPTRIE_VALUE_BITS_32:
ds->swapArray32(ds, inData, dataLength*4, outData, pErrorCode); break; case UCPTRIE_VALUE_BITS_8: if(inTrie!=outTrie) {
uprv_memmove(outData, inData, dataLength);
} break; default:
*pErrorCode=U_INVALID_FORMAT_ERROR; return 0;
}
}
return size;
}
namespace {
/** * Gets the trie version from 32-bit-aligned memory containing the serialized form * of a UTrie (version 1), a UTrie2 (version 2), or a UCPTrie (version 3). * * @param data a pointer to 32-bit-aligned memory containing the serialized form of a trie * @param length the number of bytes available at data; * can be more than necessary (see return value) * @param anyEndianOk If false, only platform-endian serialized forms are recognized. * If true, opposite-endian serialized forms are recognized as well. * @return the trie version of the serialized form, or 0 if it is not * recognized as a serialized trie
*/
int32_t
getVersion(constvoid *data, int32_t length, UBool anyEndianOk) {
uint32_t signature; if(length<16 || data==nullptr || (U_POINTER_MASK_LSB(data, 3)!=0)) { return 0;
}
signature = *static_cast<const uint32_t*>(data); if(signature==UCPTRIE_SIG) { return 3;
} if(anyEndianOk && signature==UCPTRIE_OE_SIG) { return 3;
} if(signature==UTRIE2_SIG) { return 2;
} if(anyEndianOk && signature==UTRIE2_OE_SIG) { return 2;
} if(signature==UTRIE_SIG) { return 1;
} if(anyEndianOk && signature==UTRIE_OE_SIG) { return 1;
} return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.