当前位置: 首页>>代码示例>>C++>>正文


C++ parse_double函数代码示例

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


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


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