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

C++ sizeof_array函数代码示例

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

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



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

示例1: hooked_fwrite

//------------------------------------------------------------------------------
int hooked_fwrite(const void* data, int size, int count, void* unused)
{
    wchar_t buf[2048];
    size_t characters;
    DWORD written;

    size *= count;
    
    characters = MultiByteToWideChar(
        CP_UTF8, 0,
        (const char*)data, size,
        buf, sizeof_array(buf)
    );

    characters = characters ? characters : sizeof_array(buf) - 1;
    buf[characters] = L'\0';

    if (g_alt_fwrite_hook)
    {
        g_alt_fwrite_hook(buf);
    }
    else
    {
        HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
        WriteConsoleW(handle, buf, (DWORD)wcslen(buf), &written, NULL);
    }

    return size;
}
开发者ID:CaptainFlint,项目名称:clink,代码行数:30,代码来源:hooks.c


示例2: hooked_stat

//------------------------------------------------------------------------------
int hooked_stat(const char* path, struct hooked_stat* out)
{
    int ret = -1;
    WIN32_FILE_ATTRIBUTE_DATA fad;
    wchar_t buf[2048];
    size_t characters;

    // Utf8 to wchars.
    characters = MultiByteToWideChar(
        CP_UTF8, 0,
        path, -1,
        buf, sizeof_array(buf)
    );

    characters = characters ? characters : sizeof_array(buf) - 1;
    buf[characters] = L'\0';

    // Get properties.
    out->st_size = 0;
    out->st_mode = 0;
    if (GetFileAttributesExW(buf, GetFileExInfoStandard, &fad) != 0)
    {
        unsigned dir_bit;

        dir_bit = (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : 0;

        out->st_size = fad.nFileSizeLow;
        out->st_mode |= dir_bit;
        ret = 0;
    }
    else
        errno = ENOENT;

    return ret;
}
开发者ID:EdSchroedinger,项目名称:clink,代码行数:36,代码来源:hooks.c


示例3: main

int main()
{
	int i;

	if (!rocket_init("data/sync"))
		return -1;

	for (i = 0; i < sizeof_array(s_trackNames); ++i)
		s_tracks[i] = sync_get_track(device, s_trackNames[i]);

	for (;;)
	{
		float row_f;

		rocket_update();

		row_f = ms_to_row_f(curtime_ms, rps);

		printf("current time %d\n", curtime_ms);

		for (i = 0; i < sizeof_array(s_trackNames); ++i)
			printf("%s %f\n", s_trackNames[i], sync_get_val(s_tracks[i], row_f));
	#if defined(WIN32)
		Sleep(16);
	#else
		usleep(16000);
	#endif
	}
}
开发者ID:alkama,项目名称:rocket,代码行数:29,代码来源:basic_example.c


示例4: print_keys

//------------------------------------------------------------------------------
static int print_keys()
{
    int i, n;
    const setting_decl_t* decl;

    decl = settings_get_decls(g_settings);
    if (decl == NULL)
    {
        puts("ERROR: Failed to find settings decl.");
        return 1;
    }

    puts("Available options:\n");
    for (i = 0, n = settings_get_decl_count(g_settings); i < n; ++i)
    {
        static const char dots[] = ".......................... ";
        const char* name = decl->name;
        int dot_count;

        printf("%s ", name);
        dot_count = sizeof_array(dots) - (int)strlen(name);
        if (dot_count > 0)
        {
            printf("%s", dots + sizeof_array(dots) - dot_count);
        }

        printf("%-6s %s\n", settings_get_str(g_settings, name), decl->friendly_name);

        ++decl;
    }

    printf("\nSettings path: %s\n", g_settings_path);
    return 0;
}
开发者ID:NextGenIntelligence,项目名称:clink,代码行数:35,代码来源:set.c


示例5: TEST_START

TEST_END

TEST_START(parses_ssl_options_require_cert_and_key)
{
    opt options;

    clax_options_init(&options);

    char *argv[] = {"clax", "-r", "."};
    int ret = clax_parse_options(&options, sizeof_array(argv), argv);

    ASSERT_EQ(ret, -1)

    clax_options_free(&options);
    clax_options_init(&options);

    char *argv2[] = {"clax", "-r", ".", "-t", "ssl/server.crt"};
    int ret2 = clax_parse_options(&options, sizeof_array(argv2), argv2);

    ASSERT_EQ(ret2, -1)

    clax_options_free(&options);
    clax_options_init(&options);

    char *argv3[] = {"clax", "-r", ".", "-p", "ssl/server.key"};
    int ret3 = clax_parse_options(&options, sizeof_array(argv3), argv3);

    ASSERT_EQ(ret3, -1)

    clax_options_free(&options);
}
开发者ID:Prajithp,项目名称:clax,代码行数:31,代码来源:test_clax_options.c


示例6: settings_get_str

//------------------------------------------------------------------------------
const char* settings_get_str(settings_t* s, const char* name)
{
    int i;

    // Check for an environment variable override.
    {
        static char buffer[256];

        strcpy(buffer, "clink.");
        str_cat(buffer, name, sizeof_array(buffer));

        if (GetEnvironmentVariableA(buffer, buffer, sizeof_array(buffer)))
        {
            return buffer;
        }
    }

    i = get_decl_index(s, name);
    if (i != -1)
    {
        return s->values[i];
    }

    return "";
}
开发者ID:CaptainFlint,项目名称:clink,代码行数:26,代码来源:settings.c


示例7: load_lua_scripts

//------------------------------------------------------------------------------
static void load_lua_scripts(const char* path)
{
    int i;
    char path_buf[1024];
    HANDLE find;
    WIN32_FIND_DATA fd;

    str_cpy(path_buf, path, sizeof_array(path_buf));
    str_cat(path_buf, "\\", sizeof_array(path_buf));
    i = strlen(path_buf);

    str_cat(path_buf, "*.lua", sizeof_array(path_buf));
    find = FindFirstFile(path_buf, &fd);
    path_buf[i] = '\0';

    while (find != INVALID_HANDLE_VALUE)
    {
        if (_stricmp(fd.cFileName, "clink.lua") != 0)
        {
            str_cat(path_buf, fd.cFileName, sizeof_array(path_buf));
            load_lua_script(path_buf);
            path_buf[i] = '\0';
        }

        if (FindNextFile(find, &fd) == FALSE)
        {
            FindClose(find);
            break;
        }
    }
}
开发者ID:genba,项目名称:clink,代码行数:32,代码来源:lua.c


示例8: set

//------------------------------------------------------------------------------
int set(int argc, char** argv)
{
    int ret;

    // Check we're running from a Clink session.
    extern int g_in_clink_context;
    if (!g_in_clink_context)
    {
        puts("ERROR: The 'set' verb must be run from a process with Clink present");
        return 1;
    }

    // Get the path where Clink's storing its settings.
    get_config_dir(g_settings_path, sizeof_array(g_settings_path));
    str_cat(g_settings_path, "/settings", sizeof_array(g_settings_path));

    // Load Clink's settings.
    g_settings = initialise_clink_settings();
    if (g_settings == NULL)
    {
        printf("ERROR: Failed to load Clink's settings from '%s'.", g_settings_path);
        return 1;
    }

    // List or set Clink's settings.
    ret = 0;
    switch (argc)
    {
    case 0:
    case 1:
        ret = print_keys();
        break;

    case 2:
        if (_stricmp(argv[1], "--help") == 0 ||
            _stricmp(argv[1], "-h") == 0)
        {
            ret = 1;
            print_usage();
        }
        else
        {
            ret = print_value(argv[1]);
        }
        break;

    default:
        ret = set_value(argv[1], argv[2]);
        if (!ret)
        {
            settings_save(g_settings, g_settings_path);
        }
        break;
    }

    settings_shutdown(g_settings);
    return ret;
}
开发者ID:NextGenIntelligence,项目名称:clink,代码行数:59,代码来源:set.c


示例9: vasm_rv32f_table_load

int vasm_rv32f_table_load(vasm_ctx_t* ctx)
{
    // link in static symbols above into symtab
    symbol_table_install_array(&ctx->symtab, &sym_reg_fabi[0], 
			       sizeof_array(sym_reg_fabi));
    symbol_table_install_array(&ctx->symtab, &sym_reg_fi[0],
			       sizeof_array(sym_reg_fi));
    symbol_table_install_array(&ctx->symtab, &sym_instr_rv32f[0],
			       sizeof_array(sym_instr_rv32f));
    return 0;
}
开发者ID:kennethzfeng,项目名称:vasm,代码行数:11,代码来源:vasm_rv32f.c


示例10: hooked_fprintf

//------------------------------------------------------------------------------
void hooked_fprintf(const void* unused, const char* format, ...)
{
    char buffer[2048];
    va_list v;

    va_start(v, format);
    vsnprintf(buffer, sizeof_array(buffer), format, v);
    va_end(v);

    buffer[sizeof_array(buffer) - 1] = '\0';
    hooked_fwrite(buffer, (int)strlen(buffer), 1, NULL);
}
开发者ID:CaptainFlint,项目名称:clink,代码行数:13,代码来源:hooks.c


示例11: initialise_clink_settings

//------------------------------------------------------------------------------
void* initialise_clink_settings()
{
    char settings_file[MAX_PATH];

    get_settings_file(settings_file, sizeof_array(settings_file));

    g_settings = settings_init(g_settings_decl, sizeof_array(g_settings_decl));

    if (!settings_load(g_settings, settings_file))
    {
        settings_save(g_settings, settings_file);
    }

    return g_settings;
}
开发者ID:bobbyzhu,项目名称:clink,代码行数:16,代码来源:settings.c


示例12: _ftdi_port_control

static usbh_urbstatus_t _ftdi_port_control(USBHFTDIPortDriver *ftdipp,
        uint8_t bRequest, uint8_t wValue, uint8_t bHIndex, uint16_t wLength,
        uint8_t *buff) {

    static const uint8_t bmRequestType[] = {
        USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //0 FTDI_COMMAND_RESET
        USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //1 FTDI_COMMAND_MODEMCTRL
        USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //2 FTDI_COMMAND_SETFLOW
        USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //3 FTDI_COMMAND_SETBAUD
        USBH_REQTYPE_VENDOR | USBH_REQTYPE_OUT | USBH_REQTYPE_DEVICE, //4 FTDI_COMMAND_SETDATA
    };

    osalDbgCheck(bRequest < sizeof_array(bmRequestType));
    osalDbgCheck(bRequest != 1);

    const USBH_DEFINE_BUFFER(usbh_control_request_t, req) = {
        bmRequestType[bRequest],
        bRequest,
        wValue,
        (bHIndex << 8) | (ftdipp->ifnum + 1),
        wLength
    };

    return usbhControlRequestExtended(ftdipp->ftdip->dev, &req, buff, NULL, MS2ST(1000));
}
开发者ID:rlippert,项目名称:ChibiOS-Contrib,代码行数:25,代码来源:hal_usbh_ftdi.c


示例13: UIRender_init

bool UIRender_init() {
    s_tex = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);

    for (int i = 0; i < (int)sizeof_array(s_programs); ++i) {
        ProgramInfo* program = &s_programs[i];

        program->handle = loadProgram(program->vsName, program->fsName);

        if (!isValid(program->handle))
            return false;

        const ProgramAttribs* attribs = program->attribs;
        bgfx::VertexDecl& decl = program->vertexDecl;

        decl.begin();

        while (attribs->attrib != bgfx::Attrib::Count) {
            decl = decl.add(attribs->attrib, attribs->num, attribs->type, attribs->norm);
            attribs++;
        }

        decl.end();
    }

    return true;
}
开发者ID:ezhangle,项目名称:ProDBG,代码行数:26,代码来源:ui_render.cpp


