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


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

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


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

示例1: assert

void
DetectorNCC::Write(std::ofstream &s, bool binary)
{
  assert(binary);

  int t = IOBinary::DETECTOR_NCC;
  s.write((char*)&t, sizeof(t));

  IOBinary::WriteMat(s, _refs);

  t = _patch.size();
  s.write((char*)&t, sizeof(t));
  for(size_t i=0; i< _patch.size(); i++)
    _patch[i].Write(s, true);
}
开发者ID:23119841,项目名称:face-analysis-sdk,代码行数:15,代码来源:Detector.cpp

示例2: writeCoords

void FeatureConnector::writeCoords(std::ofstream& output_file, const std::vector<geos::geom::Coordinate>* coords, bool singleton) {
    quint32 crdCount = (quint32)coords->size();
    if(!singleton) {
        output_file.write((char *)&crdCount,4);
    }
    std::vector<double> crds(crdCount * 3);
    quint32 count = 0;
    for(const geos::geom::Coordinate& crd : *coords) {
        crds[count] = crd.x;
        crds[count+1] = crd.y;
        crds[count+2] = 0;
        count +=3;
    }
    output_file.write((char *)&crds[0], crdCount * 8 * 3);

}
开发者ID:MartinSchouwenburg,项目名称:IlwisTest,代码行数:16,代码来源:ilwis3featureconnector.cpp

示例3: readsome

 void readsome(const boost::system::error_code& ec, std::size_t bytes_transferred)
 {
     if (ec == error::eof) {
         file.close();
         if (!file) {
             ERROR "Cannot write to file " << filename;
             onerror();
         } else if (filesize == 0) {
             ERROR "Empty segment " << file_url.to_string();
             onerror();
         } else {
             downloading = false;
             complete = true;
             auto download_duration = duration_cast<milliseconds>(steady_clock::now() - download_start).count();
             INFO "Completed segment " << file_url.to_string() << " (" << std::setprecision(1) << std::fixed <<
                 (filesize / 1024.0 / 1024.0) << " MB) in " << download_duration <<
                 " ms (" << (filesize * 8000 / 1024.0 / 1024.0 / download_duration) << "Mbps)";
         }
     } else if (ec) {
         ERROR "Error reading URL " << file_url.to_string() << ": " << ec.message();
         onerror();
     } else {
         file.write(&buffer[0], bytes_transferred);
         filesize += bytes_transferred;
         segment_stream.async_read_some(boost::asio::buffer(buffer), std::bind(&Segment::readsome, this, _1, _2));
     }
 }
开发者ID:tea,项目名称:hls_proxy,代码行数:27,代码来源:hls_proxy.cpp

示例4: write_rat_header

void write_rat_header(std::ofstream& file, const std::vector<uint32_t>& sizes,
                      const uint32_t var, const uint32_t type,
                      const std::string& info)
{
    using tools::endian_reverse_inplace;
    using std::string;

    auto write = [&file](uint32_t x) {
        endian_reverse_inplace(x);
        file.write(reinterpret_cast<const char*>(&x), sizeof(x));
    };

    const uint32_t dim = sizes.size();

    write(dim);
    for (auto sz : sizes) {
        write(sz);
    }
    write(var);
    write(type);

    write(0);
    write(0);
    write(0);
    write(0);

    string _info = string(80, ' ');
    boost::copy(string(info, 0, 80), _info.begin());

    file << _info;
}
开发者ID:mforner,项目名称:wpl-polsar,代码行数:31,代码来源:Export.cpp

示例5: writePnm

void Bitmap::writePnm(std::ofstream &o) const {
    o << "P5" << std::endl;
    o << width << " " << height << std::endl;
    o << "255" << std::endl;
    o.write((const char *)buf, width * height);
    o.close();
}
开发者ID:XperiaZProject,项目名称:frameworks_minikin,代码行数:7,代码来源:Layout.cpp

示例6: while

//! write sector to file
//!
//! @param file    file to write to
//!
//! @return success
//!
bool
Sector::writeToH8D(std::ofstream &file)
{

    uint16_t pos = 0;
  
    // look for the sync for the header 
    while ((buf_m[pos] != 0xfd) && (pos < bufSize_m))
    {
        pos++;
    }

    // skip past the header, since 0xfd could be the checksum
    pos += 5;

    // look for the data 
    while ((buf_m[pos++] != 0xfd) && (pos < bufSize_m))
    { }

    if ((bufSize_m - pos) < 256)
    {
        printf("Error data not found - sector: %d\n", sector_m);
        pos = bufSize_m - 256;
    }

    // write out the sector
    if (buf_m)
    {
        file.write((const char*) &buf_m[pos], 256);
    }

    return true;
}
开发者ID:mgarlanger,项目名称:heath-imager,代码行数:39,代码来源:sector.cpp

示例7: main

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

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

    traceFile.open(outputFile.Value().c_str());

    string trace_header = string("#\n"
                                 "# Shellcode detector\n"
                                 "#\n\nMAX_LEGIT_INSTRUCTION_LOG_SIZE : ") +
        KnobMaxLegitInsLogSize.ValueString() + "\n\n";

    for ( UINT32 i = 0; i < KnobModuleConcerned.NumberOfValues(); i++ )
    {
        LOG( "[+] ... " + KnobModuleConcerned.Value(i) + "\n" );
        modlist.insert( KnobModuleConcerned.Value(i) );
    }

    traceFile.write(trace_header.c_str(), trace_header.size());

    INS_AddInstrumentFunction(traceInst, 0);
    PIN_AddFiniFunction(fini, 0);

    // Never returns
    PIN_StartProgram();

    return 0;
}
开发者ID:DaviWei,项目名称:pin-tools,代码行数:32,代码来源:shellcode.cpp

示例8: gz_uncompress

	static void gz_uncompress( gzFile in, std::ofstream &out ) {
		char buf[2048 * 1024];
		int len;
		size_t bytes = 0;

		for (
			len = gzread( in, buf, 2048 * 1024 );
			len;
			len = gzread( in, buf, 2048 * 1024 )
		) {
			if ( len < 0 ) {
				int err;
				gzerror( in, &err );

				// If an error occurred in the file system and not in the compression library, err is set to Z_ERRNO
				if ( err == Z_ERRNO ) {
					throwSystemError( errno, "Failed to read compressed file" );
				} else {
					throwGenericError( "Failed to read compressed file" );
				}
			} else {
				out.write( buf, len );
				bytes += len;
			}
		}

		LOG( Debug, verbose_info ) << "Uncompressed " << bytes << " bytes";
	}
开发者ID:hahtse,项目名称:isis,代码行数:28,代码来源:imageFormat_gz_proxy.cpp

示例9: write

bool compactIntArray::write(std::ofstream& fout)
{
    fout.write((char*)&size, sizeof(size));
    fout.write((char*)&wordsize, sizeof(wordsize));
    fout.write((char*)&innersize, sizeof(innersize));

    fout.write((char*)array, sizeof(*array) * innersize);
    if(fout.bad())
    {
        return false;
    }
    else
    {
        return true;
    }
}
开发者ID:bluecliff,项目名称:CSA,代码行数:16,代码来源:compactIntArray.cpp

示例10: exception

void binary_reader::stock_data::write( std::ofstream& out )
{
	if ( !out.write( stock_name_, sizeof(char)*(stock_size+1) ) )
		throw std::exception( "Error while writing data\n" );
	int year_, month_, day_;
	sscanf( date_time_, "%4d%2d%2d", &year_, &month_, &day_ );
	boost::uint32_t day_time_ = 372*(year_-1) + 31*(month_-1) + day_;
	if ( !out.write( reinterpret_cast<char*> (&day_time_), sizeof( boost::uint32_t ) ) )
		throw std::exception( "Error while writing data\n" );
	if ( !out.write( reinterpret_cast<char*> (&vwap_), sizeof(double) ) )
		throw std::exception( "Error while writing data\n" );
	if ( !out.write( reinterpret_cast<char*> (&volume_), sizeof( boost::uint32_t ) ) )
		throw std::exception( "Error while writing data\n" );
	if ( !out.write( reinterpret_cast<char*> (&f2_), sizeof(double) ) )
		throw std::exception( "Error while writing data\n" );
}
开发者ID:Eldar322,项目名称:cpp_craft_0314,代码行数:16,代码来源:stock_data.cpp

示例11:

void d2o_writer::impl::write(std::ofstream & file) const
{
    byte_buffer buffer;
    buffer.write_bytes<false>((const uint8_t *)"D2O", 3);
    buffer << 0;
    std::unordered_map<int, int> offsets;
    for (auto && it : _objects)
    {
        offsets.emplace(it.first, buffer.tellp());
        buffer << it.second.first;
        _classes.at(it.second.first).write(_owner, buffer, it.second.second);
    }

    int header = buffer.tellp();

    buffer << static_cast<int>(offsets.size() * 8);
    for (auto && it : offsets)
        buffer << it.first << it.second;
    buffer << static_cast<int>(_classes.size());
    for (auto && it : _classes)
        it.second.pack(buffer, it.first);

    buffer.seekp(3);
    buffer << header;
    file.write((const char *)&buffer[0], buffer.size());
}
开发者ID:Ryuuke,项目名称:desperion,代码行数:26,代码来源:d2o_writer_impl.cpp

示例12: SaveState

void MemoryMap::SaveState(std::ofstream& ofs)
{
    ofs.write((char*)_ram, sizeof(_ram));
    _ppu->SaveState(ofs);
    _apu->SaveState(ofs);
    _mapper->SaveState(ofs);
}
开发者ID:colemickens,项目名称:nes,代码行数:7,代码来源:mem.cpp

示例13: writeBucketIndexSetVector

void writeBucketIndexSetVector(std::ofstream &file, const PVRTBucketIndexSetVector &indexsets)
{
	const size_t size = indexsets.size();
	file.write((const char*)&size, sizeof(size_t));
	for (unsigned int i=0; i < size; i++)
		writeBucketIndexSet(file, indexsets[i]);
}
开发者ID:joyfish,项目名称:GameThirdPartyLibs,代码行数:7,代码来源:PVRMapFileIO.cpp

示例14: write_pixels

void cineon_writer_t::write_pixels( std::ofstream& out, const image::const_image_view_t& view) const
{
    std::vector<boost::uint32_t> buffer( view.width());

    for( int y = 0; y < view.height(); ++y)
    {
		image::const_image_view_t::x_iterator src_it( view.row_begin( y));
	
		for( int x = 0; x < view.width(); ++x)
		{
			boost::uint32_t pix = 0;
	
			float r = boost::gil::get_color( *src_it, boost::gil::red_t());
			float g = boost::gil::get_color( *src_it, boost::gil::green_t());
			float b = boost::gil::get_color( *src_it, boost::gil::blue_t());
	
			boost::uint32_t ri = adobe::clamp( r, 0.0f, 1.0f) * 1023;
			boost::uint32_t gi = adobe::clamp( g, 0.0f, 1.0f) * 1023;
			boost::uint32_t bi = adobe::clamp( b, 0.0f, 1.0f) * 1023;
			pix = ( ri << 22) | ( gi << 12) | ( bi << 2);
	
			buffer[x] = IECore::asBigEndian( pix);
			++src_it;
		}
	
		// write vector
		out.write( reinterpret_cast<char *>( &buffer[0]), view.width() * sizeof( boost::uint32_t));
		
		if ( out.fail())
			throw exception( "error while writting image");
    }
}
开发者ID:JohanAberg,项目名称:Ramen,代码行数:32,代码来源:cineon_writer.cpp

示例15: CreatePath

void Permutator::CreatePath(Node* n, std::ofstream& gvFile)
{
	std::stringstream stream;
	std::string pathAttribute = "[ penwidth = 5];\n";
	
	stream << std::hex << n->GetOffset();
	std::string stateName = "\"0x" + stream.str() + "\"";
	stream.str(std::string());

	for (unsigned int i = 0; i < n->GetChildren().size(); ++i)
	{
		stream << std::hex << n->GetChildren().at(i)->GetOffset();
		std::string childName = "\"0x" + stream.str() + "\"";
		std::string pathValue = stateName + " -> " + childName + " " + pathAttribute;
		try
		{
			gvFile.write(pathValue.c_str(), pathValue.length());
		}
		catch (std::fstream::failure e)
		{
			std::cerr << "CreatePath: Error while writing paths to graphviz output file: " << e.what() << std::endl;
			return;
		}
		
		CreatePath(n->GetChildren().at(i), gvFile);
		stream.str(std::string());
	}

	return;
}
开发者ID:De117,项目名称:PErmutator,代码行数:30,代码来源:Permutator.cpp


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