• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ COUNT_OF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: InsertNode

HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
{
    WCHAR buf[MAX_NEW_KEY_LEN];
    HTREEITEM hNewItem = 0;
    TVITEMEXW item;

    if (!hItem) hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
    if (!hItem) return FALSE;
    if (SendMessageW(hwndTV, TVM_GETITEMSTATE, (WPARAM)hItem, TVIS_EXPANDEDONCE) & TVIS_EXPANDEDONCE) {
        hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
    } else {
	item.mask = TVIF_CHILDREN | TVIF_HANDLE;
	item.hItem = hItem;
	if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
	item.cChildren = 1;
	if (!TreeView_SetItemW(hwndTV, &item)) return FALSE;
    }
    SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
    if (!hNewItem) {
        for(hNewItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); hNewItem;
            hNewItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hNewItem)) {
            item.mask = TVIF_HANDLE | TVIF_TEXT;
            item.hItem = hNewItem;
            item.pszText = buf;
            item.cchTextMax = COUNT_OF(buf);
            if (!TreeView_GetItemW(hwndTV, &item)) continue;
            if (lstrcmpW(name, item.pszText) == 0) break;
        }
    }
    if (hNewItem)
        SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);

    return hNewItem;
}
开发者ID:VOID001,项目名称:wine-void,代码行数:34,代码来源:treeview.c


示例2: UPDOWN_GetBuddyInt

/***********************************************************************
 *           UPDOWN_GetBuddyInt
 * Tries to read the pos from the buddy window and if it succeeds,
 * it stores it in the control's CurVal
 * returns:
 *   TRUE  - if it read the integer from the buddy successfully
 *   FALSE - if an error occurred
 */
static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
{
    WCHAR txt[20], sep, *src, *dst;
    int newVal;

    if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
        return FALSE;

    /*if the buddy is a list window, we must set curr index */
    if (UPDOWN_IsBuddyListbox(infoPtr)) {
        newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
        if(newVal < 0) return FALSE;
    } else {
        /* we have a regular window, so will get the text */
        /* note that a zero-length string is a legitimate value for 'txt',
         * and ought to result in a successful conversion to '0'. */
        if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0)
            return FALSE;

        sep = UPDOWN_GetThousandSep();

        /* now get rid of the separators */
        for(src = dst = txt; *src; src++)
            if(*src != sep) *dst++ = *src;
        *dst = 0;

        /* try to convert the number and validate it */
        newVal = strtolW(txt, &src, infoPtr->Base);
        if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
    }

    TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
    infoPtr->CurVal = newVal;
    return TRUE;
}
开发者ID:GYGit,项目名称:reactos,代码行数:43,代码来源:updown.c


示例3: main

/*
 * Main Loop
 */
int main()
{
    LOG("--------------------------------\r\n");

    /* Unmask interrupt for output compare match A on TC0 */
    timers_setup_timer(TIMER_COUNTER0, TIMER_MODE_CTC, 1000UL);
    TIMSK0 |= (1 << OCIE0A);

    lcd_load_custom_character(degree_symbol, CUSTOM_SYMBOL_DEGREE);

    cli_init();
    motor_init(&g_timers_state);
    log_init();
	scheduler_init(&g_timers_state, g_tasks, COUNT_OF(g_tasks));
	interpolator_init(&g_timers_state);
    sei();

    log_start();

	/* Main Loop: Run Tasks scheduled by scheduler */
	while (1) {
	    int i;
	    for (i = 0; i < 50; i++) {
	        serial_check(); /* needs to be called frequently */
	    }
	    scheduler_service();
	}
}
开发者ID:posborne,项目名称:msse-embedded-systems,代码行数:31,代码来源:lab2.c


示例4: InitOpenFileName

static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
{
    FILTERPAIR FilterPairs[4];
    static WCHAR Filter[1024];

    memset(pofn, 0, sizeof(OPENFILENAME));
    pofn->lStructSize = sizeof(OPENFILENAME);
    pofn->hwndOwner = hWnd;
    pofn->hInstance = hInst;

    /* create filter string */
    FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
    FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
    FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
    FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
    FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
    FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
    FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
    FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
    BuildFilterStrings(Filter, FilterPairs, COUNT_OF(FilterPairs));

    pofn->lpstrFilter = Filter;
    pofn->lpstrFile = FileNameBuffer;
    pofn->nMaxFile = _MAX_PATH;
    pofn->lpstrFileTitle = FileTitleBuffer;
    pofn->nMaxFileTitle = _MAX_PATH;
    pofn->Flags = OFN_HIDEREADONLY;
    pofn->lpstrDefExt = L"reg";
    return TRUE;
}
开发者ID:reactos,项目名称:reactos,代码行数:30,代码来源:framewnd.c


示例5: CopyKeyName

BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
{
    BOOL bClipboardOpened = FALSE;
    BOOL bSuccess = FALSE;
    WCHAR szBuffer[512];
    HGLOBAL hGlobal;
    LPWSTR s;

    if (!OpenClipboard(hWnd))
        goto done;
    bClipboardOpened = TRUE;

    if (!EmptyClipboard())
        goto done;

    if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
        goto done;

    hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
    if (!hGlobal)
        goto done;

    s = GlobalLock(hGlobal);
    wcscpy(s, szBuffer);
    GlobalUnlock(hGlobal);

    SetClipboardData(CF_UNICODETEXT, hGlobal);
    bSuccess = TRUE;

done:
    if (bClipboardOpened)
        CloseClipboard();
    return bSuccess;
}
开发者ID:reactos,项目名称:reactos,代码行数:34,代码来源:framewnd.c


示例6: showstatus

void showstatus(FILE *f, struct guest_thread *vm_thread)
{
	struct vm_trapframe *vm_tf = &(vm_thread->uthread.u_ctx.tf.vm_tf);
	int shutdown = vm_tf->tf_exit_reason;
	char *when = shutdown & VMX_EXIT_REASONS_FAILED_VMENTRY ? "entry" : "exit";
	shutdown &= ~VMX_EXIT_REASONS_FAILED_VMENTRY;
	char *reason = "UNKNOWN";
	if (shutdown < COUNT_OF(vmxexit) && vmxexit[shutdown])
		reason = vmxexit[shutdown];
	fprintf(f, "Shutdown: core %d, %s due to %s(0x%x); ret code 0x%x\n",
	        vm_tf->tf_guest_pcoreid, when, reason, shutdown,
			vm_tf->tf_exit_reason);
	fprintf(f, "  gva %p gpa %p cr3 %p\n", (void *)vm_tf->tf_guest_va,
	        (void *)vm_tf->tf_guest_pa, (void *)vm_tf->tf_cr3);

	fprintf(f, "  rax  0x%016lx\n",           vm_tf->tf_rax);
	fprintf(f, "  rbx  0x%016lx\n",           vm_tf->tf_rbx);
	fprintf(f, "  rcx  0x%016lx\n",           vm_tf->tf_rcx);
	fprintf(f, "  rdx  0x%016lx\n",           vm_tf->tf_rdx);
	fprintf(f, "  rbp  0x%016lx\n",           vm_tf->tf_rbp);
	fprintf(f, "  rsi  0x%016lx\n",           vm_tf->tf_rsi);
	fprintf(f, "  rdi  0x%016lx\n",           vm_tf->tf_rdi);
	fprintf(f, "  r8   0x%016lx\n",           vm_tf->tf_r8);
	fprintf(f, "  r9   0x%016lx\n",           vm_tf->tf_r9);
	fprintf(f, "  r10  0x%016lx\n",           vm_tf->tf_r10);
	fprintf(f, "  r11  0x%016lx\n",           vm_tf->tf_r11);
	fprintf(f, "  r12  0x%016lx\n",           vm_tf->tf_r12);
	fprintf(f, "  r13  0x%016lx\n",           vm_tf->tf_r13);
	fprintf(f, "  r14  0x%016lx\n",           vm_tf->tf_r14);
	fprintf(f, "  r15  0x%016lx\n",           vm_tf->tf_r15);
}
开发者ID:GanShun,项目名称:akaros,代码行数:31,代码来源:vmx.c


示例7: UnloadHive

static BOOL UnloadHive(HWND hWnd)
{
    WCHAR Caption[128];
    LPCWSTR pszKeyPath;
    HKEY hRootKey;
    LONG regUnloadResult;

    /* get the item key to unload */
    pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
    /* load and set the caption and flags for dialog */
    LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));

    /* Enable the 'restore' privilege, unload the hive, disable the privilege */
    EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
    regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
    EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);

    if(regUnloadResult == ERROR_SUCCESS)
    {
        /* refresh tree and list views */
        RefreshTreeView(g_pChildWnd->hTreeWnd);
        pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
        RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
    }
    else
    {
        ErrorMessageBox(hWnd, Caption, regUnloadResult);
        return FALSE;
    }
    return TRUE;
}
开发者ID:reactos,项目名称:reactos,代码行数:31,代码来源:framewnd.c


示例8: toencounter

void toencounter(DW o) {
  if (encounterList.n >= COUNT_OF(encounterList.x)) {
    DLOG("encounter list overflow: %i",encounterList.n);
    crash();
  } else {
    encounterList.x[encounterList.n++] = o;
  }
}
开发者ID:18446744073709551615,项目名称:reDroid,代码行数:8,代码来源:re_encounter.c


示例9: WinEventTimeToString

