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

C++ parse_enum函数代码示例

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

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



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

示例1: GetValuesGP

/**
 * Gets values associated to a given option for the GenPrepare function.
 *
 * @param varName NULL-terminated string containing the option name
 * @param varValue NULL-terminated string containing the option value
 * @param PB a pointer to a structure containing benchmark parameters for this session
 */
static void
GetValuesGP (const char  *varName,
             const char  *varValue,
             UflipParams *PB)
{
  const char *fmt_str  [3] = { "None", "Seq", "Rnd" };
  const int   fmt_enum [3] = { NONE,   SEQ,   RND   };

  if (get_common_values (varName, varValue, PB))
    return;

  /* still some specific options to parse */
  if (get_common_gen_values (varName, varValue, PB))
    return;

  /* still not fatal */
  if (strcasecmp (varName, "OutName") == 0)
    {
      strcpy (PB->outName, varValue);
    }
  else if (parse_number ("IOC", varName, varValue, "%d", &PB->IOCount));
  else if (parse_number ("IOC2", varName, varValue, "%d", &PB->IOCount2));
  else if (parse_number ("Pause", varName, varValue, "%d", &PB->pauseExp))
    {
      PB->pauseExp *= 1000;
    }
  else if (parse_enum ("FormatType", varName, varValue, fmt_str, fmt_enum, 3,
                       &PB->fmtType, sizeof (PB->fmtType)));
  else
    {
      /* ok, now this is fatal */
      PrintHelp (varName);
    }
}
开发者ID:blusjune,项目名称:.bsrc,代码行数:41,代码来源:input.c


示例2: parse_alias

/* XXX EXTRA_PARAM and PARAM_NUM are a kludge to get in
 * backward-compatible support for "format" parameter type.  The
 * latter is only valid if the former is non-NULL, which is only in
 * top-level context.  */