示例14: StandardWidget

GuiSettingsWidget::GuiSettingsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::GuiSettingsWidget())
{
	ui->setupUi(this);
	performStandardSetup(tr("GUI Settings"));
	
	connect(ui->colors, SIGNAL(currentIndexChanged(int)), SLOT(colorChanged(int)));
  connect(ui->fullscreen, SIGNAL(stateChanged(int)), SLOT(fullscreenChanged(int)));
	
	SettingsProvider *settings = device->settingsProvider();
	if(!settings) {
		ui->colors->setEnabled(false);
    ui->fullscreen->setEnabled(false);
		return;
	}
	
	QColor currentColor = settings->value(GUI_COLOR_KEY, guiColors[0]).value<QColor>();
	quint16 current = 0;
	for(quint16 i = 0; i < sizeof_array(guiColors); ++i) {
		if(currentColor == guiColors[i]) {
			current = i;
			break;
		}
	}
	ui->colors->setCurrentIndex(current);
  
  const bool currentFullscreen = settings->value(FULLSCREEN_KEY, true).toBool();
  ui->fullscreen->setChecked(currentFullscreen);
}
开发者ID:kipr,项目名称:botui,代码行数:30,代码来源:GuiSettingsWidget.cpp


示例15: unitfy_data_size

struct size_of_data unitfy_data_size(unsigned int sizeInBytes)
{
	struct size_of_data retVal;
	int i;

