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


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

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


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

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

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

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

示例4: UpdateNextDataSetOffset

void DataSetHeaderWriter::UpdateNextDataSetOffset(std::ofstream &os, u_int32_t pos) const
{
	if(nextDataSetPos > 0) 
	{
		os.seekp(nextDataSetPos, std::ios::beg);
		FileOutput::WriteUInt32(os, pos);
		os.seekp(pos, std::ios::beg);
	}
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:9,代码来源:DataSetHeaderWriter.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: sizeof

ELFIO_Err
ELFOSection::Save( std::ofstream& f, std::streampos posHeader,
                   std::streampos posData )
{
    if ( 0 != GetIndex() && SHT_NOBITS != GetType() ) {
        m_sh.sh_offset = Convert32Off2Host( posData, m_pIELFO->GetEncoding() );
    }
    f.seekp( posHeader );
    f.write( reinterpret_cast<const char*>( &m_sh ), sizeof( Elf32_Shdr ) );

    if ( SHT_NOBITS != GetType() ) {
        f.seekp( posData );
        f.write( GetData(), GetSize() );
    }

    return ERR_ELFIO_NO_ERROR;
}
开发者ID:Jokymon,项目名称:anthaxia,代码行数:17,代码来源:ELFOSection.cpp

示例7: save

    bool
    save( std::ofstream& stream ) const
    {
        stream.seekp( 0 );
        stream.write( reinterpret_cast<const char*>( &header ), sizeof( header ) );

        return stream.good();
    }
开发者ID:abahdanovich,项目名称:Slim-api,代码行数:8,代码来源:elfio_header.hpp

示例8: serialise_aux

unsigned int CompactTrie::serialise_aux( std::ofstream& file, const CompactTrieNode* node, unsigned int current_offset )
{
  serialise_children_list( file, node->children_ );

  unsigned int children_offset = current_offset;
  current_offset += calculate_list_size( node->children_ ) * COMPACT_TRIE_NODE_SIZE;

  CompactTrieNodeList* children = node->children_;
  while ( children != nullptr )
  {
    file.seekp( children_offset + COMPACT_TRIE_VALUE_SIZE + COMPACT_TRIE_FREQUENCY_SIZE, std::ios::beg );
    write_binary_unsigned_int( file, current_offset, COMPACT_TRIE_CHILDREN_OFFSET_SIZE );
    file.seekp( current_offset, std::ios::beg );

    current_offset = serialise_aux( file, children->node_, current_offset );

    children_offset += COMPACT_TRIE_NODE_SIZE;
    children = children->next_;
  }

  return current_offset;
}
开发者ID:Orkat,项目名称:TextMining,代码行数:22,代码来源:CompactTrie.cpp

示例9: reset

 virtual void reset() {
   DVLOG(5) << "resetting histogram";
   if (!log_initialized) {
     log_initialized = true;
     char * jobid = getenv("SLURM_JOB_ID");
     char fname[256]; sprintf(fname, "histogram.%s/%s.%d.out", jobid, name, mycore());
     log.open(fname, std::ios::out | std::ios_base::binary);
     DVLOG(5) << "opened " << fname;
   }
   if (log_initialized) {
     log.clear();
     log.seekp(0, std::ios::beg);
   }
   value_ = nil_value;
 }
开发者ID:HPCProjectsTry,项目名称:grappa,代码行数:15,代码来源:HistogramMetric.hpp

示例10: processData

void ThrusterControl::processData(char* data, int size)
{
	static std::ofstream gpio30("/sys/class/gpio/gpio30/value");
	static std::ofstream gpio31("/sys/class/gpio/gpio31/value");
	static std::ofstream gpio48("/sys/class/gpio/gpio48/value");
	static std::ofstream gpio60("/sys/class/gpio/gpio60/value");
	static std::ofstream pwm13("/sys/devices/ocp.3/pwm_test_P8_13.15/duty");
	static std::ofstream pwm14("/sys/devices/ocp.3/pwm_test_P9_14.16/duty");

	gpio30.seekp(0, gpio30.beg);
	gpio31.seekp(0, gpio31.beg);
	gpio48.seekp(0, gpio48.beg);
	gpio60.seekp(0, gpio60.beg);
	pwm13.seekp(0, pwm13.beg);
	pwm14.seekp(0, pwm14.beg);

	gpio30 << BinaryUtils::getBit(data[0], 0);
	gpio31 << BinaryUtils::getBit(data[0], 1);
	gpio48 << BinaryUtils::getBit(data[0], 2);
	gpio60 << BinaryUtils::getBit(data[0], 3);

	// pwm data
	bool cf = BinaryUtils::getBit(data[0], 4),
		 zf = BinaryUtils::getBit(data[0], 5);
	float xd, yd;

	if(zf && !cf) // reset duty cycles (stop / 0)
	{
		xd = *reinterpret_cast<float*>(&data[1]);
		yd = *reinterpret_cast<float*>(&data[5]);

		pwm13 << PERIOD - (int)(PERIOD * std::min(1.0f, std::abs(xd)));
		pwm14 << PERIOD - (int)(PERIOD * std::min(1.0f, std::abs(yd)));
	}
	else if(zf && cf) // set respective duty cycles
	{
		xd = 0.0F;
		yd = 0.0F;

		pwm13 << PERIOD;
		pwm14 << PERIOD;
	}

	gpio30.flush();
	gpio31.flush();
	gpio48.flush();
	gpio60.flush();
	pwm13.flush();
	pwm14.flush();
}
开发者ID:TekuConcept,项目名称:BBB_Backup,代码行数:50,代码来源:ThrusterControl.cpp

示例11: seekwriting

 void seekwriting(unsigned long int& seekpos) {
     ofs_.clear();
     ofs_.seekp(B_HEADERSIZE+seekpos);
 }
开发者ID:priyankatanvani,项目名称:fire-cbir,代码行数:4,代码来源:largebinaryfeaturefile.hpp

示例12: createILF

unsigned int ilf::createILF( std::istream &infile, std::ofstream &outfile )
{
    unsigned int total = 0;
    char temp[512];

    // Write form with dummy size
    unsigned int form0Position = outfile.tellp();
    writeFormHeader( outfile, 0, "INLY" );
    // Write form with dummy size
    unsigned int form1Position = outfile.tellp();
    writeFormHeader( outfile, 0, "0000" );

    while( !infile.eof() )
    {
	unsigned int nodeSize = 0;

	infile.getline( temp, 512, ':' );
	if( infile.eof() ) { break; };
	std::string objectFilename;
	infile >> objectFilename;
	std::cout << objectFilename << std::endl;
	nodeSize += static_cast<unsigned int>( objectFilename.size() + 1 );

	infile.getline( temp, 512, ':' );
	std::string objectZone;
	infile >> objectZone;
	std::cout << objectZone << std::endl;
	nodeSize += static_cast<unsigned int>( objectZone.size() + 1 );

	// 'Transform matrix:' line
	infile.getline( temp, 512, ':' );

	std::cout.flags ( std::ios_base::showpoint );
	std::cout << std::dec;
	std::cout.flags( std::ios_base::fixed );
	float x[12];
	for( unsigned int i = 0; i < 12; ++i )
	{
	    std::cout.width( 10 );
	    infile >> x[i];
	    nodeSize += sizeof( float );
	    std::cout << x[i] << " ";
	}
	std::cout << std::endl;

	// Blank line
	infile.getline( temp, 512 );

	total += writeRecordHeader( outfile, "NODE", nodeSize );
	outfile.write( objectFilename.c_str(),
		       static_cast<unsigned int>( objectFilename.size()+1 )
	    );
	outfile.write( objectZone.c_str(),
		       static_cast<unsigned int>( objectZone.size()+1 )
	    );
	outfile.write( (char*)x, sizeof( float ) * 12 );
	total += nodeSize;
    }

    // Rewrite form with proper size.
    outfile.seekp( form1Position, std::ios_base::beg );
    total += writeFormHeader( outfile, total+4, "0000" );

    // Rewrite form with proper size.
    outfile.seekp( form0Position, std::ios_base::beg );
    total += writeFormHeader( outfile, total+4, "INLY" );

    return total;
}
开发者ID:Mesagoppinmypants,项目名称:Tools,代码行数:69,代码来源:ilf.cpp

示例13: closefile

	void closefile(){
		ply_file.seekp(pos);
		ply_file << i;
		ply_file.close();
	}
开发者ID:Modasshir,项目名称:socrob-ros-pkg,代码行数:5,代码来源:worldmapBlock.cpp

示例14: seek

		uint64_t seek(const uint64_t offs) { m_fp.seekp(offs,std::ios::beg); return m_fp.tellp();  }
开发者ID:DimitrisVlachos,项目名称:lib_bitstreams,代码行数:1,代码来源:file_stream.hpp

示例15: writeNewFiles

size_t ZipArchive::writeNewFiles(std::ofstream& ofs,
                                 std::vector<ZipArchive::ArchivedFile>& newFiles)
{
    size_t counter = 0;
    bool error = false;
    for (size_t i = 0; i < newFiles.size(); ++i) {
        if (newFiles[i].isNewInArchive_ == false) {
            LWARNING("writeNewFiles(): attempting to add an existing or non-physical file '");
            LWARNING(newFiles[i].fileName_ << "' as new file!\n");
            continue;
        }

        if ((newFiles[i].extFileName_.empty() == true) && (newFiles[i].extHandle_ == 0)) {
            LERROR("wirteNewFiles(): the external file name for the new file is empty!");
            continue;
        }

        if (newFiles[i].fileName_.size() > 0xFFFF) {
            LERROR("writeNewFiles(): the file name may not exceed (2^16 - 1) bytes!");
            continue;
        }

        if ((FileSystem::fileExists(newFiles[i].extFileName_) == false) && (newFiles[i].extHandle_ == 0)) {
            LERROR("file '" << newFiles[i].extFileName_ << "' does not exist!");
            continue;
        } else
            LINFO("Writing file " << newFiles[i].fileName_);

        // Seek forward from the current position to skip the LocalFileHeader struct and the file
        // name. The space has to be kept free until we know all details which are available
        // when deflateToDisk() has finished.
        //
        std::streampos archiveOffset = ofs.tellp();
        ofs.seekp(SIZE_ZIPLOCALFILEHEADER + newFiles[i].fileName_.size(), std::ios_base::cur);

        unsigned long crc32 = 0;
        size_t compressedSize = 0;
        size_t uncompressedSize = 0;
        if ((newFiles[i].extFileName_.empty() == false) && (newFiles[i].extHandle_ == 0)) {
            RegularFile inFile(newFiles[i].extFileName_);
            compressedSize = deflateToDisk(inFile, ofs, crc32);
            uncompressedSize = inFile.size();
        } else if (newFiles[i].extHandle_ != 0) {
            compressedSize = deflateToDisk(*(newFiles[i].extHandle_), ofs, crc32);
            uncompressedSize = newFiles[i].extHandle_->size();
        }

        error = (compressedSize == 0);

        // The compressed data now have been written and the header + file name
        // can be inserted.
        //
        if (error == false) {
            ZipLocalFileHeader& lfh = newFiles[i].zipLocalFileHeader_;
            lfh.signature = 0x04034b50;
            lfh.versionNeeded = ZIP_VERSION;
            lfh.generalPurposeFlag = 0;
            lfh.compressionMethod = 0x0008;
            lfh.lastModTime = 0;    // Argh! Need last modification time of file in DOS (!) style...
            lfh.lastModDate = 0;    // Argh! Need last modification date of file in DOS (!) style...
            lfh.crc32 = crc32;
            lfh.compressedSize = static_cast<uint32_t>(compressedSize);
            lfh.uncompressedSize = static_cast<uint32_t>(uncompressedSize);
            lfh.filenameLength = static_cast<uint16_t>(newFiles[i].fileName_.size());
            lfh.extraFieldLength = 0;

            // Seek the position where the LocalFileHeader has to be placed
            //
            ofs.seekp(archiveOffset, std::ios_base::beg);
            ofs.write(reinterpret_cast<char*>(&lfh), SIZE_ZIPLOCALFILEHEADER);
            error = ofs.fail();
        }

        if (error == false) {
            ofs.write(newFiles[i].fileName_.c_str(), newFiles[i].fileName_.size());
            error = ofs.fail();
        }

        if (error == true) {
            LERROR("writeNewFiles(): an error has occured while writing to archive!");
            break;
        } else {
            // The stream position is now again at the beginning of the block containing
            // the compressed data, so seek forward to find the position where the
            // next file can be written.
            //
            ofs.seekp(compressedSize, std::ios_base::cur);

            // Adjust the state of the file within this archive: it is not new any longer
            // and the file name has been adjusted. Furthermore the file now has a
            // offset for the LocalFileHeader within this new archive...
            //
            newFiles[i].isNewInArchive_ = false;
            newFiles[i].localHeaderOffset_ = static_cast<uint32_t>(archiveOffset);
            newFiles[i].fileExtra_ = "";
            newFiles[i].fileComment_ = "";

            // In addition, the entry for the Central Directory can be created.
            //
            ZipFileHeader& fileHeader = newFiles[i].zipFileHader_;
//.........这里部分代码省略.........
开发者ID:151706061,项目名称:Voreen,代码行数:101,代码来源:ziparchive.cpp


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