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

C++ rstrip函数代码示例

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

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



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

示例1: is

void HttpSession::parseHeader() {
	istream is(&impl->data);
	string line;
	getline(is, line);
	auto rc = split(line, " ");
	impl->code = stol(rc[1]);
	LOGD(">>%s", line);
	while(!is.eof()) {
		getline(is, line);
		if(line == "" || line == "\r")
			break;
		LOGD("%s", line);
		auto parts = split(line, ": ", 2);
		if(parts.size() == 2) {
			parts[1] = rstrip(rstrip(parts[1], '\n'), '\r');
			impl->header[parts[0]] = parts[1];
		}
	}
	auto cl = impl->header["Content-Length"];
	impl->cntSize = cl != "" ? stol(impl->header["Content-Length"]) : 0;
	if(isRedirect()) {
		LOGD("Should redirect to '%s'", impl->header["Location"]);
		//sleepms(500);
	}
}
开发者ID:sasq64,项目名称:apone,代码行数:25,代码来源:webgetter.cpp


示例2: int

int CConfigHandler::parseFile(FILE *pFile, int (*handler)(void *, const char *, const char *, const char *), void *object)
{
	char line[MAX_LINE];
	char section[MAX_SECTION];
	char *start;
	char *end;
	char *name;
	char *value;
	char *chr;
	int lineno = 0;

	memset(line, 0, sizeof(line));

	while (fgets(line, MAX_LINE, pFile) != NULL)
	{
		start = line;
		start = lstrip(rstrip(start));

		if (*start == ';' || *start == '#' || 0 >= strlen(start))
		{
			memset(line, 0, sizeof(line));
			continue;
		}

		/**
		 * [section] line
		 */
		chr = strchr(line, '[');
		if (chr)
		{
			end = strchr(chr + 1, ']');
			if (end)
			{
				*end = '\0';
				memset(section, 0, sizeof(section));
				strcpy(section, chr + 1);
			}
			continue;
		}

		/**
		 * name = value
		 */
		end = strchr(line, '=');
		if (end && strlen(section))
		{
			*end = '\0';
			name = lstrip(rstrip(start));
			value = lstrip(end + 1);
			rstrip(value);
			handler(object, section, name, value);
			++lineno;
		}
	}

	return lineno;
}
开发者ID:jugo8633,项目名称:WirelessManagerSystem,代码行数:57,代码来源:CConfigHandler.cpp


示例3: extinputs_parse_2D

int extinputs_parse_2D(const char *filename, struct pulse_2D **cfginputs,
                       int N1, int N2)
{
    FILE *fin;
    char buf[MAX_LINE];

    char *start;
    char *end;
    char *values;

    int error = 0;

    fin = fopen(filename, "r");
    if (!fin)
        return -1;

    int lineno = 0;

    double t, q1, q2, i, d, m;  /* the values to be read */

    /* Scan through file line by line */
    while (fgets(buf, sizeof(buf), fin) != NULL) {
        lineno++;
        start = lskip(rstrip(buf));     /* chop whites */

        if (*start && *start != '#') {
            /* Remove possible comments at the end */
            end = find_char_or_comment(start, '#');
            if (*end == '#')
                *end = '\0';
            values = rstrip(start);
            /* Not a comment, must be a line containing 6 numbers */
            /* Scan and check if the inputs is correctly formatted */
            if (sscanf(values, "%lf %lf %lf %lf %lf %lf",
                       &t, &d, &q1, &q2, &i, &m) == 6) {
                if (t >= 0 && d > 0 && m >= 0) {
                    *cfginputs =
                        append_pulse_2D(*cfginputs,
                                        new_pulse_2D(N1, N2, t, d,
                                                     -q1, -q2, i, m));
                } else {
                    printf("Durations and time onsets should be positive.\n");
                    printf("Check configuration file for external inputs.\n");
                    error = lineno;
                }
            } else if (!error) {
                /* No '=' found on name=value line  */
                error = lineno;
            }
        }
    }
    fclose(fin);
    return error;
}
开发者ID:djmarti,项目名称:ring_network,代码行数:54,代码来源:parser.c


示例4: conf_parse