	/* Feel free to add more - just append items to the array :) */
	const char* units[] = {
		"B",
		"KB",
		"MB",
		"GB",
		"TB",
		"PB",
		"EB",
		"ZB",
		"YB"	/* We'll never get past a yottabyte of anything... right? */
	};

	retVal.quantity = sizeInBytes;
	retVal.unit = units[0];

	for(i = 1; (retVal.quantity >= 1024) && (i < sizeof_array(units)); ++i)
	{
		retVal.quantity /= 1024;
		retVal.unit = units[i];
	}

	return retVal;
}
开发者ID:cgaebel,项目名称:CacheLineDetection,代码行数:29,代码来源:format.c


示例16: find_files_impl

//------------------------------------------------------------------------------
static int find_files_impl(lua_State* state, int dirs_only)
{
    DIR* dir;
    struct dirent* entry;
    char buffer[512];
    const char* mask;
    int i;
    int case_map;

    // Check arguments.
    i = lua_gettop(state);
    if (i == 0 || lua_isnil(state, 1))
    {
        return 0;
    }

    mask = lua_tostring(state, 1);

    // Should the mask be adjusted for -/_ case mapping?
    if (_rl_completion_case_map && i > 1 && lua_toboolean(state, 2))
    {
        char* slash;

        str_cpy(buffer, mask, sizeof_array(buffer));
        mask = buffer;

        slash = strrchr(buffer, '\\');
        slash = slash ? slash : strrchr(buffer, '/');
        slash = slash ? slash + 1 : buffer;

        while (*slash)
        {
            char c = *slash;
            if (c == '_' || c == '-')
            {
                *slash = '?';
            }

            ++slash;
        }
    }
    
    lua_createtable(state, 0, 0);

    i = 1;
    dir = opendir(mask);
    while (entry = readdir(dir))
    {
        if (dirs_only && !(entry->attrib & _A_SUBDIR))
        {
            continue;
        }

        lua_pushstring(state, entry->d_name);
        lua_rawseti(state, -2, i++);
    }
    closedir(dir);

    return 1;
}
开发者ID:genba,项目名称:clink,代码行数:61,代码来源:lua.c


