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

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

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

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

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

示例1: sizeof

NumberingSystem* U_EXPORT2NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) {    if (U_FAILURE(status)) {        return NULL;    }    UBool nsResolved = TRUE;    UBool usingFallback = FALSE;    char buffer[ULOC_KEYWORDS_CAPACITY];    int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),status);    if ( count > 0 ) { // @numbers keyword was specified in the locale        buffer[count] = '/0'; // Make sure it is null terminated.        if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||             !uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) {            nsResolved = FALSE;        }    } else {        uprv_strcpy(buffer,gDefault);        nsResolved = FALSE;    }    if (!nsResolved) { // Resolve the numbering system ( default, native, traditional or finance ) into a "real" numbering system        UErrorCode localStatus = U_ZERO_ERROR;        UResourceBundle *resource = ures_open(NULL, inLocale.getName(), &localStatus);        UResourceBundle *numberElementsRes = ures_getByKey(resource,gNumberElements,NULL,&localStatus);        while (!nsResolved) {            localStatus = U_ZERO_ERROR;            count = 0;            const UChar *nsName = ures_getStringByKeyWithFallback(numberElementsRes, buffer, &count, &localStatus);            if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // numbering system found                u_UCharsToChars(nsName,buffer,count);                buffer[count] = '/0'; // Make sure it is null terminated.                nsResolved = TRUE;            }            if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default                if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) {                    uprv_strcpy(buffer,gDefault);                } else if (!uprv_strcmp(buffer,gTraditional)) {                    uprv_strcpy(buffer,gNative);                } else { // If we get here we couldn't find even the default numbering system                    usingFallback = TRUE;                    nsResolved = TRUE;                }            }        }        ures_close(numberElementsRes);        ures_close(resource);    }    if (usingFallback) {        status = U_USING_FALLBACK_WARNING;        NumberingSystem *ns = new NumberingSystem();        return ns;    } else {        return NumberingSystem::createInstanceByName(buffer,status);    } }
开发者ID:DavidCai1993,项目名称:node,代码行数:59,


示例2: getCurrencySymbolNative

static jstring getCurrencySymbolNative(JNIEnv* env, jclass clazz,         jstring locale, jstring currencyCode) {    // LOGI("ENTER getCurrencySymbolNative");    UErrorCode status = U_ZERO_ERROR;    const char *locName = env->GetStringUTFChars(locale, NULL);    UResourceBundle *root = ures_open(NULL, locName, &status);    env->ReleaseStringUTFChars(locale, locName);    if(U_FAILURE(status)) {        return NULL;    }    UResourceBundle *rootElems = ures_getByKey(root, "Currencies", NULL, &status);    if(U_FAILURE(status)) {        ures_close(root);        return NULL;    }    const char *currName = env->GetStringUTFChars(currencyCode, NULL);    UResourceBundle *currencyElems = ures_getByKey(rootElems, currName, NULL, &status);    env->ReleaseStringUTFChars(currencyCode, currName);    if(U_FAILURE(status)) {        ures_close(rootElems);        ures_close(root);        return NULL;    }    int currSymbL;    const jchar *currSymbU = ures_getStringByIndex(currencyElems, 0, &currSymbL, &status);    if(U_FAILURE(status)) {        ures_close(currencyElems);        ures_close(rootElems);        ures_close(root);        return NULL;    }    ures_close(currencyElems);    ures_close(rootElems);    ures_close(root);    if(currSymbL == 0) {        return NULL;    }    return env->NewString(currSymbU, currSymbL);}
开发者ID:llnull,项目名称:platform_dalvik,代码行数:46,


示例3: ucol_prepareShortStringOpen

U_CAPI void U_EXPORT2ucol_prepareShortStringOpen( const char *definition,                          UBool,                          UParseError *parseError,                          UErrorCode *status){    if(U_FAILURE(*status)) return;    UParseError internalParseError;    if(!parseError) {        parseError = &internalParseError;    }    parseError->line = 0;    parseError->offset = 0;    parseError->preContext[0] = 0;    parseError->postContext[0] = 0;    // first we want to pick stuff out of short string.    // we'll end up with an UCA version, locale and a bunch of    // settings    // analyse the string in order to get everything we need.    CollatorSpec s;    ucol_sit_initCollatorSpecs(&s);    ucol_sit_readSpecs(&s, definition, parseError, status);    ucol_sit_calculateWholeLocale(&s);    char buffer[internalBufferSize];    uprv_memset(buffer, 0, internalBufferSize);    uloc_canonicalize(s.locale, buffer, internalBufferSize, status);    UResourceBundle *b = ures_open(U_ICUDATA_COLL, buffer, status);    /* we try to find stuff from keyword */    UResourceBundle *collations = ures_getByKey(b, "collations", NULL, status);    UResourceBundle *collElem = NULL;    char keyBuffer[256];    // if there is a keyword, we pick it up and try to get elements    if(!uloc_getKeywordValue(buffer, "collation", keyBuffer, 256, status)) {      // no keyword. we try to find the default setting, which will give us the keyword value      UResourceBundle *defaultColl = ures_getByKeyWithFallback(collations, "default", NULL, status);      if(U_SUCCESS(*status)) {        int32_t defaultKeyLen = 0;        const UChar *defaultKey = ures_getString(defaultColl, &defaultKeyLen, status);        u_UCharsToChars(defaultKey, keyBuffer, defaultKeyLen);        keyBuffer[defaultKeyLen] = 0;      } else {        *status = U_INTERNAL_PROGRAM_ERROR;        return;      }      ures_close(defaultColl);    }    collElem = ures_getByKeyWithFallback(collations, keyBuffer, collElem, status);    ures_close(collElem);    ures_close(collations);    ures_close(b);}
开发者ID:119120119,项目名称:node,代码行数:58,


示例4: 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);    StackUResourceBundle res;    while (U_SUCCESS(status) && ures_hasNext(bundle)) {        ures_getNextResource(bundle, res.getAlias(), &status);        if (U_FAILURE(status)) {            break;        }        const char *mzID = ures_getKey(res.getAlias());        int32_t len = static_cast<int32_t>(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(bundle);    ures_close(rb);    if (U_FAILURE(status)) {        uhash_close(gMetaZoneIDTable);        delete gMetaZoneIDs;        gMetaZoneIDTable = NULL;        gMetaZoneIDs = NULL;    }}
开发者ID:basti1302,项目名称:node,代码行数:58,


示例5: 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,


示例6: getEras

static jobjectArray getEras(JNIEnv* env, UResourceBundle *gregorian) {        jobjectArray eras;    jstring eraU;    const jchar* era;    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *gregorianElems;    UResourceBundle *eraElems;    gregorianElems = ures_getByKey(gregorian, "eras", NULL, &status);    if(U_FAILURE(status)) {        return NULL;    }    eraElems = ures_getByKey(gregorianElems, "abbreviated", NULL, &status);    if(U_FAILURE(status)) {        ures_close(gregorianElems);        return NULL;    }    int eraLength;    int eraCount = ures_getSize(eraElems);    eras = env->NewObjectArray(eraCount, string_class, NULL);    ures_resetIterator(eraElems);    for(int i = 0; i < eraCount; i++) {        era = ures_getStringByIndex(eraElems, i, &eraLength, &status);        if(U_FAILURE(status)) {            ures_close(gregorianElems);            ures_close(eraElems);            return NULL;        }        eraU = env->NewString(era, eraLength);        env->SetObjectArrayElement(eras, i, eraU);        env->DeleteLocalRef(eraU);    }    ures_close(eraElems);    ures_close(gregorianElems);    return eras;}
开发者ID:llnull,项目名称:platform_dalvik,代码行数:44,


示例7: 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,


示例8: ures_initStackObject

ResourceBundle ResourceBundle::get(const char* key, UErrorCode& status) const {    UResourceBundle r;    ures_initStackObject(&r);    ures_getByKey(fResource, key, &r, &status);    ResourceBundle res(&r, status);    if (U_SUCCESS(status)) {        ures_close(&r);    }    return res;}
开发者ID:MoonchildProductions,项目名称:Pale-Moon,代码行数:11,


示例9: U_DEBUG_TZ_MSG

const UnicodeString U_EXPORT2TimeZone::getEquivalentID(const UnicodeString& id, int32_t index) {    U_DEBUG_TZ_MSG(("gEI(%d)/n", index));    UnicodeString result;    UErrorCode ec = U_ZERO_ERROR;    UResourceBundle res;    ures_initStackObject(&res);    UResourceBundle *top = openOlsonResource(id, res, ec);    int32_t zone = -1;    if (U_SUCCESS(ec)) {        UResourceBundle r;        ures_initStackObject(&r);        int32_t size;        ures_getByKey(&res, kLINKS, &r, &ec);        const int32_t* v = ures_getIntVector(&r, &size, &ec);        if (U_SUCCESS(ec)) {            if (index >= 0 && index < size && getOlsonMeta()) {                zone = v[index];            }        }        ures_close(&r);    }    ures_close(&res);    if (zone >= 0) {        UResourceBundle *ares = ures_getByKey(top, kNAMES, NULL, &ec); // dereference Zones section        if (U_SUCCESS(ec)) {            int32_t idLen = 0;            const UChar* id = ures_getStringByIndex(ares, zone, &idLen, &ec);            result.fastCopyFrom(UnicodeString(TRUE, id, idLen));            U_DEBUG_TZ_MSG(("gei(%d) -> %d, len%d, %s/n", index, zone, result.length(), u_errorName(ec)));        }        ures_close(ares);    }    ures_close(top);#if defined(U_DEBUG_TZ)    if(result.length() ==0) {        U_DEBUG_TZ_MSG(("equiv [__, #%d] -> 0 (%s)/n", index, u_errorName(ec)));    }#endif    return result;}
开发者ID:hihihippp,项目名称:build-couchdb-1,代码行数:41,


示例10: 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,


示例11: 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,


示例12: ulocdata_getDelimiter

U_CAPI int32_t U_EXPORT2ulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type,                      UChar *result, int32_t resultLength, UErrorCode *status){    static const char* const delimiterKeys[] =  {        "quotationStart",        "quotationEnd",        "alternateQuotationStart",        "alternateQuotationEnd"    };    UResourceBundle *delimiterBundle;    int32_t len = 0;    const UChar *delimiter = NULL;    UErrorCode localStatus = U_ZERO_ERROR;    if (U_FAILURE(*status))        return 0;    delimiterBundle = ures_getByKey(uld->bundle, "delimiters", NULL, &localStatus);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        ures_close(delimiterBundle);        return 0;    }    delimiter = ures_getStringByKey(delimiterBundle, delimiterKeys[type], &len, &localStatus);    ures_close(delimiterBundle);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        return 0;    }    u_strncpy(result,delimiter, resultLength);    return len;}
开发者ID:JoeDoyle23,项目名称:node,代码行数:52,


示例13: TestDataModule

RBTestDataModule::RBTestDataModule(const char* name, TestLog& log, UErrorCode& status) : TestDataModule(name, log, status),  fModuleBundle(NULL),  fTestData(NULL),  fInfoRB(NULL),  tdpath(NULL){  fNumberOfTests = 0;  fDataTestValid = TRUE;  fModuleBundle = getTestBundle(name, status);  if(fDataTestValid) {    fTestData = ures_getByKey(fModuleBundle, "TestData", NULL, &status);    fNumberOfTests = ures_getSize(fTestData);    fInfoRB = ures_getByKey(fModuleBundle, "Info", NULL, &status);    if(status != U_ZERO_ERROR) {      log.errln(UNICODE_STRING_SIMPLE("Unable to initalize test data - missing mandatory description resources!"));      fDataTestValid = FALSE;    } else {      fInfo = new RBDataMap(fInfoRB, status);    }  }}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:22,


示例14: measurementDataBundleForLocale

static UResourceBundle * measurementDataBundleForLocale(const char *localeID, UErrorCode *status){    char fullLoc[ULOC_FULLNAME_CAPACITY];    char region[ULOC_COUNTRY_CAPACITY];    UResourceBundle *rb;    UResourceBundle *measDataBundle = 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);    measDataBundle = ures_getByKey(rb, region, NULL, status);    if (*status == U_MISSING_RESOURCE_ERROR && rb != NULL) {        *status = U_ZERO_ERROR;        measDataBundle = ures_getByKey(rb, "001", NULL, status);    }    ures_close(rb);    return measDataBundle;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:22,


示例15: getAmPmMarkersNarrow

static bool getAmPmMarkersNarrow(JNIEnv* env, jobject localeData, const char* locale_name) {  UErrorCode status = U_ZERO_ERROR;  ScopedResourceBundle root(ures_open(NULL, locale_name, &status));  if (U_FAILURE(status)) {    return false;  }  ScopedResourceBundle calendar(ures_getByKey(root.get(), "calendar", NULL, &status));  if (U_FAILURE(status)) {    return false;  }  ScopedResourceBundle gregorian(ures_getByKey(calendar.get(), "gregorian", NULL, &status));  if (U_FAILURE(status)) {    return false;  }  ScopedResourceBundle amPmMarkersNarrow(ures_getByKey(gregorian.get(), "AmPmMarkersNarrow", NULL, &status));  if (U_FAILURE(status)) {    return false;  }  setStringField(env, localeData, "narrowAm", amPmMarkersNarrow.get(), 0);  setStringField(env, localeData, "narrowPm", amPmMarkersNarrow.get(), 1);  return true;}
开发者ID:LeMaker,项目名称:android-actions,代码行数:22,


示例16: ures_openDirect

const UChar*TimeZone::getRegion(const UnicodeString& id) {    const UChar *result = WORLD;    UErrorCode ec = U_ZERO_ERROR;    UResourceBundle *rb = ures_openDirect(NULL, kZONEINFO, &ec);    // resolve zone index by name    UResourceBundle *res = ures_getByKey(rb, kNAMES, NULL, &ec);    int32_t idx = findInStringArray(res, id, ec);    // get region mapping    ures_getByKey(rb, kREGIONS, res, &ec);    const UChar *tmp = ures_getStringByIndex(res, idx, NULL, &ec);    if (U_SUCCESS(ec)) {        result = tmp;    }    ures_close(res);    ures_close(rb);    return result;}
开发者ID:hihihippp,项目名称:build-couchdb-1,代码行数:22,


示例17: resourcebundle_array_fetch

/* {{{ resourcebundle_array_fetch */static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_value, int fallback){	int32_t     meindex = 0;	char *      mekey = NULL;    zend_bool    is_numeric = 0;	char         *pbuf;	ResourceBundle_object *rb;	intl_error_reset( NULL );	RESOURCEBUNDLE_METHOD_FETCH_OBJECT;	if(Z_TYPE_P(offset) == IS_LONG) {		is_numeric = 1;		meindex = (int32_t)Z_LVAL_P(offset);		rb->child = ures_getByIndex( rb->me, meindex, rb->child, &INTL_DATA_ERROR_CODE(rb) );	} else if(Z_TYPE_P(offset) == IS_STRING) {		mekey = Z_STRVAL_P(offset);		rb->child = ures_getByKey(rb->me, mekey, rb->child, &INTL_DATA_ERROR_CODE(rb) );	} else {		intl_errors_set(INTL_DATA_ERROR_P(rb), U_ILLEGAL_ARGUMENT_ERROR,			"resourcebundle_get: index should be integer or string", 0);		RETURN_NULL();	}	intl_error_set_code( NULL, INTL_DATA_ERROR_CODE(rb) );	if (U_FAILURE(INTL_DATA_ERROR_CODE(rb))) {		if (is_numeric) {			spprintf( &pbuf, 0, "Cannot load resource element %d", meindex );		} else {			spprintf( &pbuf, 0, "Cannot load resource element '%s'", mekey );		}		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 );		efree(pbuf);		RETURN_NULL();	}	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {		UErrorCode icuerror;		const char * locale = ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &icuerror );		if (is_numeric) {			spprintf( &pbuf, 0, "Cannot load element %d without fallback from to %s", meindex, locale );		} else {			spprintf( &pbuf, 0, "Cannot load element '%s' without fallback from to %s", mekey, locale );		}		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 );		efree(pbuf);		RETURN_NULL();	}	resourcebundle_extract_value( return_value, rb );}
开发者ID:IMSoP,项目名称:php-src,代码行数:52,


