示例#1
0
StringEnumeration* U_EXPORT2
BreakIterator::getAvailableLocales(void)
{
    ICULocaleService *service = getService();
    if (service == NULL) {
        return NULL;
    }
    return service->getAvailableLocales();
}
示例#2
0
文件: numfmt.cpp 项目: gitpan/ponie
// -------------------------------------
StringEnumeration* 
NumberFormat::getAvailableLocales(void)
{
  ICULocaleService *service = getService();
  if (service) {
    return service->getAvailableLocales();
  }
  return NULL; // no way to return error condition
}
示例#3
0
 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);
     }
 }
示例#4
0
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);
}
示例#5
0
文件: numfmt.cpp 项目: gitpan/ponie
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;
}
示例#6
0
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;
}
示例#7
0
文件: calendar.cpp 项目: gitpan/ponie
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;
}
示例#8
0
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;
}
示例#9
0
 ServiceEnumeration(const ICULocaleService* service, UErrorCode &status)
     : _service(service)
     , _timestamp(service->getTimestamp())
     , _ids(uhash_deleteUnicodeString, NULL, status)
     , _pos(0)
 {
     _service->getVisibleIDs(_ids, status);
 }
示例#10
0
 UBool upToDate(UErrorCode& status) const {
     if (U_SUCCESS(status)) {
         if (_timestamp == _service->getTimestamp()) {
             return TRUE;
         }
         status = U_ENUM_OUT_OF_SYNC_ERROR;
     }
     return FALSE;
 }