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


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

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


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

示例1: checkIfWriteSucceed

void checkIfWriteSucceed(std::fstream& logFile)
{
    // The logFile.good returns 1 if everything was ok at the last op.
    // exitIfFail checks if the number she gets is not zero, so we use the not
    // to flip good to match exitIfFail
    exitIfFail(!logFile.good());
}
开发者ID:yuvaljacoby,项目名称:OS,代码行数:7,代码来源:helperFunctions.cpp

示例2: OpenFile

bool OpenFile(const std::wstring& aFile, std::fstream& aStream,
			  std::ios_base::open_mode aMode)
{
	std::string s;
	aStream.open(Ucs2ToUtf8(aFile, s).c_str(), aMode);
	return aStream.good();
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:7,代码来源:utils_win32.cpp

示例3:

static bool loadY4MHeader(std::fstream& fs, cv::Mat &img)
{
    fs.seekg(fs.beg);
    if (fs.good())
    {
        char inbuf [256];
        fs >> inbuf;
        if (strcmp(inbuf, "YUV4MPEG2") != 0)
        {
            return false;
        }
        fs.get(); // space
        int width, height;
        char c = fs.get();
        if (c != 'W')
        {
            return false;
        }
        fs >> width;
        c = fs.get();// space
        c = fs.get();
        if (c != 'H')
        {
            return false;
        }
        fs >> height;
        img.create(height * 3 / 2, width, CV_8UC1);
    }
开发者ID:icylord,项目名称:facedetect,代码行数:28,代码来源:detect.cpp

示例4: Save

bool Organism::Save (std::fstream &File) const {
   // File format:
   //          StateCount         sizeof (int)
   //          SensorCount        sizeof (int)
   //          CurrentState       sizeof (int)
   //          States             sizeof (State) * StateCount
   //          Sensors            sizeof (Sensor) * SensorCount
   //          OrgGenome          varies
   File.write ((const char *) &StateCount,   sizeof (int));
   File.write ((const char *) &SensorCount,  sizeof (int));
   File.write ((const char *) &CurrentState, sizeof (int));
   
   // Save states:
   int i;
   for (i = 0; i < StateCount; i++) {
      if (!States [i].Save (File))
         return false;
   }

   // Save sensors:
   for (i = 0; i < SensorCount; i++) {
      if (!Sensors [i].Save (File))
         return false;
   }

   // Save the genome:
   if (!OrgGenome.Save (File))
      return false;

   if (!File.good ())
      return false;

   return true;
}
开发者ID:joliva,项目名称:adaptive-ai,代码行数:34,代码来源:AdaptOrg.cpp

示例5: Load

bool Organism::Load (std::fstream &File) {
   File.read ((char *) &StateCount,   sizeof (int));
   File.read ((char *) &SensorCount,  sizeof (int));
   File.read ((char *) &CurrentState, sizeof (int));
   
   // Allocate memory for states:
   delete [] States;
   States = new State [StateCount];

   // Load states:
   int i;
   for (i = 0; i < StateCount; i++) {
      if (!States [i].Load (File))
         return false;
   }

   // Allocate memory for the sensors:
   delete [] Sensors;
   Sensors = new Sensor [SensorCount];

   // Load sensors:
   for (i = 0; i < SensorCount; i++) {
      if (!Sensors [i].Load (File))
         return false;
   }

   // Load the genome:
   if (!OrgGenome.Load (File))
      return false;

   if (!File.good ())
      return false;

   return true;
}
开发者ID:joliva,项目名称:adaptive-ai,代码行数:35,代码来源:AdaptOrg.cpp

示例6: encryptData

bool XorEncryptor::encryptData(std::fstream &original, std::fstream &result)
{
	if (!original.is_open() || !result.is_open())
	{
		return false;
	}

	original.seekg(0, std::ios::beg);
	result.seekp(0, std::ios::beg);

	char c = 0;
	unsigned i = 0;
	while (original.good())
	{
		original.read(&c, 1);
		c ^= password[i];
		if(original.gcount() > 0)
		{
			result.write(&c, 1);
		}

		if (++i == passSize)
		{
			i = 0;
		}
	}

	original.seekg(0, std::ios::beg);
	result.seekg(0, std::ios::beg);
	result.flush();

	return true;
}
开发者ID:Yashchuk,项目名称:GL-Base-camp,代码行数:33,代码来源:XorEncryptor.cpp

示例7: write

bool write(std::fstream& file, Json::Value const& root)
{
   Json::StyledWriter writer;
   std::string val = writer.write(root);
   LOG4CPLUS_INFO(CFileStorage::msLogger, val);
   file << val;
   file.flush();
   file.seekg(0, ios::beg);
   return file.good();
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例8: manageFile

void manageFile(std::fstream &InputFile, std::vector<Operator> &operators)
{
	std::cout << "File is opened" << std::endl;
	if (InputFile.good())
	{
		std::string line = "";
		while (std::getline(InputFile, line))
		{
			fillOperators(line, operators);
		}
	}
}
开发者ID:mvladimirova,项目名称:DS-Homework,代码行数:12,代码来源:main.cpp

示例9: readBoolean

static void readBoolean(std::fstream &str, bool &res)
{
  if(!str.good()){
    return;
  }
  std::string tmp;
  str>>tmp;
  std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
  if(tmp.find("true", 0) != std::string::npos){
    res = true;
  }else{
    res = false;
  }
}
开发者ID:sparker256,项目名称:xchecklist,代码行数:14,代码来源:Xchecklist.cpp

示例10:

bool CLayer:: read_layer_multi_contour_with_z(std::fstream& fin)
{

  int pos=-1;
  float levelID;
  int contourID;
  bool result=true;

  if (fin.good())
  {
    pos=fin.tellg();
    fin>>levelID;
    fin>>contourID;
    fin.seekg(pos);
  }
开发者ID:ricther,项目名称:reconstruction_program,代码行数:15,代码来源:CLayer.cpp

示例11: sizeof

bool Organism::State::Save (std::fstream &File) {
   // File format:
   //              Count         sizeof (int)
   //              Name          sizeof (char) * Count

   int Count = Name.size() + 1;

   File.write ((const char *) &Count, sizeof (int));
   File.write ((const char *) Name.c_str(), sizeof (char) * Count);

   if (!File.good ())
      return false;

   return true;
}
开发者ID:joliva,项目名称:adaptive-ai,代码行数:15,代码来源:AdaptOrg.cpp

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

示例13: ReadLine

////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Reads a line from a fstream adding it to a string, reading up
///          to a newline character.
///
///   \param[in] str File stream operator.
///   \param[out] line Line read from file (doesn't include carriage return).
///
///   \return Number of characters read.
///
////////////////////////////////////////////////////////////////////////////////////
unsigned int FileIO::ReadLine(std::fstream& str,
                              std::string& line)
{
    char ch;
    line.reserve(512);
    line.clear();
    while(str.eof() == false && str.good())
    {
        str.get(ch);
        if(ch == '\n')
        {
            break;
        }
        else
        {
            line.push_back(ch);
        }
    }

    return (unsigned int)line.size();
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:32,代码来源:fileio.cpp

示例14: main

int main()
{
    
    f1.open("/Users/robinmalhotra2/Desktop/csl201check.txt",std::ios::in|std::ios::out);
    
    f1.getline(s, 80, ' ');
        while (f1.good())
    {

        
        
        
       
        std::cout<<"addasd";
        if ((strlen(s)==1) && (s[0])<'9' && (s[0])>'0')
            
        {
            switch ((s[0]))
            {
                    
                case '1':
                    createandprintlist();
                    
                
                    break;
                    
                case '2':
                    sortlist();
                    break;
                    
                case '3':
                    nextinsert();
                    break;
                    
                case '4':
                    searchlist();
                    break;
                    
                case '5':
                    deletenext();
                    break;
                    
                case '6':
                    deduplicate();
                    break;
                    
                case '7':
                    mergesortthing();
                    break;
                    
                case '8':
                    credits();
                    break;
                    
                    
                    
                default:
                    break;
            }
        }
        
        
    }
    f1.close();
    
    
    
}
开发者ID:codeOfRobin,项目名称:Linked-lists,代码行数:68,代码来源:main.cpp

示例15: IsValid

bool OsFileImpl::IsValid() const
{
    return mFile.good();
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:4,代码来源:osfile.cpp


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