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


C++ parse_option函数代码示例

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


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

示例1: get_conf

void get_conf() {
    FILE *conffile;
    conffile = fopen ("ws.conf", "r");
    int index = 0;
    while (fgets (conf , 500, conffile)) {
        //Remove comments and whitespace
        if((strncmp(conf, "#", 1) == 0)||(strncmp(conf, "\n", 1) == 0)) continue;
        
        if(portOpt == NULL) {
            char* portOption = parse_option(conf, "Listen");
            portOpt = strdup(portOption);
            printf("PORT OPT: %s\n", portOpt);
            continue;
        }
        
        if(docRootOpt == NULL) {
            char* docOption = parse_option(conf, "DocumentRoot");
            docRootOpt = strdup(docOption);
            printf("Doc Root OPT: %s\n", docRootOpt);
            continue;
        }

        if(dirOpt == NULL) {
            int line_length = strlen(conf);
            char line_cpy[line_length + 1];
            strcpy(line_cpy, conf);
            
            dirOpt = parse_dir_options(conf, "DirectoryIndex"); 
            dirOptCount = get_num_options(line_cpy);
            for(int i = 0; i < dirOptCount; i++) {
                printf("DirIndex %d: %s\n", i, dirOpt[i]);
            }
            continue;
        }

        if(contentLookup == NULL) {
            contentLookup = malloc(MAX_DATA * sizeof(char*));
            contentOpt = malloc(MAX_DATA * sizeof(char*));
        }

        contentOptCount = parse_content_options(conf, contentLookup, contentOpt);

        if(contentLookup != NULL) {
            printf( "Content %d: %s Type: %s\n", index, contentLookup[index], contentOpt[index]);
            index++;
        }
    }
    fclose (conffile);
}
开发者ID:ryanmilvenan,项目名称:networks1,代码行数:49,代码来源:server.c

示例2: parse_opts

/** Parse options from main's argv.
 */
void parse_opts(char **argv) {
	char *current;
	
	while ((current= *argv++)) {
		if (current[0] == '-') {
			if (current[1] == '-')
				parse_option(0, current+2, &argv);
			else for (++current; *current; current++)
				parse_option(*current, NULL, &argv);
		}
		else
			// if failsafe, will not exit()
			fatal(EXIT_BAD_OPTIONS, "Unexpected argument \"%s\"\n", current);
	}
}
开发者ID:nrdvana,项目名称:daemonproxy,代码行数:17,代码来源:options.c

示例3: main

int main(int const argc, char const * const * const argv)
{
    Option opt;
    try
    {
        opt = parse_option(argv_to_args(argc, argv));
    }
    catch(std::invalid_argument const &e)
    {
        std::cout << e.what();
        return EXIT_FAILURE;
    }
    std::cout << "reading data..." << std::flush;
    //Problem const Tr = read_data(opt.Tr_path, opt.TrS_path);
    //Problem const Va = read_data(opt.Va_path, opt.VaS_path);
    Problem const Tr = read_data(opt.Tr_path);
    Problem const Va = read_data(opt.Va_path);
    std::cout << "done\n" << std::flush;

	omp_set_num_threads(static_cast<int>(opt.nr_thread));

    GBDT gbdt(opt.nr_tree);
    gbdt.fit(Tr, Va);

    write(Tr, gbdt, opt.Tr_out_path);
    write(Va, gbdt, opt.Va_out_path);

    return EXIT_SUCCESS;
}
开发者ID:alexchao2012,项目名称:kaggle-avazu-1,代码行数:29,代码来源:train.cpp

示例4: parse_options

