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


C++ fstream::clear方法代码示例

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


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

示例1: strip_file

/******************************************************************************************************
void strip_file(std::ifstream& inStream, std::string fileName)

Description: Opens a input file and strips symbols and outputs to temp file.

Parameters: std::ifstream& inStream, std::string fileName

Pre-Conditions: Input file must be opened.
Post-Conditions: Input file will be stripped of symnbols and output to temp file.
******************************************************************************************************/
void strip_file(std::ifstream& inStream, std::fstream& tempStream)
{
    std::vector<char> lines;//create a vector to hold characters.

    while (inStream)//iterate through each line in file.
    {
	   char ch;
	   int count = 0;
	   ch = inStream.get();//Get character from line.
	   while (ch != EOF)//While not end of line.
	   {
		  if (ch != ',' && ch != '[' && ch != ']')//Do not add these symbols.
		  {
			 lines.push_back(ch);//Push character to vector.
			 count++;//inc count, used to loop through vector.
		  }
		  ch = inStream.get();//get next char in line.
	   }
	   for (int i = 0; i < count; i++)
	   {

		  //std::cout << lines[i];  //Outputs each line in file to console.
		  tempStream << lines[i];//Outputs to temp.txt file

	   }
	   lines.clear();//Clears the vector of all values.
    }
    inStream.clear();//clears the end of file flag (eof).
    inStream.seekg(0L, std::ios::beg);//Move back to the beginning of the input file stream.
    tempStream.clear();//clears the end of file flag (eof).
    tempStream.seekg(0L, std::ios::beg);//Move back to the beginning of the input file stream.

}//end strip_file
开发者ID:Lagrewj,项目名称:CS325_Project2,代码行数:43,代码来源:file_action.cpp

示例2:

		static void 
		clear(std::fstream& f)
		{
			f.clear();
			errno = 0;

			return;
		}
开发者ID:jnferguson,项目名称:nfcdump,代码行数:8,代码来源:file.hpp

示例3: runtime_error

void filesystem::supercluster::save(std::fstream& s, uint32_t index)
{
	uint64_t offset = SUPERCLUSTER_SIZE * index;
	char buffer[CLUSTER_SIZE];
	for(unsigned i = 0; i < CLUSTERS_PER_SUPER; i++)
		serialization::u32b(buffer + 4 * i, clusters[i]);
	s.clear();
	s.seekp(offset, std::ios_base::beg);
	s.write(buffer, CLUSTER_SIZE);
	if(!s)
		throw std::runtime_error("Can't write cluster table");
}
开发者ID:bentley,项目名称:lsnes,代码行数:12,代码来源:filesystem.cpp

示例4: getImageCount

    static int getImageCount(std::fstream& file_list)
    {
        int sample = 0;
        std::string line;
        while (std::getline(file_list, line))
            ++sample;
        if (file_list.eof())
            file_list.clear();  //otherwise we can't do any further I/O
        else if (file_list.bad()) {
            throw  std::runtime_error("Error occured while reading files_list.txt");
        }

        return sample;
    }
开发者ID:Jinwei1,项目名称:AirSim,代码行数:14,代码来源:StereoImageGenerator.hpp

示例5: seek

	virtual bool seek(int32 offset, int whence = SEEK_SET) {
		_fileStream->clear();
		switch (whence) {
			case SEEK_SET:
				_fileStream->seekg(offset, std::ios_base::beg);
				break;
			case SEEK_CUR:
				_fileStream->seekg(offset, std::ios_base::cur);
				break;
			case SEEK_END:
				_fileStream->seekg(offset, std::ios_base::end);
				break;
		}
	}
开发者ID:somaen,项目名称:grime-tools-mac,代码行数:14,代码来源:filestream.cpp

示例6: leerLinea

void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
	linea.clear();

	char buffer[T_BUFFER];

	bool seguirLeyendo = true;
	do {
		archivo.getline(buffer, T_BUFFER, '\n');
		linea.append(buffer, archivo.gcount());

		seguirLeyendo = (archivo.gcount() == T_BUFFER);

		if (archivo.bad())
			archivo.clear();

	} while (seguirLeyendo);
}
开发者ID:SebastianBogado,项目名称:fiuba-7542-tp-final,代码行数:17,代码来源:Agente.cpp

示例7: FileLoader

void CFileManager::FileLoader(std::fstream& i_stream,std::string i_filepath)
{
	i_stream.clear();

	//i_stream.open(i_filepath.c_str());
	i_stream.open("TestData.txt");

	if(i_stream.is_open())
	{
		//i_stream << "opened this file";
		i_stream >> token;
		if(token == "gobblin")
		{
			//characters.push_back( CHARACTER() );
			//LoadGoblin( file, characters.back() ); 
		}
		i_stream.close();
	}
开发者ID:bjonke,项目名称:Exodus,代码行数:18,代码来源:CFileManager.cpp

示例8: checkformodifications

void resultsfile::checkformodifications(std::fstream& file)
   {
   assert(file.good());
   trace << "DEBUG (resultsfile): checking file for modifications." << std::endl;
   // check for user modifications
   sha curdigest;
   file.seekg(0);
   curdigest.process(file);
   // reset file
   file.clear();
   if (curdigest == filedigest)
      file.seekp(fileptr);
   else
      {
      cerr << "NOTICE: file modifications found - appending." << std::endl;
      // set current write position to end-of-file
      file.seekp(0, std::ios_base::end);
      fileptr = file.tellp();
      }
   }
开发者ID:jyzhang-bjtu,项目名称:simcommsys,代码行数:20,代码来源:resultsfile.cpp

示例9: search_forward

std::streampos search_forward ( std::fstream & _bs, const std::string & sample )
{
	size_t match ( 0 );
	cSaveIStreamPosition ip ( &_bs );
	streampos result ( static_cast<streampos>( -1 ) );
	cSaveStreamExceptions se ( &_bs, std::ios_base::goodbit );
	
	for( int ch( EOF ); match < sample.length(); match++ )
	{
		ch = _bs.get();
		if( ch == EOF )
			break;
		else if( ch != sample[match] )
			match = 0;
	}
	if( match == sample.length() )
		result = _bs.tellg() - static_cast<streampos>( match );
	
	_bs.clear();
	
	return result;
}
开发者ID:o-peregudov,项目名称:libcrs,代码行数:22,代码来源:parsing.cpp

示例10: refreshFstream

void refreshFstream(std::fstream& fs)
{
	fs.clear();
	fs.seekg(0,fs.beg);
}
开发者ID:apamburn,项目名称:CS3370,代码行数:5,代码来源:main.cpp


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