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


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

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


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

示例1: parseProgram

void parseProgram(istream &inf, vector<Statement *> & program)
{
	program.push_back(NULL);

	string line;
	while( ! inf.eof() )
	{
		getline(inf, line);
		program.push_back( parseLine( line ) );

	}
}
开发者ID:nchen2211,项目名称:DataStructure,代码行数:12,代码来源:Facile.cpp

示例2: LoadInput

//加载输入流
bool LanguageParsers::LoadInput(istream& ins)
{
	if(ins.fail())
	{
		return false;
	}

	this->input_symbols.clear();

	char c=ins.get();
	if(!ins.eof())
	{
		do
		{
			this->input_symbols.push_back(Symbols(c));
			c=ins.get();
		}while(!ins.eof());
	}

	return true;
}
开发者ID:wllxyz,项目名称:xyz,代码行数:22,代码来源:LanguageParsers.cpp

示例3: skipWhiteSpace

// Consume whitespace characters from stream.  Leaves the stream
// pointing at the next non-whitespace char (or possibly eof());
void skipWhiteSpace(istream &istr) {

  char next;
  istr >> next; // take advantage of the fact that >> uses whitespace as a field
                // separator
  if (!istr.eof()) {
    // If eof() is set, it means we didn't find any tokens after the whitespace.
    // In this case
    // there's nother to put back, and doing so would unset the eof bit.
    istr.putback(next);
  }
}
开发者ID:liyulun,项目名称:mantid,代码行数:14,代码来源:SimpleJSON.cpp

示例4: readExpression

