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

C++ parse_uint函数代码示例

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

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



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

示例1: parse_version

/* Parses version string of the form <int>.<int> */
static bool parse_version(const char **string)
{
    return
        parse_uint(string, &major_version)  &&
        parse_char(string, '.')  &&
        parse_uint(string, &minor_version);
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:8,代码来源:capture.c


示例2: parse_lineno

static mrb_bool
parse_lineno(mrb_state *mrb, char **sp, listcmd_parser_state *st)
{
  if (*sp == NULL || **sp == '\0') {
    return FALSE;
  }

  st->has_line_min = FALSE;
  st->has_line_max = FALSE;

  if (parse_uint(sp, &st->line_min)) {
    st->has_line_min = TRUE;
  }
  else {
    return FALSE;
  }

  if (skip_char(sp, ',')) {
    if (parse_uint(sp, &st->line_max)) {
      st->has_line_max = TRUE;
    }
    else {
      st->parse_error = TRUE;
      return FALSE;
    }
  }
  return TRUE;
}
开发者ID:ak-ymst,项目名称:mruby,代码行数:28,代码来源:cmdmisc.c


示例3: parse_wrap_args

static int parse_wrap_args(const struct option *opt, const char *arg, int unset)
{
	struct shortlog *log = opt->value;

	log->wrap_lines = !unset;
	if (unset)
		return 0;
	if (!arg) {
		log->wrap = DEFAULT_WRAPLEN;
		log->in1 = DEFAULT_INDENT1;
		log->in2 = DEFAULT_INDENT2;
		return 0;
	}

	log->wrap = parse_uint(&arg, ',', DEFAULT_WRAPLEN);
	log->in1 = parse_uint(&arg, ',', DEFAULT_INDENT1);
	log->in2 = parse_uint(&arg, '\0', DEFAULT_INDENT2);
	if (log->wrap < 0 || log->in1 < 0 || log->in2 < 0)
		return error(wrap_arg_usage);
	if (log->wrap &&
	    ((log->in1 && log->wrap <= log->in1) ||
	     (log->in2 && log->wrap <= log->in2)))
		return error(wrap_arg_usage);
	return 0;
}
开发者ID:Nowher2,项目名称:git,代码行数:25,代码来源:shortlog.c


示例4: perf_opt_parse

void
perf_opt_parse(int argc, char **argv)
{
	int c;
	opt_t *opt;
	isc_result_t result;
	unsigned int i;

	progname = isc_file_basename(argv[0]);

	perf_opt_add('h', perf_opt_boolean, NULL, "print this help",
		     NULL, NULL);

	while ((c = getopt(argc, argv, optstr)) != -1) {
		for (i = 0; i < nopts; i++) {
			if (opts[i].c == c)
				break;
		}
		if (i == nopts) {
			perf_opt_usage();
			exit(1);
		}
		if (c == 'h') {
			perf_opt_usage();
			exit(0);
		}
		opt = &opts[i];
		result = ISC_R_SUCCESS;
		switch (opt->type) {
		case perf_opt_string:
			*opt->u.stringp = optarg;
			break;
		case perf_opt_boolean:
			*opt->u.boolp = ISC_TRUE;
			break;
		case perf_opt_uint:
			*opt->u.uintp = parse_uint(opt->desc, optarg,
						   1, 0xFFFFFFFF);
			break;
		case perf_opt_timeval:
			*opt->u.uint64p = parse_timeval(opt->desc, optarg);
			break;
		case perf_opt_double:
			*opt->u.doublep = parse_double(opt->desc, optarg);
			break;
		case perf_opt_port:
			*opt->u.portp = parse_uint(opt->desc, optarg,
						   0, 0xFFFF);
			break;
		}
	}
	if (optind != argc) {
		fprintf(stderr, "unexpected argument %s\n", argv[optind]);
		perf_opt_usage();
		exit(1);
	}
}
开发者ID:zongyuwu,项目名称:DNSSECLoadTesting,代码行数:57,代码来源:opt.c


示例5: http_response_on_header

static int http_response_on_header(nghttp2_stream *stream, nghttp2_nv *nv,
                                   int token, int trailer) {
  if (nv->name[0] == ':') {
    if (trailer ||
        (stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
  }

  switch (token) {
  case NGHTTP2_TOKEN__STATUS: {
    if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__STATUS)) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    if (nv->valuelen != 3) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    stream->status_code = parse_uint(nv->value, nv->valuelen);
    if (stream->status_code == -1) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    break;
  }
  case NGHTTP2_TOKEN_CONTENT_LENGTH: {
    if (stream->content_length != -1) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    stream->content_length = parse_uint(nv->value, nv->valuelen);
    if (stream->content_length == -1) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    break;
  }
  /* disallowed header fields */
  case NGHTTP2_TOKEN_CONNECTION:
  case NGHTTP2_TOKEN_KEEP_ALIVE:
  case NGHTTP2_TOKEN_PROXY_CONNECTION:
  case NGHTTP2_TOKEN_TRANSFER_ENCODING:
  case NGHTTP2_TOKEN_UPGRADE:
    return NGHTTP2_ERR_HTTP_HEADER;
  case NGHTTP2_TOKEN_TE:
    if (!lstrieq("trailers", nv->value, nv->valuelen)) {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
    break;
  default:
    if (nv->name[0] == ':') {
      return NGHTTP2_ERR_HTTP_HEADER;
    }
  }

  if (nv->name[0] != ':') {
    stream->http_flags |= NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED;
  }

  return 0;
}
开发者ID:LambdaOS,项目名称:nghttp2,代码行数:57,代码来源:nghttp2_http.c


示例6: application_function_flash_receive

app_action_t application_function_flash_receive(string_t *src, string_t *dst)
{
	unsigned int chunk_offset, chunk_length;

	if(string_size(&flash_sector_buffer) < SPI_FLASH_SEC_SIZE)
	{
		string_format(dst, "ERROR flash-receive: flash sector buffer too small: %d\n", string_size(&flash_sector_buffer));
		return(app_action_error);
	}

	if(parse_uint(1, src, &chunk_offset, 0, ' ') != parse_ok)
	{
		string_append(dst, "ERROR flash-receive: chunk offset required\n");
		return(app_action_error);
	}

	if(parse_uint(2, src, &chunk_length, 0, ' ') != parse_ok)
	{
		string_append(dst, "ERROR flash-receive: chunk chunk_length required\n");
		return(app_action_error);
	}

	if((chunk_length == 0) || ((chunk_offset % chunk_length) != 0))
	{
		string_append(dst, "ERROR: flash-receive: chunk offset should be divisible by chunk size");
		return(app_action_error);
	}

	if((chunk_length == 0) || ((SPI_FLASH_SEC_SIZE % chunk_length) != 0))
	{
		string_append(dst, "ERROR: flash-receive: chunk length should be divisible by flash sector size");
		return(app_action_error);
	}

	if((chunk_offset + chunk_length) > SPI_FLASH_SEC_SIZE)
	{
		string_format(dst, "ERROR flash-receive: chunk_length(%u) + chunk_offset(%u) > sector size(%d)\n", chunk_length, chunk_offset, SPI_FLASH_SEC_SIZE);
		return(app_action_error);
	}

	if((flash_sector_buffer_use != fsb_free) && (flash_sector_buffer_use != fsb_config_cache) && (flash_sector_buffer_use != fsb_ota))
	{
		string_format(dst, "ERROR: flash_send: sector buffer in use: %u\n", flash_sector_buffer_use);
		return(app_action_error);
	}

	flash_sector_buffer_use = fsb_ota;

	string_format(dst, "OK flash-receive: sending bytes: %u, from offset: %u, data: @", chunk_length, chunk_offset);
	string_splice(dst, -1, &flash_sector_buffer, chunk_offset, chunk_length);
	string_append(dst, "\n");

	if((chunk_offset + chunk_length) >= SPI_FLASH_SEC_SIZE)
		flash_sector_buffer_use = fsb_free;

	return(app_action_normal);
}
开发者ID:eriksl,项目名称:esp8266-universal-io-bridge,代码行数:57,代码来源:ota.c


示例7: application_function_flash_checksum

app_action_t application_function_flash_checksum(string_t *src, string_t *dst)
{
	unsigned int address, current, length, done;

	SHA_CTX sha_context;
	unsigned char sha_result[SHA_DIGEST_LENGTH];
	string_new(, sha_string, SHA_DIGEST_LENGTH * 2 + 2);

	if(parse_uint(1, src, &address, 0, ' ') != parse_ok)
	{
		string_append(dst, "ERROR flash-checksum: address required\n");
		return(app_action_error);
	}

	if(parse_uint(2, src, &length, 0, ' ') != parse_ok)
	{
		string_append(dst, "ERROR flash-checksum: length required\n");
		return(app_action_error);
	}

	if((address % SPI_FLASH_SEC_SIZE) != 0)
	{
		string_append(dst, "ERROR: flash_checksum: address should be divisible by flash sector size");
		return(app_action_error);
	}

	if((length % SPI_FLASH_SEC_SIZE) != 0)
	{
		string_append(dst, "ERROR: flash_checksum: length should be divisible by flash sector size");
		return(app_action_error);
	}

	SHA1Init(&sha_context);

	for(current = address, done = 0; done < length; current += SPI_FLASH_SEC_SIZE, done += SPI_FLASH_SEC_SIZE)
	{
		spi_flash_read(current, string_buffer_nonconst(dst), SPI_FLASH_SEC_SIZE);
		SHA1Update(&sha_context, string_buffer(dst), SPI_FLASH_SEC_SIZE);
	}

	SHA1Final(sha_result, &sha_context);
	string_bin_to_hex(&sha_string, sha_result, SHA_DIGEST_LENGTH);

	string_clear(dst);
	string_format(dst, "OK flash-checksum: checksummed bytes: %u, from address: %u, checksum: ", done, address);
	string_append_string(dst, &sha_string);
	string_append(dst, "\n");

	return(app_action_normal);
}
开发者ID:eriksl,项目名称:esp8266-universal-io-bridge,代码行数:50,代码来源:ota.c


示例8: format_str_v

int
format_str_v(const StrFormatContext *ctxt, const char *format, va_list ap)
{
  unsigned int written = 0;
  const char *pos = format;
  while(*pos != '\0') {
    FormatFlags flags;
    unsigned int minwidth = 0;
    int precision = -1; /* Negative means no precision */
    char ch;
    const char *start = pos;
    while( (ch = *pos) != '\0' && ch != '%') pos++;
    if (pos != start) {
      CHECKCB(ctxt->write_str(ctxt->user_data, start, pos - start));
      written += pos - start;
    }
    if (*pos == '\0') {
      va_end(ap);
      return written;
    }
    pos++;
    if (*pos == '\0') {
      va_end(ap);
      return written;
    }
    flags = parse_flags(&pos);

    /* parse width */
    if (*pos >= '1' && *pos <= '9') {
      minwidth = parse_uint(&pos);
    } else if (*pos == '*') {
      int w = va_arg(ap,int);
      if (w < 0) {
	flags |= JUSTIFY_LEFT;
	minwidth = w;
      } else {
	minwidth = w;
      }
      pos ++;
    }

    /* parse precision */
    if (*pos == '.') {
      pos++;
      if (*pos >= '0' && *pos <= '9') {
	precision = parse_uint(&pos);
      } else if (*pos == '*') {
	pos++;
	precision = va_arg(ap,int);
      }
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:50,代码来源:strformat.c


示例9: parse_register_dcl_bracket

static boolean
parse_register_dcl_bracket(
   struct translate_ctx *ctx,
   struct parsed_dcl_bracket *bracket)
{
   uint uindex;
   memset(bracket, 0, sizeof(struct parsed_dcl_bracket));

   eat_opt_white( &ctx->cur );

   if (!parse_uint( &ctx->cur, &uindex )) {
      /* it can be an empty bracket [] which means its range
       * is from 0 to some implied size */
      if (ctx->cur[0] == ']' && ctx->implied_array_size != 0) {
         bracket->first = 0;
         bracket->last = ctx->implied_array_size - 1;
         goto cleanup;
      }
      report_error( ctx, "Expected literal unsigned integer" );
      return FALSE;
   }
   bracket->first = uindex;

   eat_opt_white( &ctx->cur );

   if (ctx->cur[0] == '.' && ctx->cur[1] == '.') {
      uint uindex;

      ctx->cur += 2;
      eat_opt_white( &ctx->cur );
      if (!parse_uint( &ctx->cur, &uindex )) {
         report_error( ctx, "Expected literal integer" );
         return FALSE;
      }
      bracket->last = (int) uindex;
      eat_opt_white( &ctx->cur );
   }
   else {
      bracket->last = bracket->first;
   }

cleanup:
   if (*ctx->cur != ']') {
      report_error( ctx, "Expected `]' or `..'" );
      return FALSE;
   }
   ctx->cur++;
   return TRUE;
}
开发者ID:01org,项目名称:iotg-lin-gfx-mesa,代码行数:49,代码来源:tgsi_text.c


示例10: gtp_boardsize

static void gtp_boardsize(
    FILE * fp,
    int id,
    const char * new_size
){
    if(new_size == NULL)
    {
        gtp_answer(fp, id, BOARD_SIZ_AS_STR);
        return;
    }

    u32 ns;
    if(!parse_uint(&ns, new_size))
    {
        gtp_error(fp, id, "syntax error");
        return;
    }

    if(ns != BOARD_SIZ)
    {
        gtp_error(fp, id, "unacceptable size");

        fprintf(stderr, "board size cannot be changed on runtime; please edit t\
he master header file and recompile matilda\n");
        char * s = alloc();
        snprintf(s, MAX_PAGE_SIZ, "requested board size change to %ux%u", ns,
            ns);
        flog_info("gtp", s);
        release(s);
    }
开发者ID:gonmf,项目名称:matilda,代码行数:30,代码来源:gtp.c


示例11: set_ndots

static void
set_ndots(const char *value) {
	isc_uint32_t n;
	isc_result_t result = parse_uint(&n, value, 128, "ndots");
	if (result == ISC_R_SUCCESS)
		ndots = n;
}
开发者ID:krichter722,项目名称:bind9,代码行数:7,代码来源:nslookup.c


示例12: parse_archive_parameters

/* Parses expected server response to CFdDVK command: should be four newline
 * terminated numbers and a version string. */
static bool parse_archive_parameters(const char **string)
{
    return
        parse_double(string, &sample_frequency)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &first_decimation)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &second_decimation)  &&
        parse_char(string, '\n')  &&
        parse_version(string)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &fa_entry_count)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &continuous_decimation)  &&
        parse_char(string, '\n');
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:18,代码来源:capture.c


示例13: set_timeout

static void
set_timeout(const char *value) {
	isc_uint32_t n;
	isc_result_t result = parse_uint(&n, value, UINT_MAX, "timeout");
	if (result == ISC_R_SUCCESS)
		timeout = n;
}
开发者ID:krichter722,项目名称:bind9,代码行数:7,代码来源:nslookup.c


示例14: set_tries

static void
set_tries(const char *value) {
	isc_uint32_t n;
	isc_result_t result = parse_uint(&n, value, INT_MAX, "tries");
	if (result == ISC_R_SUCCESS)
		tries = n;
}
开发者ID:krichter722,项目名称:bind9,代码行数:7,代码来源:nslookup.c


示例15: room_attr_set

/**
 * set an attribute on a room.
 */
static int room_attr_set(struct room *r, const char *name, const char *value) {
	int res;

	assert(r != NULL);
	assert(name != NULL);
	assert(value != NULL);

	if(!r) return 0;

	if(!strcasecmp("id", name))
		res=parse_uint(name, value, &r->id);
	else if(!strcasecmp("name.short", name))
		res=parse_str(name, value, &r->name.short_str);
	else if(!strcasecmp("name.long", name))
		res=parse_str(name, value, &r->name.long_str);
	else if(!strcasecmp("desc.short", name))
		res=parse_str(name, value, &r->desc.short_str);
	else if(!strcasecmp("desc.long", name))
		res=parse_str(name, value, &r->desc.long_str);
	else if(!strcasecmp("creator", name))
		res=parse_str(name, value, &r->creator);
	else if(!strcasecmp("owner", name))
		res=parse_str(name, value, &r->owner);
	else
		res=parse_attr(name, value, &r->extra_values);

	if(res)
		r->dirty_fl=1;
	return res;
}
开发者ID:OrangeTide,项目名称:boris,代码行数:33,代码来源:room.c


示例16: parse_data_format

/* Parses data format description in format
 *  F | d[n] | D[n]
 * where n is a three bit data mask. */
static bool parse_data_format(const char **string, enum data_format *format)
{
    if (read_char(string, 'F'))
    {
        *format = DATA_FA;
        return true;
    }
    else
    {
        if (read_char(string, 'd'))
            *format = DATA_D;
        else if (read_char(string, 'D'))
            *format = DATA_DD;
        else
            return FAIL_("Invalid data format");

        if (**string == '\0')
        {
            data_mask = 15;         // Read all fields by default
            return true;
        }
        else
            return
                parse_uint(string, &data_mask)  &&
                TEST_OK_(0 < data_mask  &&  data_mask <= 15,
                    "Invalid data mask");
    }
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:31,代码来源:capture.c


示例17: parse_id

static bool parse_id(
    const char **string, unsigned int fa_entry_count, unsigned int *id)
{
    return
        parse_uint(string, id)  &&
        TEST_OK_(*id < fa_entry_count, "id %u out of range", *id);
}
开发者ID:Araneidae,项目名称:fa-archiver,代码行数:7,代码来源:mask.c


示例18: config_defaults

/* parse default values from g_options[] into idmap_config */
static int config_defaults(
    struct idmap_config *config)
{
    const struct config_option *option;
    const int count = ARRAYSIZE(g_options);
    char *dst;
    int i, status = NO_ERROR;

    for (i = 0; i < count; i++) {
        option = &g_options[i];
        dst = (char*)config + option->offset;

        if (option->type == TYPE_INT) {
            if (!parse_uint(option->def, (UINT*)dst)) {
                status = ERROR_INVALID_PARAMETER;
                eprintf("failed to parse default value of %s=\"%s\": "
                    "expected a number\n", option->key, option->def);
                break;
            }
        } else {
            if (FAILED(StringCchCopyA(dst, option->max_len, option->def))) {
                status = ERROR_BUFFER_OVERFLOW;
                eprintf("failed to parse default value of %s=\"%s\": "
                    "buffer overflow > %u\n", option->key, option->def,
                    option->max_len);
                break;
            }
        }
    }
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:32,代码来源:idmap.c


示例19: socket_command_callback_data_received

static void socket_command_callback_data_received(lwip_if_socket_t *socket, unsigned int length)
{
	static const char command_string[] = "flash-send ";
	unsigned int chunk_length;
	int chunk_offset;

	if((command_left_to_read == 0) &&
			string_nmatch_cstr(&command_socket_receive_buffer, command_string, sizeof(command_string) - 1) &&
			(parse_uint(2, &command_socket_receive_buffer, &chunk_length, 10, ' ') == parse_ok) &&
			((chunk_offset = string_sep(&command_socket_receive_buffer, 0, 3, ' ')) >= 0))
		command_left_to_read = chunk_offset + chunk_length;

	if(command_left_to_read > 0)
	{
		if(length > command_left_to_read)
			command_left_to_read = 0;
		else
			command_left_to_read -= length;
	}

	if((command_left_to_read == 0) && (string_trim_nl(&command_socket_receive_buffer) || lwip_if_received_udp(socket)))
		dispatch_post_command(command_task_received_command);
	else
		lwip_if_receive_buffer_unlock(&command_socket);
}
开发者ID:eriksl,项目名称:esp8266-universal-io-bridge,代码行数:25,代码来源:dispatch.c


示例20: parse_time

static errcode_t parse_time(struct field_set_info *info, char *arg)
{
	struct	tm	ts;
	__u32		*ptr32;

	ptr32 = (__u32 *) info->ptr;

	if (strcmp(arg, "now") == 0) {
		*ptr32 = time(0);
		return 0;
	}
	memset(&ts, 0, sizeof(ts));
#ifdef HAVE_STRPTIME
	strptime(arg, "%Y%m%d%H%M%S", &ts);
#else
	sscanf(arg, "%4d%2d%2d%2d%2d%2d", &ts.tm_year, &ts.tm_mon,
	       &ts.tm_mday, &ts.tm_hour, &ts.tm_min, &ts.tm_sec);
	ts.tm_year -= 1900;
	ts.tm_mon -= 1;
	if (ts.tm_year < 0 || ts.tm_mon < 0 || ts.tm_mon > 11 ||
	    ts.tm_mday < 0 || ts.tm_mday > 31 || ts.tm_hour > 23 ||
	    ts.tm_min > 59 || ts.tm_sec > 61)
		ts.tm_mday = 0;
#endif
	if (ts.tm_mday == 0) {
		/* Try it as an integer... */
		return parse_uint(info, arg);
	}
	*ptr32 = mktime(&ts);
	return 0;
}
开发者ID:TELE-TWIN,项目名称:livebox2,代码行数:31,代码来源:set_fields.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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