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

C++ parse_integer函数代码示例

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

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



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

示例1: cmd_xmem

cmd_result_t
cmd_xmem(int unit, args_t *a)
{
    char          *token;
    unsigned int   addr, data;

    if ((token = ARG_GET(a)) == NULL) {
        return CMD_USAGE;
    }

    if (sal_strcasecmp(token, "r") == 0) {
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        addr = parse_integer(token);
        cli_out("0x%x: %08x\n", addr, *((unsigned int *)(INT_TO_PTR(addr))));
    } else if (sal_strcasecmp(token, "w") == 0) {
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        addr = parse_integer(token);
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        data = parse_integer(token);
        *((unsigned int *)(INT_TO_PTR(addr))) = data;
    } else {
        cli_out(cmd_xmem_usage);
        return CMD_FAIL;
    }
    return CMD_OK;
}
开发者ID:ariavie,项目名称:bcm,代码行数:32,代码来源:xmem.c


示例2: DSA_new

DSA *DSA_parse_private_key(CBS *cbs) {
  DSA *ret = DSA_new();
  if (ret == NULL) {
    return NULL;
  }

  CBS child;
  uint64_t version;
  if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
      !CBS_get_asn1_uint64(&child, &version)) {
    OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
    goto err;
  }

  if (version != 0) {
    OPENSSL_PUT_ERROR(DSA, DSA_R_BAD_VERSION);
    goto err;
  }

  if (!parse_integer(&child, &ret->p) ||
      !parse_integer(&child, &ret->q) ||
      !parse_integer(&child, &ret->g) ||
      !parse_integer(&child, &ret->pub_key) ||
      !parse_integer(&child, &ret->priv_key) ||
      CBS_len(&child) != 0) {
    OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
    goto err;
  }
  return ret;

err:
  DSA_free(ret);
  return NULL;
}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:34,代码来源:dsa_asn1.c


示例3: cmd_setfanspeed

cmd_result_t
cmd_setfanspeed(int unit, args_t *a)
{
	char *d = ARG_GET(a);
	char *s = ARG_GET(a);
	int devno = -1, speed = -1;
	int retv;

	if (!sh_check_attached(ARG_CMD(a), unit))
		return CMD_FAIL;

	if (d) {
		devno = parse_integer(d);
	}
	if (s) {
		speed = parse_integer(s);
	}
	if ((devno < 0) || (devno > 7) || (speed < 0) || (speed > 15)) {
		return CMD_USAGE;
	}

	retv = soc_bsc_max6653_set(unit, devno, speed);
	if (retv) {
		sal_printf("%s failed\n", FUNCTION_NAME());
		return CMD_FAIL;
	}

	return CMD_OK;
}
开发者ID:ariavie,项目名称:bcm,代码行数:29,代码来源:bsc_cmds.c


示例4: resource_parse_line

static cairo_bool_t
resource_parse_line (char *name, cairo_xcb_resources_t *resources)
{
    char *value;

    value = strchr (name, ':');
    if (value == NULL)
	return FALSE;

    *value++ = 0;

    name = skip_spaces (name);
    value = skip_spaces (value);

    if (strcmp (name, "Xft.antialias") == 0)
	parse_boolean (value, &(resources->xft_antialias));
    else if (strcmp (name, "Xft.lcdfilter") == 0)
	parse_integer (value, &(resources->xft_lcdfilter));
    else if (strcmp (name, "Xft.rgba") == 0)
	parse_integer (value, &(resources->xft_rgba));
    else if (strcmp (name, "Xft.hinting") == 0)
	parse_boolean (value, &(resources->xft_hinting));
    else if (strcmp (name, "Xft.hintstyle") == 0)
	parse_integer (value, &(resources->xft_hintstyle));

    return TRUE;
}
开发者ID:AZed,项目名称:cairo,代码行数:27,代码来源:cairo-xcb-resources.c


示例5: parse_environment_vars

/**
 * Parse environment variables
 */
