这篇教程C++ LENGTHOF函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中LENGTHOF函数的典型用法代码示例。如果您正苦于以下问题:C++ LENGTHOF函数的具体用法?C++ LENGTHOF怎么用?C++ LENGTHOF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了LENGTHOF函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rbControlInputMidiParserInitializevoid rbControlInputMidiParserInitialize(RBControlInputMidiParser * pParser, RBConfiguration const * pConfig){ pParser->state = RBCIMPS_CLEAR; for(size_t i = 0; i < LENGTHOF(pParser->controls.controllers); ++i) { pParser->controls.controllers[i] = 0.0f; } for(size_t i = 0; i < LENGTHOF(pParser->controls.triggers); ++i) { pParser->controls.triggers[i] = false; } // Brightness control defaults to full on -- hax pParser->controls.controllers[0] = 1.0f; pParser->controls.debugDisplayReset = true; pParser->controls.debugDisplayMode = ((pConfig->mode < 0) || (pConfig->mode >= RBDM_COUNT)) ? 0 : pConfig->mode;}
开发者ID:jlunder,项目名称:rasterblocks,代码行数:17,
示例2: binarySearchvoid MeasureUnit::initTime(const char *timeId) { int32_t result = binarySearch(gTypes, 0, LENGTHOF(gTypes)-1, "duration"); // Apple mod U_ASSERT(result != -1); fTypeId = result; result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], timeId); U_ASSERT(result != -1); fSubTypeId = result - gOffsets[fTypeId]; }
开发者ID:aosm,项目名称:ICU,代码行数:8,
示例3: WinANSIFromUnicodePerfFunctionUPerfFunction* ConverterPerformanceTest::TestWinANSI_UTF8_FromUnicode(){ UErrorCode status = U_ZERO_ERROR; UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("utf-8",utf8_uniSource, LENGTHOF(utf8_uniSource), status); if(U_FAILURE(status)){ return NULL; } return pf;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:8,
示例4: ICUToUnicodePerfFunctionUPerfFunction* ConverterPerformanceTest::TestICU_UTF8_ToUnicode(){ UErrorCode status = U_ZERO_ERROR; UPerfFunction* pf = new ICUToUnicodePerfFunction("utf-8",(char*)utf8_encSource, LENGTHOF(utf8_encSource), status); if(U_FAILURE(status)){ return NULL; } return pf;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:8,
示例5: SimplePatternFormatterQuantityFormatter::QuantityFormatter(const QuantityFormatter &other) { for (int32_t i = 0; i < LENGTHOF(formatters); ++i) { if (other.formatters[i] == NULL) { formatters[i] = NULL; } else { formatters[i] = new SimplePatternFormatter(*other.formatters[i]); } }}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:9,
示例6: getPluralIndexstatic int32_t getPluralIndex(const char *pluralForm) { int32_t len = LENGTHOF(gPluralForms); for (int32_t i = 0; i < len; ++i) { if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) { return i; } } return -1;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:9,
示例7: TestBinaryValuesvoid TestBinaryValues() { /* * Unicode 5.1 explicitly defines binary property value aliases. * Verify that they are all recognized. */ static const char *const falseValues[]={ "N", "No", "F", "False" }; static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; int32_t i; for(i=0; i<LENGTHOF(falseValues); ++i) { if(FALSE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, falseValues[i])) { log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, /"%s/")!=FALSE (Are you missing data?)/n", falseValues[i]); } } for(i=0; i<LENGTHOF(trueValues); ++i) { if(TRUE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, trueValues[i])) { log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, /"%s/")!=TRUE (Are you missing data?)/n", trueValues[i]); } }}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:19,
示例8: alphavoid UnicodeTest::TestBinaryValues() { /* * Unicode 5.1 explicitly defines binary property value aliases. * Verify that they are all recognized. */ UErrorCode errorCode=U_ZERO_ERROR; UnicodeSet alpha(UNICODE_STRING_SIMPLE("[:Alphabetic:]"), errorCode); if(U_FAILURE(errorCode)) { dataerrln("UnicodeSet([:Alphabetic:]) failed - %s", u_errorName(errorCode)); return; } static const char *const falseValues[]={ "N", "No", "F", "False" }; static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; int32_t i; for(i=0; i<LENGTHOF(falseValues); ++i) { UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]"); pattern.insert(pattern.length()-2, UnicodeString(falseValues[i], -1, US_INV)); errorCode=U_ZERO_ERROR; UnicodeSet set(pattern, errorCode); if(U_FAILURE(errorCode)) { errln("UnicodeSet([:Alphabetic=%s:]) failed - %s/n", falseValues[i], u_errorName(errorCode)); continue; } set.complement(); if(set!=alpha) { errln("UnicodeSet([:Alphabetic=%s:]).complement()!=UnicodeSet([:Alphabetic:])/n", falseValues[i]); } } for(i=0; i<LENGTHOF(trueValues); ++i) { UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]"); pattern.insert(pattern.length()-2, UnicodeString(trueValues[i], -1, US_INV)); errorCode=U_ZERO_ERROR; UnicodeSet set(pattern, errorCode); if(U_FAILURE(errorCode)) { errln("UnicodeSet([:Alphabetic=%s:]) failed - %s/n", trueValues[i], u_errorName(errorCode)); continue; } if(set!=alpha) { errln("UnicodeSet([:Alphabetic=%s:])!=UnicodeSet([:Alphabetic:])/n", trueValues[i]); } }}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:43,
示例9: assertstatic struct binary_info *binary_find(const char *name) { struct binary_info *binary; const char *current_name; unsigned i; char path[PATH_MAX + 1], *path_end; assert(name); /* name is required */ if (!*name) { fprintf(stderr, "warning: binary unspecified in sample/n"); return NULL; } /* do we already know this binary? */ binary = binary_hashtab_get(name); if (binary) return binary; /* search for it */ dprintf("searching for binary /"%.*s/" in /"%s/"/n", PROC_NAME_LEN, name, src_path); for (i = 0; i < LENGTHOF(default_binaries); i++) { snprintf(path, sizeof(path), "%s/%s", src_path, default_binaries[i]); current_name = binary_name(path); assert(current_name); if (*current_name) { /* paths not ending in slash: use if name matches */ if (strncmp(name, current_name, PROC_NAME_LEN) != 0) { continue; } } else { /* paths ending in slash: look in subdir named after * binary */ path_end = path + strlen(path); snprintf(path_end, sizeof(path) - (path_end - path), "%.*s/%.*s", PROC_NAME_LEN, name, PROC_NAME_LEN, name); } /* use access to find out whether the binary exists and is * readable */ dprintf("checking whether /"%s/" exists/n", path); if (access(path, R_OK) < 0) continue; /* ok, this seems to be the one */ return binary_add(strdup_checked(path)); } /* not found */ return NULL;}
开发者ID:josepedrazap,项目名称:trabajo2,代码行数:55,
示例10: parseDBstatic voidparseDB(const char *filename, UErrorCode *pErrorCode) { /* default Bidi classes for unassigned code points */ static const UChar32 defaultBidi[][3]={ /* { start, end, class } */ /* R: U+0590..U+05FF, U+07C0..U+08FF, U+FB1D..U+FB4F, U+10800..U+10FFF */ { 0x0590, 0x05FF, U_RIGHT_TO_LEFT }, { 0x07C0, 0x08FF, U_RIGHT_TO_LEFT }, { 0xFB1D, 0xFB4F, U_RIGHT_TO_LEFT }, { 0x10800, 0x10FFF, U_RIGHT_TO_LEFT }, /* AL: U+0600..U+07BF, U+FB50..U+FDCF, U+FDF0..U+FDFF, U+FE70..U+FEFE */ { 0x0600, 0x07BF, U_RIGHT_TO_LEFT_ARABIC }, { 0xFB50, 0xFDCF, U_RIGHT_TO_LEFT_ARABIC }, { 0xFDF0, 0xFDFF, U_RIGHT_TO_LEFT_ARABIC }, { 0xFE70, 0xFEFE, U_RIGHT_TO_LEFT_ARABIC } /* L otherwise */ }; char *fields[15][2]; UChar32 start, end; int32_t i; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return; } /* * Set default Bidi classes for unassigned code points. * See the documentation for Bidi_Class in UCD.html in the Unicode data. * http://www.unicode.org/Public/ * * Starting with Unicode 5.0, DerivedBidiClass.txt should (re)set * the Bidi_Class values for all code points including unassigned ones * and including L values for these. * This code becomes unnecesary but harmless. Leave it for now in case * someone uses genbidi on pre-Unicode 5.0 data. */ for(i=0; i<LENGTHOF(defaultBidi); ++i) { start=defaultBidi[i][0]; end=defaultBidi[i][1]; upvec_setValue(pv, start, end, 0, (uint32_t)defaultBidi[i][2], UBIDI_CLASS_MASK, pErrorCode); if(U_FAILURE(*pErrorCode)) { fprintf(stderr, "genbidi error: unable to set default bidi class for U+%04lx..U+%04lx, code: %s/n", (long)start, (long)end, u_errorName(*pErrorCode)); exit(*pErrorCode); } } u_parseDelimitedFile(filename, ';', fields, 15, unicodeDataLineFn, NULL, pErrorCode); if(U_FAILURE(*pErrorCode)) { return; }}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:55,
示例11: TestSetCharUnsafestatic void TestSetCharUnsafe() { static const uint8_t input[] = {0x61, 0xe4, 0xba, 0x8c, 0x7f, 0x2e, 0x62, 0xc5, 0x7f, 0x61, 0x80, 0x80, 0xe0, 0x80, 0x80, 0x00 }; static const int16_t start_unsafe[] = {0, 1, 1, 1, 4, 5, 6, 7, 8, 9, 9, 9, 12, 12, 12, 15 }; static const int16_t limit_unsafe[] = {0, 1, 4, 4, 4, 5, 6, 7, 9, 9, 10, 10, 10, 15, 15, 15, 16 }; uint32_t i=0; int32_t offset=0, setOffset=0; for(offset=0; offset<=LENGTHOF(input); offset++){ if (offset<LENGTHOF(input)){ setOffset=offset; UTF8_SET_CHAR_START_UNSAFE(input, setOffset); if(setOffset != start_unsafe[i]){ log_err("ERROR: UTF8_SET_CHAR_START_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, start_unsafe[i], setOffset); } setOffset=offset; U8_SET_CP_START_UNSAFE(input, setOffset); if(setOffset != start_unsafe[i]){ log_err("ERROR: U8_SET_CP_START_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, start_unsafe[i], setOffset); } } if (offset != 0) { /* Can't have it go off the end of the array */ setOffset=offset; UTF8_SET_CHAR_LIMIT_UNSAFE(input, setOffset); if(setOffset != limit_unsafe[i]){ log_err("ERROR: UTF8_SET_CHAR_LIMIT_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, limit_unsafe[i], setOffset); } setOffset=offset; U8_SET_CP_LIMIT_UNSAFE(input, setOffset); if(setOffset != limit_unsafe[i]){ log_err("ERROR: U8_SET_CP_LIMIT_UNSAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, limit_unsafe[i], setOffset); } } i++; }}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:42,
示例12: va_startvoid CMfmLog::Log(int nLevel, CPort* pPort, LPCWSTR szFormat, ...){ if (m_hLogFile != INVALID_HANDLE_VALUE && m_nLogLevel >= nLevel) { WCHAR szBuf1[MAXLOGLINE]; WCHAR szBuf2[MAXLOGLINE]; va_list args; va_start(args, szFormat); vswprintf_s(szBuf1, LENGTHOF(szBuf1), szFormat, args); va_end(args); swprintf_s(szBuf2, LENGTHOF(szBuf2), L"%s: %s", pPort->PortName(), szBuf1); Log(nLevel, szBuf2); }}
开发者ID:EBNull,项目名称:wphf-reloaded,代码行数:20,
示例13: nameAliasesLineFnstatic void U_CALLCONVnameAliasesLineFn(void *context, char *fields[][2], int32_t fieldCount, UErrorCode *pErrorCode) { char *name; int16_t length=0; static uint32_t prevCode=0; uint32_t code=0; if(U_FAILURE(*pErrorCode)) { return; } /* get the character code */ code=uprv_strtoul(fields[0][0], NULL, 16); /* get the character name */ name=fields[1][0]; length=getName(&name, fields[1][1]); if(length==0 || length>=sizeof(cpNameAliases[cpNameAliasesTop].nameAlias)) { fprintf(stderr, "gennames: error - name alias %s empty or too long for code point U+%04lx/n", name, (unsigned long)code); *pErrorCode=U_PARSE_ERROR; exit(U_PARSE_ERROR); } /* check for non-character code points */ if(!U_IS_UNICODE_CHAR(code)) { fprintf(stderr, "gennames: error - name alias for non-character code point U+%04lx/n", (unsigned long)code); *pErrorCode=U_PARSE_ERROR; exit(U_PARSE_ERROR); } /* check that the code points (code) are in ascending order */ if(code<=prevCode && code>0) { fprintf(stderr, "gennames: error - NameAliases entries out of order, U+%04lx after U+%04lx/n", (unsigned long)code, (unsigned long)prevCode); *pErrorCode=U_PARSE_ERROR; exit(U_PARSE_ERROR); } prevCode=code; if(cpNameAliasesTop>=LENGTHOF(cpNameAliases)) { fprintf(stderr, "gennames: error - too many name aliases/n"); *pErrorCode=U_PARSE_ERROR; exit(U_PARSE_ERROR); } cpNameAliases[cpNameAliasesTop].code=code; uprv_memcpy(cpNameAliases[cpNameAliasesTop].nameAlias, name, length); cpNameAliases[cpNameAliasesTop].nameAlias[length]=0; ++cpNameAliasesTop; parseName(name, length);}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:54,
示例14: UPerfTestNormalizerPerformanceTest::NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status): UPerfTest(argc,argv,status), options(0) { NFDBuffer = NULL; NFCBuffer = NULL; NFDBufferLen = 0; NFCBufferLen = 0; NFDFileLines = NULL; NFCFileLines = NULL; if(status== U_ILLEGAL_ARGUMENT_ERROR){ fprintf(stderr,gUsageString, "normperf"); return; } if(U_FAILURE(status)){ fprintf(stderr, "FAILED to create UPerfTest object. Error: %s/n", u_errorName(status)); return; } _remainingArgc = u_parseArgs(_remainingArgc, (char **)argv, (int32_t)(LENGTHOF(cmdLineOptions)), cmdLineOptions); if(cmdLineOptions[0].doesOccur && cmdLineOptions[0].value!=NULL) { options=(int32_t)strtol(cmdLineOptions[0].value, NULL, 16); } if(line_mode){ ULine* filelines = getLines(status); if(U_FAILURE(status)){ fprintf(stderr, "FAILED to read lines from file and create UPerfTest object. Error: %s/n", u_errorName(status)); return; } NFDFileLines = new ULine[numLines]; NFCFileLines = new ULine[numLines]; for(int32_t i=0;i<numLines;i++){ normalizeInput(&NFDFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFD, options); normalizeInput(&NFCFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFC, options); } }else if(bulk_mode){ int32_t srcLen = 0; const UChar* src = getBuffer(srcLen,status); NFDBufferLen = 0; NFCBufferLen = 0; if(U_FAILURE(status)){ fprintf(stderr, "FAILED to read buffer from file and create UPerfTest object. Error: %s/n", u_errorName(status)); return; } NFDBuffer = normalizeInput(NFDBufferLen,src,srcLen,UNORM_NFD, options); NFCBuffer = normalizeInput(NFCBufferLen,src,srcLen,UNORM_NFC, options); } }
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:54,
示例15: TestSetCharstatic void TestSetChar() { static const uint8_t input[] = {0x61, 0xe4, 0xba, 0x8c, 0x7f, 0xfe, 0x62, 0xc5, 0x7f, 0x61, 0x80, 0x80, 0xe0, 0x00 }; static const int16_t start_safe[] = {0, 1, 1, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; static const int16_t limit_safe[] = {0, 1, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; uint32_t i=0; int32_t offset=0, setOffset=0; for(offset=0; offset<=LENGTHOF(input); offset++){ if (offset<LENGTHOF(input)){ setOffset=offset; UTF8_SET_CHAR_START_SAFE(input, 0, setOffset); if(setOffset != start_safe[i]){ log_err("ERROR: UTF8_SET_CHAR_START_SAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, start_safe[i], setOffset); } setOffset=offset; U8_SET_CP_START(input, 0, setOffset); if(setOffset != start_safe[i]){ log_err("ERROR: U8_SET_CP_START failed for offset=%ld. Expected:%ld Got:%ld/n", offset, start_safe[i], setOffset); } } setOffset=offset; UTF8_SET_CHAR_LIMIT_SAFE(input,0, setOffset, sizeof(input)); if(setOffset != limit_safe[i]){ log_err("ERROR: UTF8_SET_CHAR_LIMIT_SAFE failed for offset=%ld. Expected:%ld Got:%ld/n", offset, limit_safe[i], setOffset); } setOffset=offset; U8_SET_CP_LIMIT(input,0, setOffset, sizeof(input)); if(setOffset != limit_safe[i]){ log_err("ERROR: U8_SET_CP_LIMIT failed for offset=%ld. Expected:%ld Got:%ld/n", offset, limit_safe[i], setOffset); } i++; }}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:40,
示例16: countMembersint32_t ScriptSet::countMembers() const { // This bit counter is good for sparse numbers of '1's, which is // very much the case that we will usually have. int32_t count = 0; for (uint32_t i=0; i<LENGTHOF(bits); i++) { uint32_t x = bits[i]; while (x > 0) { count++; x &= (x - 1); // and off the least significant one bit. } } return count;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:13,
示例17: checkDatavoid UCharsTrieTest::TestValuesForState() { // Check that saveState() and resetToState() interact properly // with next() and current(). static const StringAndValue data[]={ { "a", -1 }, { "ab", -2 }, { "abc", -3 }, { "abcd", -4 }, { "abcde", -5 }, { "abcdef", -6 } }; checkData(data, LENGTHOF(data));}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:13,
示例18: LENGTHOFint32_t MeasureUnit::getAvailable( MeasureUnit *dest, int32_t destCapacity, UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return 0; } if (destCapacity < LENGTHOF(gSubTypes)) { errorCode = U_BUFFER_OVERFLOW_ERROR; return LENGTHOF(gSubTypes); } int32_t idx = 0; for (int32_t typeIdx = 0; typeIdx < LENGTHOF(gTypes); ++typeIdx) { int32_t len = gOffsets[typeIdx + 1] - gOffsets[typeIdx]; for (int32_t subTypeIdx = 0; subTypeIdx < len; ++subTypeIdx) { dest[idx].setTo(typeIdx, subTypeIdx); ++idx; } } U_ASSERT(idx == LENGTHOF(gSubTypes)); return LENGTHOF(gSubTypes);}
开发者ID:aosm,项目名称:ICU,代码行数:22,
示例19: formatUnicodeString& SimplePatternFormatter::format( const UnicodeString &arg0, UnicodeString &appendTo, UErrorCode &status) const { const UnicodeString *params[] = {&arg0}; return format( params, LENGTHOF(params), appendTo, NULL, 0, status);}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:13,
示例20: HashtableUnicodeTest::UnicodeTest(){ UErrorCode errorCode=U_ZERO_ERROR; unknownPropertyNames=new U_NAMESPACE_QUALIFIER Hashtable(errorCode); if(U_FAILURE(errorCode)) { delete unknownPropertyNames; unknownPropertyNames=NULL; } // Ignore some property names altogether. for(int32_t i=0; i<LENGTHOF(ignorePropNames); ++i) { unknownPropertyNames->puti(UnicodeString(ignorePropNames[i], -1, US_INV), 1, errorCode); }}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:13,
示例21: uloc_forLanguageTagvoid AlphabeticIndexTest::TestChineseZhuyin() { UErrorCode status = U_ZERO_ERROR; char loc[100]; uloc_forLanguageTag("zh-u-co-zhuyin", loc, LENGTHOF(loc), NULL, &status); AlphabeticIndex index(loc, status); LocalPointer<AlphabeticIndex::ImmutableIndex> immIndex(index.buildImmutableIndex(status)); TEST_CHECK_STATUS; assertEquals("getBucketCount()", 38, immIndex->getBucketCount()); assertEquals("label 1", UnicodeString((UChar)0x3105), immIndex->getBucket(1)->getLabel()); assertEquals("label 2", UnicodeString((UChar)0x3106), immIndex->getBucket(2)->getLabel()); assertEquals("label 3", UnicodeString((UChar)0x3107), immIndex->getBucket(3)->getLabel()); assertEquals("label 4", UnicodeString((UChar)0x3108), immIndex->getBucket(4)->getLabel()); assertEquals("label 5", UnicodeString((UChar)0x3109), immIndex->getBucket(5)->getLabel());}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:14,
示例22: LENGTHOFU_NAMESPACE_BEGIN#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))//----------------------------------------------------------------------------//// ScriptSet implementation////----------------------------------------------------------------------------ScriptSet::ScriptSet() { for (uint32_t i=0; i<LENGTHOF(bits); i++) { bits[i] = 0; }}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:14,
示例23: uenum_openCharStringsEnumerationStringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) { UEnumeration *uenum = uenum_openCharStringsEnumeration( gTypes, 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;}
开发者ID:aosm,项目名称:ICU,代码行数:15,
示例24: populatePrefixSuffix// populatePrefixSuffix Adds a specific prefix-suffix pair to result for a// given variant and log10 value.// variant is 'zero', 'one', 'two', 'few', 'many', or 'other'.// formatStr is the format string from which the prefix and suffix are// extracted. It is usually of form 'Pefix 000 suffix'.// populatePrefixSuffix returns the number of 0's found in formatStr// before the decimal point.// In the special case that formatStr contains only spaces for prefix// and suffix, populatePrefixSuffix returns log10Value + 1.static int32_t populatePrefixSuffix( const char* variant, int32_t log10Value, const UnicodeString& formatStr, UHashtable* result, UErrorCode& status) { if (U_FAILURE(status)) { return 0; } int32_t firstIdx = formatStr.indexOf(kZero, LENGTHOF(kZero), 0); // We must have 0's in format string. if (firstIdx == -1) { status = U_INTERNAL_PROGRAM_ERROR; return 0; } int32_t lastIdx = formatStr.lastIndexOf(kZero, LENGTHOF(kZero), firstIdx); CDFUnit* unit = createCDFUnit(variant, log10Value, result, status); if (U_FAILURE(status)) { return 0; } // Everything up to first 0 is the prefix unit->prefix = formatStr.tempSubString(0, firstIdx); fixGraves(unit->prefix); // Everything beyond the last 0 is the suffix unit->suffix = formatStr.tempSubString(lastIdx + 1); fixGraves(unit->suffix); // If there is effectively no prefix or suffix, ignore the actual number of // 0's and act as if the number of 0's matches the size of the number. if (onlySpaces(unit->prefix) && onlySpaces(unit->suffix)) { return log10Value + 1; } // Calculate number of zeros before decimal point int32_t idx = firstIdx + 1; while (idx <= lastIdx && formatStr.charAt(idx) == u_0) { ++idx; } return (idx - firstIdx);}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:45,
示例25: TestUnicode32Normstatic void TestUnicode32Norm() { /* * test Unicode 3.2 normalization, before Public Review Issue #29 * see cnormtst.c TestComposition() */ static const UChar strings[][8]={ { 0x1100, 0x0300, 0x1161, 0x0327 }, { 0x0b47, 0x0300, 0x0b3e, 0x0327 } }; UChar ascii[20], unicode[20]; int32_t i, length; UErrorCode errorCode; for(i=0; i<LENGTHOF(strings); ++i) { errorCode=U_ZERO_ERROR; length=uidna_toASCII(strings[i], -1, ascii, LENGTHOF(ascii), 0, NULL, &errorCode); length=uidna_toUnicode(ascii, length, unicode, LENGTHOF(unicode), 0, NULL, &errorCode); if(errorCode!=U_IDNA_VERIFICATION_ERROR) { log_err("string %d yields %s instead of U_IDNA_VERIFICATION_ERROR/n", i, u_errorName(errorCode)); } }}
开发者ID:mason105,项目名称:red5cpp,代码行数:24,
示例26: indexvoid AlphabeticIndexTest::TestJapaneseKanji() { UErrorCode status = U_ZERO_ERROR; AlphabeticIndex index(Locale::getJapanese(), status); LocalPointer<AlphabeticIndex::ImmutableIndex> immIndex(index.buildImmutableIndex(status)); TEST_CHECK_STATUS; // There are no index characters for Kanji in the Japanese standard collator. // They should all go into the overflow bucket. static const UChar32 kanji[] = { 0x4E9C, 0x95C7, 0x4E00, 0x58F1 }; int32_t overflowIndex = immIndex->getBucketCount() - 1; for(int32_t i = 0; i < LENGTHOF(kanji); ++i) { char msg[40]; sprintf(msg, "kanji[%d]=U+%04lX in overflow bucket", (int)i, (long)kanji[i]); assertEquals(msg, overflowIndex, immIndex->getBucketIndex(UnicodeString(kanji[i]), status)); TEST_CHECK_STATUS; }}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:16,
示例27: LENGTHOFvoid HandViewer::DisplayDistanceFromSensor(){ std::stringstream ss; unsigned counter = 1; const PointListHandler& handler = handTracker.GetPointListHandler(); for(PointListHandler::ConstIterator it = handler.begin(); it != handler.end(); ++it) { const PointList &pointList = it.GetPointList(); XnPoint3D lastPoint = pointList.GetLastPoint(); std::string str = "Hand "; ss << counter; str = str + ss.str(); ss.str(""); ss << " distance from the sensor: "; str = str + ss.str(); ss.str(""); if(lastPoint.Z < HAND_CLOSE) { ss << 0; device.SetLedColour(LED_GREEN); } else { ss << lastPoint.Z - HAND_CLOSE; device.SetLedColour(LED_ORANGE); } str = str + ss.str(); ss.str(""); XnUInt32 nColor = it.GetKey() % LENGTHOF(COLOURS); glColor4f(COLOURS[nColor][0], COLOURS[nColor][1], COLOURS[nColor][2], 1.0f); glRasterPos2f(40, counter*30); for(int i=0;i<str.length();i++) { glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]); } counter++; } }
开发者ID:palgabor,项目名称:Onlab--Kinect-,代码行数:47,
注:本文中的LENGTHOF函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ LEN_AND_LIT函数代码示例 C++ LENGTH函数代码示例 |