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

C++ split_str函数代码示例

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

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



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

示例1: display_func

void* display_func(void) {

    int i, j, error;
    char message_buffer[LENGHT_MESSAGE], message_buffer_2[LENGHT_MESSAGE];
    char filename[LENGHT_MESSAGE];
    char confirm_file[LENGHT_MESSAGE];
    FILE *fp;

    while (state == 0) {

        if (recieve_data(LENGHT_MESSAGE, message_buffer) == 0)
            draw_new(global_display, "system>> recieve error");

        //draw_new(global_display, message_buffer);
        if (message_buffer[0] == '0') {
            split_str(1, strlen(message_buffer), message_buffer, message_buffer_2);
            draw_new(global_display, message_buffer_2);
        }
        else if (message_buffer[0] == '1') {
            //do nothing
        }
        else if (message_buffer[0] == '2') {
            split_str(27, strlen(message_buffer) - 2, message_buffer, message_buffer_2);
            strcpy(username, message_buffer_2);
            split_str(1, strlen(message_buffer), message_buffer, message_buffer_2);
            draw_new(global_display, message_buffer_2);
        }
        else if (message_buffer[0] == '3') {
            split_str(1, strlen(message_buffer), message_buffer, message_buffer_2);
            draw_new(global_display, message_buffer_2);
            split_str(31, strlen(message_buffer) - 1, message_buffer, filename);

            sprintf(message_buffer_2, "downloaded/%s", filename);
            fp = fopen(message_buffer_2, "w+");
            error = 1;
            do {
                recieve_file(message_buffer);
                fprintf(fp, "%c", message_buffer[1]);
            }while(message_buffer[0] != '5');
            fclose(fp);

            draw_new(global_display, "system>> Downloaded file success.");

        }

        //Reset value in message_buffer for check while loop's condition
        strcpy(message_buffer, "");
        strcpy(message_buffer_2, "");

    }

    return 0;

}
开发者ID:chin8628,项目名称:terminal-s-chat,代码行数:54,代码来源:socket_client.c


示例2: load_program

  void load_program(std::string path){
    get_pause();
    while(node_view.size() > 0){
      delete_node(node_view.begin()->second);
    }
    clear_local();


    std::ifstream cin(path, std::ios::in);
    char buffer[100];
    std::string str;
    int state = 0;
    std::getline(cin,str);
    int n_nodes = lexical_cast<int,std::string>(str);
    std::cout << "N Nodes:" << n_nodes << "\n";
    std::vector<Node *> nodes;

    for(int i = 0; i < n_nodes;i++){
      std::getline(cin,str);
      std::vector<std::string> args = split_str(str);
      float y = lexical_cast<float,std::string>(args[args.size()-1]);
      args.pop_back();
      float x = lexical_cast<float,std::string>(args[args.size()-1]);
      args.pop_back();
      std::string full_name;
      for(int i = 0; i < args.size();i++){
	full_name += args[i];
	if(i != args.size()-1){
	  full_name += " ";
	}
      }
      std::cout << full_name << "\n";
      nodes.push_back(create_and_insert_node(full_name,Vec2f(x,y)));
    }

    std::getline(cin,str);
    int n_connections = lexical_cast<int,std::string>(str);
    for(int i = 0; i < n_connections;i++){
      std::getline(cin,str);
      std::vector<std::string> args = split_str(str);
      int out_node = lexical_cast<int,std::string>(args[0]);
      int out_port = lexical_cast<int,std::string>(args[1]);
      int in_node = lexical_cast<int,std::string>(args[2]);
      int in_port = lexical_cast<int,std::string>(args[3]);
      backend.connect_nodes(nodes[out_node],nodes[in_node],out_port,in_port);

    }
    release_pause();
    cin.close();
    std::cout << "Done loading.. \n";
  }
开发者ID:rolfrm,项目名称:pigame,代码行数:51,代码来源:node_ui.cpp