void parse_environment_vars(parallel_wrapper *par_wrapper)
{
	char *value = NULL;
	value = getenv("_CONDOR_PROCNO");
	parse_integer(value, &par_wrapper -> this_machine -> rank);

	value = getenv("_CONDOR_NPROCS");
	parse_integer(value, &par_wrapper -> num_procs);

	return;
}
开发者ID:herzfeldd,项目名称:parallel_wrapper,代码行数:14,代码来源:parse_args_env.c


示例6: pxebs_exec

/**
 * The "pxebs" command
 *
 * @v argc		Argument count
 * @v argv		Argument list
 * @ret rc		Return status code
 */
static int pxebs_exec ( int argc, char **argv ) {
	struct pxebs_options opts;
	struct net_device *netdev;
	unsigned int pxe_type;
	int rc;

	/* Parse options */
	if ( ( rc = parse_options ( argc, argv, &pxebs_cmd, &opts ) ) != 0 )
		return rc;

	/* Parse net device name */
	if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
		return rc;

	/* Parse boot server type */
	if ( ( rc = parse_integer ( argv[ optind + 1 ], &pxe_type ) ) != 0 )
		return rc;

	/* Perform Boot Server Discovery */
	if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
		printf ( "Could not discover boot server on %s: %s\n",
			 netdev->name, strerror ( rc ) );
		return rc;
	}

	return 0;
}
开发者ID:42wim,项目名称:ipxe,代码行数:34,代码来源:dhcp_cmd.c


示例7: get_current_quota

/** Retrieve the amount of quote remaining to a player.
 * Figure out a player's quota. Add the RQUOTA attribute if he doesn't
 * have one already. This function returns the REMAINING quota, not
 * the TOTAL limit.
 * \param who player to check.
 * \return player's remaining quota.
 */
int
get_current_quota(dbref who)
{
  ATTR *a;
  int i;
  int limit;
  int owned = 0;

  /* if he's got an RQUOTA attribute, his remaining quota is that */
  a = atr_get_noparent(Owner(who), "RQUOTA");
  if (a)
    return parse_integer(atr_value(a));

  /* else, count up his objects. If he has less than the START_QUOTA,
   * then his remaining quota is that minus his number of current objects.
   * Otherwise, it's his current number of objects. Add the attribute
   * if he doesn't have it.
   */

  for (i = 0; i < db_top; i++)
    if (Owner(i) == Owner(who))
      owned++;
  owned--;                      /* don't count the player himself */

  if (owned <= START_QUOTA)
    limit = START_QUOTA - owned;
  else
    limit = owned;

  (void) atr_add(Owner(who), "RQUOTA", tprintf("%d", limit), GOD, 0);

  return limit;
}
开发者ID:zetafunction,项目名称:pennmush-mirror,代码行数:40,代码来源:predicat.c


示例8: stream_peek

static json_t *parse_value(stream_t *stream, size_t flags, json_error_t *error)
{
    json_t *result = NULL;
    char *string;
    int c = stream_peek(stream);

    switch (c) {
    case 'd':
        result = parse_dict(stream, flags, error);
        break;
    case 'l':
        result = parse_list(stream, flags, error);
        break;
    case 'i':
        stream_getc(stream);
        result = parse_integer(stream, flags, error);
        break;
    case EOF:
        error_set(error, stream, "unexpected EOF");
        break;
    default:
        if (json_isdigit(c)) {
            string = parse_string(stream, flags, error);
            if (string) {
                result = json_string_nocheck(string);
                jsonp_free(string);
            }
        } else {
            error_set(error, stream, "invalid character: %c", c);
        }
    }
    return result;
}
开发者ID:japeq,项目名称:jansson-bencode,代码行数:33,代码来源:bencode.c


示例9: skip_whitespace

/**
 * Parse the number term 's' and return its resulting value in 'value'.
 * Return a pointer behind the last character of the expression.
 * Return NULL if a syntax error occurred.
 */
