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

C++ parse_double函数代码示例

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

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



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

示例1: checked_double_parse

static
bool
checked_double_parse(const char* s,
                     double& val) {
    if ((NULL != s) && ('\0' != *s) && (0 != strcmp(s,"."))) return false;
    val=parse_double(s);
    return true;
}
开发者ID:StephenTanner,项目名称:gvcftools,代码行数:8,代码来源:VcfRecordBlocker.cpp


示例2: action_comm_size

static void action_comm_size(const char *const *action)
{
  const char *size = action[2];
  double clock = MSG_get_clock();

  communicator_size = parse_double(size);
  log_action(action, MSG_get_clock() - clock);
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:8,代码来源:actions.c


示例3: 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


示例4: parse_immediate_data

/* parses a 4-touple of the form {x, y, z, w}
 * where x, y, z, w are numbers */
static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type,
                                    union tgsi_immediate_data *values)
{
   unsigned i;
   int ret;

   eat_opt_white( &ctx->cur );
   if (*ctx->cur != '{') {
      report_error( ctx, "Expected `{'" );
      return FALSE;
   }
   ctx->cur++;
   for (i = 0; i < 4; i++) {
      eat_opt_white( &ctx->cur );
      if (i > 0) {
         if (*ctx->cur != ',') {
            report_error( ctx, "Expected `,'" );
            return FALSE;
         }
         ctx->cur++;
         eat_opt_white( &ctx->cur );
      }

      switch (type) {
      case TGSI_IMM_FLOAT64:
         ret = parse_double(&ctx->cur, &values[i].Uint, &values[i+1].Uint);
         i++;
         break;
      case TGSI_IMM_FLOAT32:
         ret = parse_float(&ctx->cur, &values[i].Float);
         break;
      case TGSI_IMM_UINT32:
         ret = parse_uint(&ctx->cur, &values[i].Uint);
         break;
      case TGSI_IMM_INT32:
         ret = parse_int(&ctx->cur, &values[i].Int);
         break;
      default:
         assert(0);
         ret = FALSE;
         break;
      }

      if (!ret) {
         report_error( ctx, "Expected immediate constant" );
         return FALSE;
      }
   }
   eat_opt_white( &ctx->cur );
   if (*ctx->cur != '}') {
      report_error( ctx, "Expected `}'" );
      return FALSE;
   }
   ctx->cur++;

   return TRUE;
}
开发者ID:01org,项目名称:iotg-lin-gfx-mesa,代码行数:59,代码来源:tgsi_text.c


示例5: action_sleep

