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


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

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


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

示例1: WriteHeader

/**
 * Write out the header information as text.
 * @param ofs The output file stream.
 * @param Dimensions[] The dimensions of the data.
 * @param Origin[] The origin.
 * @param Spacing[] The spacing.
 * @param Increment[] The increment.
 * @param ScalarType The scalar type.
 * The scalar type is defined as follows:
 * \code
 * #define VTK_VOID            0
 * #define VTK_BIT             1
 * #define VTK_CHAR            2
 * #define VTK_SIGNED_CHAR    15
 * #define VTK_UNSIGNED_CHAR   3
 * #define VTK_SHORT           4
 * #define VTK_UNSIGNED_SHORT  5
 * #define VTK_INT             6
 * #define VTK_UNSIGNED_INT    7
 * #define VTK_LONG            8
 * #define VTK_UNSIGNED_LONG   9
 * #define VTK_FLOAT          10
 * #define VTK_DOUBLE         11
 * #define VTK_ID_TYPE        12
 * \endcode
 */
void WriteHeader(std::ofstream & ofs,
   int Dimensions[3], double Origin[3], double Spacing[3],
   int Increment[3], int & ScalarType)
{
//  ofs.seekg(0,std::ios::beg);
  std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags());
  ofs << std::fixed << std::setprecision(2);

  ofs << "Dimensions:  ";
  for ( int i = 0; i < 3; ++i ) ofs << Dimensions[i] << " ";
  ofs << std::endl;
  ofs << "Origin:      ";
  for ( int i = 0; i < 3; ++i ) ofs << Origin[i] << " ";
  ofs << std::endl;
  ofs << "Spacings:    ";
  for ( int i = 0; i < 3; ++i ) ofs << Spacing[i] << " ";
  ofs << std::endl;
  ofs << "Increments:  ";
  for ( int i = 0; i < 3; ++i ) ofs << Increment[i] << " ";
  ofs << std::endl;
  ofs << "Scalar type: " << ScalarType << std::endl;

  ofs << std::setprecision(6) << std::endl;
  std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags());
  ofs.setf(flags,newflags);
}
开发者ID:caomw,项目名称:benthicQT,代码行数:52,代码来源:ReadDTM.cpp

示例2: WriteTextScalars

void DTMImage::WriteTextScalars(std::ofstream &ofs, int const & precision,
                        bool const &DisplayI, bool const &DisplayJ, bool const DisplayK)
{
  if ( this->scalars->size() != (std::size_t)(this->pointProduct[2]) )
  {
    std::cerr << "Dimensions do not match." << std::endl;
    std::cerr << "Number of Scalars:" << this->scalars->size() << " expected: " << this->pointProduct[2] << std::endl;
    return;
  }

  std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags());
  ofs << std::fixed << std::setprecision(precision);

  int choice = (DisplayK << 2) + (DisplayJ << 1) + DisplayI;
  if ( choice & 4  ) choice = 4;
  if ( choice & 2  ) choice = 2;
  if ( choice & 1  ) choice = 1;

  if ( choice == 0 )
  {
    for ( ufDTMScalarTypeBase::iterator p = this->scalars->begin(); p != this->scalars->end(); ++p )
      ofs << *p << "\n";
    return;
  }

  ufDTMScalarTypeBase::iterator p = this->scalars->begin();
  int i = 0;
  int j = 0;
  int k = 0;
  for ( i = 0; i < this->dimensions[0]; ++i )
  {
    if ( choice & 1 )
      ofs << "(" << i << ",...,...) ";
    for ( j = 0; j < this->dimensions[1]; ++j )
    {
      if( choice & 2 )
      {
        ofs << "(" << i << "," << j << ",...) ";
      }
      for ( k = 0; k < this->dimensions[2]; ++k )
      {
        if ( choice & 4 )
          ofs << "(" << i << "," << j << "," << k << ") ";
        ofs << *p++ << " ";
        if ( choice & 4 )
          ofs << std::endl;
      }
      if( choice & 2 )
        ofs << std::endl;
    }
    if ( choice & 1 )
      ofs << std::endl;
  }

  ofs << std::setprecision(6) << std::endl;
  std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags());
  ofs.setf(flags,newflags);
}
开发者ID:caomw,项目名称:benthicQT,代码行数:58,代码来源:ufDTMImage.cpp

