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


C++ Getline函数代码示例

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


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

示例1: pcre_compile

/* -----------------------------------------------------------------------------
 * Swig_string_regex()
 *
 * Executes a regular expression substitution. For example:
 *
 *   Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
 * ----------------------------------------------------------------------------- */
String *Swig_string_regex(String *s) {
  const int pcre_options = 0;

  String *res = 0;
  pcre *compiled_pat = 0;
  const char *pcre_error, *input;
  int pcre_errorpos;
  String *pattern = 0, *subst = 0;
  int captures[30];

  if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
    int rc;

    compiled_pat = pcre_compile(
          Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
    if (!compiled_pat) {
      Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
          pcre_error, Char(pattern), pcre_errorpos);
      exit(1);
    }
    rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
    if (rc >= 0) {
      res = replace_captures(rc, input, subst, captures, pattern, s);
    } else if (rc != PCRE_ERROR_NOMATCH) {
      Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
	rc, Char(pattern), input);
      exit(1);
    }
  }

  DohDelete(pattern);
  DohDelete(subst);
  pcre_free(compiled_pat);
  return res ? res : NewStringEmpty();
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:42,代码来源:misc.c

示例2: Swig_name_regexmatch_value

int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
  pcre *compiled_pat;
  const char *err;
  int errpos;
  int rc;

  compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
  if (!compiled_pat) {
    Swig_error("SWIG", Getline(n),
               "Invalid regex \"%s\": compilation failed at %d: %s\n",
               Char(pattern), errpos, err);
    exit(1);
  }

  rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
  pcre_free(compiled_pat);

  if (rc == PCRE_ERROR_NOMATCH)
    return 0;

  if (rc < 0 ) {
    Swig_error("SWIG", Getline(n),
               "Matching \"%s\" against regex \"%s\" failed: %d\n",
               Char(s), Char(pattern), rc);
    exit(1);
  }

  return 1;
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:29,代码来源:naming.c

示例3: main

int main()
{
	char s1[MAXLINE], s2[MAXLINE];
	Getline(s1, MAXLINE);
	Getline(s2, MAXLINE);
	printf("%d\n", any(s1, s2));
	return 0;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:8,代码来源:2-05.c

示例4: Swig_extend_merge

void Swig_extend_merge(Node *cls, Node *am) {
  Node *n;
  Node *csym;

  n = firstChild(am);
  while (n) {
    String *symname;
    if (Strcmp(nodeType(n),"constructor") == 0) {
      symname = Getattr(n,"sym:name");
      if (symname) {
	if (Strcmp(symname,Getattr(n,"name")) == 0) {
	  /* If the name and the sym:name of a constructor are the same,
             then it hasn't been renamed.  However---the name of the class
             itself might have been renamed so we need to do a consistency
             check here */
	  if (Getattr(cls,"sym:name")) {
	    Setattr(n,"sym:name", Getattr(cls,"sym:name"));
	  }
	}
      } 
    }

    symname = Getattr(n,"sym:name");
    DohIncref(symname);
    if ((symname) && (!Getattr(n,"error"))) {
      /* Remove node from its symbol table */
      Swig_symbol_remove(n);
      csym = Swig_symbol_add(symname,n);
      if (csym != n) {
	/* Conflict with previous definition.  Nuke previous definition */
	String *e = NewStringEmpty();
	String *en = NewStringEmpty();
	String *ec = NewStringEmpty();
	Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
	Printf(en,"%%extend definition of '%s'.",symname);
	SWIG_WARN_NODE_BEGIN(n);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
	Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
	SWIG_WARN_NODE_END(n);
	Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, 
	       Getfile(n),Getline(n),en);
	Setattr(csym,"error",e);
	Delete(e);
	Delete(en);
	Delete(ec);
	Swig_symbol_remove(csym);              /* Remove class definition */
	Swig_symbol_add(symname,n);            /* Insert extend definition */
      }
    }
    n = nextSibling(n);
  }
}
开发者ID:kkaempf,项目名称:swig,代码行数:52,代码来源:extend.c

示例5: split_regex_pattern_subst

static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
{
  const char *pats, *pate;
  const char *subs, *sube;

  /* Locate the search pattern */
  const char *p = Char(s);
  if (*p++ != '/') goto err_out;
  pats = p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  pate = p;

  /* Locate the substitution string */
  subs = ++p;
  p = strchr(p, '/');
  if (!p) goto err_out;
  sube = p;

  *pattern = NewStringWithSize(pats, (int)(pate - pats));
  *subst   = NewStringWithSize(subs, (int)(sube - subs));
  *input   = p + 1;
  return 1;

err_out:
  Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
  exit(1);
}
开发者ID:EemeliSyynimaa,项目名称:yam2d,代码行数:28,代码来源:misc.c