static void action_sleep(const char *const *action)
{
  const char *duration = action[2];
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_process_sleep(parse_double(duration));
  log_action(action, MSG_get_clock() - clock);
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:9,代码来源:actions.c


示例6: parse_generate_interpolate

static adv_error parse_generate_interpolate(const char* begin, const char* end, adv_generate_interpolate* interpolate)
{
	double d;
	adv_generate* data = &interpolate->gen;

	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	interpolate->hclock = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hactive = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hfront = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hsync = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hback = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vactive = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vfront = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vsync = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vback = d;
	parse_separator(" \t", &begin, end);
	if (begin != end)
		return -1;

	generate_normalize(data);

	return 0;
}
开发者ID:BirchJD,项目名称:advancemame-0.106.1-RPi,代码行数:49,代码来源:videoio.c


示例7: parse_float

static int parse_float (SLFUTURE_CONST char **sp, SLFUTURE_CONST char *smax, float *d)
{
   double x;
   if (1 == parse_double (sp, smax, &x))
     {
	*d = (float) x;
	return 1;
     }
   return 0;
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:10,代码来源:slscanf.c


示例8: action_compute

static void action_compute(const char *const *action)
{
  double clock = smpi_process_simulated_elapsed();
  smpi_execute_flops(parse_double(action[2]));

  if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
    char *name = xbt_str_join_array(action, " ");
    XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock);
    free(name);
  }
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:11,代码来源:smpi_replay.c


示例9: action_compute

static void action_compute(const char *const *action)
{
  const char *amount = action[2];
  msg_task_t task = MSG_task_create("task", parse_double(amount), 0, NULL);
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_task_execute(task);
  MSG_task_destroy(task);
  log_action(action, MSG_get_clock() - clock);
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:11,代码来源:actions.c


示例10: while

int HOST::parse_time_stats(FILE* fin) {
    char buf[256];

    while (fgets(buf, sizeof(buf), fin)) {
        if (match_tag(buf, "</time_stats>")) return 0;
        if (parse_double(buf, "<on_frac>", on_frac)) continue;
        if (parse_double(buf, "<connected_frac>", connected_frac)) continue;
        if (parse_double(buf, "<active_frac>", active_frac)) continue;
#if 0
        if (match_tag(buf, "<outages>")) continue;
        if (match_tag(buf, "<outage>")) continue;
        if (match_tag(buf, "<start>")) continue;
        if (match_tag(buf, "<end>")) continue;
        log_messages.printf(MSG_NORMAL,
            "HOST::parse_time_stats(): unrecognized: %s\n",
            buf
        );
#endif
    }
    return ERR_XML_PARSE;
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:21,代码来源:sched_types.cpp


示例11: strlcpy

void CScreensaver::GetDefaultDisplayPeriods(struct ss_periods &periods)
{
    char*           default_data_dir_path = NULL;
    char            buf[1024];
    FILE*           f;
    MIOFILE         mf;

    periods.GFXDefaultPeriod = GFX_DEFAULT_PERIOD;
    periods.GFXSciencePeriod = GFX_SCIENCE_PERIOD;
    periods.GFXChangePeriod = GFX_CHANGE_PERIOD;
    periods.Show_default_ss_first = false;

#ifdef __APPLE__
    default_data_dir_path = "/Library/Application Support/BOINC Data";
#else
    default_data_dir_path = (char*)m_strBOINCDataDirectory.c_str();
#endif

    strlcpy(buf, default_data_dir_path, sizeof(buf));
    strlcat(buf, PATH_SEPARATOR, sizeof(buf));
    strlcat(buf, THE_SS_CONFIG_FILE, sizeof(buf));

    f = boinc_fopen(buf, "r");
    if (!f) return;
    
    mf.init_file(f);
    XML_PARSER xp(&mf);

    while (mf.fgets(buf, sizeof(buf))) {
        if (parse_bool(buf, "default_ss_first", periods.Show_default_ss_first)) continue;
        if (parse_double(buf, "<default_gfx_duration>", periods.GFXDefaultPeriod)) continue;
        if (parse_double(buf, "<science_gfx_duration>", periods.GFXSciencePeriod)) continue;
        if (parse_double(buf, "<science_gfx_change_interval>", periods.GFXChangePeriod)) continue;
        
    }
    fclose(f);
    
    BOINCTRACE(_T("CScreensaver::GetDefaultDisplayPeriods: m_bShow_default_ss_first=%d, m_fGFXDefaultPeriod=%f, m_fGFXSciencePeriod=%f, m_fGFXChangePeriod=%f\n"),
                    (int)periods.Show_default_ss_first, periods.GFXDefaultPeriod, periods.GFXSciencePeriod, periods.GFXChangePeriod);
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:40,代码来源:screensaver.cpp


示例12: monitor_range_parse

static adv_error monitor_range_parse(adv_monitor_range* range, const char* begin, const char* end, double mult)
{
	double v0;
	double v1;

	parse_separator(" \t", &begin, end);

	if (parse_double(&v0, &begin, end))
		return -1;

	parse_separator(" \t", &begin, end);

	if (*begin == '-') {
		++begin;

		parse_separator(" \t", &begin, end);

		if (parse_double(&v1, &begin, end))
			return -1;

		if (v0 < 0 || v0 > v1 || v1 > 300)
			return -1;

		range->low = mult * v0;
		range->high = mult * v1;
	} else {
		if (v0 < 0 || v0 > 300)
			return -1;

		range->low = mult * v0;
		range->high = range->low;
	}

	parse_separator(" \t", &begin, end);

	if (begin != end)
		return -1;

	return 0;
}
开发者ID:BirchJD,项目名称:advancemame-0.106.1-RPi,代码行数:40,代码来源:videoio.c


示例13: parse_cylinder_3

static int	parse_cylinder_3(char **line, int *i, t_cylinder *obj)
{
	if (!ft_strcmp(line[i[0]], "radius"))
	{
		if (!parse_double(line, i, &obj->radius))
			return (return_print("Error parsing cylinder radius", 0));
		else
		{
			if (obj->radius < 0)
				return (return_print("Error, radius can't be negative", 0));
			obj->radius = POW2(obj->radius);
		}
	}
	else if (!ft_strcmp(line[i[0]], "height"))
	{
		if (!parse_double(line, i, &obj->h))
			return (return_print("Error parsing cylinder height", 0));
		else if (obj->h < 0)
			return (return_print("Error, height can't be negative", 0));
	}
	return (1);
}
开发者ID:Entrivax,项目名称:RT,代码行数:22,代码来源:parse_cylinder.c


示例14: while

int HOST_INFO::parse(MIOFILE& in, bool benchmarks_only) {
    char buf[1024];

    while (in.fgets(buf, sizeof(buf))) {
        if (match_tag(buf, "</host_info>")) return 0;
        else if (parse_double(buf, "<p_fpops>", p_fpops)) {
            // fix foolishness that could result in negative value here
            //
            if (p_fpops < 0) p_fpops = -p_fpops;
            continue;
        }
        else if (parse_double(buf, "<p_iops>", p_iops)) {
            if (p_iops < 0) p_iops = -p_iops;
            continue;
        }
        else if (parse_double(buf, "<p_membw>", p_membw)) {
            if (p_membw < 0) p_membw = -p_membw;
            continue;
        }
        else if (parse_double(buf, "<p_calculated>", p_calculated)) continue;

        if (benchmarks_only) continue;

        if (parse_int(buf, "<timezone>", timezone)) continue;
        else if (parse_str(buf, "<domain_name>", domain_name, sizeof(domain_name))) continue;
        else if (parse_str(buf, "<ip_addr>", ip_addr, sizeof(ip_addr))) continue;
        else if (parse_str(buf, "<host_cpid>", host_cpid, sizeof(host_cpid))) continue;
        else if (parse_int(buf, "<p_ncpus>", p_ncpus)) continue;
        else if (parse_str(buf, "<p_vendor>", p_vendor, sizeof(p_vendor))) continue;
        else if (parse_str(buf, "<p_model>", p_model, sizeof(p_model))) continue;
        else if (parse_str(buf, "<p_features>", p_features, sizeof(p_features))) continue;
        else if (parse_double(buf, "<m_nbytes>", m_nbytes)) continue;
        else if (parse_double(buf, "<m_cache>", m_cache)) continue;
        else if (parse_double(buf, "<m_swap>", m_swap)) continue;
        else if (parse_double(buf, "<d_total>", d_total)) continue;
        else if (parse_double(buf, "<d_free>", d_free)) continue;
        else if (parse_str(buf, "<os_name>", os_name, sizeof(os_name))) continue;
        else if (parse_str(buf, "<os_version>", os_version, sizeof(os_version))) continue;
        else if (match_tag(buf, "<coprocs>")) {
            coprocs.parse(in);
        }
    }
    return ERR_XML_PARSE;
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:44,代码来源:hostinfo.cpp


示例15: action_allReduce

static void action_allReduce(const char *const *action) {
  double comm_size = parse_double(action[2]);
  double comp_size = parse_double(action[3]);
  double clock = smpi_process_simulated_elapsed();
#ifdef HAVE_TRACING
  int rank = smpi_comm_rank(MPI_COMM_WORLD);
  TRACE_smpi_computing_out(rank);
  TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
  smpi_mpi_reduce(NULL, NULL, comm_size, MPI_BYTE, MPI_OP_NULL, 0, MPI_COMM_WORLD);
  smpi_execute_flops(comp_size);
  smpi_mpi_bcast(NULL, comm_size, MPI_BYTE, 0, MPI_COMM_WORLD);
#ifdef HAVE_TRACING
  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
  TRACE_smpi_computing_in(rank);
#endif

  if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
    char *name = xbt_str_join_array(action, " ");
    XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock);
    free(name);
  }
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:23,代码来源:smpi_replay.c


示例16: parse_material_2

static int	parse_material_2(char **line, int *i, t_material *mat)
{
	if (!ft_strcmp(line[i[0]], "id"))
	{
		if (line[i[0] + 1] == NULL || !(ft_strlen(line[i[0] + 1]) > 0))
			return (return_print("Error parsing material id", 0));
		else
		{
			if (!(mat->name = ft_strdup(line[++i[0]])))
				return (return_print("malloc error", 0));
			i[1] |= 1;
		}
	}
	else if (!ft_strcmp(line[i[0]], "color")
		&& !parse_color(line, i, &mat->color))
		return (return_print("Error parsing material color", 0));
	else if (!ft_strcmp(line[i[0]], "ambiant")
		&& !parse_double(line, i, &mat->k_ambiant))
		return (return_print("Error parsing material ambiant", 0));
	else if (!ft_strcmp(line[i[0]], "specular")
		&& !parse_double(line, i, &mat->k_spec))
		return (return_print("Error parsing material specular", 0));
	return (parse_material_3(line, i, mat));
}
开发者ID:Entrivax,项目名称:RT,代码行数:24,代码来源:parse_material.c


示例17: parse_number

	double parse_number(const char* json)
	{
		CE_ASSERT_NOT_NULL(json);

		TempAllocator512 alloc;
	 	Array<char> number(alloc);

		if (*json == '-')
		{
			array::push_back(number, '-');
			json = next(json, '-');
		}
		while (isdigit(*json))
		{
			array::push_back(number, *json);
			json = next(json);
		}

		if (*json == '.')
		{
			array::push_back(number, '.');
			while ((*(json = next(json))) && isdigit(*json))
			{
				array::push_back(number, *json);
			}
		}

		if (*json == 'e' || *json == 'E')
		{
			array::push_back(number, *json);
			json = next(json);

			if (*json == '-' || *json == '+')
			{
				array::push_back(number, *json);
				json = next(json);
			}
			while (isdigit(*json))
			{
				array::push_back(number, *json);
				json = next(json);
			}
		}

		// Ensure null terminated
		array::push_back(number, '\0');
		return parse_double(array::begin(number));
	}
开发者ID:zhiqiang-li,项目名称:crown,代码行数:48,代码来源:json.cpp


示例18: action_bcast

static void action_bcast(const char *const *action)
{
  int i;
  char *bcast_identifier;
  char mailbox[80];
  double comm_size = parse_double(action[2]);
  msg_task_t task = NULL;
  const char *process_name;
  double clock = MSG_get_clock();

  process_globals_t counters =
      (process_globals_t) MSG_process_get_data(MSG_process_self());

  xbt_assert(communicator_size, "Size of Communicator is not defined, "
             "can't use collective operations");

  process_name = MSG_process_get_name(MSG_process_self());

  bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++);

  if (!strcmp(process_name, "p0")) {
    XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name);

    msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);

    for (i = 1; i < communicator_size; i++) {
      sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i);
      comms[i - 1] =
          MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
    }
    MSG_comm_waitall(comms, communicator_size - 1, -1);
    for (i = 1; i < communicator_size; i++)
      MSG_comm_destroy(comms[i - 1]);
    xbt_free(comms);

    XBT_DEBUG("%s: all messages sent by %s have been received",
              bcast_identifier, process_name);

  } else {
    sprintf(mailbox, "%s_p0_%s", bcast_identifier, process_name);
    MSG_task_receive(&task, mailbox);
    MSG_task_destroy(task);
    XBT_DEBUG("%s: %s has received", bcast_identifier, process_name);
  }

  log_action(action, MSG_get_clock() - clock);
  xbt_free(bcast_identifier);
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:48,代码来源:actions.c


示例19: 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


示例20: get_format_float

bool
snp_type_info::
get_format_float(const char* const* word,
                 const char* key,
                 float& val) {

    const char* str(get_format_string_nocopy(word,key));
    if (NULL==str) return false;
    if ('\0'==*str) return false;
    if ('.'==*str) {
        if ('\0'==*(str+1)) return false;
        if (':'==*(str+1)) return false;
    }
    val=parse_double(str);
    return true;
}
开发者ID:StephenTanner,项目名称:gvcftools,代码行数:16,代码来源:related_sample_util.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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