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


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

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


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

示例1: write_dibheader

//os2 type of a header
static bool write_dibheader(int bit_depth)
{

	dib_head dib;
	dib.headsz=12;
	dib.width=w;
	dib.height=h;
	dib.colplanes=1;
	dib.bitsperpix=bit_depth;

	fout.write((char *) &(dib.headsz), sizeof(char) * 4);
	if (!fout.good()) return 0;

	fout.write((char *) &(dib.width), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(dib.height), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(dib.colplanes), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(dib.bitsperpix), sizeof(char) * 2);
	if (!fout.good()) return 0;

	return 1;
}
开发者ID:X-rayLaser,项目名称:GraphMaker,代码行数:28,代码来源:bmpMaker.cpp

示例2: write_fileheader

static bool write_fileheader(int clrtable_sz)
{
	f_head head;
	head.bmid[0]='B';
	head.bmid[1]='M';
	head.sz=14+12+clrtable_sz+sz;//head size+dib_size+color_table size+bitmap_sz
	head.res1=0;
	head.res2=0;
	head.pixoffset=14+12+clrtable_sz;

	fout.write((char *) (head.bmid), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(head.sz), sizeof(char) * 4);
	if (!fout.good()) return 0;

	fout.write((char *) &(head.res1), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(head.res2), sizeof(char) * 2);
	if (!fout.good()) return 0;

	fout.write((char *) &(head.pixoffset), sizeof(char) * 4);
	if (!fout.good()) return 0;

	return 1;
}
开发者ID:X-rayLaser,项目名称:GraphMaker,代码行数:27,代码来源:bmpMaker.cpp

示例3: save

//====================================================================
// Save network to file
//====================================================================
bool BPNet::save( ofstream &ost ) const
{
	if ( !ost.good() )
		return false;

	int numLayers = _nodeCount.size();
	int numNodes = _nodes.size();
	int numLinks = _links.size();

	ost << numLayers << endl; // num layers
	
	for(int i = 0; i != numLayers; ++i)
		ost << _nodeCount[i] << endl; // number of nodes in each layer
	
	ost << numNodes << endl; // total number of nodes
	ost << numLinks << endl; // total number of links

	// save nodes data
	for(i = 0; i != numNodes; ++i)
		_nodes[i]->save(ost);

	// save links data
	for(i = 0; i != numLinks; ++i)
		_links[i]->save(ost);
	
	if (!ost.good())
		return false;

	return true;
}
开发者ID:gpertzov,项目名称:BPNet,代码行数:33,代码来源:BPNet.cpp

示例4: DealWithMatch

bool DealWithMatch(const vector <string> &LineList, const boost::regex &RegExpress, const DataFile &TypeEntry, ofstream &TableStream,
		   const size_t FilingIndex)
// MAJOR robustness issues here!  See notes in this function.
{
//	cerr << "Going into DealWithMatch()\n";
	bool IsSuccessful;
	const vector <string> Captures = ObtainCaptures(RegExpress, LineList[0], TypeEntry.PatternExplainCount() + 1);
//	cerr << "Got Captures\n";

	const vector <string> Descriptors = GatherInfo(LineList, Captures, TypeEntry.GiveAllPatternExplains(), 
						       TypeEntry.GiveAllAssignExpressions(), IsSuccessful);
//	cerr << "Got Descriptors\n";

	// May need to put in controls of some sort to determine whether something should be quoted or not.
	if (IsSuccessful)
	{
		TableStream << GiveDelimitedList(LineList, ',') << ',' << FilingIndex << ',' << GiveDelimitedList(Descriptors, ',') << "\n";
	}


	// This above segment prints to the appropriate subcatalogue file the following info:
	//	Filename, File Group number, Volume Name, FileSize, FilingIndex, and Date information for the file, and any other descriptor information.
	// there is always DateTime_Info for Descriptors[0]

	return(TableStream.good());
}
开发者ID:BVRoot,项目名称:TinT,代码行数:26,代码来源:Sorter.C

示例5: writeFile

static bool writeFile(const wstring &res, ofstream &fs, bkplong pos)
{
	static unsigned short magic = 0xFEFF;
	//write in Unicode16-LE
	if (!fs.good())
		return false;
	if (pos >= 0)
		fs.seekp(pos, ios_base::beg);
	else
		fs.seekp(pos + 1, ios_base::end);
	fs.write((const char *)&magic, 2);
	u16string result;
	bkplong s = res.size();
	bkplong s2 = s * sizeof(wchar_t) / sizeof(char16_t);
	result.resize(s2);
#ifdef HAVE_CODECVT
	auto& f = use_facet<codecvt<wchar_t, char16_t, mbstate_t>>(locale());
	mbstate_t mb = mbstate_t();
	char16_t* from_next;
	const wchar_t* to_next;
	f.out(mb, &res[0], &res[s], to_next, &result[0], &result[s2], from_next);
#else
	ucs4toutf16((uint16_t *)&result[0], (uint32_t *)&res[0], s);
#endif
	fs.write((const char *)result.c_str(), 2 * result.length());
	return true;
}
开发者ID:Icemic,项目名称:BKOven,代码行数:27,代码来源:utils.cpp

示例6: write_custom_header

void write_custom_header(ofstream &file){

  // check input file is actually an open ofstream...
  if (!file.good()){
    cerr << "ERROR - problem with file opening. Aborting..." << endl;
    exit(1);
  }
    
  // build variables
  string line;
  string header_content;
  ifstream conf(c_CUSTOM_HEADER_FILE.c_str());
  
  if (!conf){
    cerr << "ERROR: Unable to open configuration file..." << endl
	 << "Aborting!" << endl;
    exit(1);
  }
  
  // read all of the file defined by c_CUSTOM_HEADER_FILE
  while(getline(conf,line)){
      line.append("\n");
      header_content = header_content.append(line);
  }
  
  // write to your new headerfile
  file << header_content;
  
  cout << "Loaded custom header details..." << endl;
}
开发者ID:alexholehouse,项目名称:autoClasser,代码行数:30,代码来源:autoClasser.cpp

示例7: writeChar

bool Serializer::writeChar(ofstream &outfile, char write) {
	outfile.put(write);
	if (!outfile.good())
		return false;
	
	return true;
}
开发者ID:eperiod-software,项目名称:metal-trainer,代码行数:7,代码来源:Serializer.cpp

示例8: print_bfs_tree

/* Print the BFS tree from a particular vertex. */
void graph_using_AL::print_bfs_tree(string start_vertex, ofstream& fout) {
    /* Check if 'fout' is good. */
    assert(fout.good());

    /* Find the start vertex. */
    map<string, set<string> >::iterator v_itr = find_vertex(start_vertex);
    if(v_itr == data.end()) {
        /* Vertex not found. */
        cerr << "Start Vertex not found." << endl;
        return;
    }

    map<string, string>  parent  ;
    map<string,    int>  distance;

    /* Do the BFS traversal.
     * The 'parent' and the 'distance' containers will be populated by this function.
     */
    BFS_visit(parent, distance, start_vertex);

    /* Printing the parent details. */
    if(debug_flag) clog << "Parent array: " << endl;
    vector<pair<string, string> > vp;
    for(map<string, string>::iterator p_itr = parent.begin(); p_itr != parent.end(); p_itr++) {
        vp.push_back(pair<string, string>(p_itr->first, p_itr->second));
        if(debug_flag) cout << p_itr->first << " <-- " << p_itr->second << endl;
    }

    print_tree_with_edges_colored(vp, "red", fout);

    return;
}
开发者ID:Prudhviyendluri,项目名称:Data-Structures,代码行数:33,代码来源:graph_using_adjacent_list.cpp

示例9: save

	void BitString::save(ofstream & out) const
	{
		assert(out.good());
		out.write((char*)&length,sizeof(size_t));
		out.write((char*)&uintLength,sizeof(size_t));
		out.write((char*)data,uintLength*sizeof(uint));
	}
开发者ID:rkonow,项目名称:libcds,代码行数:7,代码来源:libcdsBitString.cpp

示例10: save

 void MapperCont::save(ofstream & out) const
 {
     assert(out.good());
     uint wr = MAPPER_CONT_HDR;
     saveValue(out,wr);
     m->save(out);
 }
开发者ID:mpetri,项目名称:libcds,代码行数:7,代码来源:MapperCont.cpp

示例11: start_log

bool start_log(const char *filename) {
    event_log.open(filename);
    if(!event_log.good()) {
        std::cout << "Error!: Could not open log file" << endl;
        return false;
    }
    return true;
}
开发者ID:ubertome,项目名称:ProceduralTerrain,代码行数:8,代码来源:main.cpp

示例12: output_read

////////////////////////////////////////////////////////////////////////////////
// output_read
//
// Output the given possibly corrected and/or trimmed
// read according to the given options.
////////////////////////////////////////////////////////////////////////////////
static void output_read(ofstream & reads_out, ofstream & corlog_out, int pe_code, string header, string ntseq, string mid, string strqual, string corseq, stats & tstats) {
  if(corseq.size() >= trim_t) {
    // check for changes
    bool corrected = false;
    for(int i = 0; i < corseq.size(); i++) {
      if(corseq[i] != ntseq[i]) {
	// log it
	if(corlog_out.good())
	  corlog_out << (strqual[i]-Read::quality_scale) << "\t" << (i+1) << "\t" << corseq[i] << "\t" << ntseq[i] << endl;
	// note it
	corrected = true;
	// set qual to crap
	strqual[i] = (char)(Read::quality_scale+2);
      }
    }
    if(corrected)
      tstats.corrected++;

    // update header
    if(!orig_headers) {
      if(corrected)
	header += " correct";
      unsigned int trimlen = ntseq.size()-corseq.size();
      if(trimlen > 0) {
	stringstream trim_inter;
	trim_inter << trimlen;
	header += " trim=" + trim_inter.str();
	tstats.trimmed++;
	if(!corrected)
	  tstats.trimmed_only++;
      } else {
	if(!corrected)
	  tstats.validated++;
      }
    }
    // print
    if(contrail_out)
      reads_out << header << "\t" << corseq << endl;
    else
      reads_out << header << endl << corseq << endl << mid << endl << strqual.substr(0,corseq.size()) << endl;
    if(TESTING)
      cerr << header << "\t" << ntseq << "\t" << corseq << endl;
  } else {
    tstats.removed++;
    if(uncorrected_out || pe_code > 0) {
      // update header
      header += " error";

      //print
      if(contrail_out)
	reads_out << header << "\t" << ntseq << endl;
      else
	reads_out << header << endl << ntseq << endl << mid << endl << strqual << endl;	  
    }
    if(TESTING)
      cerr << header << "\t" << ntseq << "\t-" << endl; // or . if it's only trimmed?
  }
}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:64,代码来源:correct.cpp

示例13: WriteToFile

void costVec::WriteToFile(ofstream &fout)
{
  assert(fout.is_open() && fout.good());
  
  for(size_t cid = 0; cid < VEC_DIMENSION; cid++)
  {
    fout << ' ' << c[cid];
  }
}
开发者ID:priyankarghosh,项目名称:MLBB,代码行数:9,代码来源:CostVec.cpp

示例14: AbrirArchivoParaEscribir

void AbrirArchivoParaEscribir(ofstream &archivo)
{
    cout << "  Ingrese nombre de archivo: ";
    string opt;
    bool ok = false;
    getline(cin, opt);
    getline(cin, opt);
    archivo.open(opt.c_str());
    ok = archivo.good();

    while (!ok)
    {
        cout << "  Valor incorrecto. Ingrese nombre de archivo: ";
        getline(cin, opt);
        archivo.open(opt.c_str());
        ok = archivo.good();
    }
}
开发者ID:nlasso,项目名称:Borbotones,代码行数:18,代码来源:interfaz.cpp

示例15: openOfstream

int openOfstream(ofstream & out, const char * filename)
{
  out.open(filename);
  if(!out.good()){
    std::cerr << "Cannot write to " << filename << std::endl;
    return -1;
  }
  return 0;
}
开发者ID:gkanwar,项目名称:simit-1,代码行数:9,代码来源:mesh.cpp


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