int conf_parse(const char *filename,
               int (*handler) (void *, const char *, const char *),
               void *usercfg)
{
    FILE *fin;
    char buf[MAX_LINE];

    char *start;
    char *end;
    char *name;
    char *value;

    int error = 0;

    fin = fopen(filename, "r");
    if (!fin)
        return -1;

    int lineno = 0;

    /* Scan through file line by line */
    while (fgets(buf, sizeof(buf), fin) != NULL) {
        lineno++;
        start = lskip(rstrip(buf));     /* chop whites */

        if (*start && *start != '#') {
            /* Not a comment, must be a name = value pair  */
            end = find_char_or_comment(start, '=');
            if (*end == '=') {
                *end = '\0';
                name = rstrip(start);
                value = lskip(end + 1);
                end = find_char_or_comment(value, '#');
                if (*end == '#')
                    *end = '\0';
                value = rstrip(value);
                value = strip_quotes(value);
                /* Valid name=value pair found, call handler  */
                if (handler(usercfg, name, value) && !error)
                    error = lineno;
            } else if (!error) {
                /* No '=' found on name=value line  */
                error = lineno;
            }
        }
    }
    fclose(fin);
    return error;
}
开发者ID:djmarti,项目名称:ring_network,代码行数:49,代码来源:parser.c


示例5: gadget_print

void gadget_print(gadget_t *gadgets)
{
    /* If we're at a leaf node in the tree... */
    if (gadgets->previous.head == NULL) {
        /* Print instructions from the leaf up to the root as a gadget. */
        x86_insn_t instr;
        char line[1000];
        gadget_t *cursor = gadgets;
        
        while (cursor != NULL) {
            x86_disasm(cursor->instr, cursor->instr_len, 0, 0, &instr);
            x86_format_insn(&instr, line, sizeof(line), intel_syntax);
            rstrip(line);
            tab_to_space(line);

            printf("0x%08x: %-50s\n", cursor->virtual_address, line);

            /* Set cursor to its parent in the tree (closer to the RET). */
            cursor = cursor->next;
        }

        printf("-----------------------\n");
    } else {
        /* We're not at a leaf, so recursively print all of the children. */
        gadget_list_item_t *cursor = gadgets->previous.head;
        while (cursor != NULL) {
            gadget_print(cursor->gadget);
            cursor = cursor->next;
        }
    }
}
开发者ID:defuse,项目名称:gadgetrie,代码行数:31,代码来源:gadget.c


示例6: strip

void strip(
    char *s,
    const char *delimiters)
{
    lstrip(s, delimiters);
    rstrip(s, delimiters);
}
开发者ID:dseomn,项目名称:rpstir,代码行数:7,代码来源:stringutils.c


示例7: flytec_pbrrts

	static void
flytec_pbrrts(flytec_t *flytec)
{
	flytec_puts_nmea(flytec, "PBRRTS,");
	flytec_expectc(flytec, XOFF);
	route_head *route = 0;
	char line[128];
	while (flytec_gets_nmea(flytec, line, sizeof line)) {
		const char *p = line;
		p = match_literal(p, "PBRRTS,");
		int index = 0, count = 0, routepoint_index = 0;
		p = match_unsigned(p, &index);
		p = match_char(p, ',');
		p = match_unsigned(p, &count);
		p = match_char(p, ',');
		p = match_unsigned(p, &routepoint_index);
		p = match_char(p, ',');
		if (!p)
			continue;
		if (routepoint_index == 0) {
			char *name = 0;
			p = match_string_until(p, '\0', 0, &name);
			p = match_eos(p);
			if (p) {
				route = route_head_alloc();
				route->rte_num = index + 1;
				route->rte_name = rstrip(name);
				route_add_head(route);
			} else {
				free(name);
			}
		} else {
			char *name = 0;
			p = match_string_until(p, ',', 1, 0);
			p = match_string_until(p, '\0', 0, &name);
			p = match_eos(p);
			if (p) {
				const waypoint *w = find_waypt_by_name(rstrip(name));
				if (w)
					route_add_wpt(route, waypt_dupe(w));
			}
			free(name);
		}
	}
	flytec_expectc(flytec, XON);
}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:46,代码来源:flytec.c


示例8: initLemmaLexicon

	bool initLemmaLexicon ( const std::string sInputFile )
	{
		std::ifstream *is;

		is = new std::ifstream(sInputFile.c_str());
		if ( is->fail() ) return false;

		bool bReadSuccessful;
		std::string line;
		std::string curToken;

		getline(*is, line);

		while(is && !lstrip(line).empty())
		{
			std::string form;
			std::string lemma;
			std::string tag;

			std::istringstream iss(rstrip(line));
			getline(iss, curToken, '\t');
			ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (form not found)");
			form = curToken;

			//iss = std::istringstream(rstrip(line));
			getline(iss, curToken, '\t');
			ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (lemma not found)");
			lemma = curToken;
			if ( lemma == "=" ) lemma = form; //lexicon uses = to represent that lemma equals form

			//iss = std::istringstream(rstrip(line));
			getline(iss, curToken, '\t');
			ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (tag not found)");
			tag = curToken;

			//add to the word to lemma map
			//wordToLemma.insert(form,lemma);
			wordToLemma[form]=lemma;

			CMorphTag morphTag = lexiconTagToMorphTag(tag);
			std::pair<std::string,CMorphTag> wordMorphPair = std::pair<std::string,CMorphTag>(form,morphTag);

			wordAndTagToLemma[wordMorphPair] = lemma;

		    getline(*is, line);
		}

		is->close();
		delete is;

		//And we are done.
		return true;

	}
开发者ID:zhangmeishan,项目名称:ZPar-Meishan,代码行数:54,代码来源:aux_lexicon.cpp


示例9: lskip

static char *stripquote(char *s)
{
    s = lskip(s);
    char *p=NULL;
    rstrip(s, &p);
    p--;
    if( ISQUOTE(*s) && ISQUOTE(*p) ) {
        s++;
        *p = '\0';
    }
    return s;
}
开发者ID:adenzhang,项目名称:iniparser,代码行数:12,代码来源:iniparser.cpp


示例10: LoadExcludes

void LoadExcludes (char ***ex,int *nex,char *filename) {

  FILE       *fp;
  int         x;
  char      **test;
  static char s[CCHMAXPATHCOMP + 4];
  BOOL        temp = fSuspend;

  if(!ex ||
     !nex ||
     !filename)
    return;
  fSuspend = TRUE;
  if(*ex)
    FreeExcludes(ex,
                 nex);
  x = 0;
  sprintf(s,
          "%s%s",
          mydir,
          filename);
  fp = fopen(s,"r");
  if(fp) {
    while(!feof(fp)) {
      if(!fgets(s,
                sizeof(s),
                fp))
        break;
      s[sizeof(s) - 1] = 0;
      stripcr(s);
      lstrip(rstrip(s));
      if(*s) {
        if(x >= *nex - 1) {
          test = realloc(*ex,
                         sizeof(char *) * (*nex + 2));
          if(test)
            *ex = test;
          else
            break;
        }
        (*ex)[*nex] = strdup(s);
        if((*ex)[*nex]) {
          (*nex)++;
          (*ex)[*nex] = NULL;
        }
        else
          break;
      }
    }
    fclose(fp);
  }
  fSuspend = temp;
}
开发者ID:OS2World,项目名称:UTIL-MOUSE-MSE,代码行数:53,代码来源:EXCLUDES.C


示例11: main

/* print longest input line */
int main()
{
    int len;                /* current line length */
    int cursor;             /* The current position in the array */
    char line[MAXLINE];     /* current input line */ 

    while ((len = getline(line, MAXLINE)) > 0) {
      cursor = rstrip(len,line);
      if (cursor >= 0)
        printf("%s", line);
    }
    return 0;
}
开发者ID:nathanhicks,项目名称:KRC,代码行数:14,代码来源:exercise1-18.c


示例12: main

int main (int argc, char *argv[])
{
    char search_for[80];

    /* take input from the user and search */
    printf("Search for: ");
    fgets(search_for, 80, stdin);
    rstrip(search_for);

    /*find_track(search_for);*/
    find_track_regex(search_for);
    return 0;
}
开发者ID:jasper-chen,项目名称:SoftwareSystems,代码行数:13,代码来源:find_track.c


示例13: main

void main()
{
    char line[MAXLINE];
    int length;
    while(length = getLine(line, MAXLINE) > 0)
    {
        printf("input: %s", line);
        if (length == 0 && line[0] == '\n')
            continue;
        rstrip(line);
        printf(line);
    }
}
开发者ID:chistyakov,项目名称:krc,代码行数:13,代码来源:118.c


示例14: polezero_comment_token

static char *
polezero_comment_token(char *p) {
  if(!p) {
    return p;
  }
  p = strchr(p, ':');
  if(p) {
    p = p + 1;
    p = lstrip(p);
    p = rstrip(p);
  }
  return p;
}
开发者ID:wjlei1990,项目名称:WORKFLOW,代码行数:13,代码来源:polezero.c


示例15: event_init

void
event_init(pmID pmid)
{
    char cmd[MAXPATHLEN];
    int	i, fd;

    for (i = 0; i < numlogfiles; i++) {
	size_t pathlen = strlen(logfiles[i].pathname);

	/*
	 * We support 2 kinds of PATHNAMEs:
	 * (1) Regular paths.  These paths are opened normally.
	 * (2) Pipes.  If the path ends in '|', the filename is
	 *     interpreted as a command which pipes input to us.
	 */
	if (logfiles[i].pathname[pathlen - 1] != '|') {
	    fd = open(logfiles[i].pathname, O_RDONLY|O_NONBLOCK);
	    if (fd < 0) {
		if (logfiles[i].fd >= 0)	/* log once only */
		    __pmNotifyErr(LOG_ERR, "open: %s - %s",
				logfiles[i].pathname, strerror(errno));
	    } else {
		if (fstat(fd, &logfiles[i].pathstat) < 0)
		    if (logfiles[i].fd >= 0)	/* log once only */
			__pmNotifyErr(LOG_ERR, "fstat: %s - %s",
				    logfiles[i].pathname, strerror(errno));
		lseek(fd, 0, SEEK_END);
	    }
	}
	else {
	    strncpy(cmd, logfiles[i].pathname, sizeof(cmd));
	    cmd[pathlen - 1] = '\0';	/* get rid of the '|' */
	    rstrip(cmd);	/* Remove all trailing whitespace. */
	    fd = start_cmd(cmd, &logfiles[i].pid);
	    if (fd < 0) {
		if (logfiles[i].fd >= 0)	/* log once only */
		    __pmNotifyErr(LOG_ERR, "pipe: %s - %s",
					logfiles[i].pathname, strerror(errno));
	    } else {
		if (fd > maxfd)
		    maxfd = fd;
		FD_SET(fd, &fds);
	    }
	}

	logfiles[i].fd = fd;		/* keep file descriptor (or error) */
	logfiles[i].pmid = pmid;	/* string param metric identifier */
	logfiles[i].queueid = pmdaEventNewQueue(logfiles[i].pmnsname, maxmem);
    }
}
开发者ID:andyvand,项目名称:cygpcpfans,代码行数:50,代码来源:event.c


示例16: flytec_pbrwps

	static void
flytec_pbrwps(flytec_t *flytec)
{
	flytec_puts_nmea(flytec, "PBRWPS,");
	flytec_expectc(flytec, XOFF);
	char line[128];
	while (flytec_gets_nmea(flytec, line, sizeof line)) {
		const char *p = line;
		p = match_literal(p, "PBRWPS,");
		int lat_deg = 0, lat_min = 0, lat_mmin = 0;
		p = match_n_digits(p, 2, &lat_deg);
		p = match_n_digits(p, 2, &lat_min);
		p = match_char(p, '.');
		p = match_n_digits(p, 3, &lat_mmin);
		p = match_char(p, ',');
		char lat_hemi = '\0';
		p = match_one_of(p, "NS", &lat_hemi);
		p = match_char(p, ',');
		int lon_deg = 0, lon_min = 0, lon_mmin = 0;
		p = match_n_digits(p, 3, &lon_deg);
		p = match_n_digits(p, 2, &lon_min);
		p = match_char(p, '.');
		p = match_n_digits(p, 3, &lon_mmin);
		p = match_char(p, ',');
		char lon_hemi = '\0';
		p = match_one_of(p, "EW", &lon_hemi);
		p = match_char(p, ',');
		char *name = 0;
		p = match_string_until(p, ',', 1, 0);
		p = match_string_until(p, ',', 1, &name);
		int ele = 0;
		p = match_unsigned(p, &ele);
		p = match_eos(p);
		if (p) {
			waypoint *w = waypt_new();
			w->latitude = lat_deg + lat_min / 60.0 + lat_mmin / 60000.0;
			if (lat_hemi == 'S')
				w->latitude = -w->latitude;
			w->longitude = lon_deg + lon_min / 60.0 + lon_mmin / 60000.0;
			if (lon_hemi == 'W')
				w->longitude = -w->longitude;
			w->altitude = ele;
			w->shortname = rstrip(name);
			waypt_add(w);
		} else {
			free(name);
		}
	}
	flytec_expectc(flytec, XON);
}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:50,代码来源:flytec.c