示例3: netif_add_from_spec

void netif_add_from_spec(struct netif **ifs, const char *spec) {
    _free_ char *tmp = NULL;
    _free_ char **opts = NULL;

    if (!spec) return;

    tmp = strdup(spec);
    fail_if(!tmp, "OOM");

    size_t c = split_str(tmp, &opts, ":");
    fail_if(!c, "Invalid netif spec '%s': not enough args", spec);

    if (if_nametoindex(opts[0])) {
        fail_if(c < 2, "Invalid netif spec '%s': not enough args",spec);

        netif_add(ifs, MOVE, opts[0], opts[1]);
    } else if (!strncmp(opts[0], "macvlan", 8)) {
        fail_if(c < 3, "Invalid netif spec '%s': not enough args",spec);

        netif_add(ifs, MACVLAN, opts[1], opts[2]);
    } else if (!strncmp(opts[0], "ipvlan", 8)) {
        fail_if(c < 3, "Invalid netif spec '%s': not enough args",spec);

        netif_add(ifs, IPVLAN, opts[1], opts[2]);
    } else if (!strncmp(opts[0], "veth", 5)) {
        fail_if(c < 3, "Invalid netif spec '%s': not enough args",spec);

        netif_add(ifs, VETH, opts[1], opts[2]);
    } else {
        fail_printf("Invalid netif spec '%s'", spec);
    }
}
开发者ID:ghedo,项目名称:pflask,代码行数:32,代码来源:netif.c


示例4: bodycallback

size_t bodycallback(char *ptr, size_t size, size_t nmemb, void *userdata) {
	char* pstr = (char *)ptr;

	replace_char(pstr, '\r', ':');
	char **rows = split_str(pstr, '\n');
	if (rows == NULL || rows[0] == NULL) {
		free(rows);
		return nmemb*size;
	}

	int i = 0;
	for (i = 0; rows[i]; i++) {
#ifdef DEBUG
		fprintf(stderr, "Read body line: %s\n", rows[i]);
#endif

		BODY *curbody = (BODY *) malloc(sizeof(BODY) +  strlen(rows[i]) + 1);
		curbody->row = (char *) ((char*)curbody + sizeof(BODY));
		strcpy(curbody->row, rows[i]);
		curbody->next = body;
		body = curbody;
	}

	free(rows);
	return nmemb*size;
}
开发者ID:biancini,项目名称:Shibboleth-Authentication,代码行数:26,代码来源:libnss_shib.c


示例5: _diypy3__binary_tree

static PyObject *
_diypy3__binary_tree(PyObject *self, PyObject *args)
{
    int order;
    char *bt_str;
    char *str_slice_rec[BT_MAXSIZE];
    BTNODE *T;

    if (!PyArg_ParseTuple(args, "is", &order, &bt_str))
        return NULL;
    split_str(bt_str, str_slice_rec);
    temp_rec = str_slice_rec;
    pre_order_create(&T);
    printf("binary tree initialized\n");
    switch (order) {
        case 0:
            pre_order_visualize(T);
            indent = 0;
            break;
        default:
            PyErr_SetString(PyExc_ValueError,
                            "Unrecognised flag given");
            return NULL;
    }

    Py_RETURN_NONE;
}
开发者ID:anqurvanillapy,项目名称:diypy3,代码行数:27,代码来源:diypy3module.c


示例6: _diypy3__triplet_sparse_matrix

static PyObject *
_diypy3__triplet_sparse_matrix(PyObject *self, PyObject *args)
{
    int mu;
    int nu;
    int tu;
    char *trismx_str;
    char *str_slice_rec[TRISMX_MAXSIZE];
    TRISMX M;
    TRISMX N;

    if (!PyArg_ParseTuple(args, "iiis", &mu,
                                        &nu,
                                        &tu,
                                        &trismx_str))
        return NULL;
    split_str(trismx_str, str_slice_rec);
    temp_rec = str_slice_rec;
    create_sparse_trismx(&M, mu, nu, tu);
    printf("triplet sparse matrix initialized\n");
    visualize_trismx(&M);
    printf("fast transpose this matrix:\n");
    fast_transpose_trismx(&M, &N);
    visualize_trismx(&N);

    Py_RETURN_NONE;
}
开发者ID:anqurvanillapy,项目名称:diypy3,代码行数:27,代码来源:diypy3module.c