static int
parse_alias(struct protolib *plib, struct locus *loc,
	    char **str, struct arg_type_info **retp, int *ownp,
	    struct param **extra_param, size_t param_num)
{
	/* For backward compatibility, we need to support things like
	 * stringN (which is like string[argN], string[N], and also
	 * bare string.  We might, in theory, replace this by
	 * preprocessing configure file sources with M4, but for now,
	 * "string" is syntax.  */
	if (strncmp(*str, "string", 6) == 0) {
		(*str) += 6;
		return parse_string(plib, loc, str, retp, ownp);

	} else if (try_parse_kwd(str, "format") >= 0
		   && extra_param != NULL) {
		/* For backward compatibility, format is parsed as
		 * "string", but it smuggles to the parameter list of
		 * a function a "printf" argument pack with this
		 * parameter as argument.  */
		if (parse_string(plib, loc, str, retp, ownp) < 0)
			return -1;

		return build_printf_pack(loc, extra_param, param_num);

	} else if (try_parse_kwd(str, "enum") >=0) {

		return parse_enum(plib, loc, str, retp, ownp);

	} else {
		*retp = NULL;
		return 0;
	}
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_ltrace,代码行数:38,代码来源:read_config_file.c


示例3: fw3_parse_limit

bool
fw3_parse_limit(void *ptr, const char *val, bool is_list)
{
	struct fw3_limit *limit = ptr;
	enum fw3_limit_unit u = FW3_LIMIT_UNIT_SECOND;
	char *e;
	int n;

	if (*val == '!')
	{
		limit->invert = true;
		while (isspace(*++val));
	}

	n = strtol(val, &e, 10);

	if (errno == ERANGE || errno == EINVAL)
		return false;

	if (*e && *e++ != '/')
		return false;

	if (!strlen(e))
		return false;

	if (!parse_enum(&u, e, limit_units, 0, FW3_LIMIT_UNIT_DAY))
		return false;

	limit->rate = n;
	limit->unit = u;

	return true;
}
开发者ID:NoUsername,项目名称:firewall3,代码行数:33,代码来源:options.c


示例4: assert

/*
 * Parse the value based on the field table
 *
 * @param context	The main context pointer
 * @param rest   	String to parse
 * @param field  	Field item to parse
 * @param value	Returns the value that was parsed
 * @return the remainder of the string after the value was parsed
 */
static char
*parse_field_value(build_image_context *context,
			char *rest,
			field_item *field,
			u_int32_t *value)
{
	assert(rest != NULL);
	assert(field != NULL);
	assert((field->type != field_type_enum)
		|| (field->enum_table != NULL));

	switch (field->type) {
	case field_type_enum:
		rest = parse_enum(context, rest, field->enum_table, value);
		break;

	case field_type_u32:
		rest = parse_u32(rest, value);
		break;

	case field_type_u8:
		rest = parse_u8(rest, value);
		break;

	default:
		printf("Unexpected field type %d at line %d\n",
			field->type, __LINE__);
		rest = NULL;
		break;
	}

	return rest;
}
开发者ID:shashi0291,项目名称:ratatoskr-cbootimage,代码行数:42,代码来源:parse.c


示例5: parse

file_contents parse(parse_source source) {
	file_contents contents;
    contents.imports = ll_new();
	contents.enums = ll_new();
    contents.unions = ll_new();
	contents.structs = ll_new();
	contents.functions = ll_new();
	optional op = get_token(&source);
	while(op_has(op)) {
		parse_token current = *((parse_token*)op_get(op));
		if(equals(current.data, new_slice("struct"))) {
			struct_declaration *dec = analyze_struct(&source);
			ll_add_last(contents.structs, dec);
		} else if(equals(current.data, new_slice("union"))) {
			struct_declaration *dec = analyze_struct(&source);
			ll_add_last(contents.unions, dec);
		} else if(equals(current.data, new_slice("func"))) {
			func_declaration *func = analyze_func(&source);
			ll_add_last(contents.functions, func);
		} else if(equals(current.data, new_slice("import"))) {
            import_declaration *imp = parse_import(&source);
            ll_add_last(contents.imports, imp);
        } else if(equals(current.data, new_slice("enum"))) {
			enum_declaration *enm = parse_enum(&source);
			ll_add_last(contents.enums, enm);
		}//TODO: Throw an error for an unexpected token
		op = get_token(&source);
	}
	return contents;
}
开发者ID:fwum,项目名称:fwum,代码行数:30,代码来源:parser.c


示例6: get_common_values

/**
 * Parses the following options/values: Dev, Size, Fake. They are common to all functions.
 *
 * @param varName option name
 * @param varValue option value
 * @param PB pointer to a struct where to store the parsed options
 * @return false if given @a varName isn't a known option or if given @a varValue
 * isn't a valid value for the option, otherwise true.
 */
static bool
get_common_values (const char  *varName,
                   const char  *varValue,
                   UflipParams *PB)
{
  const char *fake_str  [2] = { "True", "False" };
  const bool  fake_enum [2] = { true,   false   };

  if (strcasecmp (varName, "Dev") == 0)
    {
      PB->device = uflip_device_new (varValue);
    }
  else if (parse_number ("Size", varName, varValue, "%d", &PB->deviceSize))
    {
      PB->deviceSize /= BLOCK;
      PB->deviceSize *= BLOCK;
    }
  else if (parse_enum ("Fake", varName, varValue, fake_str, fake_enum, 2,
                       &PB->fake, sizeof (PB->fake)));
  else
    {
      return false; /* warning, unknown option! */
    }
  return true; /* option found and parsed. */
}
开发者ID:blusjune,项目名称:.bsrc,代码行数:34,代码来源:input.c


示例7: parse_module

/** Parse module.
 *
 * Parse a program module.
 *
 * The input is read using the lexer associated with @a parse. The resulting
 * declarations are added to existing declarations in the program associated
 * with @a parse.
 *
 * If any parse error occurs, parse->error will @c b_true when this function
 * returns. parse->error_bailout will be @c b_true if the error has not
 * been recovered yet. Similar holds for other parsing functions in this
 * module.
 *
 * @param parse		Parser object.
 */
void parse_module(parse_t *parse)
{
	stree_csi_t *csi;
	stree_enum_t *enum_d;
	stree_modm_t *modm;

	while (lcur_lc(parse) != lc_eof && !parse_is_error(parse)) {
		switch (lcur_lc(parse)) {
		case lc_class:
		case lc_struct:
		case lc_interface:
			csi = parse_csi(parse, lcur_lc(parse), NULL);
			modm = stree_modm_new(mc_csi);
			modm->u.csi = csi;

			list_append(&parse->cur_mod->members, modm);
			break;
		case lc_enum:
			enum_d = parse_enum(parse, NULL);
			modm = stree_modm_new(mc_enum);
			modm->u.enum_d = enum_d;

			list_append(&parse->cur_mod->members, modm);
			break;
		default:
			lunexpected_error(parse);
			lex_next(parse->lex);
			break;
		}

	}
}
开发者ID:fhector,项目名称:helenOS-0.5-Hector,代码行数:47,代码来源:parse.c


示例8: parse_type

static int32_t
parse_type(struct snmp_toolinfo *snmptoolctx, enum tok *tok,
    enum snmp_tc *tc, struct enum_pairs **snmp_enum)
{
	int32_t syntax, mem;

	syntax = val;
	*tc = 0;