示例3: WriteScalars

  void WriteScalars(std::ofstream &ofs, std::vector<T> & Scalars, int Dimensions[3],
     bool const &DisplayI = false, bool const &DisplayJ = false, bool const DisplayK = false)
{
  std::ios::fmtflags flags = ofs.setf(std::ios::fmtflags());
  ofs << std::fixed << std::setprecision(2);

  int choice = (DisplayK << 2) + (DisplayJ << 1) + DisplayI;
  if ( choice & 4  ) choice = 4;
  if ( choice & 2  ) choice = 2;
  if ( choice & 1  ) choice = 1;

  if ( choice == 0 )
    {
      for ( typename std::vector<T>::iterator p = Scalars.begin(); p != Scalars.end(); ++p )
        ofs << *p << "\n";
      return;
    }
  if ( Scalars.size() != (size_t)(Dimensions[0]*Dimensions[1]*Dimensions[2]) )
    {
    std::cerr << "Dimensions do not match." << std::endl;
    return;
    }

  typename std::vector<T>::iterator p = Scalars.begin();
  for ( int i = 0; i < Dimensions[0]; ++i )
    {
    if ( choice & 1 )
      ofs << "(" << i << ",...,...) ";
    for ( int j = 0; j < Dimensions[1]; ++j )
      {
      if( choice & 2 )
      {
        ofs << "(" << i << "," << j << ",...) ";
      }
      for ( int k = 0; k < Dimensions[2]; ++k )
        {
        if ( choice & 4 )
          ofs << "(" << i << "," << j << "," << k << ") ";
        ofs << *p++ << " ";
        if ( choice & 4 )
          ofs << std::endl;
        }
      if( choice & 2 )
        ofs << std::endl;
      }
    if ( choice & 1 )
    ofs << std::endl;
    }


  ofs << std::setprecision(6) << std::endl;
  std::ios::fmtflags newflags = ofs.setf(std::ios::fmtflags());
  ofs.setf(flags,newflags);
}
开发者ID:caomw,项目名称:benthicQT,代码行数:54,代码来源:ReadDTM.cpp

示例4: pluginLoad

        void pluginLoad()
        {
            if (notifyFrequency > 0)
            {
                // number of cells on the current CPU for each direction
                const DataSpace<simDim> nrOfGpuCells = Environment<simDim>::get().SubGrid().getLocalDomain().size;

                // create as much storage as cells in the direction we are interested in:
                // on gpu und host
                sliceDataField = new GridBuffer<float3_X, DIM1 >
                        (DataSpace<DIM1 > (nrOfGpuCells.y()));

                Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency);

                const int rank = Environment<simDim>::get().GridController().getGlobalRank();

                // open output file
                std::stringstream oFileName;
                oFileName << "lineSliceFields_" << rank << ".txt";

                outfile.open(oFileName.str().c_str(), std::ofstream::out | std::ostream::trunc);
                outfile.precision(8);
                outfile.setf(std::ios::scientific);
            }
        }
开发者ID:AK9527lq,项目名称:picongpu,代码行数:25,代码来源:LineSliceFields.hpp

示例5: main

int main(int argc, CHAR *argv[])
{
    PIN_InitSymbols();

    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    TRACE_AddInstrumentFunction(Trace, 0);

    PIN_AddFiniFunction(Fini, 0);

    IMG_AddUnloadFunction(ImageUnload, 0);

    out.open(KnobOutputFile.Value().c_str());
    out.setf(ios::showbase);
    out << hex;

    // Never returns

    PIN_StartProgram();
    
    return 0;
}
开发者ID:FengXingYuXin,项目名称:SHMA,代码行数:25,代码来源:coco.cpp

示例6: main

int main(int argc, char *argv[])
{
    // Initialize pin & symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    // Write to a file since cout and cerr maybe closed by the application
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile << hex;
    TraceFile.setf(ios::showbase);
    
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(Image, 0);

	// RTN_AddInstrumentFunction(Routine, 0);

	// Register ImageUnload to be called when an image is unloaded
    // IMG_AddUnloadFunction(ImageUnload, 0);

	// Register Fini to be called when the application exits
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}
开发者ID:LeeeWee,项目名称:wear-leveling,代码行数:30,代码来源:malloctrace.cpp

示例7: main

