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


C++ parse_arg函数代码示例

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


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

示例1: parse_input

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  parse_input
 *  Description: separates a line of input into tokens. Passes tokens off for additional
 *  processing. 
 * =====================================================================================
 */
	void
parse_input (char *input, size_t size)
{
	char s[(int)size];
	strcpy(s, input);

	char *op_code = strtok(s, " ");
  char *raw_arg_a = strtok(NULL, " ");
	char *raw_arg_b = strtok(NULL, " ");
	char *raw_arg_c = strtok(NULL, " ");

	int argc = 0;

	struct arg_t args[3];
	if(raw_arg_a != 0) {
		args[0] = parse_arg(raw_arg_a);
		argc++;
	}
	if(raw_arg_b != 0) {
		args[1] = parse_arg(raw_arg_b);
		argc++;
	}
	if(raw_arg_c != 0) {
		args[2] = parse_arg(raw_arg_b);
		argc++;
	}

	op_code = trim_whitespace(op_code);
	str_to_lower(op_code);
	unsigned long op_hashed = hash(op_code);
	assemble_op(op_hashed, args, argc);
}		/* -----  end of function parse_input  ----- */
开发者ID:TheRealDonny,项目名称:TinyAssembler,代码行数:39,代码来源:tiny_assembler.c

示例2: parse_config

static void parse_config(void)
{
	int i;
	json_t *val;

	if (!json_is_object(opt_config))
		return;

	for (i = 0; i < ARRAY_SIZE(options); i++) {
		if (!options[i].name)
			break;
		if (!strcmp(options[i].name, "config"))
			continue;

		val = json_object_get(opt_config, options[i].name);
		if (!val)
			continue;

		if (options[i].has_arg && json_is_string(val)) {
			char *s = strdup(json_string_value(val));
			if (!s)
				break;
			parse_arg(options[i].val, s);
			free(s);
		} else if (!options[i].has_arg && json_is_true(val))
			parse_arg(options[i].val, "");
		else
			fprintf(stderr, "JSON option %s invalid\n",
				options[i].name);
	}
}
开发者ID:prcarter,项目名称:cpuminer,代码行数:31,代码来源:cpu-miner.c

示例3: oly_parse

int
oly_parse(struct command *c, char *s)
{

	c->a = 0;
	c->b = 0;
	c->c = 0;
	c->d = 0;
	c->e = 0;
	c->f = 0;
	c->g = 0;
	c->h = 0;

	if (!oly_parse_cmd(c, s))
		return FALSE;

	switch (min(ilist_len(c->parse), 9))
	{
	case 9: c->h = parse_arg(c->who, c->parse[8]);
	case 8: c->g = parse_arg(c->who, c->parse[7]);
	case 7: c->f = parse_arg(c->who, c->parse[6]);
	case 6: c->e = parse_arg(c->who, c->parse[5]);
	case 5: c->d = parse_arg(c->who, c->parse[4]);
	case 4: c->c = parse_arg(c->who, c->parse[3]);
	case 3: c->b = parse_arg(c->who, c->parse[2]);
	case 2: c->a = parse_arg(c->who, c->parse[1]);
	}

	return TRUE;
}
开发者ID:olytag,项目名称:Olympia--The-Age-of-Gods-PBEM,代码行数:30,代码来源:input.c

示例4: do_failed

static int do_failed(char *arg)
{
	char *msg = NULL;
	int msec = parse_arg(arg, &msg);

	return wdog_failed(cause, pid, msg, msec);
}
开发者ID:troglobit,项目名称:watchdogd,代码行数:7,代码来源:watchdogctl.c

示例5: trans_inst

int trans_inst(const char* name, int argc, char* const* argv, int* bin_ptr) {
    int _instno = 0;
    int _argi = 0;
    int _parg = 0;

    for (; _instno != INST_COUNT; ++_instno) {
        if (!util_stricmp(name, __inst[_instno].name)) {
            break;
        }
    }
    if (_instno == INST_COUNT) {
        fprintf(stderr, "no match function [%s] found.\n", name);
        return FAILURE;
    }

    if (argc > 0 && argc != strlen(__inst[_instno].argument)) {
        fputs("argument count not matched.\n", stderr);
        return FAILURE;
    }

    *(bin_ptr++) = _instno;

    for (; _argi != argc; ++_argi) {
        _parg = parse_arg(__inst[_instno].argument[_argi],
                          argv[_argi], bin_ptr);
        if (_parg == FAILURE) {
            fputs("argument parse error.\n", stderr);
            return FAILURE;
        }
        bin_ptr += typechr_len(__inst[_instno].argument[_argi]);
    }

    return (arg_len(_instno) + 1);
}
开发者ID:shouya,项目名称:svm,代码行数:34,代码来源:svm.c