示例18: ures_openDirect

NumberingSystem* U_EXPORT2NumberingSystem::createInstanceByName(const char *name, UErrorCode& status) {         UResourceBundle *numberingSystemsInfo = NULL;     UResourceBundle *nsTop, *nsCurrent;     const UChar* description = NULL;     int32_t radix = 10;     int32_t algorithmic = 0;     int32_t len;     numberingSystemsInfo = ures_openDirect(NULL,gNumberingSystems, &status);     nsCurrent = ures_getByKey(numberingSystemsInfo,gNumberingSystems,NULL,&status);     nsTop = ures_getByKey(nsCurrent,name,NULL,&status);     description = ures_getStringByKey(nsTop,gDesc,&len,&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 );     UnicodeString nsd;     nsd.setTo(description);	 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:venkatarajasekhar,项目名称:Qt,代码行数:38,


示例19: 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,


示例20: getMonthNames

static jobjectArray getMonthNames(JNIEnv* env, UResourceBundle* gregorian, bool longNames) {    UErrorCode status = U_ZERO_ERROR;    ScopedResourceBundle gregorianElems(ures_getByKey(gregorian, "monthNames", NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }        ScopedResourceBundle monthNameElems(ures_getByKey(gregorianElems.get(), "format", NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }        ScopedResourceBundle monthNameElemsFormat(ures_getByKey(monthNameElems.get(), longNames ? "wide" : "abbreviated", NULL, &status));    if (U_FAILURE(status)) {        return NULL;    }        ures_resetIterator(monthNameElemsFormat.get());    int monthCount = ures_getSize(monthNameElemsFormat.get());    // the array length is +1 because the harmony locales had an empty string at the end of their month name array    jobjectArray months = env->NewObjectArray(monthCount + 1, string_class, NULL);    for (int i = 0; i < monthCount; ++i) {        int monthNameLength;        const jchar* month = ures_getStringByIndex(monthNameElemsFormat.get(), i, &monthNameLength, &status);        if (U_FAILURE(status)) {            return NULL;        }        jstring monthU = env->NewString(month, monthNameLength);        env->SetObjectArrayElement(months, i, monthU);        env->DeleteLocalRef(monthU);    }        jstring monthU = env->NewStringUTF("");    env->SetObjectArrayElement(months, monthCount, monthU);    env->DeleteLocalRef(monthU);        return months;}
开发者ID:Ar3kkusu,项目名称:android_libcore,代码行数:38,


示例21: 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,


示例22: TestFallback

static void TestFallback(){    UErrorCode status = U_ZERO_ERROR;    UResourceBundle *fr_FR = NULL;    UResourceBundle *subResource = NULL;    const UChar *junk; /* ignored */    int32_t resultLen;    log_verbose("Opening fr_FR..");    fr_FR = ures_open(NULL, "fr_FR", &status);    if(U_FAILURE(status))    {        log_err_status(status, "Couldn't open fr_FR - %s/n", u_errorName(status));        return;    }    status = U_ZERO_ERROR;    /* clear it out..  just do some calls to get the gears turning */    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);    (void)junk;    /* Suppress set but not used warning. */    status = U_ZERO_ERROR;    junk = ures_getStringByKey(fr_FR, "LocaleString", &resultLen, &status);    status = U_ZERO_ERROR;    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);    status = U_ZERO_ERROR;    /* OK first one. This should be a Default value. */    subResource = ures_getByKey(fr_FR, "layout", NULL, &status);    if(status != U_USING_DEFAULT_WARNING)    {        log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get layout from fr_FR, got %s/n",            u_errorName(status));    }    ures_close(subResource);    status = U_ZERO_ERROR;    /* and this is a Fallback, to fr */    junk = ures_getStringByKey(fr_FR, "ExemplarCharacters", &resultLen, &status);    if(status != U_USING_FALLBACK_WARNING)    {        log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get ExemplarCharacters from fr_FR, got %s/n",             u_errorName(status));    }    status = U_ZERO_ERROR;    ures_close(fr_FR);}
开发者ID:icu-project,项目名称:icu4c,代码行数:50,


示例23: getOlsonMeta

static UBool getOlsonMeta(const UResourceBundle* top) {    if (OLSON_ZONE_COUNT == 0) {        UErrorCode ec = U_ZERO_ERROR;        UResourceBundle res;        ures_initStackObject(&res);        ures_getByKey(top, kZONES, &res, &ec);        if(U_SUCCESS(ec)) {            OLSON_ZONE_COUNT = ures_getSize(&res);            U_DEBUG_TZ_MSG(("OZC%d/n",OLSON_ZONE_COUNT));        }        ures_close(&res);    }    return (OLSON_ZONE_COUNT > 0);}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:14,


示例24: ures_open

voidCalendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status){    // Read the week count data from the resource bundle.  This should    // have the form:    //    //   DateTimeElements:intvector {    //      1,    // first day of week    //      1     // min days in week    //   }    //   Both have a range of 1..7    if (U_FAILURE(status)) return;    fFirstDayOfWeek = UCAL_SUNDAY;    fMinimalDaysInFirstWeek = 1;    UResourceBundle *resource = ures_open(NULL, desiredLocale.getName(), &status);    // If the resource data doesn't seem to be present at all, then use last-resort    // hard-coded data.    if (U_FAILURE(status))    {        status = U_USING_FALLBACK_WARNING;        ures_close(resource);        return;    }    //dateTimeElements = resource.getStringArray(kDateTimeElements, count, status);    UResourceBundle *dateTimeElements = ures_getByKey(resource, kDateTimeElements, NULL, &status);    if (U_SUCCESS(status)) {        int32_t arrLen;        const int32_t *dateTimeElementsArr = ures_getIntVector(dateTimeElements, &arrLen, &status);        if(U_SUCCESS(status) && arrLen == 2            && 1 <= dateTimeElementsArr[0] && dateTimeElementsArr[0] <= 7            && 1 <= dateTimeElementsArr[1] && dateTimeElementsArr[1] <= 7)        {            fFirstDayOfWeek = (UCalendarDaysOfWeek)dateTimeElementsArr[0];            fMinimalDaysInFirstWeek = (uint8_t)dateTimeElementsArr[1];        }        else {            status = U_INVALID_FORMAT_ERROR;        }    }    ures_close(dateTimeElements);    ures_close(resource);}
开发者ID:gitpan,项目名称:ponie,代码行数:50,


示例25: hasCollationElements

UBool hasCollationElements(const char *locName) {  UErrorCode status = U_ZERO_ERROR;  UResourceBundle *loc = ures_open(U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll", locName, &status);;  if(U_SUCCESS(status)) {    status = U_ZERO_ERROR;    loc = ures_getByKey(loc, "collations", loc, &status);    ures_close(loc);    if(status == U_ZERO_ERROR) { /* do the test - there are real elements */      return TRUE;    }  }  return FALSE;}
开发者ID:icu-project,项目名称:icu4c,代码行数:16,


示例26: 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,


示例27: ulocdata_getLocaleSeparator

U_DRAFT int32_t U_EXPORT2ulocdata_getLocaleSeparator(ULocaleData *uld,                            UChar *result,                            int32_t resultCapacity,                            UErrorCode *status)  {    UResourceBundle *separatorBundle;    int32_t len = 0;    const UChar *separator = NULL;    UErrorCode localStatus = U_ZERO_ERROR;    if (U_FAILURE(*status))        return 0;    separatorBundle = ures_getByKey(uld->bundle, "localeDisplayPattern", NULL, &localStatus);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        ures_close(separatorBundle);        return 0;    }    separator = ures_getStringByKey(separatorBundle, "separator", &len, &localStatus);    ures_close(separatorBundle);    if ( (localStatus == U_USING_DEFAULT_WARNING) && uld->noSubstitute ) {        localStatus = U_MISSING_RESOURCE_ERROR;    }    if (localStatus != U_ZERO_ERROR) {        *status = localStatus;    }    if (U_FAILURE(*status)){        return 0;    }    u_strncpy(result, separator, resultCapacity);    return len;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:47,


示例28: 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,


示例29: getDayIntVector

static bool getDayIntVector(JNIEnv* env, UResourceBundle* gregorian, int* values) {    // get the First day of week and the minimal days in first week numbers    UErrorCode status = U_ZERO_ERROR;    ScopedResourceBundle gregorianElems(ures_getByKey(gregorian, "DateTimeElements", NULL, &status));    if (U_FAILURE(status)) {        return false;    }    int intVectSize;    const int* result = ures_getIntVector(gregorianElems.get(), &intVectSize, &status);    if (U_FAILURE(status) || intVectSize != 2) {        return false;    }    values[0] = result[0];    values[1] = result[1];    return true;}
开发者ID:Ar3kkusu,项目名称:android_libcore,代码行数:18,


示例30: ures_initStackObject

int32_t U_EXPORT2TimeZone::countEquivalentIDs(const UnicodeString& id) {    int32_t result = 0;    UErrorCode ec = U_ZERO_ERROR;    UResourceBundle res;    ures_initStackObject(&res);    U_DEBUG_TZ_MSG(("countEquivalentIDs../n"));    UResourceBundle *top = openOlsonResource(id, res, ec);    if (U_SUCCESS(ec)) {        UResourceBundle r;        ures_initStackObject(&r);        ures_getByKey(&res, kLINKS, &r, &ec);        ures_getIntVector(&r, &result, &ec);        ures_close(&r);    }    ures_close(&res);    ures_close(top);    return result;}
开发者ID:hihihippp,项目名称:build-couchdb-1,代码行数:19,



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


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