示例7: _diypy3__link_queue

static PyObject *
_diypy3__link_queue(PyObject *self, PyObject *args)
{
    int i;
    int rec_size;
    char *queue_str;
    char *str_slice_rec[LNKQ_MAXSIZE];
    char *deq;
    LNKQ Q;

    if (!PyArg_ParseTuple(args, "s", &queue_str))
        return NULL;
    rec_size = split_str(queue_str, str_slice_rec);
    temp_rec = str_slice_rec;
    if (!init_queue(&Q))
        return NULL;
    printf("linked list queue initialized\n");
    printf("\n");
    for (i = 0; i < rec_size; i++) {
        printf("enqueue: %s\n", temp_rec[i]);
        enqueue(&Q, temp_rec[i]);
    }
    while (Q.front != Q.rear) {
        printf("\nstatus: ");
        show_queue(Q);
        dequeue(&Q, &deq);
        printf("dequeue: %s\n", deq);
    }
    printf("\nwarning: empty queue\n");

    Py_RETURN_NONE;
}
开发者ID:anqurvanillapy,项目名称:diypy3,代码行数:32,代码来源:diypy3module.c


示例8: perform_cmd

static void	perform_cmd(t_client *client, char *cmd)
{
  char		**tab;
  int		i;
  int		n;

  tab = split_str(cmd, ' ');
  n = 0;
  while (tab && tab[n])
    n++;
  if (n == 0)
    {
      free_tab(tab);
      return ;
    }
  i = 0;
  while (i < COMMANDS)
    {
      if (!my_strcmp_case(client->commands[i].str, tab[0]))
	{
	  client->commands[i].func(client, n, tab);
	  free_tab(tab);
	  return ;
	}
      i++;
    }
}
开发者ID:PSNRigner,项目名称:jetpack2Tek3,代码行数:27,代码来源:select.c


示例9: message_training_setup

/** 
 * One time initializations done when we want to display a new training mission.
 * 
 * This does all the processing and setup required to actually display it, including 
 * starting the voice file playing
 */
void message_training_setup(int m, int length, char *special_message)
{
	if ((m < 0) || !Messages[m].message[0]) {  // remove current message from the screen
		Training_num_lines = 0;
		return;
	}

	// translate tokens in message to the real things
	if (special_message == NULL)
		message_translate_tokens(Training_buf, Messages[m].message);
	else
		message_translate_tokens(Training_buf, special_message);

	HUD_add_to_scrollback(Training_buf, HUD_SOURCE_TRAINING);

	// moved from message_training_display() because we got rid of an extra buffer and we have to determine
	// the number of lines earlier to avoid inadvertant modification of Training_buf.  - taylor
	training_process_message(Training_buf);
	Training_num_lines = split_str(Training_buf, TRAINING_LINE_WIDTH, Training_line_lengths, Training_lines, MAX_TRAINING_MESSAGE_LINES);

	Assert( Training_num_lines >= 0 );

	if (message_play_training_voice(Messages[m].wave_info.index) < 0) {
		if (length > 0)
			Training_message_timestamp = timestamp(length * 1000);
		else
			Training_message_timestamp = timestamp(TRAINING_TIMING_BASE + strlen(Messages[m].message) * TRAINING_TIMING);  // no voice file playing

	} else
		Training_message_timestamp = 0;
}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:37,代码来源:missiontraining.cpp


示例10: seek_to_regname

