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


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

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


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

示例1: index_path

	em_blob(const char *path) : completed(0), path_(path) {
		try {
			data.open(path, std::ios_base::in | std::ios_base::binary);
			std::string index_path(path);
			index_path += ".index";
			index.open(index_path.c_str(), std::ios_base::in | std::ios_base::binary);
		} catch (...) {
			data.close();
			index.close();

			throw;
		}
	}
开发者ID:torkve,项目名称:eblob,代码行数:13,代码来源:merge.cpp

示例2: parseScript

	void ConfigLoader::parseScript(std::ifstream &stream)
	{
		//Get first token
		_nextToken(stream);
		if (tok == TOKEN_EOF)
		{
			stream.close();
			return;
		}
 
		//Parse the script
		_parseNodes(stream, 0);
 
		stream.close();
	}
开发者ID:JonathanOhara,项目名称:CGFinalWork,代码行数:15,代码来源:ConfigLoader.cpp

示例3: catch

 /// destructor
 ~basic_file_reader() {
     if (!m_open) return;
     try {
         m_file.close();
     } catch (...) {
     }
 }
开发者ID:GHamrouni,项目名称:utxx,代码行数:8,代码来源:file_reader.hpp

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

示例5: wordInStr

Counter::Counter(std::ifstream &file)
{
	numWords = 0;
	numChars = 0;
	numLines = 0;
	numDigits = 0;
	numLower = 0;
	numUpper = 0;
	lineCond = 0;
	lineCond2 = 0;
	std::string word;
	std::string line;

	//Read by word
	while (file.peek() != EOF)
	{
		
		getline(file, line);
		numWords += wordInStr(line);
		numChars += line.length();
		numDigits += numInStr(line);
		numLower += lowerInStr(line);
		numUpper += upperInStr(line);
		if ((numInStr(line) >= 1) && (lowerInStr(line)>=1))
		{
			lineCond += 1;
			if ((numInStr(line) >= 2) && (lowerInStr(line) >= 3))
			{
				lineCond2 += 1;
			}
		}

	}
	file.close();
}
开发者ID:EthanJamesLew,项目名称:hw3,代码行数:35,代码来源:counter.cpp

示例6: memoryMonitor

/*
monitor memory consumption information
*/
VOID WINAPI memoryMonitor()
{
	HANDLE hProc = NULL;
	PROCESS_MEMORY_COUNTERS pmc;
	SIZE_T tmp = 0;
	while (true)
	{
		hProc = GetCurrentProcess();		
		GetProcessMemoryInfo(hProc, &pmc, sizeof(pmc));
		CloseHandle(hProc);
		tmp = pmc.PagefileUsage + pmc.WorkingSetSize + pmc.QuotaNonPagedPoolUsage + pmc.QuotaPeakPagedPoolUsage;
		memoryCost = tmp > memoryCost ? tmp : memoryCost;
		if (memoryCost > (SIZE_T)MEMORY_OUT * (SIZE_T)1024 * (SIZE_T)1024) //eat too much memory
		{
			ResetEvent(eExit);
			WaitForSingleObject(eBlock, INFINITE);
			//so far, all workers have exited
			fTask.close();
			DumpTasks();
			outputStatistics();
			exit(0);
		}
		Sleep(1000 * 1);//sleep 1 sec
	}
}
开发者ID:brokendragon,项目名称:All-SMT-Solver,代码行数:28,代码来源:dynamicAsChild.cpp

示例7: readPack

void BFieldLog::readPack (std::ifstream &in)//, uint8_t &head1, uint8_t &head2)
{
	if (in.eof())
	{
		in.close();
		return;
	}

	in.read(reinterpret_cast<char*>(&packnum_), sizeof(packnum_));
	in.read(reinterpret_cast<char*>(&time_), sizeof(time_));
	in.read(reinterpret_cast<char*>(&freq_), sizeof(freq_));
	in.read(reinterpret_cast<char*>(&sign1_), sizeof(sign1_));
	in.read(reinterpret_cast<char*>(&sign2_), sizeof(sign2_));
	in.read(reinterpret_cast<char*>(&temp1_), sizeof(temp1_));
	in.read(reinterpret_cast<char*>(&temp2_), sizeof(temp2_));
	in.read(reinterpret_cast<char*>(&flags_), sizeof(flags_));
	in.read(reinterpret_cast<char*>(&crc_), sizeof(crc_));

//	pack_num.push_back(packnum_);
//	time_marks.push_back(time_);
//	frequency.push_back(freq_);
//	signal_1.push_back(sign1_);
//	signal_2.push_back(sign2_);
//	temp_sensor.push_back(temp1_);
//	temp_lamp.push_back(temp2_);
//	flag.push_back(flags_);
}
开发者ID:Fenolftalein,项目名称:GeoScan,代码行数:27,代码来源:b_log.cpp

示例8: closeEdgeFile

  bool closeEdgeFile(int iter_counter) {
 	 if (fin.is_open()) {
 		 fin.close();
 		 //logstream(LOG_INFO) << "close edge block-" << block_id << std::endl;
 	 }
 	 return true;
  }
开发者ID:HybridGraph,项目名称:GraphLab-PowerGraph,代码行数:7,代码来源:dynamic_csr_storage_disk.hpp

示例9: versionReader

bool TetraTools::GMSHMeshLoader::ParseFile(std::ifstream& file_)
{
	std::string cmd;
	unsigned int gmshFormat = 0;
	std::getline(file_, cmd); //Version
	std::istringstream versionReader(cmd);
	std::string version;
	versionReader >> version;
	std::string line;
	if (version == "$MeshFormat") // Reading gmsh 2.0 file
	{
		gmshFormat = 2;
		std::getline(file_, line); // we don't care about this line (2 0 8)
		std::getline(file_, cmd); // end Version
		std::istringstream endMeshReader(cmd);
		std::string endMesh;
		endMeshReader >> endMesh;

		if (endMesh != std::string("$EndMeshFormat") ) // it should end with $EndMeshFormat
		{
			std::cerr << "Closing File as it doesn't end with $EndMeshFormat" << std::endl;
			file_.close();
			return false;
		}
		else
		{
			std::getline(file_, cmd); // First Command
		}
	}
开发者ID:AlexanderSimonov,项目名称:qtetramesher,代码行数:29,代码来源:GMSHMeshLoader.cpp

示例10: ErrorCodePrintOut

void ErrorCodePrintOut(int num)
{
	switch (num)
	{
	case (INFILE_ERROR + OUTFILE_ERROR) :
	{
		std::cout << "There was an error opening both the input and output files." << std::endl;
		break;
	}
	case INFILE_ERROR:
	{
		 std::cout << "Could not open the provided input file" << std::endl;
		 out_file.close();
		 break;
	}
	case OUTFILE_ERROR:
	{
		std::cout << "Could not open the provided output file or do not have write permission" << std::endl;
		in_file.close();
		break;
	}
	default:
		break;
	}
}
开发者ID:BazzalSeed,项目名称:Programming-Systems-and-Languages,代码行数:25,代码来源:cse425_lab0.cpp

示例11: readMatchMatrix

void readMatchMatrix() {
    //reading the match file for pruning the matched edges
    int id, matchId;
    float abdnc, weight, var;
    
    // mFile.open("/cbcb/project-scratch/fdorri/Code/methylFlow/testing/match.txt");
    mFile >> truePatternNum  >> estimatedPatternNum ;
    for (int i = 0; i < truePatternNum ; i++){
        mFile >> id >> abdnc;
        idTrue.push_back(id);
        abdnc_map[id] = abdnc;
    }
    for (int i = 0; i < estimatedPatternNum ; i++){
        mFile >> id >> abdnc;
        idEstimated.push_back(id);
        abdnc_map[id] = abdnc;
    }
    
    for (int i=0; i< truePatternNum ; i++ ){
        mFile >> var >> id >> matchId >> weight ;
        matchTrue_map[id] = matchId;
        weight_map[id] = weight;
        matchEstimated_map[matchId] = id;
    }
    
    mFile.close();
}
开发者ID:hcorrada,项目名称:methylFlow_analyses,代码行数:27,代码来源:main.cpp

示例12: InvokeFunTaint

VOID InvokeFunTaint()
{
	string infileName = "c:\\pinInput.txt";
	ADDRINT argu0=0;
	ADDRINT argu1=0;


	in.open(infileName.c_str());


	in >> hex;

	in >> argu0;
	in >> argu1;

	in.close();

	out <<"argu0 " <<argu0 <<endl;

	out <<"argu1 " <<argu1 <<endl;

	if(argu1!=0)
	{
		int n = 2*wcslen((wchar_t *)argu1);
		out <<endl<<"senmatic: argu2"<<endl;
		out << "variable address: "<<argu1<<endl;
		out <<"variable type: BSTR"  << endl;
		out <<"variable length-byte: " << n <<endl;
		ADDRINT taint = (ADDRINT)argu1;
		AddTaint(taint,n,type_WORD);
		InsertTaintInstrumentation();//find taint source , then enable DTA and instruction-level taint analysis
	}
}
开发者ID:imholulu,项目名称:DTA,代码行数:33,代码来源:MyPinTool.cpp

示例13: LoadDataFromFile

void RegionFileLoader::LoadDataFromFile(std::ifstream &file)
{
    if (file.fail())
    {
        std::cerr << "Error <RegionFileLoader::LoadDataFromFile> File is unreadable" <<  std::endl;
        return;
    }

    Double_t sa;
    std::string aline;
    std::stringstream ss;
    while(1)
    {
        std::getline(file,aline);
        if ( FileIsNotOkay(file) )
            break;
        else if ( LineShouldBeSkipped(aline) )
            continue;
        else if ( BeginningOfRegions(aline) )
        {
//            std::cout << aline << std::endl;
            Regions regions = ReadRegions(file);
            if (regions.size()>0)
                fTheRegions.push_back(regions);
        }
    }

    file.close();

}
开发者ID:jrtomps,项目名称:phdwork,代码行数:30,代码来源:RegionIntegratorMultiDim.cpp

示例14: ReadMatrix

void FDSMesh::ReadMatrix(std::string line, std::ifstream &pFile)
{
    int m = 0;
    int n;
    std::vector<std::string> strVec;
    while (std::getline(pFile, line)) {
        n = 0;
        strVec = split2(line, ',', strVec);
        for (auto &elem : strVec)
        {
            //std::cout << elem << " col " << n  << " line " << m << std::endl;
            if (elem=="nan" || elem=="NAN" || elem=="NaN" || elem=="-inf" || elem=="inf")
            {
                _matrix[m][n].SetValue(1.0);
                //Log->Write("ERROR: Mesh values consist of nan!");
                //exit(EXIT_FAILURE);
            }
            else
                _matrix[m][n].SetValue(std::stod(elem));
            ++n;
        }
        strVec.clear();
        ++m;
    }

    pFile.close();
    _statMesh=true;
}
开发者ID:chraibi,项目名称:jpscore,代码行数:28,代码来源:FireMesh.cpp

示例15: Parse

JsonNode JsonReader::Parse(std::ifstream &file) {
   std::string keyname;

   file.seekg(0, std::ios::end);
   m_size = static_cast<size_t>(file.tellg());

   m_data = new char[m_size];

   m_start = m_data;
   m_end = m_start + m_size;

   file.seekg(0, std::ios::beg);
   file.read(m_data, m_size);
   file.close();

   this->SkipWhiteSpaces();

   JsonNode root;

   /* The root element of a JSON document has to be an object or an array. */
   if (*m_data == '[') {
      root = this->ParseArray();
   } else if (*m_data == '{') {
      root = this->ParseObject();
   } else {
      PrintError("Syntax Error : '{' , '[' were expected. ");
   }

   /* clean up */
   delete[] m_start;

   return root;
}
开发者ID:dtbinh,项目名称:darkmatter,代码行数:33,代码来源:JsonReader.cpp


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