示例6: main

int main(int argc, const char** argv)
{
    const char* input_path = 0;
    output_list outputs;
    Mode mode = textureMode;
    InputFileType inputType;
    size_t optimize = 1;
    bool bench = false;
    bool verbose = false;
    int result;

    parse_arg(argc, argv, input_path, outputs, optimize, bench, verbose, mode, inputType);

    if (input_path == 0 || outputs.size() == 0)
    {
        mode = helpMode;
    }

    if (mode == helpMode)
    {
        help();
        result = 1;
    }
    else
    {
        process_image(input_path, outputs, optimize, bench, verbose, mode, inputType);
        result = 0;
    }
    return result;
}
开发者ID:JGAndersen,项目名称:lightpng,代码行数:30,代码来源:lightpng.cpp

示例7: main

int main(int  argc,
	 char **argv)
{
   SOCKET              listen_sock;
   struct sockaddr_un  addr;
   union conv_sockaddr u_sock_addr;
   int                 len, nb_str;
   char                **print_me;
   listen_sock = create_socket();
   strcpy(addr.sun_path, get_path());
   addr.sun_family = AF_LOCAL;
   u_sock_addr.un = &addr;
   if (connect(listen_sock, u_sock_addr.ad, sizeof(addr)) == -1)
   {
      printf("Client not connected.\n");
      return (-1);
   }
   if ((nb_str =parse_arg(argc, argv, &print_me)) == 0)
      return (close_server(listen_sock));
   for (; nb_str > 0; nb_str--)
   {
      len = strlen(print_me[nb_str - 1]);
      write(listen_sock, &len, sizeof(len));
      write(listen_sock, print_me[nb_str - 1], len);
   }
   close(listen_sock);
   free(print_me);
   return (0);
}
开发者ID:Oicho,项目名称:psychic-hipster,代码行数:29,代码来源:sv_stl.c

示例8: do_reset

static int do_reset(char *arg)
{
	char *msg = NULL;
	int msec = parse_arg(arg, &msg);

	return wdog_reset_timeout(pid, msg, msec);
}
开发者ID:troglobit,项目名称:watchdogd,代码行数:7,代码来源:watchdogctl.c

示例9: add_entry

bool add_entry(char *lbuf, int length, struct dict_entry_t *entry)
{
	char *cp;

	if (length == 0)
		return false;

	/* allocate line buffer */
	entry->lbuf = (char *) ecalloc(1, length + 1);
	strncpy(entry->lbuf, lbuf, length);

	/* format: keyword TAB candidate1 TAB candidate2 TAB candidate3... TAB */
	if ((cp = strchr(entry->lbuf, '\t')) == NULL)
		goto error;

	*cp = '\0';
	entry->keyword = entry->lbuf;

	parse_reset(&entry->candidate);
	parse_arg(cp + 1, &entry->candidate, '\t', not_tab);

	/* illegal entry */
	if (entry->candidate.argc <= 0)
		goto error;

	return true;
error:
	free(entry->lbuf);
	return false;
}
开发者ID:uobikiemukot,项目名称:yaskk,代码行数:30,代码来源:sortdict.c

示例10: getopt

int getopt(int argc, char *const argv[], const char *optstring) {
    if (!optinited) {
        parse_arg(optstring);
        optinited = true;
    }
    optarg = nullptr;
    if (optind >= argc) {
        return -1;
    }
    else if (argv[optind][0] != '-' || argv[optind][1] == '\0') {
        // begin with no dash or dash alone
        return -1;
    }
    char optname = argv[optind][1];
    if (optnames[optname] == 0) {
        return -1;
        return '?';
    }
    if (optnames[optname] == 2) {
        // an argument
        if (++optind >= argc) {
            return -1;
        }
        optarg = argv[optind];
    }
    else {
        ++optind;
    }
    return optname;
}
开发者ID:CalvinNeo,项目名称:CFortranTranslator,代码行数:30,代码来源:getopt.cpp

示例11: parse

static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
{
	int inum = *params / sizeof(cell), iarg = 2, c;
	char* arg, *parse = get_amxstring(amx, params[1], 0, c);
	cell *cptr;
	int state;
	
	while (*parse)
	{
		arg = parse_arg(&parse,state);
		
		if (state)
		{
			if (inum <= iarg)
				return ((iarg - 2)>>1);
			
			cptr = get_amxaddr(amx, params[iarg++]);
			c = *get_amxaddr(amx, params[iarg++]);
			
			while (c-- && *arg)
				*cptr++ = (cell)*arg++;
			*cptr = 0;
		}
	}

	return ((iarg - 2)>>1);
}
开发者ID:VasilVasilev93,项目名称:amxmodx,代码行数:27,代码来源:string.cpp