static bool seek_to_regname(FILE *f, const char *regname)
{
	char str[1024];

	while (true) {
		fpos_t pos;
		int r;

		r = fgetpos(f, &pos);
		if (r)
			myerr2("fgetpos failed");

		if (!fgets(str, sizeof(str), f))
			return false;

		char *parts[3] = { 0 };

		r = split_str(str, ",", parts, 3);
		if (r != 3)
			myerr("Failed to parse register description: '%s'", str);

		if (strcmp(regname, parts[0]) == 0) {
			r = fsetpos(f, &pos);
			if (r)
				myerr2("fsetpos failed");

			return true;
		}

		if (!seek_to_next_reg(f))
			return false;
	}

	return false;
}
开发者ID:nmenon,项目名称:rwmem,代码行数:35,代码来源:parser.c


示例11: c_calloc_2

void *_job_proc(void* data)
{
	queue_item *job = (queue_item*) data;
	char **job_desc = c_calloc_2(10, 30);

	int count = split_str(job->job_description, " ", job_desc);
	if (count == 0)
	{
		fprintf(stdout, "This job has some problem!\n");
	}
	else if (!strcmp(job_desc[0], "srun"))
	{
		drun_proc(count, job_desc);
	}
	else if (!strcmp(job_desc[0], "dcancel"))
	{
		//dcancel_proc(job_origin_desc_left);
	}
	else if (!strcmp(job_desc[0], "dinfo"))
	{
		//dinfo_proc(job_origin_desc_left);
	};
	pthread_exit(NULL);
	return NULL;
}
开发者ID:kwangiit,项目名称:SLURMPP,代码行数:25,代码来源:controller.c


示例12: print_result

void	print_result(float *tab, int max)
{
	char	**tmp;
	int		degree;
	char	*reduced_form;

	reduced_form = get_reduced_form(tab, max);
	ft_putstr("\033[4mReduced form:\033[0;0m");
	ft_putendl(ft_strjoin(" ", ft_strjoin(reduced_form, " = 0")));
	tmp = split_str(reduced_form);
	degree = get_degree(tmp);
	ft_putendl(ft_strjoin("Polynomial degree: ", ft_itoa(degree)));
	if (!ft_strcmp(reduced_form, "0"))
		ft_putendl("\033[32mAll real numbers are solution.");
	else if (!check_all_tab(tab, max))
	{
		ft_putendl("\033[31mThere is no solution.");
		return ;
	}
	else if (degree > 2)
		print_error(3);
	else if (degree == 0 || degree == 1)
		print_result3(tab, degree);
	else if (degree >= 2)
		print_result4(tab);
	do_mlx(tab);
}
开发者ID:plisieck,项目名称:ComputorV1,代码行数:27,代码来源:computor5.c


示例13: GetOption

int GetOption (char *str, char *option, int option_len, char *value,
					  int val_len)
{
	char *argv[2];
	char key [MENU_TITLE_BUF_LEN +1] = {0};
	char val [VALUE_LEN +1] = {0};
	char *p;
	int argc;

	argv[0] = key;
	argv[1] = val;

	//split string to two part,key and value ,splited by SPACE or TAB
	argc = split_str (str, argv);


	//if split to two part, return 2.
	if( argc < 2 )
		return -1;

	//remove SPACE and TAB from key and val header and tail.
	p = trim (key);
	//copy to buffer.
	strncpy (option, p, option_len - 1);

	p = trim (val);
	//remove comment data from string.
	remove_comment(p);
	strncpy (value, p, val_len -1);

	return 0;
}
开发者ID:kisom,项目名称:pmon,代码行数:32,代码来源:boot_cfg.c


示例14: get_arg

/*********************************************************************
 *	文字列 *buf から、パラメータを読み取り、( adrs , memcnt ) を決める
 *********************************************************************
 */