/* Format Timestamp from EventLog */
WCHAR * WinEventTimeToString(ULONGLONG ulongTime)
{
	SYSTEMTIME sysTime;
	FILETIME fTime, lfTime;
	ULARGE_INTEGER ulargeTime;
	struct tm tm_struct;
	WCHAR result[17] = L"";
	static WCHAR formatted_result[] = L"Mmm dd hh:mm:ss";

	memset(&tm_struct, 0, sizeof(tm_struct));

	/* Convert from ULONGLONG to usable FILETIME value */
	ulargeTime.QuadPart = ulongTime;
	
	fTime.dwLowDateTime = ulargeTime.LowPart;
	fTime.dwHighDateTime = ulargeTime.HighPart;

	/* Adjust time value to reflect current timezone */
	/* then convert to a SYSTEMTIME */
	if (FileTimeToLocalFileTime(&fTime, &lfTime) == 0) {
		Log(LOG_ERROR|LOG_SYS,"Error formatting event time to local time");
		return NULL;
	}
	if (FileTimeToSystemTime(&lfTime, &sysTime) == 0) {
		Log(LOG_ERROR|LOG_SYS,"Error formatting event time to system time");
		return NULL;
	}

	/* Convert SYSTEMTIME to tm */
	tm_struct.tm_year = sysTime.wYear - 1900;
	tm_struct.tm_mon  = sysTime.wMonth - 1;
	tm_struct.tm_mday = sysTime.wDay;
	tm_struct.tm_hour = sysTime.wHour;
	tm_struct.tm_wday = sysTime.wDayOfWeek;
	tm_struct.tm_min  = sysTime.wMinute;
	tm_struct.tm_sec  = sysTime.wSecond;
	
	/* Format timestamp string */
	wcsftime(result, COUNT_OF(result), L"%b %d %H:%M:%S", &tm_struct);
	if (result[4] == L'0') /* Replace leading zero with a space for */
		result[4] = L' ';  /* single digit days so we comply with the RFC */

	wcsncpy_s(formatted_result, COUNT_OF(L"Mmm dd hh:mm:ss"), result, _TRUNCATE);
	
	return formatted_result;
}
开发者ID:PTRWang,项目名称:eventlog-to-syslog,代码行数:47,代码来源:winevent.c


示例10: create_child_with_stdfds

/* Creates a child process for exe, and shares the parent's standard FDs (stdin,
 * stdout, stderr) with the child.  Returns the child's PID on success, -1 o/w.
 */
pid_t create_child_with_stdfds(const char *exe, int argc, char *const argv[],
                               char *const envp[])
{
	struct childfdmap fd_dups[3] = { {0, 0}, {1, 1}, {2, 2} };
	pid_t kid;
	int ret;

	kid = create_child(exe, argc, argv, envp);
	if (kid < 0)
		return -1;
	ret = syscall(SYS_dup_fds_to, kid, fd_dups, COUNT_OF(fd_dups));
	if (ret != COUNT_OF(fd_dups)) {
		sys_proc_destroy(kid, -1);
		return -1;
	}
	return kid;
}
开发者ID:GanShun,项目名称:akaros,代码行数:20,代码来源:parlib.c


示例11: toDeviceId

DeviceId toDeviceId(DeviceIndex device) {
    if (device < 0 || (unsigned)device > COUNT_OF(deviceTable)) {
        errno = EINVAL;
        return -1;
    }

    return deviceTable[device]->id;
}
开发者ID:hellertime,项目名称:manos,代码行数:8,代码来源:fromDeviceId.c


示例12: InitializeRemoteRegistryPicker

