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


C++ rstrip函数代码示例

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


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


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