char *parse_number_term(char *s, int *value) {
  unsigned char token;
  s = skip_whitespace(s);
  token = next_token(s);
  if (token == TOKEN_DIGITS || token == TOKEN_PLUS || token == TOKEN_MINUS) {
    if (s = parse_integer(s, value)) {
      return s;
    } else {
      syntax_error_invalid_number();
    }
  } else if (token == TOKEN_VAR_NUMBER) {
    unsigned int var_name;
    unsigned char var_type;
    variable *var;
    s = parse_variable(s, &var_name, &var_type);
    var = find_variable(var_name, VAR_TYPE_INTEGER, NULL);
    if (var) {
      *value = get_integer_variable_value(var);
      return s;
    } else {
      syntax_error_msg("Variable not found");
    }
  } else {
    syntax_error();
  }

  return NULL;
}
开发者ID:punkofnewsociety,项目名称:homecomputer-6502,代码行数:33,代码来源:basic.c


示例10: u_comp

/** qsort() comparision routine used by sortby() */
int
u_comp(const void *s1, const void *s2)
{
  char result[BUFFER_LEN], *rp;
  char const *tbuf;
  int n;

  /* Our two arguments are passed as %0 and %1 to the sortby u-function. */

  /* Note that this function is for use in conjunction with our own
   * sane_qsort routine, NOT with the standard library qsort!
   */
  global_eval_context.wenv[0] = (char *) s1;
  global_eval_context.wenv[1] = (char *) s2;

  /* Run the u-function, which should return a number. */

  tbuf = ucomp_buff;
  rp = result;
  if (process_expression(result, &rp, &tbuf,
                         ucomp_executor, ucomp_caller, ucomp_enactor,
                         PE_DEFAULT, PT_DEFAULT, ucomp_pe_info))
    return 0;
  n = parse_integer(result);

  return n;
}
开发者ID:tkrajcar,项目名称:pypenn,代码行数:28,代码来源:sort.c


示例11: parse_integer

uintmax_t
parse_integer (const char *str, gboolean * invalid)
{
    uintmax_t n;
    char *suffix;
    strtol_error_t e;

    e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0");
    if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x')
    {
        uintmax_t multiplier;

        multiplier = parse_integer (suffix + 1, invalid);
        if (multiplier != 0 && n * multiplier / multiplier != n)
        {
            *invalid = TRUE;
            return 0;
        }

        n *= multiplier;
    }
    else if (e != LONGINT_OK)
    {
        *invalid = TRUE;
        n = 0;
    }

    return n;
}
开发者ID:CTU-OSP,项目名称:mc,代码行数:29,代码来源:strutil.c


示例12: parse_value

static struct buffer parse_value(struct buffer buff,
      struct rmsgpack_dom_value *value, const char **error)
{
   buff = chomp(buff);

   if (peek(buff, "nil"))
   {
      buff.offset += strlen("nil");
      value->type = RDT_NULL;
   }
   else if (peek(buff, "true"))
   {
      buff.offset += strlen("true");
      value->type = RDT_BOOL;
      value->val.bool_ = 1;
   }
   else if (peek(buff, "false"))
   {
      buff.offset += strlen("false");
      value->type = RDT_BOOL;
      value->val.bool_ = 0;
   }
   else if (peek(buff, "b") || peek(buff, "\"") || peek(buff, "'"))
      buff = parse_string(buff, value, error);
   else if (isdigit((int)buff.data[buff.offset]))
      buff = parse_integer(buff, value, error);
   return buff;
}
开发者ID:Joonie86,项目名称:RetroArch,代码行数:28,代码来源:query.c


示例13: RSA_new

RSA *RSA_parse_public_key(CBS *cbs) {
  RSA *ret = RSA_new();
  if (ret == NULL) {
    return NULL;
  }
  CBS child;
  if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
      !parse_integer(&child, &ret->n) ||
      !parse_integer(&child, &ret->e) ||
      CBS_len(&child) != 0) {
    OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_ENCODING);
    RSA_free(ret);
    return NULL;
  }
  return ret;
}
开发者ID:dconnolly,项目名称:ring,代码行数:16,代码来源:rsa_asn1.c


示例14: DSA_SIG_new

DSA_SIG *DSA_SIG_parse(CBS *cbs) {
  DSA_SIG *ret = DSA_SIG_new();
  if (ret == NULL) {
    return NULL;
  }
  CBS child;
  if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
      !parse_integer(&child, &ret->r) ||
      !parse_integer(&child, &ret->s) ||
      CBS_len(&child) != 0) {
    OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
    DSA_SIG_free(ret);
    return NULL;
  }
  return ret;
}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:16,代码来源:dsa_asn1.c