示例17: parse_items

bool parse_items( player_t* p, js_node_t* items )
{
  if ( !items ) return true;

  static const char* const slot_map[] = {
    "head",
    "neck",
    "shoulder",
    "shirt",
    "chest",
    "waist",
    "legs",
    "feet",
    "wrist",
    "hands",
    "finger1",
    "finger2",
    "trinket1",
    "trinket2",
    "back",
    "mainHand",
    "offHand",
    "ranged",
    "tabard"
  };

  assert( sizeof_array( slot_map ) == SLOT_MAX );

  for ( unsigned i = 0; i < SLOT_MAX; ++i )
  {
    js_node_t* item = js_t::get_child( items, slot_map[ i ] );
    if ( ! item ) continue;

    std::string item_id;
    if ( ! js_t::get_value( item_id, item, "id" ) ) continue;

    std::string gem_ids[3];
    js_t::get_value( gem_ids[0], item, "tooltipParams/gem0" );
    js_t::get_value( gem_ids[1], item, "tooltipParams/gem1" );
    js_t::get_value( gem_ids[2], item, "tooltipParams/gem2" );

    std::string enchant_id;
    js_t::get_value( enchant_id, item, "tooltipParams/enchant" );

    std::string reforge_id;
    js_t::get_value( reforge_id, item, "tooltipParams/reforge" );

    std::string tinker_id;
    js_t::get_value( tinker_id, item, "tooltipParams/tinker" );

    std::string suffix_id;
    js_t::get_value( suffix_id, item, "tooltipParams/suffix" );

    if ( ! item_t::download_slot( p -> items[ i ], item_id, enchant_id, tinker_id, reforge_id, suffix_id, gem_ids ) )
      return false;
  }

  return true;
}
开发者ID:coleb,项目名称:Raid-Sim,代码行数:59,代码来源:sc_bcp_api.cpp


示例18: get_dom_select_pseudo

/* Maps the content of a scanner token to a pseudo-class or -element ID. */
static enum dom_select_pseudo
get_dom_select_pseudo(struct dom_scanner_token *token)
{
	static struct {
		struct dom_string string;
		enum dom_select_pseudo pseudo;
	} pseudo_info[] = {

#define INIT_DOM_SELECT_PSEUDO_STRING(str, type) \
	{ STATIC_DOM_STRING(str), DOM_SELECT_PSEUDO_##type }

	INIT_DOM_SELECT_PSEUDO_STRING("first-line",	FIRST_LINE),
	INIT_DOM_SELECT_PSEUDO_STRING("first-letter",	FIRST_LETTER),
	INIT_DOM_SELECT_PSEUDO_STRING("selection",	SELECTION),
	INIT_DOM_SELECT_PSEUDO_STRING("after",		AFTER),
	INIT_DOM_SELECT_PSEUDO_STRING("before",		BEFORE),
	INIT_DOM_SELECT_PSEUDO_STRING("link",		LINK),
	INIT_DOM_SELECT_PSEUDO_STRING("visited",	VISITED),
	INIT_DOM_SELECT_PSEUDO_STRING("active",		ACTIVE),
	INIT_DOM_SELECT_PSEUDO_STRING("hover",		HOVER),
	INIT_DOM_SELECT_PSEUDO_STRING("focus",		FOCUS),
	INIT_DOM_SELECT_PSEUDO_STRING("target",		TARGET),
	INIT_DOM_SELECT_PSEUDO_STRING("enabled",	ENABLED),
	INIT_DOM_SELECT_PSEUDO_STRING("disabled",	DISABLED),
	INIT_DOM_SELECT_PSEUDO_STRING("checked",	CHECKED),
	INIT_DOM_SELECT_PSEUDO_STRING("indeterminate",	INDETERMINATE),

	/* Content pseudo-classes: */

	INIT_DOM_SELECT_PSEUDO_STRING("contains",	CONTAINS),

	/* Structural pseudo-classes: */

	INIT_DOM_SELECT_PSEUDO_STRING("nth-child",	NTH_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("nth-last-child",	NTH_LAST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("first-child",	FIRST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("last-child",	LAST_CHILD),
	INIT_DOM_SELECT_PSEUDO_STRING("only-child",	ONLY_CHILD),

	INIT_DOM_SELECT_PSEUDO_STRING("nth-of-type",	NTH_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("nth-last-of-type",NTH_LAST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("first-of-type",	FIRST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("last-of-type",	LAST_TYPE),
	INIT_DOM_SELECT_PSEUDO_STRING("only-of-type",	ONLY_TYPE),

	INIT_DOM_SELECT_PSEUDO_STRING("root",		ROOT),
	INIT_DOM_SELECT_PSEUDO_STRING("empty",		EMPTY),

#undef INIT_DOM_SELECT_PSEUDO_STRING

	};
	int i;

	for (i = 0; i < sizeof_array(pseudo_info); i++)
		if (!dom_string_casecmp(&pseudo_info[i].string, &token->string))
			return pseudo_info[i].pseudo;

	return DOM_SELECT_PSEUDO_UNKNOWN;
}
开发者ID:ezc,项目名称:elinks,代码行数:60,代码来源:select.c


示例19: R_PRE

struct r_hash_link *r_hash_lookup(struct r_hash_table *ht, const char *id)
{
	struct r_id rid;
	R_PRE(strlen(id) < sizeof_array(rid.id_name));

	strcpy(rid.id_name, id);
	return r_hash_lookup_id(ht, &rid);
}
开发者ID:nikitadanilov,项目名称:r,代码行数:8,代码来源:hash.c


示例20: class_flag

  bool class_flag( unsigned flag ) const
  {
    unsigned index = flag / 32;
    unsigned bit = flag % 32;

    assert( index < sizeof_array( _class_flags ) );
    return ( _class_flags[ index ] & ( 1u << bit ) ) != 0;
  }
开发者ID:dpf44,项目名称:simulationcraft,代码行数:8,代码来源:dbc.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sizes函数代码示例发布时间:2022-05-30
下一篇:
C++ sizeofW函数代码示例发布时间: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