int	get_arg(char *buf)
{
	arena = AREA_RAM;
	if(*buf == 'p') {
		buf++; arena = AREA_PGMEM;
	}else
	if(*buf == 'r') {
		buf++; arena = AREA_EEPROM;
	}
	memcnt = 64;
	adrs2 = (-1);

	buf = sp_skip(buf);
	if(*buf==0) return 0;

	arg_cnt = split_str(buf,',',arg_ptr);
	scan_args(arg_cnt);

	if(arg_cnt>=1) {
		adrs = arg_hex[0];
	}
	if(arg_cnt>=2) {
		adrs2 = arg_hex[1];
		if(adrs2 != (-1) ) {
			memcnt = adrs2 - adrs + 1;
		}
		if(	memcnt < 0) {
			memcnt = adrs2;
		}
	}
	return arg_cnt;
}
开发者ID:DharmaPatil,项目名称:PIC18F_BOOTLOADER,代码行数:36,代码来源:monit.c


示例15: fopen

struct reg_desc *find_reg_by_address(const char *regfile, uint64_t addr)
{
	char str[1024];

	FILE *f = fopen(regfile, "r");

	ERR_ON_ERRNO(f == NULL , "Failed to open regfile %s", regfile);

	if (!seek_to_regaddr(f, addr))
		return NULL;

	if (!fgets(str, sizeof(str), f))
		ERR("Failed to parse register");

	char *parts[3] = { 0 };

	int r = split_str(str, ",", parts, 3);

	ERR_ON(r != 3, "Failed to parse register description: '%s'", str);

	struct reg_desc *reg;
	reg = malloc(sizeof(struct reg_desc));
	memset(reg, 0, sizeof(*reg));
	reg->name = strdup(parts[0]);
	reg->offset = strtoull(parts[1], NULL, 0);
	reg->width = strtoul(parts[2], NULL, 0);

	parse_reg_fields(f, reg);

	fclose(f);

	return reg;
}
开发者ID:nmenon,项目名称:rwmem,代码行数:33,代码来源:parser.c


示例16: string

 //------------------------------------------------------------------------
 string qt_dbtreemodel_impl::_value( const row *r, const string& format, const string& columns ) const
 {
     if( !r )
         return string();
     
     string          result( format );
     vector<string>  dest;
     split_str( columns, ",", dest );
     
     for( size_t i = 0; i < dest.size(); ++i )
     {
         size_t n = result.find( "%s" );
         if( n != string::npos )
         {
             try {
                 result.replace( n, 2, r->at( str_to_size_t( dest[i] ) ) );
             } catch( std::out_of_range& ) {
                 _lprintf( LOG_ERR, "Column %lu is wrong\n", dest[i].c_str() );
                 continue;
             }
         }
     }
     
     return result;
 }
开发者ID:sblab,项目名称:libeast,代码行数:26,代码来源:qt_dbtreemodel_impl.cpp


示例17: parse_raw_data

smartphone_gps_t parse_raw_data(char *buffer, size_t buf_size)
{
	fprintf(stderr, "Parsing smartphone gps data: %s\n", buffer);
	smartphone_gps_t gps;

	gps.time = time(NULL);
	
	/* Latitude */
	char *token = split_str(&buffer, ",");
	gps.lat = atof(token);
		
	/* Longitude */
	token = split_str(&buffer, ",");
	gps.lng = atof(token);

	return gps;
}
开发者ID:mantell,项目名称:EE-180D-Project,代码行数:17,代码来源:smartphone_gps.c


示例18: techroom_init_desc

void techroom_init_desc(char *src, int w)
{
	Text_size = Text_offset = 0;
	if (!src) {
		return;
	}

	Text_size = split_str(src, w, Text_line_size, Text_lines, MAX_TEXT_LINES);
	Assert(Text_size >= 0 && Text_size < MAX_TEXT_LINES);
}
开发者ID:RandomTiger,项目名称:fs2open.github.com,代码行数:10,代码来源:techmenu.cpp


示例19: main