示例15: next_token

	void OrderPropertyParser::parse(StylePropertySetter *setter, const std::string &name, StyleParser &parser)
	{
		auto &tokens = parser.tokens;

		StyleSetValue order;

		size_t pos = 0;
		StyleToken token = next_token(pos, tokens);
		if (token.type == StyleTokenType::ident && pos == tokens.size())
		{
			if (equals(token.value, "inherit"))
				order = StyleSetValue::from_keyword("inherit");
			else
				return;
		}
		else if (token.type == StyleTokenType::number && pos == tokens.size())
		{
			int value = 0;
			if (parse_integer(token.value, value))
			{
				order = StyleSetValue::from_number((float)value);
			}
			else
			{
				return;
			}
		}
		else
		{
			return;
		}

		setter->set_value("order", order);
	}
开发者ID:RobertoMalatesta,项目名称:ClanLib,代码行数:34,代码来源:flex.cpp


示例16: main

int main(int argc, char **argv)
{
	if (argc != 2) {
		fprintf(stderr, "This program expects one argument.\n");
		return 1;
	}

	int fork_failed = 0;
	long children_count = parse_integer(argv[1]);

	for (long i = 0; i < children_count; ++i) {
		long child = fork();

		if (child < 0) {
			/* parent, fork() failed */
			fprintf(stderr, "Failed to fork() child #%zu: %m\n", i + 1);
			fork_failed = 1;
		} else if (child == 0) {
			/* child */
			printf("child #%zu pid %ld ppid %ld\n", i + 1, (long)getpid(), (long)getppid());
			return 0;
		}

		/* parent, fork() succeeded */
	}

	return fork_failed ? 1 : 0;
}
开发者ID:Dredeg,项目名称:mipt-informatics,代码行数:28,代码来源:task2.c


示例17: parser_visible

extern jobject
parser_visible(JNIEnv* env, jclass exception, json_t* root, int is_java_call)
{
	if(NULL == root)
	{
		return NULL;
	}

//	LOGE("parser_visible");

	if(is_java_call)
	{
		errno = 0;
	}

	jclass visible_class = NULL;
	jobject visible_obj  = NULL;

	visible_class = (*env) -> FindClass(env, CB_CLASS_VISIBLE);
	init_fieldid(env, visible_class);
	init_methodid(env, visible_class);
	visible_obj   = (*env) -> NewObject(env, visible_class, constructor);
	throw_parse_exception(env, exception, PARSER_VISIBLE_ERROR);

	int type_value 		  		= parse_integer(&root, "type");
	int list_id_value 		= parse_integer(&root, "list_id");

	(*env) -> SetIntField(env, visible_obj, type, type_value);
	throw_parse_exception(env, exception, PARSER_VISIBLE_ERROR);
	(*env) -> SetIntField(env, visible_obj, list_id, list_id_value);
	throw_parse_exception(env, exception, PARSER_VISIBLE_ERROR);

	// clean
//	LOGE("visible clean");
	if(is_java_call)
	{
		json_decref(root);
	}

	if(errno != 0)
	{
		(*env) -> ThrowNew(env, exception, PARSER_VISIBLE_ERROR);
	}

	return visible_obj;

}
开发者ID:wangliangrc,项目名称:simplemvc4j,代码行数:47,代码来源:visible_parser.c


示例18: to_long

long to_long(const char* p, const char* p_end, const char** p_parse_ended)
{
    long val = parse_integer(p, p_end);
    if (p_parse_ended)
        *p_parse_ended = p;

    return val;
}
开发者ID:CarterWeron,项目名称:liborcus,代码行数:8,代码来源:measurement.cpp


示例19: integer_

int integer_()
{
    int result=0;

    check(parse_integer(result));

    return result;
}
开发者ID:vmorgulys,项目名称:sandbox,代码行数:8,代码来源:class.string.h.number.cpp


示例20: byte_

unsigned char byte_()
{
    int result=0;

    check(parse_integer(result));

    return coerce<unsigned char>(result);
}
开发者ID:vmorgulys,项目名称:sandbox,代码行数:8,代码来源:class.string.h.number.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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