void parse_options() {
    // Parse command line options, and update the environment to match the
    // specified options.
    argp->usage(
        "Usage: jgdoc [OPTIONS] FILE...\n"
        "Generates documentation from comments found in Jogo source files.\n\n"
        "   -o, --output DIR     Write output to DIR.\n"
        "   -i, --include DIR    Add the directory DIR to the search path.\n"
        "   -h, --help           Print this help message.\n"
        "   -f, --format FORMAT  Set output format to FORMAT.\n"
        "   -v, --verbose        Print extra information.\n"
        "   --version            Print the compiler version number.\n");

    for (ArgToken tok = argp->next(); tok; tok = argp->next()) {
        // Convert abbreviated flags into the longer descriptive form (e.g.,
        // convert -p to --path)
        if (ArgToken::SHORT == tok.type()) {
            parse_short_option(tok.value());
        } else if (ArgToken::LONG == tok.type()) {
            parse_option(tok.value());
        } else {
            env->input(tok.value());
        }
    }

    std::string gen = env->generator();
    if (gen != "Markdown") {
        argp->error("Invalid output format (options: Markdown");
    }
}
开发者ID:mfichman,项目名称:jogo,代码行数:30,代码来源:Doc.cpp

示例5: fs_uae_read_custom_uae_options

void fs_uae_read_custom_uae_options(int argc, char **argv) {
	fs_log("read_custom_uae_options\n");
    if (g_fs_uae_config_file_path) {
        FILE *f = fs_fopen(g_fs_uae_config_file_path, "rb");
		read_custom_uae_options_from_file(f);
        fclose(f);
    }

    for (int i = 0; i < argc; i++) {
        char *arg = argv[i];
        if (!fs_str_has_prefix(arg, "--")) {
            continue;
        }
        char *key = arg + 2;
        char *value = strchr(arg, '=');
        if (value) {
            char *k = fs_strndup(key, value - key);
            fs_strdelimit (k, "-", '_');
            char *v = fs_strdup(value + 1);
            char *key_lower = fs_ascii_strdown(k, -1);
            free(k);
            parse_option(key_lower, v);
            free(key_lower);
            free(v);
        }
    }
}
开发者ID:lunixbochs,项目名称:fs-uae-gles,代码行数:27,代码来源:uae_config.c

示例6: parse_tv_tag

/* Handle/record information received in a transfer vector entry.  */
static enum ld_plugin_status
parse_tv_tag (struct ld_plugin_tv *tv)
{
#define SETVAR(x) x = tv->tv_u.x
  switch (tv->tv_tag)
    {
      case LDPT_OPTION:
	return parse_option (tv->tv_u.tv_string);
      case LDPT_NULL:
      case LDPT_GOLD_VERSION:
      case LDPT_GNU_LD_VERSION:
      case LDPT_API_VERSION:
      default:
	break;
      case LDPT_OUTPUT_NAME:
	output_name = tv->tv_u.tv_string;
	break;
      case LDPT_LINKER_OUTPUT:
	linker_output = tv->tv_u.tv_val;
	break;
      case LDPT_REGISTER_CLAIM_FILE_HOOK:
	SETVAR(tv_register_claim_file);
	break;
      case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
	SETVAR(tv_register_all_symbols_read);
	break;
      case LDPT_REGISTER_CLEANUP_HOOK:
	SETVAR(tv_register_cleanup);
	break;
      case LDPT_ADD_SYMBOLS:
	SETVAR(tv_add_symbols);
	break;
      case LDPT_GET_SYMBOLS:
	SETVAR(tv_get_symbols);
	break;
      case LDPT_GET_SYMBOLS_V2:
	tv_get_symbols_v2 = tv->tv_u.tv_get_symbols;
	break;
      case LDPT_ADD_INPUT_FILE:
	SETVAR(tv_add_input_file);
	break;
      case LDPT_MESSAGE:
	SETVAR(tv_message);
	break;
      case LDPT_GET_INPUT_FILE:
	SETVAR(tv_get_input_file);
	break;
      case LDPT_RELEASE_INPUT_FILE:
	SETVAR(tv_release_input_file);
	break;
      case LDPT_ADD_INPUT_LIBRARY:
	SETVAR(tv_add_input_library);
	break;
      case LDPT_SET_EXTRA_LIBRARY_PATH:
	SETVAR(tv_set_extra_library_path);
	break;
    }
#undef SETVAR
  return LDPS_OK;
}
开发者ID:B-Rich,项目名称:binutils,代码行数:61,代码来源:testplug.c

示例7: parse_options

