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


C++ ifstream::peek方法代码示例

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


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

示例1: getRead

string getRead(ifstream& readFile){
	string read,header,inter;
	char c;
	for(uint64_t i(0);i<1;++i){
		getline(readFile,header);
		getline(readFile,read);
	point:
		c=readFile.peek();
		if(c=='>'){
			if(read.size()>2){
				bool fail(false);
				for(uint64_t j(0);(j)<read.size();++j){
					if(read[j]!='A' and read[j]!='C' and read[j]!='T' and read[j]!='G'){
						fail=true;
						break;
					}
				}
				if(!fail){
					return read;
				}
			}
			read="";
		}else{
			if(!readFile.eof()){
				getline(readFile,inter);
				read+=inter;
				goto point;
			}else{
				if(read.size()>2){
					bool fail(false);
					for(uint64_t j(0);(j)<read.size();++j){
						if(read[j]!='A' and read[j]!='C' and read[j]!='T' and read[j]!='G'){
							fail=true;
							break;
						}
					}
					if(!fail){
							return read;
					}
				}
				return "";
			}
		}
	}
	return "";
}
开发者ID:Malfoy,项目名称:pyranha,代码行数:46,代码来源:utils.cpp

示例2: sum

Item::Item(ifstream &theFile)
    : sum(0.0), mean(0.0), min(0.0), q25(0.0), median(0.0), q75(0.0), max(0.0),
      statInformation(false), valid_values( true ), data_status_description()
{
    theFile >> name;
    theFile >> count;
    ReadWhitespaces(theFile);
    if(theFile.peek() != '-')
    {
        theFile >> mean;
        theFile >> median;
        theFile >> min;
        theFile >> max;
        theFile >> sum;
        if(count >= 2)
        {
            theFile >> variance;
        }
开发者ID:linearregression,项目名称:scalasca,代码行数:18,代码来源:BoxPlot.cpp

示例3: ReadEntryAC

// Read protein entry's ACCESSION ID ( AC )by specified file position
bool CFastaParser::ReadEntryAC(string& strAC, long   lPosEntryStart, ifstream& ifDB)
{
	std::streamsize tLength = MAX_AC_LENGTH_PRO;
	char* pszBuf = new char[MAX_AC_LENGTH_PRO];


	ifDB.seekg(lPosEntryStart, ios::beg);

	if (ifDB.peek() == '>') 					//skip the char '>'
		ifDB.get();

	ifDB.getline(pszBuf, tLength - 1, ' ');

	strAC = pszBuf ;
	strAC = strAC.substr(0, strAC.find_last_not_of('\r')+1);
	delete pszBuf;
	return true;
}
开发者ID:pLinkSS,项目名称:pLink-SS,代码行数:19,代码来源:FastaParser.cpp

示例4: GetStrs

void GetStrs(ifstream & fin, vector<string> & vistr)
{
	size_t len;
	string str;
	char ch;
	// check that there is something to read
	while (fin.peek() && !fin.eof()) 
	{
		fin.read((char *) &len, sizeof(size_t));
		for (size_t i = 0; i < len; i++)
		{
			fin.read(&ch, sizeof(char));
			str.push_back(ch);
		}
		vistr.push_back(str);
		str.clear();
	}
}
开发者ID:daixiongming,项目名称:C-PrimerPlus,代码行数:18,代码来源:pe17-7.cpp

示例5: hasNextLog

bool hasNextLog (ifstream & file)
{
#ifdef MAP
    cout << "Appel à la methode Read::hasNextLog" << endl;
#endif

	if ( !file.eof() && file.peek() != char_traits<wchar_t>::eof() )
	{
#ifdef MAP
	cout << "Read::hasNextLog = true" << endl;
#endif
		return true;
	}
#ifdef MAP
	cout << "Read::hasNextLog = false" << endl;
#endif
	return false;
} //----- Fin de hasNextLog
开发者ID:BuonOmo,项目名称:Analogs,代码行数:18,代码来源:test_read.cpp

示例6: while

void
ignoreComment(ifstream& inpt)
{
  ECString nxt;
  char a;
  inpt.get(a);
  if(a == '/')
    {
      char b = inpt.peek();
      if(b == '*')
	{
	  while(inpt)
	    {
	      inpt >> nxt;
	      if(nxt == "*/") break;
	    }
	  return;
	}
    }
开发者ID:KerstenDoering,项目名称:CPI-Pipeline,代码行数:19,代码来源:utils.C

示例7: readStream

//
// Name: readStream()
// Discription: Reads the stream and gets the full instruction, then returning.
// Parameters: ifstream &stream - Stream to read from.
// Returns: bool - true errors, false no errors.
//
bool I_Let::readStream(ifstream &stream) {
    if (debug)
        readLineForDebug(stream);

    // var
    checkForEndOfLine();
    string var;
    stream >> var;
    int num = vars->asciiNumber(var);
    if (num == -1) {
        string error = "Variable unknown: ";
        error += var;
        reportError(error.c_str());
    } else {
        theVar = vars->asciiNumber(var);
        vars->isUsed(theVar);
    }

    // =
    checkForEndOfLine();
    char c = stream.peek();
    if (c != '=') {
        reportError("Missing \"=\" in let command.");
        return true;
    } else{
        char c[1];
        stream.read(c,1);
    }

    // Expression
    checkForEndOfLine();
    e.setVariableClass(vars);
    e.setDebug(debug);
    e.type = type;
    e.readStream(stream);

    return (moveToTheEndOfTheLine(stream));
}
开发者ID:icefox,项目名称:smada,代码行数:44,代码来源:i_let.cpp

示例8: getFormFile

string getFormFile(long start,long frame)
{
	

	char c;
	c=myfile.peek();;
	myfile.seekg(start);
	string toret;
	while(myfile.tellg()<start+frame && !myfile.eof())
		  {
			  int pos=myfile.tellg();
			  // c=myfile.peek();;
			  myfile>>c;
			 // cout<<"C:"<<c<<endl;
			  if(c=='a')c='A';
			  if(c=='t' || c=='u' || c=='U')c='T';
			  if(c=='g')c='G';
			  if(c=='c')c='C';
			  if(c=='.' ||c==' ' || c=='\n' || c=='>')continue;
			  toret+=c;
		  };
	return toret;
};
开发者ID:victor-yacovlev,项目名称:biosymbol,代码行数:23,代码来源:main.cpp

示例9: current

dll::dll(ifstream & infile)
{
	char buffer[100];
	int length;
	root = NULL;

	while(infile.eof() == false)
	{
		char * name;
		int classrooms, max_students, age_group;



		infile.getline(buffer, 100, ':');
		length = strlen(buffer);
		name = new char[length+1];
		strcpy(name, buffer);

		infile.getline(buffer, 5, ':');
		classrooms = atoi(buffer);

		infile.getline(buffer, 5, ':');
		max_students = atoi(buffer);

		infile.getline(buffer, 5);
		age_group = atoi(buffer);

		school current(name, classrooms, max_students, age_group);
		add(current);

		delete [] name;

		infile.peek();


	}
}
开发者ID:Greenmanpdx,项目名称:SchoolProjects,代码行数:37,代码来源:location.cpp

示例10: carregaParamDC

//DC <valor> (para fonte DC)
void Tensao::carregaParamDC(ifstream &arq)
{
	int i = 0;
	while(arq.good() && arq.peek() != '\n')
	{
		switch(i)
		{
			case 0: 
				arq >> m_DC;
				break;
			default:
				arq>>m_ignora;
				break;
		}
		i++;
	}
	if(i!=1)
	{
		cout<< m_nome <<" DC: Numero de parametros errado" << i << "/1"<<endl;
		arq.close();
		m_erro = true;
	}
	cout<<m_nome<<" DC: "<<m_nome_a<<" "<<m_nome_b<<" "<<m_DC<<endl;
}
开发者ID:Cyfer6969,项目名称:CE20142,代码行数:25,代码来源:Tensao.cpp

示例11: readNext

int ParameterList::readNext(ifstream in,char * tmp){
	int tmp_lenght;
	//remove all leading spaces
	while(in.peek()==32) in.get();
	//check if end of line
	if((in.peek()==10 || in.peek()==13)) 
		return-1;

	in>>tmp;
	
	if(in.eof()) return -1;
	tmp_lenght=strlen(tmp);
	// look for comment sign
	if((int)strcspn(tmp,"#")<tmp_lenght){
		//found comment: read till the end and go to next line
		while(!(in.peek()==10 || in.peek()==13)) in.get();
		//remove end of line
		while((in.peek()==10 || in.peek()==13)) in.get();
		return -1;
	}
	return 1;


}
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:24,代码来源:ParameterList.cpp

示例12: checkAndAddTokens

bool lexicalAnalyzer::checkAndAddTokens(char charToBeChecked, vector<Token> &tokenList, int& lineNumber, ifstream& in){
    Token tokenToBeAdded = Token();
    string tempString = string(1, charToBeChecked);
    char nextChar = in.peek();
    char tempChar;
    int currLine = lineNumber;
    bool endstring = false;
    int aposCount = 1;
    
    if(isspace(charToBeChecked)){
        return true;
    }
    
    else if(isalpha(charToBeChecked)){
        string word = string(1, charToBeChecked);
        while(isalnum(nextChar)){
            in.get(tempChar);
            word += string(1, tempChar);
            //cout << word << endl;
            if (isToken(word) != ""){
                if(!isalnum(in.peek())){
                    tokenToBeAdded = Token (isToken(word), word, lineNumber);
                    tokenList.push_back(tokenToBeAdded);
                    return true;
                }
            }
            nextChar = in.peek();
        }
    tokenToBeAdded = Token ("ID", word, lineNumber);
    tokenList.push_back(tokenToBeAdded);
    return true;
        //cout << word << endl;
    } //Keep Reading from input

    switch (charToBeChecked){
        case ',':
            tokenToBeAdded = Token ("COMMA", tempString, lineNumber);
            tokenList.push_back(tokenToBeAdded);
            return true;
            //output comma
            break;
        case ':':
            if(nextChar == '-'){
                tempString += nextChar;
                in.get(tempChar);
                tokenToBeAdded = Token ("COLON_DASH", tempString, lineNumber);
                tokenList.push_back(tokenToBeAdded);
                return true;
            }
            else{
                tokenToBeAdded = Token ("COLON", tempString, lineNumber);
                tokenList.push_back(tokenToBeAdded);
                return true;
            }
            //check if it's a c-dash, then output colon
        case '.':
            tokenToBeAdded = Token ("PERIOD", tempString, lineNumber);
            tokenList.push_back(tokenToBeAdded);
            return true;
            //create token object for period, and add to tokenList
        case '?':
            tokenToBeAdded = Token ("Q_MARK", tempString, lineNumber);
            tokenList.push_back(tokenToBeAdded);  
            return true;
            //create token object for qmark, and add to tokenList
        case '(':
            tokenToBeAdded = Token ("LEFT_PAREN", tempString, lineNumber);
            tokenList.push_back(tokenToBeAdded);
            return true;
            //create token object for lparenth, and add to tokenList
        case ')':
            tokenToBeAdded = Token ("RIGHT_PAREN", tempString, lineNumber);
            tokenList.push_back(tokenToBeAdded);
            return true;
            //create token object for r parenth, and add to tokenList
        case '#':
            if (nextChar == '|'){
                in.get(tempChar);
                tempString += string(1, tempChar);
                if(in.peek() == '|'){
                    in.get(tempChar);
                    tempString += string(1, tempChar);
                    if(in.peek() == '#'){
                        in.get(tempChar);
                        tempString += string(1, tempChar);
                        tokenToBeAdded = Token ("COMMENT", tempString, currLine);
                        tokenList.push_back(tokenToBeAdded);
                        return true;
                    }
                }
                do {
                    if(in.eof()){
                        tokenToBeAdded = Token ("UNDEFINED", tempString, currLine);
                        tokenList.push_back(tokenToBeAdded);
                        return false;
                    }
                    in.get(tempChar);
                    if(tempChar == '\n'){
                        lineNumber++;
                    }
//.........这里部分代码省略.........
开发者ID:azjkjensen,项目名称:Data-Structures-and-Discrete-Structures-Labs,代码行数:101,代码来源:lexicalAnalyzer.cpp

示例13: eatspaces

// This will eath through white spaces.
void eatspaces(ifstream &inp)
{
    while(inp.peek() == ' ' || inp.peek() == '\n') inp.get();
}
开发者ID:lianke123321,项目名称:differentiation-detector-android,代码行数:5,代码来源:filter.cpp

示例14: key

/**
* Constructor responsible for reading data from the EDF file.
* It reads data from the header and stores key-value pairs in dictionry.
* Also EDF image is read.
*/
edf_reader::edf_reader(ifstream &in){
    
    char buffer[256], value_string[256];
    double value;
    char a = ' ';
    bool is_header = 0;
    int dim1, dim2;
    //
    //read first character from the file
    //
    in.get(a);
    //
    // read file until bace closing the header is met
    //
    while(in.peek()!='}'){
        //
	//prevention from corrupted bits in file
	//
	if(in.fail()){
            in.clear(in.rdstate() & ~ios::failbit);
            in.getline(buffer, 255);
            break;
        }
	//
	//check if the header begins
	//
	if((a=='{') || is_header==1){
	    //
	    //set flag if first time in the loop 
	    //
	    if(!is_header){
	        in.get(a);
	        is_header = 1;
	    }
	    //
	    //get key 
	    //
	    in.getline(buffer, 255,' ');
	    string key(buffer);
	    //
	    //check if key corresponds to float value
	    //
	    if(!strcmp(buffer,"Center_1")||!strcmp(buffer,"Center_2")||!strcmp(buffer,"DDummy")||!strcmp(buffer,"Dummy")||!strcmp(buffer,"Offset_2")||!strcmp(buffer,"Psize_1")||!strcmp(buffer,"Psize_2")||!strcmp(buffer,"SampleDistance")||!strcmp(buffer,"SaxsDataVersion")||!strcmp(buffer,"WaveLength")||!strcmp(buffer,"EDF_BinarySize")||!strcmp(buffer,"Image")||!strcmp(buffer, "Offset_1")) {
	        
	        //
		//get value corresponding to key
		//
		in.getline(buffer, 255, '=');
		while(in.peek()==' ')in.ignore(1,'\n');
                in >> value;
		//
		//store pairs key-double value in key_double dictionary
		//
		key_double.insert(pair<string, double>(key, value));        
	    }
	    
	    //
	    //get dimension separately and store in dictionary
	    //
	    
	    else if(!strcmp(buffer,"Dim_1")){
	        in.getline(buffer, 255, '=');
		while(in.peek()==' ')in.ignore(1,'\n');
                in >> value;
		dim1 = (int)value;
		(void)dim1; // TODO unused varable - quiet warnings
		key_double.insert(pair<string, double>(key, value));	            
	    }
开发者ID:Acidburn0zzz,项目名称:code,代码行数:73,代码来源:edf_reader.cpp

示例15: isEmpty

bool isEmpty(ifstream& pFile)
{
    return pFile.peek() == ifstream::traits_type::eof();
}
开发者ID:loan181,项目名称:jeu-video-cpp,代码行数:4,代码来源:main.cpp


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