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


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

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


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

示例1: decompress

// 3(X2(B)Y)
//  ^
//   get -> X
// A-Z -> expr
// 2(A-Z) -> expr(A-Z, A-Z)
// ) return
void decompress(ifstream& input, queue<char>& expr) {
  while (input) {
    char c;
    input.get(c);
    if (')' == c) {
      return;

    } else if (c == '\n') {
      expr.push(c);

    } else if ('A' <= c && c <= 'Z') {
      expr.push(c);

    } else if ('0' <= c && c <= '9') {
      int repeat = c - '0';
      while (true) {
        input.get(c);
        if (c == '(') {
          break;
        }
        repeat *= 10;
        repeat += c - '0';
      }

      queue<char> internalRepeat;
      decompress(input, internalRepeat);

      while (repeat--) {
        queue<char> temp = internalRepeat;
        while (!temp.empty()) {
          char repeatChar;
          temp.pop(repeatChar);
          expr.push(repeatChar);
        }
      }
    }
  }
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:44,代码来源:compression.cpp

示例2: rawLong

/**
   Utility function to read in a raw 4-byte integer.
   This assumes the host byteorder is LSB first.
*/
static unsigned int rawLong( ifstream &stream ) {
    unsigned int val = 1;
  
    // Get a pointer into val.
    char *p = (char *)&val;

    // Test the byte order (stupid to do this every time)
    if ( *p == 1 ) {
        // Read each of the bytes of val.
        stream.get( p[ 0 ] );
        stream.get( p[ 1 ] );
        stream.get( p[ 2 ] );
        stream.get( p[ 3 ] );
    } else {
        stream.get( p[ 3 ] );
        stream.get( p[ 2 ] );
        stream.get( p[ 1 ] );
        stream.get( p[ 0 ] );
    }
  
    // Return the result.
    return val;
}
开发者ID:shuiyong,项目名称:3D_ChessBoard,代码行数:27,代码来源:Image.cpp

示例3: Get

Token Lexer::Get() {
	if (ifs.good()) {
		char c = ifs.get();
		// it's a valid token
		Token t = Token();
		t.value = c;
		return t;
	}
	else {
		Token t = Token();
                t.empty = true;
                return t;
	}
}
开发者ID:FIU-SCIS-Senior-Projects,项目名称:Medzmate,代码行数:14,代码来源:Lexer.cpp

示例4: start_thread

 void start_thread(int num) {
   cerr << "starting worker " << num << endl;
   char buffer[mem_each*1024];
   //cerr << "stream good: " << input.good() << endl;
   input.get(buffer, mem_each*1024, EOF);
   //cerr << "Buffer: " << string(buffer) << endl;
   maps[num] = unordered_map<string, int>();
   //cerr << "Map clean: " << maps[num].empty() << endl;
   workers[num] = thread(wc, string(buffer), ref(maps[num]));
   if (input.eof()) {
     done = true;
     cerr << "End of file" << endl;
   }
 }
开发者ID:jesikitty,项目名称:graduate-coursework,代码行数:14,代码来源:WordCount.cpp

示例5: makeMap

//Function that makes a map from all potential seeds of length specified by order to a vector of all characters that follow the after the seed in the text.
void makeMap(ifstream& sourceText, int order, Map<string, Vector<char> >& possibleNextChars){
    char ch;
    string seed;
    
    //Get the first letters of number equal to order from the text.
    for(int i = 0; i < order; i++){ 
        ch = sourceText.get();
        seed += ch;
    }
    
    seed = toLowerCase(seed);
    
    //Get every other possible seed in text and map them to vector of chars that follow them.
    while(true){
        int next = sourceText.get();
        if(next == EOF) break;
        ch = next;
        seed = toLowerCase(seed);
        possibleNextChars[seed] += ch;
        seed = seed.substr(1,seed.length()-1) + ch;
    }

}
开发者ID:ryanefoley,项目名称:repo3,代码行数:24,代码来源:RandomWriter.cpp

示例6:

//chete 32bitovo pololijelno chislo 
unsigned int read32bit_integer(ifstream& reader){

		char bytes[4];
		for(int i = 0; i<4; i++){
				bytes[i] = reader.get();
		}
		unsigned int result = 0;
		for(int i = 0; i<4; i++){
				result = (result << 8) | ((unsigned char) bytes[i]);
		}

		//cout<<result<<endl;
		return result;
}
开发者ID:zahofinta,项目名称:Huffman,代码行数:15,代码来源:help_functions.cpp

示例7: read_quoted_str

string read_quoted_str(ifstream &fin)
{
  string r;
  int c;
  for(;;)
    {
      c=fin.get();
      if(c==EOF)
	assert(0);
      if(c=='"')
	break;
    }
  for(;;)
    {
      c=fin.get();
      if(c=='"')
	break;
      if(c==EOF)
	assert(0);
      r+=c;
    }
  return r;
}
开发者ID:lonway,项目名称:autotool,代码行数:23,代码来源:instruction.cpp

示例8: load

int UserList::load( ifstream& fp)
{
  int		type;
  int		end_found = 0;
  char		dummy[40];

  for (;;)
  {
    fp >> type;

    switch( type) {
      case user_eData_User: break;
      case user_eData_UserName:
        fp.get();
        fp.getline( name, sizeof(name));
        break;
      case user_eData_UserPassword:
        fp.get();
        fp.getline( password, sizeof(password));
        break;
      case user_eData_UserPrivilege: fp >> priv; priv = idecrypt( priv); break;
      case user_eData_UserId: fp >> id; break;
      case user_eData_UserFullName:
        fp.get();
        fp.getline( fullname, sizeof(fullname));
        break;
      case user_eData_UserDescription:
        fp.get();
        fp.getline( description, sizeof(description));
        break;
      case user_eData_UserEmail:
        fp.get();
        fp.getline( email, sizeof(email));
        break;
      case user_eData_UserPhone:
        fp.get();
        fp.getline( phone, sizeof(phone));
        break;
      case user_eData_UserSms:
        fp.get();
        fp.getline( sms, sizeof(sms));
        break;
      case user_eData_End: end_found = 1; break;
      default:
        cout << "User:open syntax error" << endl;
        fp.getline( dummy, sizeof(dummy));
   }
   if ( end_found)
     break;
  }
  return 1;
}
开发者ID:jordibrus,项目名称:proview,代码行数:52,代码来源:co_user.cpp

示例9: readLineForDebug

//
// Name: readLineForDebug()
// Discription: This will read in an entire line and save it.  It will then move
//              The stream back to the start of the line.  Used for debugging
//              instructions.
// Parameters: ifstream &stream - The stream to read from.
// Returns: void
//
void Instruction::readLineForDebug(ifstream &stream) {
    string s;
    while (!stream.eof()) {
        if (stream.peek() == endOfInstruction || stream.peek() == EOF)
            break;
        char c = stream.get();
        if (c == '\n')
            break;
        lineOfCode += c;
    }
    stream.seekg(((int)stream.tellg())-lineOfCode.size());
    lineOfCode = typeToString(type) + lineOfCode;
    cerr << lineNumber << " " << lineOfCode << endl;
    lineOfCode = "Smada Instruction: " + lineOfCode;
}
开发者ID:icefox,项目名称:smada,代码行数:23,代码来源:instruction.cpp

示例10: readLineFromFile

int readLineFromFile(vector<int>& dataLineVec, u_int& dataVecLen){
	if(inpFileStream.eof()) return 0;
	char c = inpFileStream.get();
	int no;
	dataVecLen = 0;
	dataLineVec.clear();
	while( c != '\n' && !inpFileStream.eof()){
		if( c == ' ')
		c = inpFileStream.get();
		no = 0;
		bool empty = true;
		while(c>='0' && c<='9'){
			empty = false;
			no *= 10;
			no += (c - '0');
			c = inpFileStream.get();
		}
		if(!empty){
			dataLineVec.push_back(no);
			++dataVecLen;
		}
	}
	return 1;
}
开发者ID:1098896743,项目名称:Improved-Apriori-Algorithm,代码行数:24,代码来源:common.cpp

示例11: handle_literal

// Literals (char, string)
// Make sure that <,>, etc are escaped inside literals!
void handle_literal(char delimiter, ifstream& inFile, ofstream& outFile) {
	
	outFile << "<font color=\"gray\">";	
	outFile.put(delimiter);
	
	char ch;
	
	while(inFile.get(ch)) {
		
		if(ch == delimiter) {
			outFile.put(ch);
			break;
		}
		else if(ch == '\\'){
			outFile.put(ch);		// TEST
			inFile.get(ch) && outFile.put(ch);
		}
		else
			outputChar(ch, outFile);
	}
	
	outFile << "</font>";
	
}
开发者ID:rwinston,项目名称:code2html,代码行数:26,代码来源:parsefiles.cpp

示例12: invert_image

void invert_image(ifstream &infile, ofstream &outfile, BITMAPFILEHEADER &file_header, BITMAPINFOHEADER &info_header)
{
	RGBQUAD	pixel = { 0, 0, 0};
	long	size;	//Size of the file
	
	//Getting the size of the stream
	infile.seekg(0, infile.end);
	size = infile.tellg();							
	
	//Outputting the file headers													
	outfile.write(reinterpret_cast<char*>(&file_header), sizeof(file_header));
	outfile.write(reinterpret_cast<char*>(&info_header), sizeof(info_header));
		
			
	infile.seekg(54, infile.beg);		//Moving stream to location 54 to avoid file header values

	for (int i = 54; i < size; i++)		//Loop through all of the pixel data
	{
		pixel.rgbBlue	  = infile.get();	//Read in pixel value
		pixel.rgbGreen	  = infile.get();
		pixel.rgbRed	  = infile.get();
		

		pixel.rgbBlue	  = 255 - pixel.rgbBlue;	//Inverts the colour
		pixel.rgbGreen	  = 255 - pixel.rgbGreen;
		pixel.rgbRed	  = 255 - pixel.rgbRed;
		

		outfile.write(reinterpret_cast<char*>(&pixel), 3);
	}

	/*Closing the io streams and ending the program*/
	infile.close();
	outfile.close();
	cout << "\nThe operation is completed\nThe file has been closed...\n";
}
开发者ID:Matthew94,项目名称:Bitmap-Inverter-And-Scaling-Project,代码行数:36,代码来源:invert_image.cpp

示例13: space_remover

void space_remover(ifstream& in_stream, ofstream& out_stream)
{
	char current_char;
	bool shouldContinue = true;

	do {
		in_stream.get(current_char);

		if (current_char == ' ') {
			out_stream.put(current_char);

			do {
				in_stream.get(current_char);
			} while (current_char == ' ');

			out_stream.put(current_char);

		} else if (!in_stream.eof()) {
			out_stream.put(current_char);
		} else {
			shouldContinue = false;
		}
	} while (shouldContinue == true);
}
开发者ID:eligundry,项目名称:ksu-cs1,代码行数:24,代码来源:file_fixer.cpp

示例14: readsinglesymbol

/**
 * \brief Read single single symbol into the end of a string buffer.
 * \param fin The input file stream.
 * \param str The string buffer.
 */
void readsinglesymbol(ifstream& fin, string& str)
{
  char currentchar;
  fin.get(currentchar);
  if (fin.eof()) {
    return;
  }
  if (currentchar == '\"') {
    // read a string literal
    do {
      str += currentchar;
      fin.get(currentchar);
    } while (currentchar != '\"');
    str += currentchar;
  } else {
    do {
      str += currentchar;
      fin.get(currentchar);
    } while ((false == iswhitespace(currentchar)) 
	     && ('(' != currentchar) 
	     && (false == fin.eof()));
    fin.putback(currentchar);  
  }
}
开发者ID:mindworker,项目名称:scheme-interpreter,代码行数:29,代码来源:main.cpp

示例15: LeerCabecera

bool LeerCabecera (ifstream& f, int& filas, int& columnas)
{
   int maxvalor;

   while (SaltarSeparadores(f)=='#')
   f.ignore(10000,'\n');

   f >> columnas >> filas >> maxvalor;
   
   if (/*str &&*/ f && filas>0 && filas <5000 && columnas >0 && columnas<5000) {
      f.get(); // Saltamos separador
      return true;
   }
   else return false;
}
开发者ID:jmml97,项目名称:practicas_mp,代码行数:15,代码来源:imagenES.cpp


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