static HRESULT
InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
{
    HRESULT hRet;

    *pDsObjectPicker = NULL;

    hRet = CoCreateInstance(&CLSID_DsObjectPicker,
                            NULL,
                            CLSCTX_INPROC_SERVER,
                            &IID_IDsObjectPicker,
                            (LPVOID*)pDsObjectPicker);
    if (SUCCEEDED(hRet))
    {
        DSOP_INIT_INFO InitInfo;
        static DSOP_SCOPE_INIT_INFO Scopes[] =
        {
            {
                sizeof(DSOP_SCOPE_INIT_INFO),
                DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE | DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE |
                DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN |
                DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP |
                DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,
                0,
                {
                    {
                        DSOP_FILTER_COMPUTERS,
                        0,
                        0
                    },
                    DSOP_DOWNLEVEL_FILTER_COMPUTERS
                },
                NULL,
                NULL,
                S_OK
            },
        };

        InitInfo.cbSize = sizeof(InitInfo);
        InitInfo.pwzTargetComputer = NULL;
        InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
        InitInfo.aDsScopeInfos = Scopes;
        InitInfo.flOptions = 0;
        InitInfo.cAttributesToFetch = 0;
        InitInfo.apwzAttributeNames = NULL;

        hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
                &InitInfo);

        if (FAILED(hRet))
        {
            /* delete the object picker in case initialization failed! */
            (*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
        }
    }

    return hRet;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:58,代码来源:framewnd.c


示例13: COUNT_OF

DemuxTable::DemuxTable()
{
	int i = 0;
	int count = COUNT_OF(table_);
	while (i++ < count)
	{
		table_[i].handler_ = NULL;
	}
}
开发者ID:neowei1987,项目名称:Zeus,代码行数:9,代码来源:SelectReactorImpl.cpp


示例14: CreateShaders

	bool CreateShaders()
	{
		// Load the shaders and get a linked program object
		const char * srcs_color_vertex[] = { ZLGLSL_LIST_LOW_PRECISION_HEADER baseattribs_vertex_shader_src, color_vertex_shader_src };
		const char * srcs_color_fragment[] = { ZLGLSL_LIST_LOW_PRECISION_HEADER baseattribs_fragment_shader_src, color_fragment_shader_src };
		const char * const attr_color[] = { "a_position", "a_color" };
		if (!(_COLOR_PROGRAM = CreateProgramFromVertexAndFragmentShaders(COUNT_OF(srcs_color_vertex), srcs_color_vertex, COUNT_OF(srcs_color_fragment), srcs_color_fragment, COUNT_OF(attr_color), attr_color))) return false;
		COLOR_UNI_MVP       = (GLuint)glGetUniformLocation(_COLOR_PROGRAM, "u_mvpMatrix");

		// Load the shaders and get a linked program object
		const char * const attr_texture[] = { "a_position", "a_color", "a_texcoord" };
		if (!(_TEXTURE_PROGRAM = CreateProgramFromVertexAndFragmentShaders(COUNT_OF(srcs_texture_vertex), srcs_texture_vertex, COUNT_OF(srcs_texture_fragment), srcs_texture_fragment, COUNT_OF(attr_texture), attr_texture))) return false;
		TEXTURE_UNI_MVP       = (GLuint)glGetUniformLocation(_TEXTURE_PROGRAM, "u_mvpMatrix");

		glEnableVertexAttribArrayUnbuffered(0); //0 = POSITION = always required

		return true;
	}
开发者ID:schellingb,项目名称:ZillaLib,代码行数:18,代码来源:ZL_PlatformGLSL.cpp


示例15: decode_codon

static int
decode_codon(char codon)
{
	for (int i = 0; i < COUNT_OF(kCodonMatrix); i++) {
		if (kCodonMatrix[i].code == codon)
			return i;
	}
	return -1;
}
开发者ID:kallisti5,项目名称:genoc,代码行数:9,代码来源:main.cpp


示例16: decode_amino

static int
decode_amino(char amino)
{
	for (int i = 0; i < COUNT_OF(kAminoMatrix); i++) {
		if (kAminoMatrix[i].code == amino)
			return i;
	}
	return -1;
}
开发者ID:kallisti5,项目名称:genoc,代码行数:9,代码来源:main.cpp


示例17: modem_signal_strength_to_dbm

static s8 modem_signal_strength_to_dbm(u32 signal_raw)
{
  s8 signal_dbm = 0; // unknown will remain 0

  if (signal_raw < (s8)COUNT_OF(signal_to_dbm_lookup)) {
    signal_dbm = signal_to_dbm_lookup[signal_raw];
  }
  return signal_dbm;
}
开发者ID:swift-nav,项目名称:piksi_buildroot,代码行数:9,代码来源:at_command_utils.c


示例18: fromDeviceId

/* assumes presence of the global device table */
DeviceIndex fromDeviceId(DeviceId id) {
    for (unsigned i = 0; i < COUNT_OF(deviceTable); i++) {
        if (deviceTable[i]->id == id)
            return i;
    }

    errno = ENODEV;
    return -1;
}
开发者ID:hellertime,项目名称:manos,代码行数:10,代码来源:fromDeviceId.c


示例19: initButtons

/*
 * Initialize the button clocks. And configure the buttons.
 */
static void initButtons(void) {
  static const Button buttons[] = { Button1, Button2 };
  
  SIM_SCGC5 |= (SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK); /* clock port D & E */
  
  for (unsigned i = 0; i < COUNT_OF(buttons); i++) {
    makeGPIOIn(buttons[i]);
  }
}
开发者ID:hellertime,项目名称:manos,代码行数:12,代码来源:devswpb.c


示例20: modem_error_rate_to_percent

static float modem_error_rate_to_percent(u32 error_raw)
{
  float error_percent = 0.0; // unknown will remain 0

  if (error_raw < (u32)COUNT_OF(error_to_percent_lookup)) {
    error_percent = error_to_percent_lookup[error_raw];
  }
  return error_percent;
}
开发者ID:swift-nav,项目名称:piksi_buildroot,代码行数:9,代码来源:at_command_utils.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COleDateTime函数代码示例发布时间:2022-05-30
下一篇:
C++ COUNTOF函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap