• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::ofstream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: outputGlobalPropFile

void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) {
	std::string warnings;
	for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i)
		warnings +=  *i + ';';

	std::string definesList;
	for (StringList::const_iterator i = defines.begin(); i != defines.end(); ++i) {
		if (i != defines.begin())
			definesList += ';';
		definesList += *i;
	}

	// Add define to include revision header
	if (runBuildEvents)
		definesList += REVISION_DEFINE ";";

	properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
	              "<VisualStudioPropertySheet\n"
	              "\tProjectType=\"Visual C++\"\n"
	              "\tVersion=\"8.00\"\n"
	              "\tName=\"" << PROJECT_DESCRIPTION << "_Global\"\n"
	              "\tOutputDirectory=\"$(ConfigurationName)" << bits << "\"\n"
	              "\tIntermediateDirectory=\"$(ConfigurationName)" << bits << "/$(ProjectName)\"\n"
	              "\t>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCCLCompilerTool\"\n"
	              "\t\tDisableLanguageExtensions=\"true\"\n"
	              "\t\tDisableSpecificWarnings=\"" << warnings << "\"\n"
	              "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines;$(" << LIBS_DEFINE << ")\\include;$(TargetDir)\"\n"
	              "\t\tPreprocessorDefinitions=\"" << definesList << "\"\n"
	              "\t\tExceptionHandling=\"0\"\n";

#if NEEDS_RTTI
	properties << "\t\tRuntimeTypeInfo=\"true\"\n";
#else
	properties << "\t\tRuntimeTypeInfo=\"false\"\n";
#endif

	properties << "\t\tRuntimeTypeInfo=\"false\"\n"
	              "\t\tWarningLevel=\"4\"\n"
	              "\t\tWarnAsError=\"false\"\n"
	              "\t\tCompileAs=\"0\"\n"
	              "\t\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCLibrarianTool\"\n"
	              "\t\tIgnoreDefaultLibraryNames=\"\"\n"
	              "\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCLinkerTool\"\n"
	              "\t\tIgnoreDefaultLibraryNames=\"\"\n"
	              "\t\tSubSystem=\"1\"\n"
	              "\t\tEntryPointSymbol=\"WinMainCRTStartup\"\n"
	              "\t\tAdditionalLibraryDirectories=\"$(" << LIBS_DEFINE << ")\\lib\\" << ((bits == 32) ? "x86" : "x64") << "\"\n"
	              "\t/>\n"
	              "\t<Tool\n"
	              "\t\tName=\"VCResourceCompilerTool\"\n"
	              "\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n"
	              "\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n"
	              "\t/>\n"
	              "</VisualStudioPropertySheet>\n";

	properties.flush();
}
开发者ID:bluddy,项目名称:scummvm,代码行数:63,代码来源:visualstudio.cpp


示例2: setup

namespace Log {

   // component-scope variables
   const unsigned int log_master = 0;
   std::string log_file;
   std::ofstream lout;

   bool initialized = false;
   std::stringstream buffer;

   // =========================================================================
   // Set up

   void setup () {

      // ----------------------------------------------------------------------
      // Initialize the Log component

      // Name of log file
      log_file = Parameters::get_optional<std::string>(
            "Log.log_file", "log.txt");
      log_file = Driver::output_dir + log_file;

      // Open log file
#ifdef PARALLEL_MPI
      if (Driver::proc_ID == log_master) {
         lout.open(log_file.c_str());
      }
#else // PARALLEL_MPI
      lout.open(log_file.c_str());
#endif // PARALLEL_MPI
      initialized = true;

      // Write the log file header
      lout << "Hydrodynamics Simulation" << std::endl << std::endl;

      // If the buffer is not empty, push it to the file
      lout << buffer.str();
      buffer.clear();
      buffer.str("");

   }

   // =========================================================================
   // Clean up

   void cleanup () {

      // Final printing
      write_single("\n" + std::string(79,'_') + "\nProgram Complete\n");

      if (initialized) {
         // If the log file is open, close it
#ifdef PARALLEL_MPI
         if (Driver::proc_ID == log_master) {
#endif // PARALLEL_MPI
            lout.close();
            initialized = false;
#ifdef PARALLEL_MPI
         }
#endif // PARALLEL_MPI
      } else {
         // If the log file was never opened, print the buffer to the screen
         std::cout << buffer.str();
         buffer.clear();
         buffer.str("");
      }

   }

   // =========================================================================
   // Write to the log file

   void write_all(std::string message) {
#ifdef PARALLEL_MPI
      // Declare variables
      int length, max_length;
      char *send_buf, *recv_buf;

      // MPI_Allreduce to determine length of longest message
      length = message.length();
      MPI_Allreduce(&length, &max_length, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);

      // Pad message to max_length
      message.resize(max_length, '\0');

      // Allocate a character array of max_length
      send_buf = (char*) message.c_str();
      recv_buf = new char[Driver::n_procs*max_length];

      // MPI_Gather the messages into a read buffer
      MPI_Gather(send_buf, max_length, MPI_CHAR,
                 recv_buf, max_length, MPI_CHAR, log_master, MPI_COMM_WORLD);

      // If you are the master:
      if (Driver::proc_ID == log_master) {
         // Parse the read buffer into individual messages
         for (int i = 0; i < Driver::n_procs; i++) {
            for (int j = 0; j < max_length; j++) {
               if (recv_buf[i*max_length+j] == '\0') {
//.........这里部分代码省略.........
开发者ID:bkkrueger,项目名称:toy_hydro,代码行数:101,代码来源:Log.cpp


示例3: saveToStream

bool EyeRecord::saveToStream(std::ofstream& output) const
{
    output.write((const char*) &cEYES, 4);
    if (!saveSizeAndUnknownValues(output, getWriteSize())) return false;

    //write EDID
    output.write((const char*) &cEDID, 4);
    //EDID's length
    uint16_t subLength = editorID.length()+1;
    output.write((const char*) &subLength, 2);
    //write editor ID
    output.write(editorID.c_str(), subLength);

    //write FULL
    if (!name.saveToStream(output, cFULL))
        return false;

    //write ICON
    output.write((const char*) &cICON, 4);
    //ICON's length
    subLength = iconPath.length()+1;
    output.write((const char*) &subLength, 2);
    //write icon path
    output.write(iconPath.c_str(), subLength);

    //write DATA
    output.write((const char*) &cDATA, 4);
    //DATA's length
    subLength = 1;
    output.write((const char*) &subLength, 2);
    //write DATA's content
    output.write((const char*) &flags, 1);

    return output.good();
}
开发者ID:Thoronador,项目名称:morrowtools,代码行数:35,代码来源:EyeRecord.cpp


示例4: saveParameters

bool Cylinder::saveParameters(std::ofstream& fout) const
{
  fout << "# cylinder normal_x normal_y normal_z point_x point_y point_z radius" << std::endl;
  fout << "cylinder " << _normal << " " << _point << " " << _radius << std::endl;
  return fout.good();
}
开发者ID:caomw,项目名称:GlobFit,代码行数:6,代码来源:Cylinder.cpp


示例5: saveToStream

bool PathGridRecord::saveToStream(std::ofstream& output) const
{
    output.write((const char*) &cPGRD, 4);
    uint32_t Size;
    Size = 4 /* DATA */ +4 /* 4 bytes for length */ + 12 /* size of data */
           +4 /* NAME */ +4 /* 4 bytes for length */
           +CellName.length()+1 /* length of cell name +1 byte for NUL termination */;
    if (!Points.empty())
    {
        Size = Size + 4 /* PGRP */ +4 /* 4 bytes for length */
               +16 * Points.size();
    }
    if (!Connections.empty())
    {
        Size = Size + 4 /* PGRC */ +4 /* 4 bytes for length */
               +8 * Connections.size();
    }
    output.write((const char*) &Size, 4);
    output.write((const char*) &HeaderOne, 4);
    output.write((const char*) &HeaderFlags, 4);

    /*Path Grid:
      DATA = (path grid data, 12 bytes)
               int32_t GridX
               int32_t GridY
               uint16_t Granularity (a power of two within [128;4096])
               uint16_t NumQuads (number of points in PGRP)
      NAME = name of cell the grid belongs to
      PGRP = unknown data (path grid points?)
               looks like an array of int32_t quads
               struct PointData
               {
                 int32_t X
                 int32_t Y
                 int32_t Z
                 int32_t Unknown
               };

      PGRC = unknown data (length: ?)
               Possibly path grid connections?
               Looks like an array of uint32_t pairs, where
               first value is the index of the starting point
               and second value is index of the end point.
    */

    //write DATA
    output.write((const char*) &cDATA, 4);
    //DATA's length
    uint32_t SubLength;
    SubLength = 12; //length is always twelve bytes
    output.write((const char*) &SubLength, 4);
    //write path grid data
    output.write((const char*) &GridX, 4);
    output.write((const char*) &GridY, 4);
    output.write((const char*) &Granularity, 2);
    output.write((const char*) &NumQuads, 2);

    //write NAME
    output.write((const char*) &cNAME, 4);
    //NAME's length
    SubLength = CellName.length()+1;//length of string plus one for NUL-termination
    output.write((const char*) &SubLength, 4);
    //write cell name
    output.write(CellName.c_str(), SubLength);

    if (!Points.empty())
    {
        //write PGRP
        output.write((const char*) &cPGRP, 4);
        //PGRP's length
        SubLength = Points.size()*16;//length is 16 bytes per point
        output.write((const char*) &SubLength, 4);
        //write points
        unsigned int i;
        for (i=0; i<Points.size(); ++i)
        {
            //write next point
            output.write((const char*) &(Points[i].X), 4);
            output.write((const char*) &(Points[i].Y), 4);
            output.write((const char*) &(Points[i].Z), 4);
            output.write((const char*) &(Points[i].Unknown), 4);
        }//for
    }//Points

    if (!Connections.empty())
    {
        //write PGRC
        output.write((const char*) &cPGRC, 4);
        //PGRC's length
        SubLength = Connections.size()*8;//length is 8 bytes per connection
        output.write((const char*) &SubLength, 4);
        //write connections
        unsigned int i;
        for (i=0; i<Connections.size(); ++i)
        {
            //write next point
            output.write((const char*) &(Connections[i].Start), 4);
            output.write((const char*) &(Connections[i].End), 4);
        }//for
    }//connections
//.........这里部分代码省略.........
开发者ID:Thoronador,项目名称:morrowtools,代码行数:101,代码来源:PathGridRecord.cpp


示例6: createOutputFile

void createOutputFile (std::ofstream & outputFile, FILE * ptr_fp, bool isRestart, double delT, double delV, 
		       double tMin, double tMax, double vMin, double vMax, int Nvsteps, int Ntsteps, 
		       int downSampleT, int downSampleV, char * rChoice, char * regionChoice, 
		       char * distChoice, char * scattType, char * gradientOption, double vthe, 
		       double memi, double B, double wpe, double wce, double wci, double beta_e, 
		       double vA, double c1, double nu, double omega, double delB, double deln, 
		       double delR, double kpar, int Lx, int l0) {
  
  if (isRestart == 1) {
    outputFile.open("outputFile.txt", std::ios::out | std::ios::app); 
    std::cout << "Restart -> appending already existing outfile" << std::endl; 
  } else {

    // Opening output file 
    outputFile.open("outputFile.txt"); 

    // Opening saving file
    /*if((ptr_fp = fopen("cppTestOutput.bin", "ab")) == NULL)
      {
	printf("Unable to open file!\n");
	exit(1);
	}else printf("Opened file successfully for writing.\n");*/
    
    // Adding important information to the output file
    outputFile << "Simulation Variables:" << std::endl; 
    outputFile << "delT = " << delT << std::endl; 
    outputFile << "delV = " << delV << std::endl;
    outputFile << "tMin = " << tMin << std::endl; 
    outputFile << "tMax = " << tMax << std::endl; 
    outputFile << "vMin = " << vMin << std::endl; 
    outputFile << "vMax = " << vMax << std::endl;
    outputFile << "Nvsteps = " << Nvsteps << std::endl;
    outputFile << "Ntsteps = " << Ntsteps << std::endl; 
    outputFile << "downSampleT = " << downSampleT << std::endl; 
    outputFile << "downSampleV = " << downSampleV << std::endl << std::endl; 
  
    outputFile << "Physical Variables:" << std::endl;
    outputFile << "rChoice = " << rChoice << std::endl; 
    outputFile << "regionChoice = " << regionChoice << std::endl; 
    outputFile << "distChoice = " << distChoice << std::endl; 
    outputFile << "scattType = " << scattType << std::endl; 
    outputFile << "gradientOption = " << gradientOption << std::endl << std::endl;

    outputFile << "Physical Parameters:" << std::endl; 
    outputFile << "vthe = " << vthe << std::endl; 
    outputFile << "memi = " << memi << std::endl; 
    outputFile << "B = " << B << std::endl;
    outputFile << "wpe = " << wpe << std::endl;
    outputFile << "wce = " << wce << std::endl;
    outputFile << "wci = " << wci << std::endl;
    outputFile << "beta_e = " << beta_e << std::endl;
    outputFile << "vA = " << vA << std::endl;
    outputFile << "c1 = " << c1 << std::endl;
    outputFile << "nu = " << nu << std::endl;
    outputFile << "omega = " << omega << std::endl;
    outputFile << "delB = " << delB << std::endl;
    outputFile << "deln = " << deln << std::endl;
    outputFile << "delR = " << delR << std::endl;
    outputFile << "kpar = " << kpar << std::endl;
    outputFile << "Lx = " << Lx << std::endl;
    outputFile << "l0 = " << l0 << std::endl << std::endl;

    outputFile << "Simulation Output:" << std::endl;
  }
}
开发者ID:elichko27,项目名称:MagneticPumping,代码行数:65,代码来源:createOutputFile.cpp


示例7: closeFileStream

 static void closeFileStream(std::ofstream& fileStream) {
     assert_true(fileStream.good());
     fileStream.close();
 }
开发者ID:AlexanderKazakov,项目名称:gcm,代码行数:4,代码来源:FileUtils.hpp


示例8: openTextFileStream

 /** Open file stream to write in */
 static void openTextFileStream(std::ofstream& fileStream,
                                const std::string& fileName) {
     fileStream.open(fileName, std::ios::out);
     assert_true(fileStream.is_open());
     fileStream.clear();
 }
开发者ID:AlexanderKazakov,项目名称:gcm,代码行数:7,代码来源:FileUtils.hpp


示例9: flush

	static void flush(std::ofstream& out)
	{
		out.write(_outBuffer, _outBufferSize);
		_outBufferSize = 0;
	}
开发者ID:koblyk-dmitry,项目名称:DiplomaProject,代码行数:5,代码来源:SortItem.hpp


示例10: DoSerialization

void ParticleEmitterComponent::DoSerialization(std::ofstream &saveStream) const
{ 
	saveStream.write((char*)&particleEmitInterval_s, sizeof(particleEmitInterval_s));
	saveStream.write((char*)&lastTimeOfEmission_s, sizeof(lastTimeOfEmission_s));
	saveStream.write((char*)&particlesPerEmission, sizeof(particlesPerEmission));
}
开发者ID:emdeha,项目名称:floyd,代码行数:6,代码来源:ParticleEmitterComponent.cpp


示例11: process_arg

static int process_arg(std::string		&basename,
	std::ofstream 	&fout,
	const int 		argc,
	char* 			argv[],
	float 			&min,
	float			&max,
	int				&num,
	int				&sfid,
	int				&efid)
{
	for (int i = 1; i < argc; ++i){
		std::string arg = argv[i];
		if ((arg == "-h") || (arg == "--help")){
			show_usage(argv[0]);
			return 0;
		}
		else if ((arg == "-i") || (arg == "--input")){
			if (i + 1 < argc){
				//fin.push_back(new std::ifstream(argv[i + 1], std::ios::in));
				basename = argv[i + 1];
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-l") || (arg == "--lower")){
			if (i + 1 < argc){
				min = strtof(argv[i + 1], NULL);
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-u") || (arg == "--upper")){
			if (i + 1 < argc){
				max = strtof(argv[i + 1], NULL);
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-N") || (arg == "--boxes")){
			if (i + 1 < argc){
				num = int(strtof(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-s") || (arg == "--start")){
			if (i + 1 < argc){
				sfid = int(strtod(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-e") || (arg == "--end")){
			if (i + 1 < argc){
				efid = int(strtod(argv[i + 1], NULL));
				i++;
			}
			else {
				std::cerr << "--input option requires one argument." << std::endl;
				return 1;
			}
		}
		else if ((arg == "-o") || (arg == "--output")){
			if (i + 1 < argc){
				fout.open(argv[i + 1]);
				i++;
			}
			else{
				std::cerr << "--output option requires one argument." << std::endl;
				return 1;
			}
		}
		else{
			fout.open("SvT.csv");
			return 2;
		}
	}
}
开发者ID:mvarga6,项目名称:Nematic-Worms-Analysis,代码行数:93,代码来源:varden.cpp


示例12: saveToStream

bool LoadScreenRecord::saveToStream(std::ofstream& output) const
{
  output.write((const char*) &cLSCR, 4);
  if (!saveSizeAndUnknownValues(output, getWriteSize())) return false;

  //write EDID
  output.write((const char*) &cEDID, 4);
  //EDID's length
  uint16_t subLength = editorID.length()+1;
  output.write((const char*) &subLength, 2);
  //write editor ID
  output.write(editorID.c_str(), subLength);

  //write DESC
  if (!text.saveToStream(output, cDESC))
    return false;

  std::vector<CTDA_CIS2_compound>::size_type i;
  for (i=0; i<unknownCTDA_CIS2s.size(); ++i)
  {
    //write CTDA and CIS2
    if (!unknownCTDA_CIS2s[i].saveToStream(output))
    {
      std::cout << "Error while writing CTDA and CIS2 of LSCR!\n";
      return false;
    }
  }//for

  //write NNAM
  output.write((const char*) &cNNAM, 4);
  //NNAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write NNAM
  output.write((const char*) &unknownNNAM, 4);

  //write SNAM
  output.write((const char*) &cSNAM, 4);
  //SNAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write SNAM
  output.write((const char*) &unknownSNAM, 4);

  //write RNAM
  output.write((const char*) &cRNAM, 4);
  //RNAM's length
  subLength = 6;
  output.write((const char*) &subLength, 2);
  //write RNAM's stuff
  output.write((const char*) unknownRNAM, 6);

  //write ONAM
  output.write((const char*) &cONAM, 4);
  //ONAM's length
  subLength = 4; //fixed size
  output.write((const char*) &subLength, 2);
  //write ONAM
  output.write((const char*) &unknownONAM, 4);

  //write XNAM
  output.write((const char*) &cXNAM, 4);
  //XNAM's length
  subLength = 12;
  output.write((const char*) &subLength, 2);
  //write XNAM's stuff
  output.write((const char*) unknownXNAM, 12);

  if (!unknownMOD2.empty())
  {
    //write MOD2
    output.write((const char*) &cMOD2, 4);
    //MOD2's length
    subLength = unknownMOD2.length()+1;
    output.write((const char*) &subLength, 2);
    //write model path
    output.write(unknownMOD2.c_str(), subLength);
  }

  return output.good();
}
开发者ID:Thoronador,项目名称:morrowtools,代码行数:81,代码来源:LoadScreenRecord.cpp


示例13: OpenAndCleanFiles

void OpenAndCleanFiles(){
	if (isDefaultFolder)
	{
		Log.open("..//OutPut//Log.txt", ios::trunc | ios::app);
		if (Log.is_open()) printf("Log File Not Open\n");
	}
	else
	{
		Log.open((OutPutFolder+"Log.txt").c_str(), ios::trunc | ios::app);
	}

	FILE * LogFile;
	errno_t err;
	if (isDefaultFolder)
	{
		err = fopen_s(&LogFile, "..//OutPut//Log.txt", "w");
	}
	else
	{
		err = fopen_s(&LogFile, (OutPutFolder+"Log.txt").c_str(), "w");
	}
	fclose(LogFile);
	ofstream  OutFile;
	if (isDefaultFolder)
	{
		OutFile.open("..//OutPut//Summary.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//Paras.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//PrintInputRequest.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AirLineDelayAndFairness.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//ResultRequest.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AllocateTime.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AirLineByRuleSummary.txt", ios::trunc);
		OutFile.close();
		OutFile.open("..//OutPut//AllMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//GFSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//NewSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//OtherSummary.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//AllAirLineSummary.txt", ios::trunc);
		OutFile.close();


		OutFile.open("..//OutPut//GFMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//NewMovementDelay.txt", ios::trunc);
		OutFile.close();

		OutFile.open("..//OutPut//OtherMovementDelay.txt", ios::trunc);
		OutFile.close();
		
		CplexLog.open("..//OutPut//CplexLog.txt", ios::trunc);
	}
	else
	{
		OutFile.open((OutPutFolder+"Summary.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"Paras.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"PrintInputRequest.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AirLineDelayAndFairness.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"ResultRequest.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AllocateTime.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AirLineByRuleSummary.txt").c_str(), ios::trunc);
		OutFile.close();
		OutFile.open((OutPutFolder+"AllMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "GFSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "NewSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "OtherSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		
		OutFile.open((OutPutFolder + "AllAirLineSummary.txt").c_str(), ios::trunc);
		OutFile.close();

		OutFile.open((OutPutFolder + "GFMovementDelay.txt").c_str(), ios::trunc);
		OutFile.close();
//.........这里部分代码省略.........
开发者ID:hkujy,项目名称:MyProject,代码行数:101,代码来源:FilesOpenClose.cpp


示例14: writePickle

void writePickle(){

	int data_length = 0;
	current_node = data_stream;
	// find length of linked list
	while (current_node->next != NULL){
		data_length++;
		current_node = current_node->next;
	}
	// create arrays to hold data
	float * zRotArray;
	zRotArray = new float[data_length];
	float * xRotArray;
	xRotArray = new float[data_length];
	float * facingAngle;
	facingAngle = new float[data_length];

	// fill arrays, first node holds no data
	current_node = data_stream->next;
	data_stream_node * temp_node;
	for (int i = 0; i < data_length - 1; i++){
		zRotArray[i] = current_node->zRotAngle;
		xRotArray[i] = current_node->xRotAngle;
		facingAngle[i] = current_node->facingAngle;
		temp_node = current_node;
		current_node = temp_node->next;
		delete temp_node;
	}
	current_node = data_stream;
	
	// construct file name from time
	time_t rawtime;
	struct tm timeinfo;
	char buffer[80];

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);
	strftime(buffer, 80, "Kinect %Y_%m_%d %H-%M-%S", &timeinfo);
	
	// create txt file
	if (pickled_data == FALSE){
		std::string file_name = std::string(buffer) + ".txt";
		output_file.open(file_name);
		output_file << std::flush;
		output_file << "frames," << std::endl;
		output_file << data_length - 1 << "," << std::endl;
		output_file << "zRotAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			output_file << zRotArray[i] << ",";
		}
		output_file << std::endl;
		output_file << "xRotAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			output_file << xRotArray[i] << ",";
		}
		output_file << std::endl;		
		output_file << "facingAngle," << std::endl;
		for (int i = 0; i < data_length - 1; i++){
			if (i < data_length - 2){
				output_file << facingAngle[i] << ",";
			}
			else {
				output_file << facingAngle[i] << std::endl;
			}
		}
		output_file.close();
	}
	// create python pickle file
	else { // pickled_data == TRUE
		std::string file_name = std::string(buffer) + ".p";
		output_file.open(file_name, std::ofstream::binary);
		output_file << std::flush;
		output_file << "(dp0" << "\n";
		output_file << "S'frames'" << "\n";
		output_file << "p1" << "\n";
		output_file << "I" << data_length - 1 << "\n";
		output_file << "sS'zRotAngle'" << "\n";
		output_file << "p2" << "\n";
		output_file << "(lp3" << "\n";
		output_file << "F" << zRotArray[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << zRotArray[i] << "\n";
		}
		output_file << "asS'xRotAngle'" << "\n";
		output_file << "p4" << "\n";
		output_file << "(lp5" << "\n";
		output_file << "F" << xRotArray[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << xRotArray[i] << "\n";
		}
		output_file << "asS'facingAngle'" << "\n";
		output_file << "p6" << "\n";
		output_file << "(lp7" << "\n";
		output_file << "F" << facingAngle[0] << "\n";
		for (int i = 1; i < data_length - 1; i++){
			output_file << "aF" << facingAngle[i] << "\n";
		}
		output_file << "as.";
		output_file.close();
	}
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:kinect,代码行数:101,代码来源:main.cpp


示例15: trace_instrument

VOID trace_instrument(TRACE trace, VOID *v){
  for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl)){ 
    /* iterate over all basic blocks */
    
    string codelet_string = "";
    // this writes disassembly 
    char codelet_buffer[65536*2]; int cbs = 0;
    INS head = BBL_InsHead(bbl);
    INS tail = BBL_InsTail(bbl);
    
    ADDRINT stage_entry = INS_Address( head );
    ADDRINT target = 0;
    if (INS_IsCall(tail)){
      if( INS_IsDirectBranchOrCall(tail)){
        target = INS_DirectBranchOrCallTargetAddress(tail);}}

    INS cur ;
    int branch_id = slp_count;
      
    /* If compression is turned off (default), only output the addresses of
     * the BBL once
     */
    if (!KnobNoCompress){
      /* Instrument the head instruction right before it is called, but also
       * before we instrument the instructions in the basic block 
       */
      string msg_pre  = "\[email protected]@BBL(" + decstr( branch_id ) + ") STAGE " + Target2String(stage_entry)->c_str() + "\n" ;
      INS_InsertCall(head, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(msg_pre),
		     IARG_END);
    }
   
    /* Walk the list of instructions inside the BBL. Disassemble each, and add
     * it to the codelet string. Also, instrument each instruction at the
     * point before it is called with the do_count function.
     */
    for ( cur = head; INS_Valid( cur ); cur = INS_Next(cur ) ){
      cbs += sprintf( codelet_buffer + cbs , "\n\[email protected]%llx\t%s", INS_Address( cur ), INS_Disassemble( cur ).c_str() );
      INS_InsertCall(cur, IPOINT_BEFORE, (AFUNPTR)do_count, IARG_ADDRINT, INS_Address( cur ), IARG_END);
    }

    /* Finish off the codelet assembly string with an out message and
     * address ranges of the BBL
     */
    cbs += sprintf( codelet_buffer + cbs , "\n\t}BBL.OUT [%d] %llx - %llx\n", branch_id, INS_Address( head ), INS_Address( tail ));
  
    /* If compression is turned on, output the codelet every single time we
     * hit the same block.
     */
    if(KnobNoCompress){
      INS_InsertCall(tail, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(codelet_buffer),
		     IARG_END);
      slp_count ++;
    }
    else{
      /* add the mapped BBL to output */
      TraceFile.write(codelet_buffer, cbs);	
 
      /* Instrument the tail instruction by inserting just before it is called
      */
      string msg_post = "[email protected]@BBL(" + decstr( branch_id ) + ") ACHIEVE : GOTO " + Target2String(target)->c_str();
      INS_InsertCall(tail, IPOINT_BEFORE, AFUNPTR(string_report),
		     IARG_PTR, new string(msg_post),
		     IARG_END);

      slp_count ++;
    }
  }
}
开发者ID:toejamhoney,项目名称:pin,代码行数:70,代码来源:map_syms.cpp


示例16: Fini

VOID Fini(INT32 code, VOID *v)
{
    TraceFile.close();
}
开发者ID:toejamhoney,项目名称:pin,代码行数:4,代码来源:map_syms.cpp


示例17: write

		bool write(const uint8_t v) { m_fp.put(v); return true; }
开发者ID:DimitrisVlachos,项目名称:lib_bitstreams,代码行数:1,代码来源:file_stream.hpp


示例18:

AutoThread::~AutoThread()

{
    output.close();

}
开发者ID:andrea-nisti,项目名称:mavutils,代码行数:6,代码来源:AutoThread.cpp


示例19: tell

		uint64_t tell() { return m_fp.tellp(); }
开发者ID:DimitrisVlachos,项目名称:lib_bitstreams,代码行数:1,代码来源:file_stream.hpp


示例20: is_open

		bool is_open() { return m_fp.is_open(); }
开发者ID:DimitrisVlachos,项目名称:lib_bitstreams,代码行数:1,代码来源:file_stream.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::priority_queue类代码示例发布时间:2022-05-31
下一篇:
C++ std::mutex类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap