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


C++ istream::good方法代码示例

本文整理汇总了C++中istream::good方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::good方法的具体用法?C++ istream::good怎么用?C++ istream::good使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在istream的用法示例。


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

示例1: ReadTextFile

int TextFileScript::ReadTextFile (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) {
    int line_height;
    char delim;
    char pathname[BUFSIZ];

    TextFileComp* textfilecomp = (TextFileComp*)addr1;

    in >> line_height;
    ParamList::skip_space(in); 
    in >> delim; 
    if (delim == ',' && in.good()) {
	ParamList::skip_space(in);
	if (ParamList::parse_pathname(in, pathname, BUFSIZ, textfilecomp->GetBaseDir()) != 0) 
	    return -1;
    }

    if (!in.good()) {
	return -1;
    }
    else {
	textfilecomp->_pathname = strdup(pathname);
    	TextGraphic* tg = new TextGraphic("", line_height); 	
	tg->SetFont(psstdfont);
	tg->SetColors(psblack, nil);
	tg->FillBg(false);
	textfilecomp->SetGraphic(tg);
        return 0;
    }
}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:29,代码来源:textfile.c

示例2: uniqueKeywords

shared_ptr<DocumentDatabase> DocumentDatabaseBuilder::create(istream& keywordsStream,
		istream& documentsStream) {
	shared_ptr<DocumentDatabase> dbPtr = make_shared<DocumentDatabase>();

	if (!keywordsStream.good()) {
		cerr << "Bad keywords stream." << endl;
		return nullptr;
	}

	shared_ptr<Document> keywords = documentBuilderPtr->createOne(keywordsStream);
	unordered_set<string> uniqueKeywords(
		keywords->getStemmedContent().begin(),
		keywords->getStemmedContent().end());

	keywords->getStemmedContent() = vector<string>(
		uniqueKeywords.begin(), uniqueKeywords.end());
	
	dbPtr->getKeywords() = keywords;

	if (!documentsStream.good()) {
		cerr << "Bad documents stream." << endl;
		return nullptr;
	}

	dbPtr->getDocuments() = documentBuilderPtr->createMany(documentsStream);

	return dbPtr;
}
开发者ID:kareth,项目名称:ezi,代码行数:28,代码来源:document_database.cpp

示例3: while

bool
fcnn::internal::read_comment(istream &is, string &s)
{
    if (!is.good() || is.eof()) return false;
    char c;
    s.clear();
    c = is.peek();
    if (c != '#') return false;
    is.get(c);

start_line:
    do { is.get(c); }
    while ((is.good() && !is.eof()) && ((c == ' ') || (c == '\t')));
    if (is.eof()) return true;
    if (is.fail()) return false;
    while ((is) && (c != '\n')) {
        s += c;
        is.get(c);
    }
    if (is.eof()) return true;
    if (is.fail()) return false;
    if (c == '\n') {
        if (is.peek() == '#') { s += c; goto start_line; }
        else return true;
    }
    return true;
}
开发者ID:bakaschwarz,项目名称:ptfc_fcnn,代码行数:27,代码来源:utils.cpp

示例4: read

	void read(istream& is)
	{
		vector<char> line;
		while (is.good())
		{
			// Read until the end of the line is found.
			line.clear();
			int c;
			while (is.good() && (c = is.get()) != '\n')
				line.push_back((char)c);

			// Skip empty lines or comment lines.
			if (line.empty() || line[0] == '#')
				continue;

			// Parse the line, moving its contents into one of the sets.
			size_t sol = 1;
			for (sol = 1; sol < line.size() && (line[sol] == ' ' || line[sol] == '\t'); sol++);
			string param(&line[sol], line.size()-sol);

			switch (line[0]) {
				case '+': additions.insert(param); break;
				case '-': deletions.insert(param); break;
				case 'p': patches.insert(param); break;
				default: std::cerr << "ignoring garbage line " << string(&line[0], line.size()) << " in index\n";
			}
		}
	}
开发者ID:fabianschuiki,项目名称:Auris,代码行数:28,代码来源:Index.hpp

示例5: scanString

string scanString(istream& input)
{
    // TODO: this code does not check for buf overrun
    // TODO: this code doesn't properly check for FEOF condition
    char buf[4096];
    char *ptr=buf;
    char c;
    while(input.good()){
        input.get(c);
        if(!isspace(c)) break;
    }
    if(!input.good()) return "";

    if(c!='"'){
        while(input.good()){
            *ptr++=c;
            input.get(c);
            if(isspace(c)) break;
        }
    }else{
        while(input.good()){
            input.get(c);
            if(c=='\\'){
                input.get(c);
                *ptr++=c;
            }else if(c=='"'){
                break;
            }else{
                *ptr++=c;
            }
        }
    }
    *ptr++=0;
    return string(buf);
}
开发者ID:wdas,项目名称:partio,代码行数:35,代码来源:GEO.cpp

示例6: PIVOT_parseinput