示例6: VetoThres2

void VetoThres2(Int_t Lo, Int_t Hi)
{
  TCanvas* Window;
  TTimer* Refresh;
  TH1F* Energy;
  Char_t Buff[256];
  Char_t* Keyb;
  Double_t Pos[438];

  Window = new TCanvas();
  Window->SetCrosshair();
  Window->ToggleEventStatus();
  Refresh = new TTimer("Flush()", 50, kFALSE);
  for(Int_t ch=Lo; ch<Hi+1; ch++)
  {
    sprintf(Buff, "Veto_Energy%d", ch);
    Energy = (TH1F*)gROOT->FindObject(Buff);
    Energy->GetXaxis()->SetRange(0, 250);
    Energy->Draw();
    Window->Update();
    sprintf(Buff, "Threshold for %d: ", ch);
    Refresh->TurnOn();
    Refresh->Reset();
    Keyb = Getline(Buff);
    Refresh->TurnOff();
    Pos[ch] = atof(Keyb);
  }
  for(Int_t ch=Lo; ch<Hi+1; ch++)
    printf("%5.1f\n", Pos[ch]);
}
开发者ID:A2-Collaboration,项目名称:acqu,代码行数:30,代码来源:LadderTimes.cpp

示例7: strchr

/* internal function for processing an encoding */
static DOH *encode(char *name, DOH *s) {
    DOH *handle, *ns;
    DOH *(*fn) (DOH *);
    long pos;
    char *cfmt = strchr(name, ':');
    DOH *tmp = 0;
    if (cfmt) {
        tmp = NewString(cfmt + 1);
        Append(tmp, s);
        Setfile(tmp, Getfile((DOH *) s));
        Setline(tmp, Getline((DOH *) s));
        *cfmt = '\0';
    }
    if (!encodings || !(handle = Getattr(encodings, name))) {
        return Copy(s);
    }
    if (tmp)
        s = tmp;
    pos = Tell(s);
    Seek(s, 0, SEEK_SET);
    fn = (DOH *(*)(DOH *)) Data(handle);
    ns = (*fn) (s);
    Seek(s, pos, SEEK_SET);
    if (tmp)
        Delete(tmp);
    return ns;
}
开发者ID:sunaku,项目名称:swig-ruby-ffi,代码行数:28,代码来源:fio.c

示例8: Getattr

Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
  if (!namewarn_hash && !namewarn_list)
    return 0;
  if (n) {
    /* Return in the obvious cases */
    if (!name || !Swig_need_name_warning(n)) {
      return 0;
    } else {
      String *access = Getattr(n, "access");
      int is_public = !access || Equal(access, "public");
      if (!is_public && !Swig_need_protected(n)) {
	return 0;
      }
    }
  }
  if (name) {
    /* Check to see if the name is in the hash */
    Hash *wrn = Swig_name_object_get(Swig_name_namewarn_hash(), prefix, name, decl);
    if (wrn && !Swig_name_match_nameobj(wrn, n))
      wrn = 0;
    if (!wrn) {
      wrn = Swig_name_nameobj_lget(Swig_name_namewarn_list(), n, prefix, name, decl);
    }
    if (wrn && Getattr(wrn, "error")) {
      if (n) {
	Swig_error(Getfile(n), Getline(n), "%s\n", Getattr(wrn, "name"));
      } else {
	Swig_error(cparse_file, cparse_line, "%s\n", Getattr(wrn, "name"));
      }
    }
    return wrn;
  } else {
    return 0;
  }
}
开发者ID:progranism,项目名称:Allegro-5-SWIG-Wrapper,代码行数:35,代码来源:naming.c

示例9: NewStringEmpty

String *Swig_stringify_with_location(DOH *object) {
  String *str = NewStringEmpty();

  if (!init_fmt)
    Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);

  if (object) {
    int line = Getline(object);
    String *formatted_filename = format_filename(Getfile(object));
    if (line > 0) {
      Printf(str, diag_line_fmt, formatted_filename, line);
    } else {
      Printf(str, diag_eof_fmt, formatted_filename);
    }
    if (Len(object) == 0) {
      Printf(str, "[EMPTY]");
    } else {
      Printf(str, "[%s]", object);
    }
    Delete(formatted_filename);
  } else {
    Printf(str, "[NULL]");
  }

  return str;
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:26,代码来源:error.c

示例10: NewStringEmpty

