const CollationKey& CollationKey::operator=(const CollationKey& other) { if (this != &other) { if (other.isBogus()) { return setToBogus(); } if (other.fBytes != NULL) { ensureCapacity(other.fCount); if (isBogus()) { return *this; } fHashCode = other.fHashCode; uprv_memcpy(fBytes, other.fBytes, fCount); } else { fCount = 0; fBogus = FALSE; fHashCode = kEmptyHashCode; } } return *this; }
CollationKey::CollationKey(const CollationKey& other) : UObject(other), fFlagAndLength(other.getLength()), fHashCode(other.fHashCode) { if (other.isBogus()) { setToBogus(); return; } int32_t length = fFlagAndLength; if (length > getCapacity() && reallocate(length, 0) == NULL) { setToBogus(); return; } if (length > 0) { uprv_memcpy(getBytes(), other.getBytes(), length); } }
CollationKey::CollationKey(const CollationKey& other) : UObject(other), fBogus(FALSE), fCount(other.fCount), fCapacity(other.fCapacity), fHashCode(other.fHashCode), fBytes(NULL) { if (other.fBogus) { setToBogus(); return; } fBytes = (uint8_t *)uprv_malloc(fCapacity); if (fBytes == NULL) { setToBogus(); return; } uprv_memcpy(fBytes, other.fBytes, other.fCount); if(fCapacity>fCount) { uprv_memset(fBytes+fCount, 0, fCapacity-fCount); } }
// Create a collation key from a bit array. CollationKey::CollationKey(const uint8_t* newValues, int32_t count) : UObject(), fBogus(FALSE), fCount(count), fCapacity(count), fHashCode(kInvalidHashCode) { fBytes = (uint8_t *)uprv_malloc(count); if (fBytes == NULL) { setToBogus(); return; } uprv_memcpy(fBytes, newValues, fCount); }
// Create a collation key from a bit array. CollationKey::CollationKey(const uint8_t* newValues, int32_t count) : UObject(), fFlagAndLength(count), fHashCode(kInvalidHashCode) { if (count < 0 || (newValues == NULL && count != 0) || (count > getCapacity() && reallocate(count, 0) == NULL)) { setToBogus(); return; } if (count > 0) { uprv_memcpy(getBytes(), newValues, count); } }
const CollationKey& CollationKey::operator=(const CollationKey& other) { if (this != &other) { if (other.isBogus()) { return setToBogus(); } int32_t length = other.getLength(); if (length > getCapacity() && reallocate(length, 0) == NULL) { return setToBogus(); } if (length > 0) { uprv_memcpy(getBytes(), other.getBytes(), length); } fFlagAndLength = (fFlagAndLength & 0x80000000) | length; fHashCode = other.fHashCode; } return *this; }
UnicodeString & UnicodeString::toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options) { UCaseMap csm=UCASEMAP_INITIALIZER; csm.options=options; setTempCaseMap(&csm, locale.getName()); BreakIterator *bi=titleIter; if(bi==NULL) { UErrorCode errorCode=U_ZERO_ERROR; bi=BreakIterator::createWordInstance(locale, errorCode); if(U_FAILURE(errorCode)) { setToBogus(); return *this; } } csm.iter=reinterpret_cast<UBreakIterator *>(bi); caseMap(&csm, unistr_case_internalToTitle); if(titleIter==NULL) { delete bi; } return *this; }
CollationKey& CollationKey::ensureCapacity(int32_t newSize) { if (fCapacity < newSize) { uprv_free(fBytes); fBytes = (uint8_t *)uprv_malloc(newSize); if (fBytes == NULL) { return setToBogus(); } uprv_memset(fBytes, 0, fCapacity); fCapacity = newSize; } fBogus = FALSE; fCount = newSize; fHashCode = kInvalidHashCode; return *this; }
CDFLocaleStyleData::~CDFLocaleStyleData() { setToBogus(); }