int main(int argc, char **argv)
{
    rados_t cluster;
    char cluster_name[] = "ceph";
    char user_name[] = "client.admin";
    APPNAME = &argv[0][2];
    uint64_t flags;
   
    int err;

    /* Initialize the cluster handle */
    err = rados_create2(&cluster, cluster_name, user_name, flags);
    // err = rados_create(&cluster, NULL);
    error_print(err, "Couldn't create the cluster handle!", "Created a cluster handle.");
    
    /* Read a Ceph configuration file to configure the cluster handle. */
    err = rados_conf_read_file(cluster, "/etc/ceph/ceph.conf");
    error_print(err, "Cannot read config file!", "Read the config file.");

    /* Connect to the cluster */
    err = rados_connect(cluster);
    error_print(err, "Cannot connect to cluster!", "Connected to the cluster.");

    /* List pools. */
    char buf[1024];
    err = rados_pool_list(cluster, buf, 1024);
    split_str(buf, 1024);
    error_print(err, "Cannot list pools!", buf);

    /* List pool stats */
    char *poolname = strtok(buf, ",");
    while(poolname != NULL)
    {
        rados_ioctx_t io;
        struct rados_pool_stat_t stats;
        
        err = rados_ioctx_create(cluster, poolname, &io);
        error_print(err, "Cannot create IO context!", "IO context created.");

        err = rados_ioctx_pool_stat(io, &stats);
        error_print(err, "Cannot list pool stats!", "Pool stats listed.");

        printf("[%s][%s]: Number of read: %"PRIu64"\n", APPNAME, poolname, stats.num_rd);
        printf("[%s][%s]: Number of read in kb: %"PRIu64"\n", APPNAME, poolname, stats.num_rd_kb);
        printf("[%s][%s]: Number of write: %"PRIu64"\n", APPNAME, poolname, stats.num_wr);
        printf("[%s][%s]: Number of write in kb: %"PRIu64"\n", APPNAME, poolname, stats.num_wr_kb);

        rados_ioctx_destroy(io);
        poolname = strtok(NULL, ",");
    }

    /* Shut down the cluster */
    rados_shutdown(cluster);
    printf("[%s]: Cluster shut down.\n", APPNAME);
}
开发者ID:Aegeaner,项目名称:ceph-osd-monitor,代码行数:55,代码来源:pool_mon.c


示例20: _nss_shib_getgrgid_r

enum nss_status _nss_shib_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop)
{
#ifdef DEBUG
	fprintf(stderr, "\nEntering _nss_shib_getgrgid_r with gid=%d.\n", gid);
#endif

	int ret = NSS_STATUS_UNAVAIL;
	readconfig();
	char newurl[1024];
	sprintf(newurl, "%s", url_group);
	if (!geturl(newurl, username, password, cafile, sslcheck) || body == NULL) {
		ret = NSS_STATUS_UNAVAIL;
		goto getgrgid_err;
	}

	BODY *cursor = body;
	while (cursor)
	{
		char *cur_row = cursor->row;
		int count_separator = count_char_in_str(cur_row, ':');
		char **array = split_str(cur_row, ':');

		if (array[0] != NULL  && count_separator >= 3 && atoi(array[2]) == gid)
		{
			int setting = setgroupfromarray(array, result, buffer, buflen);
			if (setting != 0) {
				if (setting == 1) {
					if(array) free(array);

					*errnop = ERANGE;
					ret = NSS_STATUS_TRYAGAIN;
				}
				else {
					ret = NSS_STATUS_UNAVAIL;
				}
				goto getgrgid_err;
			}

#ifdef DEBUG
			fprintf(stderr, "Found item for gid=%d: [name=%s]\n", gid, array[0]);
#endif

			ret = NSS_STATUS_SUCCESS;
		}

		if(array) free(array);
		cursor = cursor->next;
	}  

getgrgid_err:
	cleanbody();
	return ret;
}
开发者ID:biancini,项目名称:Shibboleth-Authentication,代码行数:53,代码来源:libnss_shib.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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