/**
   Parses an input stream.  The file has format: <gadget type> <reg> <offset>.
*/
pivot_set PIVOT_parseinput(istream &f) {
  pivot_set ps; 

  while (f.good()) {
    pivot_t p;
    string s;


    /* Read gadget address. */
    f >> hex >> p.address;

    if (!f.good()) break;

    /* Set pivot type. */
    f >> s;
    p.t = PIVOT_parse_pivottype(s);
    if (p.t == UNKNOWN) {
      break;
    }

    /* Read register name. */
    f >> s;
    p.base = PIVOT_string_reg(s);
    
    /* Read offset. */
    f >> hex >> p.offset;

    /* Add pivot to pivot set. */
    ps.insert(p);
  }

  return ps; /* return by value; slow but easy */
}
开发者ID:0day1day,项目名称:bap,代码行数:36,代码来源:pivot.cpp

示例7: readAdjList

/** Read adjacency list from an input stream, add it to the graph.
 *  @param in is an open input stream
 *  @return true on success, false on error.
 */
bool Graph::readAdjList(istream& in) {
	if (!Util::verify(in,'[')) return false;
	vertex u;
	if (!Adt::readIndex(in,u)) return false;
	if (u > n()) expand(u,M());
	if (!Util::verify(in,':')) return false;
	while (in.good() && !Util::verify(in,']')) {
		vertex v; edge e;
		if (!Adt::readIndex(in,v)) return false;
		if (v > n()) expand(v,M());
		if (m() >= M()) expand(n(),max(1,2*M()));
		if (!Util::verify(in,'#')) {
			if (u < v) join(u,v);
		} else {
			if (!Util::readInt(in,e)) return false;
			if (e >= M()) expand(n(),e);
			if (u < v) {
				if (joinWith(u,v,e) != e) return false;
			} else {
				if ((u == left(e)  && v != right(e)) ||
				    (u == right(e) && v != left(e)))
					return false;
			}
		}
	}
	return in.good();
}
开发者ID:tts-ll,项目名称:grafalgo,代码行数:31,代码来源:Graph.cpp

示例8: while