int main(int argc, char *argv[])
{
    // Initialize pin & symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }

    pinplay_engine.Activate(argc, argv,
      KnobPinPlayLogger, KnobPinPlayReplayer);
    
    // Write to a file since cout and cerr maybe closed by the application
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile << hex;
    TraceFile.setf(ios::showbase);
    cout << hex;
    cout.setf(ios::showbase);
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(Image, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}
开发者ID:HarishRohini,项目名称:PinplayTools,代码行数:27,代码来源:malloctrace.cpp

示例8: main

int main(int argc, char *argv[])
{
    string trace_header = string("#\n"
                                 "# Memory Access Trace Generated By Pin\n"
                                 "#\n");
    
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile.write(trace_header.c_str(),trace_header.size());
    TraceFile.setf(ios::showbase);
    
    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns

    PIN_StartProgram();
    
    RecordMemWrite(0);
    RecordWriteAddrSize(0, 0);
    
    return 0;
}
开发者ID:aarony,项目名称:arm-v7a-pintool,代码行数:27,代码来源:pinatrace.C

示例9: main

int  main(int argc, char *argv[])
{
    
    PIN_InitSymbols();

    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    

    TraceFile.open(KnobOutputFile.Value().c_str());

    TraceFile << hex;
    TraceFile.setf(ios::showbase);
    
    string trace_header = string("#\n"
                                 "# Call Trace Generated By Pin\n"
                                 "#\n");
    

    TraceFile.write(trace_header.c_str(),trace_header.size());
    
    TRACE_AddInstrumentFunction(Trace, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns

    PIN_StartProgram();
    
    return 0;
}
开发者ID:alagenchev,项目名称:school_code,代码行数:32,代码来源:calltrace.cpp

示例10: main

int main(int argc, char *argv[])
{
    // Initialize pin & symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    // Write to a file since cout and cerr maybe closed by the application
    outFile.open(KnobOutputFile.Value().c_str());
    outFile << hex;
    outFile.setf(ios::showbase);

    
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(Image, 0);
    INS_AddInstrumentFunction(Instruction, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
} 
开发者ID:LeeeWee,项目名称:wear-leveling,代码行数:25,代码来源:memtracker.cpp

示例11: main

int main(int argc, char *argv[])
{
    // Initialize pin & symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    thread_init();
    
    PIN_AddFollowChildProcessFunction(FollowChild, 0);    
    
    // Write to a file since cout and cerr maybe closed by the application
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile << hex;
    TraceFile.setf(ios::showbase);
    
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(ImageLoad, 0);
    IMG_AddUnloadFunction(ImageUnLoad, 0);
    TRACE_AddInstrumentFunction(trace_instrument, 0);

    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}
开发者ID:toejamhoney,项目名称:pin,代码行数:29,代码来源:map_syms.cpp

示例12: main

int main(int argc, char *argv[])
{
    PIN_InitSymbols();

    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    

    TraceFile.open(KnobOutputFile.Value().c_str());

    TraceFile << hex;
    TraceFile.setf(ios::showbase);

    cout << hex;
    cout.setf(ios::showbase);
    
    IMG_AddInstrumentFunction(Image, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}
开发者ID:dcashman,项目名称:Coursework,代码行数:26,代码来源:malloctrace.cpp

示例13: WriteLasLine

void LasWell::WriteLasLine(std::ofstream     & file,
                           const std::string & mnemonic,
                           const std::string & units,
                           double              data,
                           const std::string & description)
{
  file.precision(3);
  file.setf(std::ios_base::fixed);

  file << mnemonic << " ." << units << " " << data << " : " << description << "\n";
}
开发者ID:alfbr,项目名称:crava,代码行数:11,代码来源:laswell.cpp

示例14: PrepareOutputFile

	void DiskFromCFD::PrepareOutputFile(const boost::filesystem::path file_name, std::ofstream& fOutput)
	{
		fOutput.open(file_name.c_str(), std::ios::out);
		fOutput.setf(std::ios::scientific);

		unsigned int count = 1;
		OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, "x[mm]", count);
		OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, "T[K]", count);
		for (unsigned int j = 0; j < thermodynamicsMap_.NumberOfSpecies(); j++)
			OpenSMOKE::PrintTagOnASCIILabel(22, fOutput, thermodynamicsMap_.NamesOfSpecies()[j] + "_w", count);
		fOutput << std::endl;
	}
开发者ID:acuoci,项目名称:CVI,代码行数:12,代码来源:DiskFromCFD.hpp

示例15: write_cams

void write_cams(std::ofstream &file, CameraArray& cam_list)
{
	file.precision(10);
	file.setf(std::ios_base::scientific);

	size_t n_cams = cam_list.size();
	for (size_t i = 0; i < n_cams; ++i) {
		Camera &cam = *(std::dynamic_pointer_cast<Camera>(cam_list[i]));
		file << cam.focal[0] << " " << cam.disto_coeffs[0] << " " << cam.disto_coeffs[1] << std::endl;
		file << cam.rotation.toRotationMatrix() << std::endl;
		file << cam.translation.transpose() << std::endl;
	}
}
开发者ID:srajotte,项目名称:easyBA,代码行数:13,代码来源:io.cpp


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