Пример #1
0
StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
    UEnumeration *uenum = uenum_openCharStringsEnumeration(
            gTypes, UPRV_LENGTHOF(gTypes), &errorCode);
    if (U_FAILURE(errorCode)) {
        uenum_close(uenum);
        return NULL;
    }
    StringEnumeration *result = new UStringEnumeration(uenum);
    if (result == NULL) {
        errorCode = U_MEMORY_ALLOCATION_ERROR;
        uenum_close(uenum);
        return NULL;
    }
    return result;
}
Пример #2
0
static void TestCharStringsEnumeration(void)  {
  UErrorCode status = U_ZERO_ERROR;

  /* //! [uenum_openCharStringsEnumeration] */
  const char* strings[] = { "Firstly", "Secondly", "Thirdly", "Fourthly" };
  UEnumeration *u = uenum_openCharStringsEnumeration(strings, 4, &status);
  /* //! [uenum_openCharStringsEnumeration] */
  if(U_FAILURE(status)) {
    log_err("FAIL: could not open char strings enumeration: %s\n", u_errorName(status));
    return;
  }

  verifyEnumeration(__LINE__, u, strings, NULL, 4);

  uenum_close(u);
}