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


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

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


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

示例1: writeHeader

void BackgroundRemovedImage::writeHeader(std::ofstream& os) {

    HeaderInfoT hi;

    hi.headersize = headerSizeInBytes;
    hi.idcode = idCode();


    //fill in header with 0s
    std::ofstream::pos_type cur_loc = os.tellp();
    char zero[headerSizeInBytes] = {0};
    os.write(zero, headerSizeInBytes);
    std::ofstream::pos_type end_loc = os.tellp();

    //return to the beginning of the header and write data
    os.seekp(cur_loc);

    if (differencesFromBackground.empty()) {
        hi.depth = 0;
        hi.nchannels = 0;
        hi.numims = 0;
    } else {
        hi.depth = differencesFromBackground.front().second->depth;
        hi.nchannels = differencesFromBackground.front().second->nChannels;
        hi.numims = differencesFromBackground.size();
    }
    os.write((char *) &hi, sizeof(hi));
    if (metadata != NULL) {
        metadata->toDisk(os);
    }
    os.seekp(end_loc);
    
}
开发者ID:bafonso,项目名称:mmf_writer_ros,代码行数:33,代码来源:BackgroundRemovedImage.cpp

示例2: fileSize

	unsigned int fileSize(std::ofstream& file)
	{
		unsigned int oldpos = file.tellp();
		file.seekp(0, std::ios::end);
		unsigned int filesize = file.tellp();
		file.seekp(oldpos, std::ios::beg);
		return filesize;
	}
开发者ID:CBaiz,项目名称:PeLib,代码行数:8,代码来源:PeLibAux.cpp

示例3: writeArrayToBinaryFileStream

 static void writeArrayToBinaryFileStream(std::ofstream& fileStream,
         const T* array, const size_t sizeOfArray) {
     assert_gt(sizeOfArray, 0);
     auto bufferSize = (std::streamsize)(sizeOfArray * sizeof(T));
     auto previousNumberOfBytes = fileStream.tellp();
     assert_true(fileStream.write(reinterpret_cast<const char*>(array), bufferSize));
     auto currentNumberOfBytes = fileStream.tellp();
     assert_eq(bufferSize, currentNumberOfBytes - previousNumberOfBytes);
 }
开发者ID:AlexanderKazakov,项目名称:gcm,代码行数:9,代码来源:FileUtils.hpp

示例4: memcpy

// Write out the LLVM symbol table as an archive member to the file.
void
Archive::writeSymbolTable(std::ofstream& ARFile) {

  // Construct the symbol table's header
  ArchiveMemberHeader Hdr;
  Hdr.init();
  memcpy(Hdr.name,ARFILE_LLVM_SYMTAB_NAME,16);
  uint64_t secondsSinceEpoch = sys::TimeValue::now().toEpochTime();
  char buffer[32];
  sprintf(buffer, "%-8o", 0644);
  memcpy(Hdr.mode,buffer,8);
  sprintf(buffer, "%-6u", sys::Process::GetCurrentUserId());
  memcpy(Hdr.uid,buffer,6);
  sprintf(buffer, "%-6u", sys::Process::GetCurrentGroupId());
  memcpy(Hdr.gid,buffer,6);
  sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch));
  memcpy(Hdr.date,buffer,12);
  sprintf(buffer,"%-10u",symTabSize);
  memcpy(Hdr.size,buffer,10);

  // Write the header
  ARFile.write((char*)&Hdr, sizeof(Hdr));

#ifndef NDEBUG
  // Save the starting position of the symbol tables data content.
  unsigned startpos = ARFile.tellp();
#endif

  // Write out the symbols sequentially
  for ( Archive::SymTabType::iterator I = symTab.begin(), E = symTab.end();
        I != E; ++I)
  {
    // Write out the file index
    writeInteger(I->second, ARFile);
    // Write out the length of the symbol
    writeInteger(I->first.length(), ARFile);
    // Write out the symbol
    ARFile.write(I->first.data(), I->first.length());
  }

#ifndef NDEBUG
  // Now that we're done with the symbol table, get the ending file position
  unsigned endpos = ARFile.tellp();
#endif

  // Make sure that the amount we wrote is what we pre-computed. This is
  // critical for file integrity purposes.
  assert(endpos - startpos == symTabSize && "Invalid symTabSize computation");

  // Make sure the symbol table is even sized
  if (symTabSize % 2 != 0 )
    ARFile << ARFILE_PAD;
}
开发者ID:Gcrosby5269,项目名称:clamav-bytecode-compiler,代码行数:54,代码来源:ArchiveWriter.cpp

示例5:

std::streamoff
fileSize(std::ofstream& file)
{
  std::streamoff curr = file.tellp();

  file.seekp(0, std::ios::end);
  std::streamoff size = file.tellp();
  file.seekp(0, std::ios::beg);
  size -= file.tellp();

  file.seekp(curr, std::ios::beg);
  return size;
}
开发者ID:aalto-ics-kepaco,项目名称:path-index-graph-kernel,代码行数:13,代码来源:utils.cpp

示例6: end

		void end(char*,std::size_t){
			file
				<<"{"
				<<"\"type\":\"FeatureCollection\","
				<<"\"features\":[";

			bool done=false;
			for(std::size_t idx=0;idx<lon.size()&&!done;++idx){
				file
					<<"{"
					<<"\"type\":\"Feature\","
					<<"\"geometry\":"
					<<"{"
					<<"\"type\":\"Point\","
					<<"\"coordinates\":["<<lon[idx]<<","<<lat[idx]<<"]"
					<<"}"
					<<"}";
				file.flush();
				if((std::size_t)(file.tellp())+file_thresh>=file_lim)
					done=true;
				else
					file<<",";
			}

			file
				<<"]"
				<<"}";
		}
开发者ID:korteste-krogstie,项目名称:edib,代码行数:28,代码来源:cartodb.hpp

示例7: write

  void BezierCurves::write(std::ofstream& file)
  {
    int type = BEZIER_CURVES;
    file.write((char*)&type,sizeof(int));
    file.write((char*)&numTimeSteps,sizeof(int));
    file.write((char*)&numVertices,sizeof(int));
    file.write((char*)&numCurves,sizeof(int));

    for (size_t j=0; j<numTimeSteps; j++) {
      while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
      for (size_t i=0; i<numVertices; i++) file.write((char*)&vertex(i,j),sizeof(Vec3fa));  
    }

    while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
    for (size_t i=0; i<numCurves; i++) file.write((char*)&curve(i),sizeof(int));  
  }
开发者ID:utkarshayachit,项目名称:OSPRay,代码行数:16,代码来源:scene_bezier_curves.cpp

示例8:

	static void
	_mark_session (std::ofstream& fs)
	{
		if (!fs) return;
		
		std::time_t t = std::time (nullptr);
		struct tm lt;
		localtime_r (&t, &lt);
		
		if (fs.tellp () > 0)
			fs << "\n\n" << std::flush;
		
		fs <<
"********************************************************************************\n"
"    New Session:\n"
"      @ " << std::setfill ('0')
 					 << std::setw (2) << lt.tm_hour << ":"
 					 << std::setw (2) << lt.tm_min << ":"
 					 << std::setw (2) << lt.tm_sec << "   "
 					 << std::setw (2) << lt.tm_mon << "/"
 					 << std::setw (2) << lt.tm_mday << "/"
 					 << (lt.tm_year + 1900) << std::setfill (' ') << "\n" <<
"********************************************************************************\n"
			 << std::endl;
	}
开发者ID:BizarreCake,项目名称:hCraft,代码行数:25,代码来源:logger.cpp

示例9: if

  std::ostream& LoggerImpl::getAppender()
  {
    if (pipe)
      return *pipe;
    else if (!fname.empty())
    {
      if (!outfile.is_open())
      {
        outfile.clear();
        outfile.open(fname.c_str(), std::ios::out | std::ios::app);
        counter.resetCount(outfile.tellp());
      }

      if (maxfilesize > 0)
      {
        if (counter.getCount() > maxfilesize)
        {
          doRotate();
          counter.resetCount();
        }
        return tee;
      }
      else
        return outfile;
    }
    else if (loghost.isConnected())
      return udpmessage;
    else
      return std::cerr;
  }
开发者ID:gema-arta,项目名称:zim-vendor,代码行数:30,代码来源:log.cpp

示例10: append

			static void append(
				std::ofstream & out, std::string const & filename,
				std::vector< IndexEntry > & index
			)
			{
				uint64_t const indexpos = IndexLoader::getIndexPos(filename);
				libmaus2::autoarray::AutoArray< IndexEntry > subindex = IndexLoader::loadIndex(filename);
				
				if ( subindex.size() )
				{
					uint64_t const datapos = subindex[0].pos;
					uint64_t const datalen = indexpos-datapos;
					
					// shift all towards zero
					for ( uint64_t i = 0; i < subindex.size(); ++i )
						subindex[i].pos -= datapos;
						
					uint64_t const ndatapos = out.tellp();

					for ( uint64_t i = 0; i < subindex.size(); ++i )
						subindex[i].pos += ndatapos;
						
					std::ifstream istr(filename.c_str(),std::ios::binary);
					istr.seekg(datapos,std::ios::beg);
					::libmaus2::util::GetFileSize::copy ( istr, out, datalen, 1 );
					
					for ( uint64_t i = 0; i < subindex.size(); ++i )
						index.push_back(subindex[i]);
				}
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:30,代码来源:RLEncoder.hpp

示例11: write_resultes_into_the_file

//Function that writes the line with name age sex and time taken by the player into the file puzzle_NxNyyy
void write_resultes_into_the_file(std::ofstream& myfile, string time){
	int ii = 0;
	vector<string> vec = Tokenize(time);
	int here = myfile.tellp();
	myfile << "                               ";
	for (std::vector<std::string>::size_type a = 0; a < vec.size(); ++a){
		switch (ii)
		{		
		case 0:
			myfile.seekp ((here + 4) );
			myfile << vec.at(a);
			break;
		case 1:
			myfile.seekp ((here + 25 ));
			myfile << vec.at(a);
			break;
		case 2: 
			myfile.seekp ((here + 29 ));
			myfile << vec.at(a);
			break;
		case 3: 
			myfile.seekp ((here + 31 ));
			myfile << vec.at(a);
			break;
		}
		ii++;
	}
}
开发者ID:anonacz,项目名称:feup_puzzle,代码行数:29,代码来源:puzzle.cpp

示例12: time

std::ofstream& Logger::LogStart(TLogLevel level){ 
	char buffer[64];
	
	if (logger_os.tellp() >= logger_max_file_size){
		logger_os.close();
		std::string renamed_file = logger_filename;
		renamed_file.append(".backup");
		
		if (file_exists(renamed_file.c_str())) remove (renamed_file.c_str());

		rename(logger_filename.c_str(), renamed_file.c_str());
		remove (logger_filename.c_str());
	}	

	if (!file_exists(logger_filename.c_str())){
		logger_os.close();
		logger_os.open(logger_filename.c_str(),  std::ios::out | std::ios::app);
		if (logger_os.is_open()){
			logger_messageLevel = loggger_wantedLevel;
		}else{
			logger_messageLevel = logNone; //prevent from sending data into the not opened stream
		}
	}

	time_t thetime = time(0);
	tm * ptm = std::localtime(& thetime);
	strftime(buffer, sizeof(buffer), "%d.%m.%Y %H:%M:%S", ptm);// Format: 15.06.2009 20:20:00 

	logger_os << "-" << buffer << " " << ToString(level) << ": ";

	return logger_os;
}
开发者ID:tom-2015,项目名称:rpi-geiger-counter,代码行数:32,代码来源:log.cpp

示例13: writeCentralDirectory

bool ZipArchive::writeCentralDirectory(std::ofstream& ofs,
                                       const std::vector<ZipArchive::ArchivedFile>& files)
{
    std::streampos offsetCD = ofs.tellp();
    size_t sizeCD = 0;
    bool error = false;
    for (size_t i = 0; i < files.size(); ++i) {
        const ZipFileHeader& fileHeader = files[i].zipFileHader_;
        ofs.write(reinterpret_cast<const char*>(&fileHeader), SIZE_ZIPFILEHEADER);
        sizeCD += SIZE_ZIPFILEHEADER;
        error = ofs.fail();

        size_t stringSize = files[i].fileName_.size();
        sizeCD += stringSize;
        if ((error == false) && (stringSize > 0) && (stringSize == fileHeader.filenameLength)) {
            ofs.write(files[i].fileName_.c_str(), stringSize);
            error = ofs.fail();
        }

        stringSize = files[i].fileExtra_.size();
        sizeCD += stringSize;
        if ((error == false) && (stringSize > 0) && (stringSize == fileHeader.extraFieldLength)) {
            ofs.write(files[i].fileExtra_.c_str(), stringSize);
            error = ofs.fail();
        }

        stringSize = files[i].fileComment_.size();
        sizeCD += stringSize;
        if ((error == false) && (stringSize > 0) && (stringSize == fileHeader.fileCommentLength)) {
            ofs.write(files[i].fileComment_.c_str(), stringSize);
            error = ofs.fail();
        }

        if (error == true) {
            LERROR("writeCentralDirectory(): failed to write Central Directory Entry in zip archive!");
            break;
        }
    }   // for

    ZipEOCDHeaderRecord eocd;
    eocd.signature = SIGNATURE_ZIPEOCDHEADERRECORD;
    eocd.numberOfDisk = 0;
    eocd.numberOfDiskWithStartOfCD = 0;
    eocd.numberOfEntriesInThisCD = static_cast<uint16_t>(files.size());
    eocd.numberOfEntriesInCD = static_cast<uint16_t>(files.size());
    eocd.sizeOfCD = static_cast<uint32_t>(sizeCD);
    eocd.offsetStartCD = (offsetCD >= 0) ? static_cast<uint32_t>(offsetCD) : 0;
    eocd.commmentLength = 0;

    if (error == false) {
        ofs.write(reinterpret_cast<char*>(&eocd), SIZE_ZIPEOCDRECORD);
        error = ofs.fail();
    }

    return (! error);
}
开发者ID:151706061,项目名称:Voreen,代码行数:56,代码来源:ziparchive.cpp

示例14: write

  void QuadMesh::write(std::ofstream& file)
  {
    int type = QUAD_MESH;
    file.write((char*)&type,sizeof(int));
    file.write((char*)&numTimeSteps,sizeof(int));
    int numVerts = numVertices();
    file.write((char*)&numVerts,sizeof(int));
    int numQuads = quads.size();
    file.write((char*)&numQuads,sizeof(int));

    for (size_t j=0; j<numTimeSteps; j++) {
      while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
      for (size_t i=0; i<numVerts; i++) file.write((char*)vertexPtr(i,j),sizeof(Vec3fa));  
    }

    while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
    for (size_t i=0; i<numQuads; i++) file.write((char*)&quad(i),sizeof(Quad));  

  }
开发者ID:Dade916,项目名称:embree,代码行数:19,代码来源:scene_quad_mesh.cpp

示例15: write

  void TriangleMesh::write(std::ofstream& file)
  {
    int type = TRIANGLE_MESH;
    file.write((char*)&type,sizeof(int));
    file.write((char*)&numTimeSteps,sizeof(int));
    int numVerts = numVertices();
    file.write((char*)&numVerts,sizeof(int));
    int numTriangles = triangles.size();
    file.write((char*)&numTriangles,sizeof(int));

    for (size_t j=0; j<numTimeSteps; j++) {
      while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
      for (size_t i=0; i<numVerts; i++) file.write((char*)vertexPtr(i,j),sizeof(Vec3fa));  
    }

    while ((file.tellp() % 16) != 0) { char c = 0; file.write(&c,1); }
    for (size_t i=0; i<numTriangles; i++) file.write((char*)&triangle(i),sizeof(Triangle));  

  }
开发者ID:eyalsoreq,项目名称:embree,代码行数:19,代码来源:scene_triangle_mesh.cpp


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