//---------------------------------------------------------------------------
unique_ptr<Expression> ExpressionParser::parseSingleExpression(istream& input, ExpressionType lastExpression, Environment& environment)
{
   // read
   harriet::skipWhiteSpace(input);
   char a = input.get();
   if(!input.good())
      return nullptr;

   // other single letter operators
   if(a == '(') return make_unique<OpeningPharentesis>();
   if(a == ')') return make_unique<ClosingPharentesis>();
   if(a == '+') return make_unique<PlusOperator>();
   if(a == '-') { if(lastExpression==ExpressionType::TBinaryOperator || lastExpression==ExpressionType::TUnaryOperator || lastExpression==ExpressionType::TOpeningPharentesis) return make_unique<UnaryMinusOperator>(); else return make_unique<MinusOperator>(); }
   if(a == '*') return make_unique<MultiplicationOperator>();
   if(a == '/') return make_unique<DivisionOperator>();
   if(a == '%') return make_unique<ModuloOperator>();
   if(a == '^') return make_unique<ExponentiationOperator>();
   if(a == '&') return make_unique<AndOperator>();
   if(a == '|') return make_unique<OrOperator>();
   if(a=='>' && input.peek()!='=') return make_unique<GreaterOperator>();
   if(a=='<' && input.peek()!='=') return make_unique<LessOperator>();
   if(a=='!' && input.peek()!='=') return make_unique<NotOperator>();
   if(a=='=' && input.peek()!='=') return make_unique<AssignmentOperator>();

   // check for string
   char b = input.get();
   if(a=='"') {
      string result;
      while(b!='"' && a!='\\') {
         if(!input.good())
            throw harriet::Exception{"unterminated string expression"};
         result.push_back(b);
         a = b;
         b = input.get();
      }
      return make_unique<StringValue>(result);
   }

   // check for two signed letters
   if(input.good()) {
      if(a=='=' && b=='=') return make_unique<EqualOperator>();
      if(a=='>' && b=='=') return make_unique<GreaterEqualOperator>();
      if(a=='<' && b=='=') return make_unique<LessEqualOperator>();
      if(a=='!' && b=='=') return make_unique<NotEqualOperator>();
      input.unget();
   } else {
      input.clear();
   }

   // check for a number
   input.unget();
   if(isdigit(a)) {
      int32_t intNum;
      input >> intNum;
      if(input.peek()=='.' && input.good()) {
         float floatNum;
         input >> floatNum;
         return make_unique<FloatValue>(floatNum+intNum);
      } else {
         return make_unique<IntegerValue>(intNum);
开发者ID:alexandervanrenen,项目名称:Harriet,代码行数:61,代码来源:ExpressionParser.cpp

示例9: scan_pgn

int ChessIO::scan_pgn(istream &game_file, vector<string> &contents)
{
    Board board;
    int c;

    while (game_file.good() && !game_file.eof())
    {
        // Collect the header:
        long first;
        vector<Header> hdrs;
        string eventStr;
        collect_headers(game_file, hdrs, first);
        if (get_header(hdrs,"Event",eventStr))
        {
           // We have the headers, munge them into a single-line game
           // description. Append the index to the game so the GUI
           // can navigate to the game when the user clicks on the
           // description.
           string descr;
           get_game_description(hdrs, descr, first);
           contents.push_back(descr);
        }
        hdrs.clear();

        while (game_file.good() && !game_file.eof())
        {
           if ((c = game_file.get()) == '[')
           {
               game_file.putback(c);
               break;
           }
        }
    }
    return 1;
}
开发者ID:jdart1,项目名称:arasan-chess,代码行数:35,代码来源:chessio.cpp

示例10: assertfail

static void
loadmult_datafile_sub(istream &f, bool binary, const char *fname, 
                  xvec_t &xp, yvec_t &yp, int &maxdim, int maxrows)
{
  cout << "# Reading file " << fname << endl;
  if (! f.good())
    assertfail("Cannot open " << fname);

  int pcount = 0;
  while (f.good() && maxrows--)
    {
	double y;
      	SVector x;
	y = (f.get());
        x.load(f);
      
      if (f.good())
        {          
          xp.push_back(x);
          yp.push_back(y);
          pcount += 1;
          if (x.size() > maxdim)
            maxdim = x.size();
        }
    }
  cout << "# Read " << pcount << " examples." << endl;
  

}
开发者ID:yqxian,项目名称:zsl,代码行数:29,代码来源:data_mult.cpp

示例11: while

/**
 * \brief Tokenize a stream of XML by chopping it up into XMLTokens and
 *        returning a vector of these tokens.
 *
 * This function consumes all data in the stream
 */
vector<XMLToken>
XMLToken::tokenize(istream& istrm) {
  vector<XMLToken> tokens;
  while (istrm.good()) {
    chomp(istrm);
    if (!istrm.good()) break;

    // parse tag
    if (istrm.peek() == '<') {
      string tagname;
      bool isEndTag = false;

      istrm.get(); // skip <
      chomp(istrm);
      if (!istrm.good()) break;
      if (istrm.peek() == '/') {
          istrm.get(); // skip /
          isEndTag = true;
      }

      while (istrm.good() && (istrm.peek() != '>'))
          tagname += istrm.get();
      istrm.get(); // skip >
      tokens.push_back(XMLToken(tagname,isEndTag));
    } else {
      // parse string
      string buf = "";
      while (istrm.good() && (istrm.peek() != '<'))
          buf += istrm.get();
      tokens.push_back(XMLToken(buf));
    }
  }
  return tokens;
}
开发者ID:cooleel,项目名称:piranha,代码行数:40,代码来源:SimpleXML.cpp

示例12: while

void tune::readX0(istream &is) 
{
   int c;
   while (is.good() && (c = is.get()) != '(') ;
   for (int i = 0; is.good() && i < tune::NUM_TUNING_PARAMS; i++) {
      is >> tune::tune_params[i].current;
   }
}
开发者ID:jmptrader,项目名称:arasan-chess,代码行数:8,代码来源:tune.cpp

示例13: getImageList

list<string> getImageList(istream& input) {
  list<string> imlist;
  while (!input.eof() && input.good()) {
    string imname;
    input >> imname;
    if(!input.eof() && input.good())
      imlist.push_back(imname);
  }
  return imlist;
}
开发者ID:LuisServin,项目名称:catkin_ws,代码行数:10,代码来源:w2d_time.cpp

示例14: skip_comment

// eats up a comment, stream must start with "/*", eats everything until "*/"
void skip_comment(istream& in) {
    int i = in.get();
    int j = in.get();
    if (i != '/' || j != '*') {
        throw BadInputException("Bad comment start!");
    }
    while (in.good()) {
        in.ignore(numeric_limits<streamsize>::max(), '*'); //ignore everything until next '*'
        i = in.get();
        if (in.good() && i == '/') return; // successfully skipped comment
    }
    throw BadInputException("Incomplete comment!");
}
开发者ID:mkoeppe,项目名称:Normaliz,代码行数:14,代码来源:input.cpp

示例15: setState

bool EGS_RandomGenerator::setState(istream &data) {
    if( !egsGetI64(data,count) ) return false;
    int np1;
    data >> np1 >> ip;
    if( !data.good() || data.fail() || data.eof() ) return false;
    if( np1 < 1 ) return false;
    if( np1 != np && np > 0 ) {
        delete [] rarray; rarray = new EGS_Float [np1];
    }
    np = np1;
    for(int j=0; j<np; j++) data >> rarray[j];
    if( !data.good() ) return false;
    return setPrivateState(data);
}
开发者ID:tener32,项目名称:EGSnrc,代码行数:14,代码来源:egs_rndm.cpp


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