void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
                   void (* parse_arg_function)(void *, const char*))
{
    const char *opt;
    int optindex, handleoptions = 1, ret;

    /* perform system-dependent conversions for arguments list */
    prepare_app_arguments(&argc, &argv);

    /* parse options */
    optindex = 1;
    while (optindex < argc) {
        opt = argv[optindex++];

        if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
            if (opt[1] == '-' && opt[2] == '\0') {
                handleoptions = 0;
                continue;
            }
            opt++;

            if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
                exit_program(1);
            optindex += ret;
        } else {
            if (parse_arg_function)
                parse_arg_function(optctx, opt);
        }
    }
}
开发者ID:Tjoppen,项目名称:FFmpeg,代码行数:30,代码来源:cmdutils.c

示例8: setup_parameters

/* 
 * Setup parameters for the use case.
 * Return: 0 succeed; -1 fail.
 */
static int 
setup_parameters(int argc, char * const argv[])
{
    /* use case defaults */
    chunksize_g = Chunksize_DFT;
    use_swmr_g = 1;	/* use swmr open */
    chunkplanes_g = 1;

    /* parse options */
    if (parse_option(argc, argv) < 0){
	return(-1);
    }
    /* set chunk dims */
    chunkdims_g[0] = chunkplanes_g;
    chunkdims_g[1]= chunkdims_g[2] = chunksize_g;

    /* set dataset initial and max dims */
    dims_g[0] = 0;
    max_dims_g[0] = H5S_UNLIMITED;
    dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = chunksize_g;

    /* set nplanes */
    if (nplanes_g == 0)
        nplanes_g = chunksize_g;

    /* show parameters and return */
    show_parameters();
    return(0);
} /* setup_parameters() */
开发者ID:Starlink,项目名称:hdf5,代码行数:33,代码来源:use_disable_mdc_flushes.c

示例9: cmd_opt

int cmd_opt(char **arg)
{
	const char *opt_text = get_arg(arg);
	struct opdb_key key;
	union opdb_value value;

	if (opt_text) {
		if (opdb_get(opt_text, &key, &value) < 0) {
			printc_err("opt: no such option: %s\n",
				opt_text);
			return -1;
		}
	}

	if (**arg) {
		if (parse_option(key.type, &value, *arg) < 0) {
			printc_err("opt: can't parse option: %s\n",
				*arg);
			return -1;
		}

		opdb_set(key.name, &value);
	} else if (opt_text) {
		display_option(NULL, &key, &value);
	} else {
		opdb_enum(display_option, NULL);
	}

	return 0;
}
开发者ID:noccy80,项目名称:mspdebug,代码行数:30,代码来源:stdcmd.c

示例10: parse_config_line

static int
parse_config_line(struct dhcpcd_ctx *ctx, const char *ifname,
    struct if_options *ifo, const char *opt, char *line,
    struct dhcp_opt **ldop, struct dhcp_opt **edop)
{
	unsigned int i;

	for (i = 0; i < sizeof(cf_options) / sizeof(cf_options[0]); i++) {
		if (!cf_options[i].name ||
		    strcmp(cf_options[i].name, opt) != 0)
			continue;

		if (cf_options[i].has_arg == required_argument && !line) {
			fprintf(stderr,
			    PACKAGE ": option requires an argument -- %s\n",
			    opt);
			return -1;
		}

		return parse_option(ctx, ifname, ifo, cf_options[i].val, line,
		    ldop, edop);
	}