示例12: parse_line

static int parse_line(struct binrpc_cmd* cmd, char* line)
{
	char* p;
	int count;

	cmd->method=strtok(line, " \t");
	if (cmd->method==0)
		goto error_no_method;
	count=0;
	for(p=strtok(0, " \t"); p; p=strtok(0, " \t")){
		if (count>=MAX_BINRPC_ARGS)
			goto error_too_many;
		if (parse_arg(&cmd->argv[count], p)<0){
			goto error_arg;
		}
		count++;
	}
	cmd->argc=count;
	return 0;
error_no_method:
	printf( "ERROR: no method name\n");
	return -1;
error_too_many:
	printf("ERROR: too many arguments (%d), no more than %d allowed\n",
			count, MAX_BINRPC_ARGS);
	return -1;
error_arg:
	printf("ERROR: bad argument %d: %s\n", count+1, p);
	return -1;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:30,代码来源:kamcmd.c

示例13: read_args

void read_args(int argc, const char** argv,
               GD<COMP_T, SUPV_T, DAT_DIM_T, N_DAT_T>::GDParam& gd_param,
               SGD<COMP_T, SUPV_T, DAT_DIM_T, N_DAT_T>::SGDParam& sgd_param,
               MySolver::MyParam& my_param,
               char* data_file) {
    int i;
    for (i = 1; i < argc && argv[i][0] == '-'; ++i) {
        switch (parse_arg(argv[i])) {
            case 0  : print_help(); exit(0);
            case 1  : ++i; gd_param.verbosity(argv[i][0] - '0');
            case 2  : ++i; my_param.regul_coef(std::atof(argv[i]));
            case 3  : ++i; my_param.regul_coef(std::atof(argv[i])); break;
            case 5  : ++i; sgd_param.num_of_epoches(std::atoi(argv[i]));
            case 6  : ++i; sgd_param.num_of_epoches(std::atoi(argv[i])); break;
            case 11 : ++i; gd_param.init_learning_rate(std::atof(argv[i]));
            case 12 : ++i; gd_param.init_learning_rate(std::atof(argv[i])); break;
            case 14 : ++i; gd_param.learning_rate_1st_try(std::atof(argv[i]));
            case 15 : ++i; gd_param.learning_rate_1st_try(std::atof(argv[i])); break;
            case 17 : ++i; gd_param.learning_rate_try_factor(std::atof(argv[i]));
            case 18 : ++i; gd_param.learning_rate_try_factor(std::atof(argv[i])); break;
            default:
                std::cerr << "Unrecognized option " << argv[i] << "! Please type \"labeltree_train -h\" for help.\n";
                exit(1);
        }
    }
    if (i >= argc) {
        std::cerr << "Not enough input parameters! Please type \"main -h\" for help.\n";
        exit(1);
    }
    std::strcpy(data_file, argv[i]);
}
开发者ID:Raychee,项目名称:my_tree,代码行数:31,代码来源:main.cpp

示例14: main

int
main(int argc, char *argv[])
{
	int ii;
	int ret = 0;

	if (argc < 2) {
		fprintf(stderr, "arguments plox\n");
		exit(1);
	}

	g_hdl = pcidb_open(PCIDB_VERSION);
	if (g_hdl == NULL)
		fatal("failed to open pci database: %s\n", strerror(errno));

	for (ii = 1; ii < argc; ii++) {
		g_case = L_INVALID;
		parse_arg(argv[ii]);
		print_arg();
	}


	pcidb_close(g_hdl);

	return (ret);
}
开发者ID:jclulow,项目名称:illumos-hcl,代码行数:26,代码来源:pcilookup.c

示例15: main

int main(int argc, char **argv)
{
	int n;
	OPTION opt;
	
	#if defined(WIN32)
	_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
	_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
	_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
	_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_CHECK_ALWAYS_DF|_CRTDBG_LEAK_CHECK_DF);
	#endif

	n = parse_arg(&opt, argc, argv);
	if(n+2 > argc){
		show_usage();
		exit(EXIT_FAILURE);
	}

	for(;n<=(argc-2);n+=2){
		test_arib_std_b25(argv[n+0], argv[n+1], &opt);
	}
	
	#if defined(WIN32)
	_CrtDumpMemoryLeaks();
	#endif

	return EXIT_SUCCESS;
}
开发者ID:ha1t,项目名称:recfriio,代码行数:31,代码来源:td.c


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