当前位置: 首页>>代码示例>>C++>>正文


C++ LENGTHOF函数代码示例

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


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

示例1: rbControlInputMidiParserInitialize

void 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,代码来源:control_input.c

示例2: binarySearch

void 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,代码来源:measunit.cpp

示例3: WinANSIFromUnicodePerfFunction

UPerfFunction* 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,代码来源:convperf.cpp

示例4: ICUToUnicodePerfFunction

UPerfFunction*  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,代码来源:convperf.cpp

示例5: SimplePatternFormatter

QuantityFormatter::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,代码来源:quantityformatter.cpp

示例6: getPluralIndex

static 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,代码来源:quantityformatter.cpp

示例7: TestBinaryValues

void 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,代码来源:cucdapi.c

示例8: alpha

void 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,代码来源:ucdtest.cpp

示例9: assert

static 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,代码来源:sprofalyze.c

示例10: parseDB

static void
parseDB(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,代码来源:genbidi.c

示例11: TestSetCharUnsafe

static 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,代码来源:utf8tst.c

示例12: va_start

void 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,代码来源:log.cpp

示例13: nameAliasesLineFn

static void U_CALLCONV
nameAliasesLineFn(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,代码来源:gennames.c

示例14: UPerfTest

NormalizerPerformanceTest::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,代码来源:normperf.cpp

示例15: TestSetChar

static 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,代码来源:utf8tst.c


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