	syslog(LOG_ERR, "unknown option: %s", opt);
	return -1;
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:26,代码来源:if-options.c

示例11: parse

int parse(struct file_system_info *fsinfo, int argc, char **argv){
        
    int i = 0;
        
    if ((argc == 2) && ((strcmp(argv[1], OPT_VERSION) == 0) || (strcmp(argv[1], OPT_VERSION_FULL) == 0))){
		printf(PROGRAM_NAME " - filesystem in userspace for rdiff-backup repositories; version %s\n", PACKAGE_VERSION);
		exit(0);	
    };	
    if (argc < 3)
		fail(ERR_PARAMETRES);
    for (i = 1; i < argc; i++){
		if (isOption(argv[i]) == 1)
	    	parse_option(fsinfo, argc, argv, &i);
		else if (mount == NULL)
	    	parse_mount(argv[i]);
		else
	    	parse_repo(fsinfo, argc, argv, &i);
	};
    if (mount == NULL)
		fail(ERR_NO_MOUNT);
    if (fsinfo->repo_count == 0)
		fail(ERR_NO_REPO);
	if ((layout == LAYOUT_LAST) && (structure != STRUCTURE_FULL))
		fail(ERR_FULL_ONLY);
    
    return 0;
    
};
开发者ID:tnt,项目名称:rdiff-backup-fs,代码行数:28,代码来源:parse.c

示例12: read_config

static
bool read_config(ZString filename)
{
    bool rv = true;
    io::ReadFile in(filename);
    if (!in.is_open())
    {
        FPRINTF(stderr, "Monitor config file not found: %s\n", filename);
        exit(1);
    }

    FString line;
    while (in.getline(line))
    {
        if (is_comment(line))
            continue;
        XString name;
        ZString value;
        if (!config_split(line, &name, &value))
        {
            PRINTF("Bad line: %s\n", line);
            rv = false;
            continue;
        }

        if (!parse_option(name, value))
        {
            PRINTF("Bad key/value: %s\n", line);
            rv = false;
            continue;
        }
    }
    return rv;
}
开发者ID:Binford2000,项目名称:tmwa,代码行数:34,代码来源:main.cpp

示例13: parse_header

int
parse_header(parsed_header_t *parse,
	     const gchar *buf, const size_t buf_len) {
  header_option_t *current;
  synchro_option_t *opt;
  const gchar *start = buf;
  const gchar *end;

  /* seek the first option -- I need bitstream examples to
     reverse-engeneer the very first option */
  while (*buf != FILENAME) {
    buf++;
    if (buf > start + buf_len)
      return -1;
  }

  current = (void *) buf;

  while (current->code != CODE) {
    parse_option(parse, current);
    current = next_option(current);
  }

  opt = (void*) current;
  parse_synchro(opt);
  end = (void *) opt->data;

  return (end - start);
}
开发者ID:Martoni,项目名称:debit,代码行数:29,代码来源:bitheader.c

示例14: flowop_parse_options

static int
flowop_parse_options(char *str_options, flowop_t *flowop)
{
	char	*options;	/* Temp string to get the token */
	char	opt_arr[100][100];	/* Array to copy the tokens */
	int	i = 0, j;			/* Iterators */
	char	*delimiters = " \t";

	flowop->options.count = 1;	/* Default count */
	flowop->options.size = 0;	/* Default size */
	flowop->options.duration = 0;	/* Default duration */
	flowop->p_id = UPERF_ANY_CONNECTION;

	for (options = strtok(str_options, delimiters);
	    options != NULL;
	    options = strtok(NULL, delimiters)) {
		if (isalpha(options[0]))
			(void) strlcpy(opt_arr[i++], options, 100);
	}
	for (j = 0; j < i; j++) {
		parse_option(opt_arr[j], flowop);
	}

	return (UPERF_SUCCESS);
}
开发者ID:vladzcloudius,项目名称:uperf,代码行数:25,代码来源:parse.c

示例15: main

int main(int const argc, char const * const * const argv) {
    Option opt;
    try {
        opt = parse_option(argv_to_args(argc, argv));
    }
    catch(std::invalid_argument const &e) {
        std::cout << e.what();
        return EXIT_FAILURE;
    }

    std::cout << "reading data..." << std::flush;
    Problem const Va = read_problem(opt.Va_path);
    Problem const Tr = read_problem(opt.Tr_path);
    std::cout << "done\n" << std::flush;

    std::cout << "initializing model..." << std::flush;
    Model model(Tr.nr_feature, opt.nr_factor, Tr.nr_field);
    init_model(model);
    std::cout << "done\n" << std::flush;

	omp_set_num_threads(static_cast<int>(opt.nr_threads));

    train(Tr, Va, model, opt);

	omp_set_num_threads(1);

    if(opt.do_prediction) predict(Va, model, opt.Va_path+".out");

    return EXIT_SUCCESS;
}
开发者ID:implus,项目名称:kaggle-2014-criteo,代码行数:30,代码来源:train.cpp


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