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


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

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


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

示例1: ParseFromFStream

		bool XTextureFileName::ParseFromFStream(std::ifstream& in)
		{
			std::streampos pos;
			char separator;

			if (!in.good())
			{
				return false;
			}

			in.clear();
			pos = in.tellg();

			if (!FileName.ParseFromFStream(in))
			{
				in.clear();
				in.seekg(pos);
				return false;
			}

			in >> separator;

			if (!in.good() || separator != ';')
			{
				in.clear();
				in.seekg(pos);
				return false;
			}

			return true;
		}
开发者ID:SaulHP91,项目名称:DIYlib,代码行数:31,代码来源:xTextureFileName.cpp

示例2: solveMoreOfTheProblem

char* solveMoreOfTheProblem() {
    try {
        if (! inFile.eof()) {
            string t = getaline(inFile);
            if (t.size() == 0) {
                inFile.clear();
                inFile.close();
                return error[4];
            } else {
                sprintf(lzbfr, "%s", t.c_str());
            }
            return lzbfr;
        } else {
            inFile.clear();
            inFile.close();
            return error[4];
        }
    } catch (string message) {
        inFile.clear();
        inFile.close();
        throw message;
    } catch (...) {
        inFile.clear();
        inFile.close();
        throw string("More went bad!!");
    }
    return error[3];
}
开发者ID:bvds,项目名称:andes,代码行数:28,代码来源:colander.cpp

示例3: readRecord

        static int readRecord(std::ifstream& stream, string& id, string& counts)
        {
            std::string line;
            if (std::getline(stream, line)) {
                if ('>' == line[0]) {

                    id.assign(line.begin() + 1, line.end());

                    //std::string sequence;
                    /*while (stream.good() && '>' != stream.peek()) {
                        std::getline(stream, line);
                        sequence += line;
                    }*/

                    // We assume the counts are on a single line
                    std::getline(stream, line);
                    counts = line;

                    stream.clear();

                    return 0;
                }
                else {
                    stream.clear(std::ios_base::failbit);
                }
            }

            return -1;
        }
开发者ID:emmaggie,项目名称:KAT,代码行数:29,代码来源:plot_profile.hpp

示例4: OpenInput

bool NxsFilePath::OpenInput(std::ifstream &inFStream) const
	{
	inFStream.close();
	inFStream.clear();
	inFStream.open(GetNative().c_str());
	if (inFStream.good())
		return true;
	inFStream.close();
	inFStream.clear();
	return false;
	}
开发者ID:danielfan,项目名称:Phycas,代码行数:11,代码来源:nxs_file_path.cpp

示例5: 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

示例6: loadFile

void AnimatedObjModel::loadFile(std::ifstream& _dataStream)
{
	DataCounts counts = readFileCounts(_dataStream);
	_dataStream.clear(std::ios::goodbit);
	_dataStream.seekg(0, std::ios::beg);
	loadDataStructures(_dataStream, counts);
}
开发者ID:Jereq,项目名称:Raytracer,代码行数:7,代码来源:AnimatedObjModel.cpp

示例7: open

 void open( const std::string& anchorFile ) {
   _in.close();
   _in.clear();
   _in.open( anchorFile.c_str() );
   _buffer.clear();
   _readDocumentHeader();
 }
开发者ID:busjaeger,项目名称:cs410sp12,代码行数:7,代码来源:AnchorTextAnnotator.hpp

示例8: readEntry

			IndexEntry readEntry(std::ifstream & indexistr, uint64_t const entryid) const
			{
				uint64_t const entrybitpos = getEntryBitPos(entryid);
				uint64_t const entrybytepos = entrybitpos>>3;
				uint64_t const entrybitoff = entrybitpos - (entrybytepos<<3);
				
				// seek to index position
				indexistr.clear();
				indexistr.seekg(entrybytepos,std::ios::beg);
				if ( static_cast<int64_t>(indexistr.tellg()) != static_cast<int64_t>(entrybytepos) )
				{
					::libmaus2::exception::LibMausException se;
					se.getStream() << "Failed to seek to index position " << entrybytepos << " in file " << filename << " of size " 
						<< ::libmaus2::util::GetFileSize::getFileSize(filename) << std::endl;
					se.finish();
					throw se;
				}
				::libmaus2::bitio::StreamBitInputStream SBIS(indexistr);
			
				SBIS.read(entrybitoff);
				
				uint64_t const pos = SBIS.read(posbits);
				uint64_t const kcnt = SBIS.read(kbits);
				uint64_t const vcnt = SBIS.read(vbits);
				
				return IndexEntry(pos,kcnt,vcnt);
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:27,代码来源:IndexDecoderDataArray.hpp

示例9: temp

std::vector <points> read (std::ifstream &f,int a,int b,int c,int d){
std::vector <points> v;
f.clear();
f.seekg(0, std::ios::beg);

while (f.good()){
std::string s;
f>>s;
std::stringstream ss;
ss<<s;
int temp_x,temp_y;
ss>>temp_x;
s.clear();ss.clear();
f>>s;
ss<<s;
ss>>temp_y;


points temp(temp_x,temp_y,a,b,c,d);
v.push_back(temp);
}







return v;
}
开发者ID:geriasd2,项目名称:github_repo,代码行数:30,代码来源:gubge_beadando.cpp

示例10: in

/**\brief Used by testers.  
 *
 * Not operators because that would conflict
 * with the std:: operators for unsigned ints, alas.
 */
void in(std::ifstream& i, unsigned48_t& res)
{
    /*
     * print "0x........,0x........,0x........"
     */
    union {
       unsigned48_t   seed;
       unsigned short dummy[sizeof(unsigned48_t)/sizeof(unsigned short)];
    } PUN ;

    char             comma = ',';
    unsigned         j=0;

    while( (comma == ',') && 
        (j < sizeof(PUN.dummy)/sizeof(unsigned short)) &&
        (i >>  PUN.dummy[j])
        ) {

            if(i.peek() == ',') i >> comma;
            j++;
    }
    if(j < sizeof(PUN.dummy)/sizeof(unsigned short) ) {
        // This actually sets the badbit:
        i.clear(std::ios::badbit|i.rdstate());
    }
    res = PUN.seed;
}
开发者ID:yaochang,项目名称:shore-mt,代码行数:32,代码来源:rand48.cpp

示例11: open

void GlowNodeGroup::open(std::ifstream& fp)
{
  int type = 0;
  int end_found = 0;
  char dummy[40];

  for (;;) {
    if (!fp.good()) {
      fp.clear();
      fp.getline(dummy, sizeof(dummy));
      printf("** Read error GlowNodeGroup: \"%d %s\"\n", type, dummy);
    }

    fp >> type;
    switch (type) {
    case glow_eSave_NodeGroup:
      break;
    case glow_eSave_NodeGroup_nodeclass_part:
      GlowNodeClass::open(fp);
      break;
    case glow_eSave_End:
      end_found = 1;
      break;
    default:
      std::cout << "GrowGroup:open syntax error\n";
      fp.getline(dummy, sizeof(dummy));
    }
    if (end_found)
      break;
  }
}
开发者ID:siamect,项目名称:proview,代码行数:31,代码来源:glow_nodegroup.cpp

示例12: Error

void CSourceFilesProcessor::Error( const CError& error )
{
	std::cerr << error.UserMessage() << std::endl;
	if( error.Severity() == ES_FatalError ) {
		file.clear( std::ios_base::eofbit );
		std::cin.clear( std::ios_base::eofbit );
	}
}
开发者ID:Mazdaywik,项目名称:refal2-msu-iterpreter,代码行数:8,代码来源:main.cpp

示例13: GetLastLine

std::string GetLastLine(std::ifstream& in)
{
  std::ifstream::pos_type pos = in.tellg();

  std::ifstream::pos_type lastPos;
  while (in >> std::ws && Ignoreline(in, lastPos))
    pos = lastPos;

  in.clear();
  in.seekg(pos);

  std::string line;
  std::getline(in, line);
  in.clear();
  in.seekg(std::ios::beg);
  return line;
}
开发者ID:StevenRoan,项目名称:Steven,代码行数:17,代码来源:utility.cpp

示例14: QWidget

Gslib_input_pointset_dialog::Gslib_input_pointset_dialog( std::ifstream& infile,
							  QWidget* parent , 
							  const char* name ) 
  : QWidget( parent) {

  setupUi(this);
  std::streampos mark = infile.tellg();

  // read how many properties are defined in the file (indicated at the
  // second line of the file)
  std::string line;

  std::getline( infile, line );
  int nb_properties;
  infile >> nb_properties;
  infile.clear();
  infile.seekg( mark );


  X_col_->setMaximum( nb_properties );
  Y_col_->setMaximum( nb_properties );
  Z_col_->setMaximum( nb_properties );

  
  // make a preview of the file

  QString text;

  int count = 0;
  const int limit = 50;
 
  // Read up to "limit" lines
  while( std::getline( infile, line ) && count < limit ) {
    line += "\n";
    text.append( line.c_str() );
    count ++;
  } 
    
  text_preview_->setPlainText( text );
  
  // set the stream back to where it was
  infile.clear();
  infile.seekg( mark );

  name_->setFocus();
}
开发者ID:fnavarrov,项目名称:SGeMS,代码行数:46,代码来源:filter_qt_dialogs.cpp

示例15: OpenDatafile

    /** Opens the filestream with the first file called @p filename
     found by looking 
     successively in the following directories:
     - the current directory
     - in a subdirectory (of the directory below) with the version of 
     OpenBabel as its name
     - the parent directory specified by the environment variable 
     named @p envvar 
     or "BABEL_DATADIR" if @p envvar is not specified, or the compiled-in
     macro BABEL_DATADIR if the environment variable is not set

     \param ifs        Stream to load
     \param filename   Name of the data file to load
     \param envvar     Name of the environment variable 

     \return the name of the file that was opened. This includes the path
     unless it is in current directory

  **/
  std::string OpenDatafile(std::ifstream& ifs, const std::string& filename, 
                           const std::string& envvar)
  {
    ios_base::openmode imode = ios_base::in;
    #ifdef ALL_READS_BINARY //Makes unix files compatible with VC++6
      imode = ios_base::in|ios_base::binary;
    #endif

    // check the current directory
    ifs.close();
    ifs.clear();
    ifs.open(filename.c_str(),imode);
    if(ifs)
      return filename;

    string file;
    const char* datadir = getenv(envvar.c_str());
    if(!datadir)
      datadir = BABEL_DATADIR;

    // check the subdirectory for this version number
    file = datadir;
    file += FILE_SEP_CHAR;
    file += BABEL_VERSION;
    file += FILE_SEP_CHAR + filename;

    ifs.clear();
    ifs.open(file.c_str(),imode);
    if(ifs)
      return file;

    // couldn't find it with the version built in, so try the parent
    file = datadir;
    file += FILE_SEP_CHAR;
    file += filename;

    ifs.clear();
    ifs.open(file.c_str(),imode);

    if (ifs)
      return file;

    ifs.clear();
    ifs.close();
    return(""); // error
  }
开发者ID:baoilleach,项目名称:obstereo-2-2-x,代码行数:65,代码来源:tokenst.cpp


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