示例17: while

char *read_clipped_line(FILE *f, char **buffer, size_t *maxlen)
{
    while(readline(f, buffer, maxlen))
    {
        char *line, *comment;

        line = lstrip(*buffer);
        comment = strchr(line, '#');
        if(comment) *(comment++) = 0;

        line = rstrip(line);
        if(line[0]) return line;
    }
    return NULL;
}
开发者ID:rudi-c,项目名称:procedural-terrain-488,代码行数:15,代码来源:ambdec.c


示例18: main

int main(int argc, char *argv[])
{
	char buf[LEN];
	char *t = NULL;

	char **list = NULL;
	int word = 1;
	int i;
	FILE *fp;

	fp = fopen(argv[1], "r");
	assert(fp);

	/* this leaks  you need to fix*/
	while(fgets(buf, LEN, fp)) {
		/* remove new line */
		rstrip(buf); 
		tolowercase(buf);
		t = malloc((strlen(buf) + 1) * sizeof(char));
		assert(t);
		strncpy(t, buf, strlen(buf) + 1);
		/* printf("%s\n", t);  */
		list = realloc(list, word * sizeof(char *)); 
		list[word - 1] = t; 
		word++;
	}
	/* overcounted */
	word--;

	/* print the list */
	for(i = 0; i < word; i++) 
		printf("%s\n", list[i]);

	printf("\n");

	heapsort(list, word, sizeof(list[0]), genericStrcmp);

	/* print the sorted list */
	for(i = 0; i < word; i++) {
		printf("%s\n", list[i]);
		free(list[i]);
	}
	
	free(list);
	fclose(fp);

	return 0; 
}
开发者ID:MintPaw,项目名称:College,代码行数:48,代码来源:test_heap.c


示例19: joinall

void
joinall(char *baseuri, char **uris, int size){
  int i;
  char *parsed = NULL;
  
  for (i = 0; i < size; i++){
    lstrip(uris[i]); rstrip(uris[i]);
    parsed = join(baseuri,uris[i]);
    if (parsed == NULL) {
      continue;
    }
    free(uris[i]);
    uris[i] = NULL;
    uris[i] = parsed;
    parsed = NULL;
  }
}
开发者ID:Git8fire,项目名称:CSpider,代码行数:17,代码来源:uriparser.c


示例20: main

int main(void) {

	const char* t1 = "This is a test sentence to see if\nwhitespace removal is working";
	const char* t2 = "gggThis tests if lstrip is working";
	const char* t3 = "This tests if rstrip is workinghhh";
	const char* t4 = "000 this tests is strip is working 000";
	const char* t5 = "this tEsts if UpPer is WorkINg";
	const char* t6 = "THIS TESTS if LOwEr is WORKInG"; 

	printf("%s\n %s\n\n", t1, removeWhiteSpace(t1));
	printf("%s\n %s\n\n", t2, lstrip(t2, 'g'));
	printf("%s\n %s\n\n", t3, rstrip(t3, 'h'));
	printf("%s\n %s\n\n", t4, strip(t4, '0'));
	printf("%s\n %s\n\n", t5, upper(t5));
	printf("%s\n %s\n\n", t6, lower(t6));
	

	return 0;
}
开发者ID:Rodot-,项目名称:SpaceGameThing,代码行数:19,代码来源:parseTest.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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