StringEnumeration* U_EXPORT2 BreakIterator::getAvailableLocales(void) { ICULocaleService *service = getService(); if (service == NULL) { return NULL; } return service->getAvailableLocales(); }
// ------------------------------------- StringEnumeration* NumberFormat::getAvailableLocales(void) { ICULocaleService *service = getService(); if (service) { return service->getAvailableLocales(); } return NULL; // no way to return error condition }
virtual void reset(UErrorCode& status) { if (status == U_ENUM_OUT_OF_SYNC_ERROR) { status = U_ZERO_ERROR; } if (U_SUCCESS(status)) { _timestamp = _service->getTimestamp(); _pos = 0; _service->getVisibleIDs(_ids, status); } }
URegistryKey U_EXPORT2 BreakIterator::registerInstance(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status) { ICULocaleService *service = getService(); if (service == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return NULL; } return service->registerInstance(toAdopt, locale, kind, status); }
URegistryKey NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status) { ICULocaleService *service = getService(); if (service) { return service->registerFactory(new NFFactory(toAdopt), status); } status = U_MEMORY_ALLOCATION_ERROR; return NULL; }
URegistryKey U_EXPORT2 NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status) { ICULocaleService *service = getNumberFormatService(); if (service) { NFFactory *tempnnf = new NFFactory(toAdopt); if (tempnnf != NULL) { return service->registerFactory(tempnnf, status); } } status = U_MEMORY_ALLOCATION_ERROR; return NULL; }
static ICULocaleService* getService(void) { UBool needInit; { Mutex mutex; needInit = (UBool)(gService == NULL); } if (needInit) { UErrorCode status = U_ZERO_ERROR; #ifdef U_DEBUG_CALSVC fprintf(stderr, "Spinning up Calendar Service\n"); #endif ICULocaleService * newservice = new CalendarService(); #ifdef U_DEBUG_CALSVC fprintf(stderr, "Registering classes..\n"); #endif // Register all basic instances. newservice->registerFactory(new BasicCalendarFactory("japanese"),status); newservice->registerFactory(new BasicCalendarFactory("buddhist"),status); newservice->registerFactory(new BasicCalendarFactory("gregorian"),status); #ifdef U_DEBUG_CALSVC fprintf(stderr, "Done..\n"); #endif if(U_FAILURE(status)) { #ifdef U_DEBUG_CALSVC fprintf(stderr, "err (%s) registering classes, deleting service.....\n", u_errorName(status)); #endif delete newservice; newservice = NULL; } if (newservice) { Mutex mutex; if (gService == NULL) { gService = newservice; newservice = NULL; } } if (newservice) { delete newservice; } else { // we won the contention - we can register the cleanup. ucln_i18n_registerCleanup(); } } return gService; }
const UnicodeString& ICULocaleService::validateFallbackLocale() const { const Locale& loc = Locale::getDefault(); ICULocaleService* ncThis = (ICULocaleService*)this; { Mutex mutex(&ncThis->llock); if (loc != fallbackLocale) { ncThis->fallbackLocale = loc; LocaleUtility::initNameFromLocale(loc, ncThis->fallbackLocaleName); ncThis->clearServiceCache(); } } return fallbackLocaleName; }
ServiceEnumeration(const ICULocaleService* service, UErrorCode &status) : _service(service) , _timestamp(service->getTimestamp()) , _ids(uhash_deleteUnicodeString, NULL, status) , _pos(0) { _service->getVisibleIDs(_ids, status); }
UBool upToDate(UErrorCode& status) const { if (U_SUCCESS(status)) { if (_timestamp == _service->getTimestamp()) { return TRUE; } status = U_ENUM_OUT_OF_SYNC_ERROR; } return FALSE; }