您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ures_openDirect函数代码示例

51自学网 2021-06-03 09:17:18
  C++
这篇教程C++ ures_openDirect函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ures_openDirect函数的典型用法代码示例。如果您正苦于以下问题:C++ ures_openDirect函数的具体用法?C++ ures_openDirect怎么用?C++ ures_openDirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ures_openDirect函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: measurementTypeBundleForLocale

static UResourceBundle * measurementTypeBundleForLocale(const char *localeID, const char *measurementType, UErrorCode *status){    char region[ULOC_COUNTRY_CAPACITY];    UResourceBundle *rb;    UResourceBundle *measTypeBundle = NULL;    ulocimp_getRegionForSupplementalData(localeID, TRUE, region, ULOC_COUNTRY_CAPACITY, status);    rb = ures_openDirect(NULL, "supplementalData", status);    ures_getByKey(rb, "measurementData", rb, status);    if (rb != NULL) {        UResourceBundle *measDataBundle = ures_getByKey(rb, region, NULL, status);        if (U_SUCCESS(*status)) {		measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);        }        if (*status == U_MISSING_RESOURCE_ERROR) {            *status = U_ZERO_ERROR;            if (measDataBundle != NULL) {                ures_close(measDataBundle);            }            measDataBundle = ures_getByKey(rb, "001", NULL, status);            measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);        }        ures_close(measDataBundle);    }    ures_close(rb);    return measTypeBundle;}
开发者ID:JoeDoyle23,项目名称:node,代码行数:27,


示例2: ulocdata_getCLDRVersion

U_CAPI void U_EXPORT2ulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status) {    UResourceBundle *rb = NULL;    rb = ures_openDirect(NULL, "supplementalData", status);    ures_getVersionByKey(rb, "cldrVersion", versionArray, status);    ures_close(rb);}
开发者ID:JoeDoyle23,项目名称:node,代码行数:7,


示例3: u_strlen

const UChar*ZoneMeta::getShortIDFromCanonical(const UChar* canonicalID) {    const UChar* shortID = NULL;    int32_t len = u_strlen(canonicalID);    char tzidKey[ZID_KEY_MAX + 1];    u_UCharsToChars(canonicalID, tzidKey, len);    tzidKey[len] = (char) 0; // Make sure it is null terminated.    // replace '/' with ':'    char *p = tzidKey;    while (*p++) {        if (*p == '/') {            *p = ':';        }    }    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *rb = ures_openDirect(NULL, gKeyTypeData, &status);    ures_getByKey(rb, gTypeMapTag, rb, &status);    ures_getByKey(rb, gTimezoneTag, rb, &status);    shortID = ures_getStringByKey(rb, tzidKey, NULL, &status);    ures_close(rb);    return shortID;}
开发者ID:basti1302,项目名称:node,代码行数:26,


示例4: getCanonicalCountry

UnicodeString& U_EXPORT2ZoneMeta::getSingleCountry(const UnicodeString &tzid, UnicodeString &country) {    UErrorCode status = U_ZERO_ERROR;    // Get canonical country for the zone    getCanonicalCountry(tzid, country);    if (!country.isEmpty()) {         UResourceBundle *supplementalDataBundle = ures_openDirect(NULL, gSupplementalData, &status);        UResourceBundle *zoneFormatting = ures_getByKey(supplementalDataBundle, gZoneFormattingTag, NULL, &status);        UResourceBundle *multizone = ures_getByKey(zoneFormatting, gMultizoneTag, NULL, &status);        if (U_SUCCESS(status)) {            while (ures_hasNext(multizone)) {                int32_t len;                const UChar* multizoneCountry = ures_getNextString(multizone, &len, NULL, &status);                if (country.compare(multizoneCountry, len) == 0) {                    // Included in the multizone country list                    country.remove();                    break;                }            }        }        ures_close(multizone);        ures_close(zoneFormatting);        ures_close(supplementalDataBundle);    }    return country;}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:31,


示例5: initAvailableMetaZoneIDs

static void U_CALLCONV initAvailableMetaZoneIDs () {    U_ASSERT(gMetaZoneIDs == NULL);    U_ASSERT(gMetaZoneIDTable == NULL);    ucln_i18n_registerCleanup(UCLN_I18N_ZONEMETA, zoneMeta_cleanup);    UErrorCode status = U_ZERO_ERROR;    gMetaZoneIDTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, &status);    if (U_FAILURE(status) || gMetaZoneIDTable == NULL) {        gMetaZoneIDTable = NULL;        return;    }    uhash_setKeyDeleter(gMetaZoneIDTable, uprv_deleteUObject);    // No valueDeleter, because the vector maintain the value objects    gMetaZoneIDs = new UVector(NULL, uhash_compareUChars, status);    if (U_FAILURE(status) || gMetaZoneIDs == NULL) {        gMetaZoneIDs = NULL;        uhash_close(gMetaZoneIDTable);        gMetaZoneIDTable = NULL;        return;    }    gMetaZoneIDs->setDeleter(uprv_free);    UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);    UResourceBundle *bundle = ures_getByKey(rb, gMapTimezonesTag, NULL, &status);    UResourceBundle res;    ures_initStackObject(&res);    while (U_SUCCESS(status) && ures_hasNext(bundle)) {        ures_getNextResource(bundle, &res, &status);        if (U_FAILURE(status)) {            break;        }        const char *mzID = ures_getKey(&res);        int32_t len = uprv_strlen(mzID);        UChar *uMzID = (UChar*)uprv_malloc(sizeof(UChar) * (len + 1));        if (uMzID == NULL) {            status = U_MEMORY_ALLOCATION_ERROR;            break;        }        u_charsToUChars(mzID, uMzID, len);        uMzID[len] = 0;        UnicodeString *usMzID = new UnicodeString(uMzID);        if (uhash_get(gMetaZoneIDTable, usMzID) == NULL) {            gMetaZoneIDs->addElement((void *)uMzID, status);            uhash_put(gMetaZoneIDTable, (void *)usMzID, (void *)uMzID, &status);        } else {            uprv_free(uMzID);            delete usMzID;        }    }    ures_close(&res);    ures_close(bundle);    ures_close(rb);    if (U_FAILURE(status)) {        uhash_close(gMetaZoneIDTable);        delete gMetaZoneIDs;        gMetaZoneIDTable = NULL;        gMetaZoneIDs = NULL;    }}
开发者ID:Akesure,项目名称:jxcore,代码行数:60,


示例6: UMTX_CHECK

const char*TimeZone::getTZDataVersion(UErrorCode& status){    /* This is here to prevent race conditions. */    UBool needsInit;    UMTX_CHECK(&LOCK, !TZDataVersionInitialized, needsInit);    if (needsInit) {        int32_t len = 0;        UResourceBundle *bundle = ures_openDirect(NULL, "zoneinfo", &status);        const UChar *tzver = ures_getStringByKey(bundle, "TZVersion",            &len, &status);        if (U_SUCCESS(status)) {            if (len >= (int32_t)sizeof(TZDATA_VERSION)) {                // Ensure that there is always space for a trailing nul in TZDATA_VERSION                len = sizeof(TZDATA_VERSION) - 1;            }            umtx_lock(&LOCK);            if (!TZDataVersionInitialized) {                u_UCharsToChars(tzver, TZDATA_VERSION, len);                TZDataVersionInitialized = TRUE;            }            umtx_unlock(&LOCK);            ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);        }        ures_close(bundle);    }    if (U_FAILURE(status)) {        return NULL;    }    return (const char*)TZDATA_VERSION;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:33,


示例7: openOlsonResource

static UResourceBundle* openOlsonResource(const UnicodeString& id,                                          UResourceBundle& res,                                          UErrorCode& ec){#if U_DEBUG_TZ    char buf[128];    id.extract(0, sizeof(buf)-1, buf, sizeof(buf), "");#endif    UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);    U_DEBUG_TZ_MSG(("pre: res sz=%d/n", ures_getSize(&res)));    /* &res = */ getZoneByName(top, id, &res, ec);    // Dereference if this is an alias.  Docs say result should be 1    // but it is 0 in 2.8 (?).    U_DEBUG_TZ_MSG(("Loading zone '%s' (%s, size %d) - %s/n", buf, ures_getKey((UResourceBundle*)&res), ures_getSize(&res), u_errorName(ec)));    if (ures_getSize(&res) <= 1 && getOlsonMeta(top)) {        int32_t deref = ures_getInt(&res, &ec) + 0;        U_DEBUG_TZ_MSG(("getInt: %s - type is %d/n", u_errorName(ec), ures_getType(&res)));        UResourceBundle *ares = ures_getByKey(top, kZONES, NULL, &ec); // dereference Zones section        ures_getByIndex(ares, deref, &res, &ec);        ures_close(ares);        U_DEBUG_TZ_MSG(("alias to #%d (%s) - %s/n", deref, "??", u_errorName(ec)));    } else {        U_DEBUG_TZ_MSG(("not an alias - size %d/n", ures_getSize(&res)));    }    U_DEBUG_TZ_MSG(("%s - final status is %s/n", buf, u_errorName(ec)));    return top;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:27,


示例8: ures_openDirect

const UChar*TimeZone::dereferOlsonLink(const UnicodeString& id) {    const UChar *result = NULL;    UErrorCode ec = U_ZERO_ERROR;    UResourceBundle *rb = ures_openDirect(NULL, kZONEINFO, &ec);    // resolve zone index by name    UResourceBundle *names = ures_getByKey(rb, kNAMES, NULL, &ec);    int32_t idx = findInStringArray(names, id, ec);    result = ures_getStringByIndex(names, idx, NULL, &ec);    // open the zone bundle by index    ures_getByKey(rb, kZONES, rb, &ec);    ures_getByIndex(rb, idx, rb, &ec);    if (U_SUCCESS(ec)) {        if (ures_getType(rb) == URES_INT) {            // this is a link - dereference the link            int32_t deref = ures_getInt(rb, &ec);            const UChar* tmp = ures_getStringByIndex(names, deref, NULL, &ec);            if (U_SUCCESS(ec)) {                result = tmp;            }        }    }    ures_close(names);    ures_close(rb);    return result;}
开发者ID:hihihippp,项目名称:build-couchdb-1,代码行数:31,


示例9: ures_openDirect

NumberingSystem* U_EXPORT2NumberingSystem::createInstanceByName(const char *name, UErrorCode& status) {    UResourceBundle *numberingSystemsInfo = NULL;    UResourceBundle *nsTop, *nsCurrent;    int32_t radix = 10;    int32_t algorithmic = 0;    numberingSystemsInfo = ures_openDirect(NULL,gNumberingSystems, &status);    nsCurrent = ures_getByKey(numberingSystemsInfo,gNumberingSystems,NULL,&status);    nsTop = ures_getByKey(nsCurrent,name,NULL,&status);    UnicodeString nsd = ures_getUnicodeStringByKey(nsTop,gDesc,&status);    ures_getByKey(nsTop,gRadix,nsCurrent,&status);    radix = ures_getInt(nsCurrent,&status);    ures_getByKey(nsTop,gAlgorithmic,nsCurrent,&status);    algorithmic = ures_getInt(nsCurrent,&status);    UBool isAlgorithmic = ( algorithmic == 1 );    ures_close(nsCurrent);    ures_close(nsTop);    ures_close(numberingSystemsInfo);    if (U_FAILURE(status)) {        status = U_UNSUPPORTED_ERROR;        return NULL;    }    NumberingSystem* ns = NumberingSystem::createInstance(radix,isAlgorithmic,nsd,status);    ns->setName(name);    return ns;}
开发者ID:MIPS,项目名称:external-icu,代码行数:33,


示例10: initAvailableLocaleList

static void U_CALLCONV initAvailableLocaleList(UErrorCode &status) {    U_ASSERT(availableLocaleListCount == 0);    U_ASSERT(availableLocaleList == NULL);    // for now, there is a hardcoded list, so just walk through that list and set it up.    UResourceBundle *index = NULL;    UResourceBundle installed;    int32_t i = 0;        ures_initStackObject(&installed);    index = ures_openDirect(U_ICUDATA_COLL, "res_index", &status);    ures_getByKey(index, "InstalledLocales", &installed, &status);        if(U_SUCCESS(status)) {        availableLocaleListCount = ures_getSize(&installed);        availableLocaleList = new Locale[availableLocaleListCount];                if (availableLocaleList != NULL) {            ures_resetIterator(&installed);            while(ures_hasNext(&installed)) {                const char *tempKey = NULL;                ures_getNextString(&installed, NULL, &tempKey, &status);                availableLocaleList[i++] = Locale(tempKey);            }        }        U_ASSERT(availableLocaleListCount == i);        ures_close(&installed);    }    ures_close(index);    ucln_i18n_registerCleanup(UCLN_I18N_COLLATOR, collator_cleanup);}
开发者ID:cyrusimap,项目名称:icu4c,代码行数:31,


示例11: measurementTypeBundleForLocale

static UResourceBundle * measurementTypeBundleForLocale(const char *localeID, const char *measurementType, UErrorCode *status){    char fullLoc[ULOC_FULLNAME_CAPACITY];    char region[ULOC_COUNTRY_CAPACITY];    UResourceBundle *rb;    UResourceBundle *measTypeBundle = NULL;        /* The following code is basically copied from Calendar::setWeekData and     * Calendar::getCalendarTypeForLocale with adjustments for resource name     */    uloc_addLikelySubtags(localeID, fullLoc, ULOC_FULLNAME_CAPACITY, status);    uloc_getCountry(fullLoc, region, ULOC_COUNTRY_CAPACITY, status);        rb = ures_openDirect(NULL, "supplementalData", status);    ures_getByKey(rb, "measurementData", rb, status);    if (rb != NULL) {        UResourceBundle *measDataBundle = ures_getByKey(rb, region, NULL, status);        if (U_SUCCESS(*status)) {        	measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);        }        if (*status == U_MISSING_RESOURCE_ERROR) {            *status = U_ZERO_ERROR;            if (measDataBundle != NULL) {                ures_close(measDataBundle);            }            measDataBundle = ures_getByKey(rb, "001", NULL, status);            measTypeBundle = ures_getByKey(measDataBundle, measurementType, NULL, status);        }        ures_close(measDataBundle);    }    ures_close(rb);    return measTypeBundle;}
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:32,


示例12: resourcebundle_ctor

/* {{{ ResourceBundle_ctor */static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor){	const char *bundlename;	size_t		bundlename_len = 0;	const char *locale;	size_t		locale_len = 0;	zend_bool	fallback = 1;	int         zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;	zval                  *object = return_value;	ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );	intl_error_reset( NULL );	if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s!s!|b",		&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )	{		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,			"resourcebundle_ctor: unable to parse input parameters", 0 );		return FAILURE;	}	INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);	if (locale == NULL) {		locale = intl_locale_get_default();	}	if (bundlename_len >= MAXPATHLEN) {		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,	"Bundle name too long", 0 );		zval_ptr_dtor(return_value);		ZVAL_NULL(return_value);		return FAILURE;	}	if (fallback) {		rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));	} else {		rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));	}	INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||			INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {		char *pbuf;		intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb));		spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource "				"'%s' without fallback from %s to %s",				bundlename ? bundlename : "(default data)", locale,				ures_getLocaleByType(					rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));		intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1);		efree(pbuf);		return FAILURE;	}	return SUCCESS;}
开发者ID:IMSoP,项目名称:php-src,代码行数:60,


示例13: TZEnumeration

    TZEnumeration(const char* country) : map(NULL), len(0), pos(0) {        if (!getOlsonMeta()) {            return;        }        UErrorCode ec = U_ZERO_ERROR;        UResourceBundle *res = ures_openDirect(0, kZONEINFO, &ec);        ures_getByKey(res, kREGIONS, res, &ec);        if (U_SUCCESS(ec) && ures_getType(res) == URES_ARRAY) {            UChar uCountry[] = {0, 0, 0, 0};            if (country) {                u_charsToUChars(country, uCountry, 2);            } else {                u_strcpy(uCountry, WORLD);            }            // count matches            int32_t count = 0;            int32_t i;            const UChar *region;            for (i = 0; i < ures_getSize(res); i++) {                region = ures_getStringByIndex(res, i, NULL, &ec);                if (U_FAILURE(ec)) {                    break;                }                if (u_strcmp(uCountry, region) == 0) {                    count++;                }            }            if (count > 0) {                map = (int32_t*)uprv_malloc(sizeof(int32_t) * count);                if (map != NULL) {                    int32_t idx = 0;                    for (i = 0; i < ures_getSize(res); i++) {                        region = ures_getStringByIndex(res, i, NULL, &ec);                        if (U_FAILURE(ec)) {                            break;                        }                        if (u_strcmp(uCountry, region) == 0) {                            map[idx++] = i;                        }                    }                    if (U_SUCCESS(ec)) {                        len = count;                    } else {                        uprv_free(map);                        map = NULL;                    }                } else {                    U_DEBUG_TZ_MSG(("Failed to load tz for region %s: %s/n", country, u_errorName(ec)));                }            }        }        ures_close(res);    }
开发者ID:hihihippp,项目名称:build-couchdb-1,代码行数:56,


示例14: getOlsonMeta

static UBool getOlsonMeta() {    if (OLSON_ZONE_COUNT == 0) {        UErrorCode ec = U_ZERO_ERROR;        UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);        if (U_SUCCESS(ec)) {            getOlsonMeta(top);        }        ures_close(top);    }    return (OLSON_ZONE_COUNT > 0);}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:11,


示例15: _findMetaData

/** * Internal function to look up currency data.  Result is an array of * two integers.  The first is the fraction digits.  The second is the * rounding increment, or 0 if none.  The rounding increment is in * units of 10^(-fraction_digits). */static const int32_t*_findMetaData(const UChar* currency, UErrorCode& ec) {    if (currency == 0 || *currency == 0) {        if (U_SUCCESS(ec)) {            ec = U_ILLEGAL_ARGUMENT_ERROR;        }        return LAST_RESORT_DATA;    }    // Get CurrencyMeta resource out of root locale file.  [This may    // move out of the root locale file later; if it does, update this    // code.]    UResourceBundle* currencyData = ures_openDirect(NULL, CURRENCY_DATA, &ec);    UResourceBundle* currencyMeta = ures_getByKey(currencyData, CURRENCY_META, currencyData, &ec);    if (U_FAILURE(ec)) {        ures_close(currencyMeta);        // Config/build error; return hard-coded defaults        return LAST_RESORT_DATA;    }    // Look up our currency, or if that's not available, then DEFAULT    char buf[ISO_COUNTRY_CODE_LENGTH+1];    UErrorCode ec2 = U_ZERO_ERROR; // local error code: soft failure    UResourceBundle* rb = ures_getByKey(currencyMeta, myUCharsToChars(buf, currency), NULL, &ec2);      if (U_FAILURE(ec2)) {        ures_close(rb);        rb = ures_getByKey(currencyMeta,DEFAULT_META, NULL, &ec);        if (U_FAILURE(ec)) {            ures_close(currencyMeta);            ures_close(rb);            // Config/build error; return hard-coded defaults            return LAST_RESORT_DATA;        }    }    int32_t len;    const int32_t *data = ures_getIntVector(rb, &len, &ec);    if (U_FAILURE(ec) || len != 2) {        // Config/build error; return hard-coded defaults        if (U_SUCCESS(ec)) {            ec = U_INVALID_FORMAT_ERROR;        }        ures_close(currencyMeta);        ures_close(rb);        return LAST_RESORT_DATA;    }    ures_close(currencyMeta);    ures_close(rb);    return data;}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:59,


示例16: loadOlsonIDs

static UBool loadOlsonIDs() {    if (OLSON_IDS != 0) {        return TRUE;    }    UErrorCode ec = U_ZERO_ERROR;    UnicodeString* ids = 0;    int32_t count = 0;    UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);    UResourceBundle *nres = ures_getByKey(top, kNAMES, NULL, &ec); // dereference Names section    if (U_SUCCESS(ec)) {        getOlsonMeta(top);        int32_t start = 0;        count = ures_getSize(nres);        ids = new UnicodeString[(count > 0) ? count : 1];        // Null pointer check        if (ids != NULL) {            for (int32_t i=0; i<count; ++i) {                int32_t idLen = 0;                const UChar* id = ures_getStringByIndex(nres, i, &idLen, &ec);                ids[i].fastCopyFrom(UnicodeString(TRUE, id, idLen));                if (U_FAILURE(ec)) {                    break;                }            }        } else {            ec = U_MEMORY_ALLOCATION_ERROR;        }    }    ures_close(nres);    ures_close(top);    if (U_FAILURE(ec)) {        delete[] ids;        return FALSE;    }    // Keep mutexed operations as short as possible by doing all    // computations first, then doing pointer copies within the mutex.    umtx_lock(&LOCK);    if (OLSON_IDS == 0) {        OLSON_IDS = ids;        ids = 0;        ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONE, timeZone_cleanup);    }    umtx_unlock(&LOCK);    // If another thread initialized the statics first, then delete    // our unused data.    delete[] ids;    return TRUE;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:52,


示例17: isAvailableLocaleListInitialized

static UBool isAvailableLocaleListInitialized(UErrorCode &status) {    // for now, there is a hardcoded list, so just walk through that list and set it up.    UBool needInit;    UMTX_CHECK(NULL, availableLocaleList == NULL, needInit);    if (needInit) {        UResourceBundle *index = NULL;        UResourceBundle installed;        Locale * temp;        int32_t i = 0;        int32_t localeCount;                ures_initStackObject(&installed);        index = ures_openDirect(U_ICUDATA_COLL, "res_index", &status);        ures_getByKey(index, "InstalledLocales", &installed, &status);                if(U_SUCCESS(status)) {            localeCount = ures_getSize(&installed);            temp = new Locale[localeCount];                        if (temp != NULL) {                ures_resetIterator(&installed);                while(ures_hasNext(&installed)) {                    const char *tempKey = NULL;                    ures_getNextString(&installed, NULL, &tempKey, &status);                    temp[i++] = Locale(tempKey);                }                                umtx_lock(NULL);                if (availableLocaleList == NULL)                {                    availableLocaleListCount = localeCount;                    availableLocaleList = temp;                    temp = NULL;                    ucln_i18n_registerCleanup(UCLN_I18N_COLLATOR, collator_cleanup);                }                 umtx_unlock(NULL);                needInit = FALSE;                if (temp) {                    delete []temp;                }            }            ures_close(&installed);        }        ures_close(index);    }    return !needInit;}
开发者ID:CucasLoon,项目名称:in-the-box,代码行数:50,


示例18: u_getDataVersion

U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status) {    UResourceBundle *icudatares = NULL;    if (U_FAILURE(*status)) {        return;    }    if (dataVersionFillin != NULL) {        icudatares = ures_openDirect(NULL, U_ICU_VERSION_BUNDLE , status);        if (U_SUCCESS(*status)) {            ures_getVersionByKey(icudatares, U_ICU_DATA_KEY, dataVersionFillin, status);        }        ures_close(icudatares);    }}
开发者ID:AceRiddle,项目名称:node,代码行数:15,


示例19: getCurrencyCodeNative

static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz, jstring key) {    UErrorCode status = U_ZERO_ERROR;    ScopedResourceBundle supplData(ures_openDirect(NULL, "supplementalData", &status));    if (U_FAILURE(status)) {        return NULL;    }    ScopedResourceBundle currencyMap(ures_getByKey(supplData.get(), "CurrencyMap", NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }    const char* keyChars = env->GetStringUTFChars(key, NULL);    ScopedResourceBundle currency(ures_getByKey(currencyMap.get(), keyChars, NULL, &status));    env->ReleaseStringUTFChars(key, keyChars);    if (U_FAILURE(status)) {        return NULL;    }    ScopedResourceBundle currencyElem(ures_getByIndex(currency.get(), 0, NULL, &status));    if (U_FAILURE(status)) {        return env->NewStringUTF("None");    }    // check if there is a 'to' date. If there is, the currency isn't used anymore.    ScopedResourceBundle currencyTo(ures_getByKey(currencyElem.get(), "to", NULL, &status));    if (!U_FAILURE(status)) {        // return and let the caller throw an exception        return NULL;    }    // We need to reset 'status'. It works like errno in that ICU doesn't set it    // to U_ZERO_ERROR on success: it only touches it on error, and the test    // above means it now holds a failure code.    status = U_ZERO_ERROR;    ScopedResourceBundle currencyId(ures_getByKey(currencyElem.get(), "id", NULL, &status));    if (U_FAILURE(status)) {        // No id defined for this country        return env->NewStringUTF("None");    }    int length;    const jchar* id = ures_getString(currencyId.get(), &length, &status);    if (U_FAILURE(status) || length == 0) {        return env->NewStringUTF("None");    }    return env->NewString(id, length);}
开发者ID:Ar3kkusu,项目名称:android_libcore,代码行数:48,


示例20: getID

 UBool getID(int32_t i) {     UErrorCode ec = U_ZERO_ERROR;     int32_t idLen = 0;     const UChar* id = NULL;     UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);     top = ures_getByKey(top, kNAMES, top, &ec); // dereference Zones section     id = ures_getStringByIndex(top, i, &idLen, &ec);     if(U_FAILURE(ec)) {         unistr.truncate(0);     }     else {         unistr.fastCopyFrom(UnicodeString(TRUE, id, idLen));     }     ures_close(top);     return U_SUCCESS(ec); }
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:16,


示例21: numsysNames

StringEnumeration* NumberingSystem::getAvailableNames(UErrorCode &status) {    // TODO(ticket #11908): Init-once static cache, with u_cleanup() callback.    static StringEnumeration* availableNames = NULL;    if (U_FAILURE(status)) {        return NULL;    }    if ( availableNames == NULL ) {        // TODO: Simple array of UnicodeString objects, based on length of table resource?        LocalPointer<UVector> numsysNames(new UVector(uprv_deleteUObject, NULL, status), status);        if (U_FAILURE(status)) {            return NULL;        }                UErrorCode rbstatus = U_ZERO_ERROR;        UResourceBundle *numberingSystemsInfo = ures_openDirect(NULL, "numberingSystems", &rbstatus);        numberingSystemsInfo = ures_getByKey(numberingSystemsInfo,"numberingSystems",numberingSystemsInfo,&rbstatus);        if(U_FAILURE(rbstatus)) {            status = U_MISSING_RESOURCE_ERROR;            ures_close(numberingSystemsInfo);            return NULL;        }        while ( ures_hasNext(numberingSystemsInfo) ) {            UResourceBundle *nsCurrent = ures_getNextResource(numberingSystemsInfo,NULL,&rbstatus);            const char *nsName = ures_getKey(nsCurrent);            numsysNames->addElement(new UnicodeString(nsName, -1, US_INV),status);            ures_close(nsCurrent);        }        ures_close(numberingSystemsInfo);        if (U_FAILURE(status)) {            return NULL;        }        availableNames = new NumsysNameEnumeration(numsysNames.getAlias(), status);        if (availableNames == NULL) {            status = U_MEMORY_ALLOCATION_ERROR;            return NULL;        }        numsysNames.orphan();  // The names got adopted.    }    return availableNames;}
开发者ID:MIPS,项目名称:external-icu,代码行数:45,


示例22: ures_openDirect

UnicodeString& U_EXPORT2ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &region, UnicodeString &result) {    UErrorCode status = U_ZERO_ERROR;    const UChar *tzid = NULL;    int32_t tzidLen = 0;    char keyBuf[ZID_KEY_MAX + 1];    int32_t keyLen = 0;    if (mzid.isBogus() || mzid.length() > ZID_KEY_MAX) {        result.setToBogus();        return result;    }    keyLen = mzid.extract(0, mzid.length(), keyBuf, ZID_KEY_MAX + 1, US_INV);    keyBuf[keyLen] = 0;    UResourceBundle *rb = ures_openDirect(NULL, gMetaZones, &status);    ures_getByKey(rb, gMapTimezonesTag, rb, &status);    ures_getByKey(rb, keyBuf, rb, &status);    if (U_SUCCESS(status)) {        // check region mapping        if (region.length() == 2 || region.length() == 3) {            keyLen = region.extract(0, region.length(), keyBuf, ZID_KEY_MAX + 1, US_INV);            keyBuf[keyLen] = 0;            tzid = ures_getStringByKey(rb, keyBuf, &tzidLen, &status);            if (status == U_MISSING_RESOURCE_ERROR) {                status = U_ZERO_ERROR;            }        }        if (U_SUCCESS(status) && tzid == NULL) {            // try "001"            tzid = ures_getStringByKey(rb, gWorldTag, &tzidLen, &status);        }    }    ures_close(rb);    if (tzid == NULL) {        result.setToBogus();    } else {        result.setTo(tzid, tzidLen);    }    return result;}
开发者ID:basti1302,项目名称:node,代码行数:45,


示例23: ures_openDirect

//Get test data from ResourceBundlesUResourceBundle* RBTestDataModule::getTestBundle(const char* bundleName, UErrorCode &status) {  if(U_SUCCESS(status)) {    UResourceBundle *testBundle = NULL;    const char* icu_data = fLog.getTestDataPath(status);    if (testBundle == NULL) {        testBundle = ures_openDirect(icu_data, bundleName, &status);        if (status != U_ZERO_ERROR) {            fLog.dataerrln(UNICODE_STRING_SIMPLE("Could not load test data from resourcebundle: ") + UnicodeString(bundleName, -1, US_INV) + "/n");            fDataTestValid = FALSE;        }    }    return testBundle;  } else {    return NULL;  }}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:19,


示例24: DayPeriodRulesData

void U_CALLCONV DayPeriodRules::load(UErrorCode &errorCode) {    if (U_FAILURE(errorCode)) {        return;    }    data = new DayPeriodRulesData();    data->localeToRuleSetNumMap = uhash_open(uhash_hashChars, uhash_compareChars, NULL, &errorCode);    LocalUResourceBundlePointer rb_dayPeriods(ures_openDirect(NULL, "dayPeriods", &errorCode));    // Get the largest rule set number (so we allocate enough objects).    DayPeriodRulesCountSink countSink;    ures_getAllItemsWithFallback(rb_dayPeriods.getAlias(), "rules", countSink, errorCode);    // Populate rules.    DayPeriodRulesDataSink sink;    ures_getAllItemsWithFallback(rb_dayPeriods.getAlias(), "", sink, errorCode);    ucln_i18n_registerCleanup(UCLN_I18N_DAYPERIODRULES, dayPeriodRulesCleanup);}
开发者ID:DavidCai1993,项目名称:node,代码行数:19,


示例25: ICU_getCurrencyCode

// TODO: rewrite this with int32_t ucurr_forLocale(const char* locale, UChar* buff, int32_t buffCapacity, UErrorCode* ec)...static jstring ICU_getCurrencyCode(JNIEnv* env, jclass, jstring javaCountryCode) {    UErrorCode status = U_ZERO_ERROR;    ScopedResourceBundle supplData(ures_openDirect(U_ICUDATA_CURR, "supplementalData", &status));    if (U_FAILURE(status)) {        return NULL;    }    ScopedResourceBundle currencyMap(ures_getByKey(supplData.get(), "CurrencyMap", NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }    ScopedUtfChars countryCode(env, javaCountryCode);    ScopedResourceBundle currency(ures_getByKey(currencyMap.get(), countryCode.c_str(), NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }    ScopedResourceBundle currencyElem(ures_getByIndex(currency.get(), 0, NULL, &status));    if (U_FAILURE(status)) {        return env->NewStringUTF("XXX");    }    // Check if there's a 'to' date. If there is, the currency isn't used anymore.    ScopedResourceBundle currencyTo(ures_getByKey(currencyElem.get(), "to", NULL, &status));    if (!U_FAILURE(status)) {        return NULL;    }    // Ignore the failure to find a 'to' date.    status = U_ZERO_ERROR;    ScopedResourceBundle currencyId(ures_getByKey(currencyElem.get(), "id", NULL, &status));    if (U_FAILURE(status)) {        // No id defined for this country        return env->NewStringUTF("XXX");    }    int32_t charCount;    const jchar* chars = ures_getString(currencyId.get(), &charCount, &status);    return (charCount == 0) ? env->NewStringUTF("XXX") : env->NewString(chars, charCount);}
开发者ID:LeMaker,项目名称:android-actions,代码行数:42,


示例26: findLikelySubtags

/** * This function looks for the localeID in the likelySubtags resource. * * @param localeID The tag to find. * @param buffer A buffer to hold the matching entry * @param bufferLength The length of the output buffer * @return A pointer to "buffer" if found, or a null pointer if not. */static const char*  U_CALLCONVfindLikelySubtags(const char* localeID,                  char* buffer,                  int32_t bufferLength,                  UErrorCode* err) {    const char* result = NULL;    if (!U_FAILURE(*err)) {        int32_t resLen = 0;        const UChar* s = NULL;        UErrorCode tmpErr = U_ZERO_ERROR;        UResourceBundle* subtags = ures_openDirect(NULL, "likelySubtags", &tmpErr);        if (U_SUCCESS(tmpErr)) {            s = ures_getStringByKey(subtags, localeID, &resLen, &tmpErr);            if (U_FAILURE(tmpErr)) {                /*                 * If a resource is missing, it's not really an error, it's                 * just that we don't have any data for that particular locale ID.                 */                if (tmpErr != U_MISSING_RESOURCE_ERROR) {                    *err = tmpErr;                }            }            else if (resLen >= bufferLength) {                /* The buffer should never overflow. */                *err = U_INTERNAL_PROGRAM_ERROR;            }            else {                u_UCharsToChars(s, buffer, resLen + 1);                result = buffer;            }            ures_close(subtags);        } else {            *err = tmpErr;        }    }    return result;}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:49,


示例27: TZEnumeration

    TZEnumeration(const char* country) : map(NULL), len(0), pos(0) {        if (!getOlsonMeta()) {            return;        }        char key[] = {0, 0, 0, 0,0, 0, 0,0, 0, 0,0}; // e.g., "US", or "Default" for no country        if (country)  {          uprv_strncat(key, country, 2);        } else {          uprv_strcpy(key, kDEFAULT);        }        UErrorCode ec = U_ZERO_ERROR;        UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);        top = ures_getByKey(top, kREGIONS, top, &ec); // dereference 'Regions' section        if (U_SUCCESS(ec)) {            UResourceBundle res;            ures_initStackObject(&res);            ures_getByKey(top, key, &res, &ec);            // The list of zones is a list of integers, from 0..n-1,            // where n is the total number of system zones.            const int32_t* v = ures_getIntVector(&res, &len, &ec);            if (U_SUCCESS(ec)) {                U_ASSERT(len > 0);                map = (int32_t*)uprv_malloc(sizeof(int32_t) * len);                if (map != 0) {                    for (uint16_t i=0; i<len; ++i) {                        U_ASSERT(v[i] >= 0 && v[i] < OLSON_ZONE_COUNT);                        map[i] = v[i];                    }                }            } else {              U_DEBUG_TZ_MSG(("Failed to load tz for region %s: %s/n", country, u_errorName(ec)));            }            ures_close(&res);        }        ures_close(top);    }
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:38,


示例28: ures_openDirect

UnicodeString&TimeZone::dereferOlsonLink(const UnicodeString& linkTo, UnicodeString& linkFrom) {    UErrorCode ec = U_ZERO_ERROR;    linkFrom.remove();    UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec);    UResourceBundle *res = getZoneByName(top, linkTo, NULL, ec);    if (U_SUCCESS(ec)) {        if (ures_getSize(res) == 1) {            int32_t deref = ures_getInt(res, &ec);            UResourceBundle *nres = ures_getByKey(top, kNAMES, NULL, &ec); // dereference Names section            int32_t len;            const UChar* tmp = ures_getStringByIndex(nres, deref, &len, &ec);            if (U_SUCCESS(ec)) {                linkFrom.setTo(tmp, len);            }            ures_close(nres);        } else {            linkFrom.setTo(linkTo);        }    }    ures_close(res);    ures_close(top);    return linkFrom;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:24,



注:本文中的ures_openDirect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uri函数代码示例
C++ ures_open函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。