String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
{
  String *result = NewStringEmpty();
  const char *p = Char(subst);

  while (*p) {
    /* Copy part without substitutions */
    const char *q = strchr(p, '\\');
    if (!q) {
      Write(result, p, strlen(p));
      break;
    }
    Write(result, p, q - p);
    p = q + 1;

    /* Handle substitution */
    if (*p == '\0') {
      Putc('\\', result);
    } else if (isdigit((unsigned char)*p)) {
      int group = *p++ - '0';
      if (group < num_captures) {
	int l = captures[group*2], r = captures[group*2 + 1];
	if (l != -1) {
	  Write(result, input + l, r - l);
	}
      } else {
	Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
	    Char(pattern), input, group, num_captures-1);
      }
    }
  }

  return result;
}
开发者ID:Distrotech,项目名称:swig,代码行数:34,代码来源:misc.c

示例11: main

int main()	/* Reverse Polish notation */
{
	int type;
	double op2;
	char s[MAXOP];
	double ans = 0.0;
	while (Getline(expression, MAXOP))
		while ((type = getop(s)) != EOF) {
			switch (type) {
				case NUMBER:
					push(atof(s));
					break;
				case 'a':
					push(ans);
					break;
				case '+':
					push(pop() + pop());
					break;
				case '*':
					push(pop() * pop());
					break;
				case '-':
					op2 = pop();
					push(pop() - op2);
					break;
				case '/':
					op2 = pop();
					if (op2 != 0.0) push(pop() / op2);
					else printf("error: zero divisor\n");
					break;
				case '%':
					op2 = pop();
					if (op2 != 0.0) push(fmod(pop(), op2));	/* use g++ to compile */
					else printf("error: zero divisor\n");
					break;
				case SIN:
					push(sin(pop()));
					break;
				case EXP:
					push(exp(pop()));
					break;
				case POW:
					op2 = pop();
					push(pow(pop(), op2));
					break;
				case '\n':
					ans = pop();
					printf("\t%.8g\n", ans);
					break;
				default:
					printf("error: unknown command %s\n", s);
					break;
			}
			if (type == '\n') break;
		}
	return 0;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:57,代码来源:4-10-main.c

示例12: SwigScanner_push

void 
SwigScanner_push(SwigScanner *s, String *txt) {
  assert(s && txt);
  Push(s->scanobjs,txt);
  if (s->str) Delete(s->str);
  s->str = txt;
  DohIncref(s->str);
  s->line = Getline(txt);
}
开发者ID:kanbang,项目名称:Colt,代码行数:9,代码来源:scanner.c

示例13: Swig_require

int 
Swig_require(const char *ns, Node *n, ...) {
  va_list ap;
  char *name;
  DOH *obj;
  char   temp[512];

  va_start(ap, n);
  name = va_arg(ap, char *);
  while (name) {
    int newref = 0;
    int opt = 0;
    if (*name == '*') {
      newref = 1;
      name++;
    } else if (*name == '?') {
      newref = 1;
      opt = 1;
      name++;
    }
    obj = Getattr(n,name);
    if (!opt && !obj) {
      Printf(stderr,"%s:%d. Fatal error (Swig_require).  Missing attribute '%s' in node '%s'.\n", 
	     Getfile(n), Getline(n), name, nodeType(n));
      assert(obj);
    }
    if (!obj) obj = DohNone;
    if (newref) {
      /* Save a copy of the attribute */
      strcpy(temp,ns);
      strcat(temp,":");
      strcat(temp,name);
      Setattr(n,temp,obj);
    } 
    name = va_arg(ap, char *);
  }
  va_end(ap);

  /* Save the view */
  {
    String *view = Getattr(n,"view");
    if (view) {
      if (Strcmp(view,ns) != 0) {
	strcpy(temp,ns);
	strcat(temp,":view");
	Setattr(n,temp,view);
	Setattr(n,"view",ns);
      }
    } else {
      Setattr(n,"view",ns);
    }
  }

  return 1;
}
开发者ID:janearc,项目名称:posixnap_old,代码行数:55,代码来源:tree.c

示例14: main

int main()
{
	int i;
	char len[MAX_LEN];

	Getline(len, MAX_LEN);
	for(i = 0; len[i] != '\0'; i++)
		;
	reverse_line(len, i);
	
}
开发者ID:wxiaodong0829,项目名称:aka_edu_learned,代码行数:11,代码来源:reverse_doc.c

示例15: main

int main()
{
	char line[MAXLINE];
	int found = 0;

	while (Getline(line, MAXLINE) > 0)
		if (strrindex(line, pattern) >= 0) {
			printf("%s", line);
			found++;
		}
	return found;
}
开发者ID:RuohengLiu,项目名称:learn-to-code,代码行数:12,代码来源:4-01-main.c


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