	if (*tok == TOK_ENUM || *tok == TOK_BITS) {
		if (*snmp_enum == NULL) {
			if ((*snmp_enum = enum_pairs_init()) == NULL)
				return (-1);
			mem = 1;
			*tc = SNMP_TC_OWN;
		} else
			mem = 0;

		if (gettoken(snmptoolctx) != '(') {
			warnx("'(' expected after ENUM/BITS");
			return (-1);
		}

		if ((*tok = gettoken(snmptoolctx)) != TOK_NUM) {
			warnx("need value for ENUM//BITS");
			if (mem == 1) {
				free(*snmp_enum);
				*snmp_enum = NULL;
			}
			return (-1);
		}

		if (parse_enum(snmptoolctx, tok, *snmp_enum) < 0) {
			enum_pairs_free(*snmp_enum);
			*snmp_enum = NULL;
			return (-1);
		}

		*tok = gettoken(snmptoolctx);

	} else if (*tok == TOK_DEFTYPE) {
		struct enum_type *t;

		*tc = 0;
		t = snmp_enumtc_lookup(snmptoolctx, nexttok);
		if (t != NULL)
			*snmp_enum = t->snmp_enum;

		*tok = gettoken(snmptoolctx);

	} else {
		if ((*tok = gettoken(snmptoolctx)) == '|') {
			if (parse_subtype(snmptoolctx, tok, tc) < 0)
				return (-1);
		}
	}

	return (syntax);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:59,代码来源:bsnmpimport.c


示例9: parse_decl

void parse_decl(context& ctx) throw (coord) {
	parse_enum(ctx);
	if (ctx.tag == IDENT)
		parse_vars(ctx);
	if (ctx.tag != SEMICOLON)
		throw ctx.start;
	next_token(ctx);

}
开发者ID:ZOO-OO,项目名称:IU9,代码行数:9,代码来源:parser.cpp


示例10: parse_session_id

__owur static int parse_session_id(SSL_TEST_CTX *test_ctx, const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_session_id, OSSL_NELEM(ssl_session_id),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->session_id_expected = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:10,代码来源:ssl_test_ctx.c


示例11: parse_key_update_type

__owur static int parse_key_update_type(SSL_TEST_CTX *test_ctx, const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_key_update_types, OSSL_NELEM(ssl_key_update_types),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->key_update_type = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:10,代码来源:ssl_test_ctx.c


示例12: parse_handshake_mode

__owur static int parse_handshake_mode(SSL_TEST_CTX *test_ctx, const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_handshake_modes, OSSL_NELEM(ssl_handshake_modes),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->handshake_mode = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:10,代码来源:ssl_test_ctx.c


示例13: parse_test_method

__owur static int parse_test_method(SSL_TEST_CTX *test_ctx, const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_test_methods, OSSL_NELEM(ssl_test_methods),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->method = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:10,代码来源:ssl_test_ctx.c


示例14: parse_expected_result

__owur static int parse_expected_result(SSL_TEST_CTX *test_ctx, const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_test_results, OSSL_NELEM(ssl_test_results),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->expected_result = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:10,代码来源:ssl_test_ctx.c


示例15: parse_servername_callback

__owur static int parse_servername_callback(SSL_TEST_SERVER_CONF *server_conf,
                                            const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_servername_callbacks,
                    OSSL_NELEM(ssl_servername_callbacks), &ret_value, value)) {
        return 0;
    }
    server_conf->servername_callback = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c


示例16: parse_expected_servername

__owur static int parse_expected_servername(SSL_TEST_CTX *test_ctx,
                                            const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_servername, OSSL_NELEM(ssl_servername),
                    &ret_value, value)) {
        return 0;
    }
    test_ctx->expected_servername = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c


示例17: parse_servername

__owur static int parse_servername(SSL_TEST_CLIENT_CONF *client_conf,
                                   const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_servername, OSSL_NELEM(ssl_servername),
                    &ret_value, value)) {
        return 0;
    }
    client_conf->servername = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c


示例18: parse_client_verify_callback

__owur static int parse_client_verify_callback(SSL_TEST_CLIENT_CONF *client_conf,
                                               const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_verify_callbacks, OSSL_NELEM(ssl_verify_callbacks),
                    &ret_value, value)) {
        return 0;
    }
    client_conf->verify_callback = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c


示例19: parse_certstatus

__owur static int parse_certstatus(SSL_TEST_SERVER_CONF *server_conf,
                                            const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_certstatus, OSSL_NELEM(ssl_certstatus), &ret_value,
                    value)) {
        return 0;
    }
    server_conf->cert_status = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c


示例20: parse_ct_validation

__owur static int parse_ct_validation(SSL_TEST_CLIENT_CONF *client_conf,
                                      const char *value)
{
    int ret_value;
    if (!parse_enum(ssl_ct_validation_modes, OSSL_NELEM(ssl_ct_validation_modes),
                    &ret_value, value)) {
        return 0;
    }
    client_conf->ct_validation = ret_value;
    return 1;
}
开发者ID:cedral,项目名称:openssl,代码行数:11,代码来源:ssl_test_ctx.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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