void readExpression(istream& is, bitset* minterms, bitset* donotcare, uint8_t* varsCount) {
    char temp = '0';
    long long number;
    bitset* currentSet = minterms;
    is >> number;
    *varsCount = number;
    cout << *varsCount << endl;
    if (is.fail() || int(*varsCount) > int(16))
        throw logic_error("Variables count could not be read or invalid");
    is >> temp;
    if (is.fail() || is.eof() || temp != ';')
        throw logic_error("Syntax error: expected ';'");
    _t_minterm maxValue = (pow(2, *varsCount) - 1);
    minterms->resize(maxValue + 1);
    donotcare->resize(maxValue + 1);
    is >> number;
    if (!is.eof()) {
        while (true) {
            if (is.fail())
                throw logic_error("Syntax error");
            if (number > maxValue)
                throw out_of_range("Invalid min-term value: given value is greater than maximum");
            currentSet->set(number);
            temp = '0';
            is >> temp;
            if (is.fail() || is.eof() || (temp != ';' && temp != ','))
                throw logic_error("Syntax error: expected ';'");
            if (temp == ',') {
                is >> number;
            } else if (temp == ';') {
                if (currentSet == donotcare)
                    break;
                else {
                    currentSet = donotcare;
                    is >> number;
                    if (is.eof())
                        break;
                }
            } else {
                throw logic_error("Unhandled weird exception");
开发者ID:hussam-a,项目名称:circ-min,代码行数:40,代码来源:Util.cpp

示例5: read

void HumdrumFileBasic::read(istream& inStream) {
   char* templine;
   templine = new char[4096];
   int linecount = 0;
   while (!inStream.eof()) {
      inStream.getline(templine, 4096);
#ifdef USING_URI
      if ((linecount++ == 0) && (strstr(templine, "://") != NULL)) {
         if (strncmp(templine, "http://", strlen("http://")) == 0) {
            readFromHttpURI(templine);
            delete [] templine;
            return;
         }
         if (strncmp(templine, "humdrum://", strlen("humdrum://")) == 0) {
            readFromHumdrumURI(templine);
            delete [] templine;
            return;
         } 
         if (strncmp(templine, "hum://", strlen("hum://")) == 0) {
            readFromHumdrumURI(templine);
            delete [] templine;
            return;
         } 
         if (strncmp(templine, "h://", strlen("h://")) == 0) {
            readFromHumdrumURI(templine);
            delete [] templine;
            return;
         } 
      }
#endif
      if (inStream.eof() && (strcmp(templine, "") == 0)) {
         break;
      } else {
         appendLine(templine);
      }
   }
   analyzeSpines();
   analyzeDots();
   delete [] templine;
}
开发者ID:mdsmus,项目名称:humdrum,代码行数:40,代码来源:HumdrumFileBasic.cpp

示例6: splitString

	vector<string> splitString(char* rawSplit, istream& source, char delimiter, unsigned int estimatedSplitCount)
	{
		vector<string> splits;
		splits.reserve(estimatedSplitCount);

		while (!source.eof())
		{
			source.getline(rawSplit, MAX_SPLIT_LENGTH, delimiter);
			splits.push_back(rawSplit);
		}

		return splits;
	}
开发者ID:simplegsb,项目名称:gazengine,代码行数:13,代码来源:Direct3D10ModelFactory.cpp

示例7: SkipOnError

bool SkipOnError(istream& istr){
  if (istr.fail()){
    if (istr.eof()){
      exit(EXIT_FAILURE);
    }

    // skip one character
    char ch;
    istr.clear();
    istr >> ch;
    return true;
  } else {
    return false;
开发者ID:DaisukeYamato,项目名称:book,代码行数:13,代码来源:Input2.cpp

示例8: createProcesses

void createProcesses(istream& ifs, vector<Process*>& processes)
{	
	while(!ifs.eof())
	{
		unsigned id;
		unsigned arrivalTime;
		unsigned totalCPU;
		unsigned averageBurst;
		ifs >> id >> arrivalTime >> totalCPU >> averageBurst;
		Process* p = new Process(id, arrivalTime, totalCPU, averageBurst);
		processes.push_back(p);
	}
}
开发者ID:QiaoYangHan,项目名称:ProcessScheduler,代码行数:13,代码来源:main.cpp

示例9: getLine

bool getLine( istream &fileP, vector< string > &item )
{
  if (fileP.eof())
    return false;

  string line;
  if (!getline(fileP, line))
    return false;

  item = splitLine(line.c_str());

  return true;
}
开发者ID:840462307cn,项目名称:mosesdecoder,代码行数:13,代码来源:consolidate-main.cpp

示例10: returnCh

// DO NOT CHANGE THIS PART...
// DO NOT CHANGE THIS PART...
//
// This part will be used by TA to test your program.
//
// TA will use "make -DTA_KB_SETTING" to test your program
//
ParseChar
CmdParser::getChar(istream& istr) const
{
   char ch = mygetc(istr);

   if (istr.eof())
      return returnCh(INPUT_END_KEY);
   switch (ch) {
      // Simple keys: one code for one key press
      // -- The following should be platform-independent
      case LINE_BEGIN_KEY:  // Ctrl-a
      case LINE_END_KEY:    // Ctrl-e
      case INPUT_END_KEY:   // Ctrl-d
      case TAB_KEY:         // tab('\t') or Ctrl-i
      case NEWLINE_KEY:     // enter('\n') or ctrl-m
         return returnCh(ch);

      // -- The following simple/combo keys are platform-dependent
      //    You should test to check the returned codes of these key presses
      // -- You should either modify the "enum ParseChar" definitions in
      //    "charDef.h", or revise the control flow of the "case ESC" below
      case BACK_SPACE_KEY:
         return returnCh(ch);

      // Combo keys: multiple codes for one key press
      // -- Usually starts with ESC key, so we check the "case ESC"
      case ESC_KEY: {
         char combo = mygetc(istr);
         // Note: ARROW_KEY_INT == MOD_KEY_INT, so we only check MOD_KEY_INT
         if (combo == char(MOD_KEY_INT)) {
            char key = mygetc(istr);
            if ((key >= char(MOD_KEY_BEGIN)) && (key <= char(MOD_KEY_END))) {
               if (mygetc(istr) == MOD_KEY_DUMMY)
                  return returnCh(int(key) + MOD_KEY_FLAG);
               else return returnCh(UNDEFINED_KEY);
            }
            else if ((key >= char(ARROW_KEY_BEGIN)) &&
                     (key <= char(ARROW_KEY_END)))
               return returnCh(int(key) + ARROW_KEY_FLAG);
            else return returnCh(UNDEFINED_KEY);
         }
         else { mybeep(); return getChar(istr); }
      }
      // For the remaining printable and undefined keys
      default:
         if (isprint(ch)) return returnCh(ch);
         else return returnCh(UNDEFINED_KEY);
   }

   return returnCh(UNDEFINED_KEY);
}
开发者ID:ATeamMember,项目名称:dsnp_hw3_2,代码行数:58,代码来源:cmdCharDef.cpp

示例11: readPmx

void ScorePageBase::readPmx(istream& infile, int verboseQ) {
   clear();

   ScoreItem* sip = NULL;
   while (!infile.eof()) {
      sip = readPmxScoreLine(infile, verboseQ);
      if (sip != NULL) {
         // setPageOwner will store the pointer for the ScoreItem
         // on the given page.  The page will delete it when it
         // is deconstructed.
         sip->setPageOwner(this);
      }
   }
}
开发者ID:UIKit0,项目名称:scorelib,代码行数:14,代码来源:ScorePageBase_read.cpp

示例12: fill_vector

// EOFまたは終了インジゲータが検出されるまでistからvに整数を読み取る
void fill_vector(istream& ist, vector<int>& v, char terminator){
	int i = 0;
	while(ist >> i) v.push_back(i);
	if(ist.eof()) return;		// OK: EOFが検出された

	if(ist.fail()){				// できるだけ後始末をし、問題を報告する
		ist.clear();			// ストリームの状態をクリアし、終了インジゲータを調査できるようにする
		char c;
		ist >> c;				// 文字を読み取る(終了インジゲータでありますように)
		if(c != terminator){	// 予想外の文字
			ist.unget();
			ist.clear(ios_base::failbit);	// 状態をfailに設定する
		}
	}
开发者ID:k-mi,项目名称:Stroustrup_PPP,代码行数:15,代码来源:10_6_2.cpp

示例13: readStreamAsString

string Utils::readStreamAsString(istream &inStream) {
	ostringstream result;

	while (true) {
		char got = static_cast<char>(inStream.get());
		if (!inStream.eof()) {
			result << got;
		} else {
			break;
		}
	}

	return result.str();
}
开发者ID:BackupTheBerlios,项目名称:kinneret-svn,代码行数:14,代码来源:Utils.cpp

示例14:

obj ReplacementSelection<obj>::fill(istream& infile){
	obj newelement;
	int i;
	int newIndex;
	infile>>newelement; 
	for(i=0; i<size && !infile.eof(); i++){
		heap[i]=newelement;
		leftEnd=i;
		heapify(true);
		infile>>newelement;

	}
	return newelement;
}
开发者ID:jeffwitthuhn,项目名称:ReplacementSelection,代码行数:14,代码来源:ReplacementSelection.cpp

示例15: createPrimary

void createPrimary(istream& read, ostream& primary){
    int number,byte = 0;
    map<int,int> mymap;
    PrimaryIndex p;
    ClientData client;
    read.clear();
    read.seekg(0);
    primary.seekp(0);
    if(read.eof())return;
    read >> client;
    while(!read.eof()){
        if(number = client.getAccountNumber()){
            mymap[number] = byte;
            byte = read.tellg();
        }
        read >> client;
    }
    for(map<int,int>::iterator it = mymap.begin(); it != mymap.end(); it++){
        p.AccountNumber = it->first;
        p.Byte = it->second;
        primary.write(reinterpret_cast<char*>(&p), sizeof(PrimaryIndex));
    }
}
开发者ID:7sean68,项目名称:File-structure-Project,代码行数:23,代码来源:PrimaryIndex.cpp


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