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


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

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


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

示例1: SaveToStream

WError WEffect::SaveToStream(WFile* file, std::ostream& outputStream) {
	if (!Valid())
		return WError(W_NOTVALID);

	uint tmp;

	outputStream.write((char*)&m_topology, sizeof(m_topology));
	outputStream.write((char*)&m_depthStencilState, sizeof(m_depthStencilState));
	outputStream.write((char*)&m_rasterizationState, sizeof(m_rasterizationState));
	tmp = m_blendStates.size();
	outputStream.write((char*)&tmp, sizeof(tmp));
	outputStream.write((char*)m_blendStates.data(), m_blendStates.size() * sizeof(VkPipelineColorBlendAttachmentState));
	tmp = m_shaders.size();
	outputStream.write((char*)&tmp, sizeof(tmp));
	std::streampos shaderIdsBegin = outputStream.tellp();
	for (uint i = 0; i < m_shaders.size(); i++) {
		tmp = 0;
		outputStream.write((char*)&tmp, sizeof(tmp));
	}
	_MarkFileEnd(file, outputStream.tellp());
	for (uint i = 0; i < m_shaders.size(); i++) {
		WError err = file->SaveAsset(m_shaders[i], &tmp);
		if (!err)
			return err;
		outputStream.seekp(shaderIdsBegin + std::streamoff(i * sizeof(uint)));
		outputStream.write((char*)&tmp, sizeof(tmp));
	}

	return WError(W_SUCCEEDED);
}
开发者ID:Hasan-Jawaheri,项目名称:Wasabi,代码行数:30,代码来源:WEffect.cpp

示例2: recursive_treewrite

	void recursive_treewrite(std::ostream &out, radix_tree_node<std::string, std::unordered_set<zsr::filecount>> *n, zsr::offset treestart)
	{
		static int nwritten = 0;
		logb(++nwritten);
		treesize nval = 0;
		if (n->m_children.count("") && n->m_children[""]->m_value) nval = n->m_children[""]->m_value->second.size();
		treesize nchild = 0;
		for (const std::pair<const std::string, radix_tree_node<std::string, std::unordered_set<zsr::filecount>> *> child : n->m_children) if (child.first != "" && child.second) nchild++; // TODO Probably a faster way?
		zsr::serialize(out, nchild);
		std::deque<zsr::offset> childpos{};
		for (const std::pair<const std::string, radix_tree_node<std::string, std::unordered_set<zsr::filecount>> *> child : n->m_children)
		{
			if (child.first == "" || ! child.second) continue;
			uint16_t namelen = child.first.size();
			zsr::serialize(out, namelen);
			out.write(&child.first[0], namelen);
			childpos.push_back(static_cast<zsr::offset>(out.tellp()));
			zsr::serialize(out, ptrfill);
		}
		zsr::serialize(out, nval);
		if (n->m_children.count("") && n->m_children[""]->m_value)
			for (const zsr::filecount &i : n->m_children[""]->m_value->second) zsr::serialize(out, i);
		for (const std::pair<const std::string, radix_tree_node<std::string, std::unordered_set<zsr::filecount>> *> child : n->m_children)
		{
			if (child.first == "" || ! child.second) continue;
			zsr::offset childstart = static_cast<zsr::offset>(out.tellp()) - treestart;
			out.seekp(childpos.front());
			zsr::serialize(out, childstart);
			out.seekp(0, std::ios_base::end);
			recursive_treewrite(out, child.second, treestart);
			childpos.pop_front();
		}
	}
开发者ID:showermat,项目名称:zsr-utils,代码行数:33,代码来源:search.cpp

示例3: serialize

bool VehicleStateBasicLux::serialize(std::ostream& os) const
{
	const std::istream::pos_type startPos = os.tellp();

	lock();

	ibeo::writeLE(os, m_timestamp);
	ibeo::writeLE(os, m_scanNumber);
	ibeo::writeLE(os, m_errorFlags);
	ibeo::writeLE(os, m_longitudinalVelocity);
	ibeo::writeLE(os, m_steeringWheeAngle);
	ibeo::writeLE(os, m_wheelAngle);
	ibeo::writeLE(os, m_reserved0);

	ibeo::writeLE(os, m_xPos);
	ibeo::writeLE(os, m_yPos);
	ibeo::writeLE(os, m_courseAngle);

	ibeo::writeLE(os, m_timeDiff);
	ibeo::writeLE(os, m_xDiff);
	ibeo::writeLE(os, m_yDiff);
	ibeo::writeLE(os, m_yaw);

	ibeo::writeLE(os, m_reserved1);
	ibeo::writeLE(os, m_currentYawRate);
	ibeo::writeLE(os, m_reserved2);

	unlock();

	return !os.fail() && ((os.tellp() - startPos) == this->getSerializedSize());
}
开发者ID:jannickep,项目名称:snowbots,代码行数:31,代码来源:VehicleStateBasicLux.cpp

示例4: sizeof

void OSGA_Archive::IndexBlock::write(std::ostream& out)
{
    pos_type currentPos = ARCHIVE_POS( out.tellp() );

    if (_filePosition==pos_type(0))
    {
        OSG_INFO<<"OSGA_Archive::IndexBlock::write() setting _filePosition"<<std::endl;
        _filePosition = currentPos;
    }
    else
    {
         out.seekp( STREAM_POS( _filePosition ) );
    }
    OSG_INFO<<"OSGA_Archive::IndexBlock::write() to _filePosition"<< ARCHIVE_POS( out.tellp() )<<std::endl;

    out.write(reinterpret_cast<char*>(&_blockSize), sizeof(_blockSize));
    out.write(reinterpret_cast<char*>(&_filePositionNextIndexBlock), sizeof(_filePositionNextIndexBlock));
    out.write(reinterpret_cast<char*>(&_offsetOfNextAvailableSpace), sizeof(_offsetOfNextAvailableSpace));

    out.write(reinterpret_cast<char*>(_data),_blockSize);

    if( _filePosition < currentPos ) // move file ptr to the end of file
        out.seekp( STREAM_POS( currentPos ) );

    OSG_INFO<<"OSGA_Archive::IndexBlock::write() end"<<std::endl;
}
开发者ID:MORTAL2000,项目名称:OpenSceneGraph,代码行数:26,代码来源:OSGA_Archive.cpp

示例5:

	inline std::ostream::pos_type get_size(std::ostream& stream)
	{
		auto original_pos = stream.tellp();
		stream.seekp(0, std::ios::end);
		auto pos = stream.tellp();
		stream.seekp(original_pos);
		return pos;
	}
开发者ID:planaria,项目名称:kumori,代码行数:8,代码来源:stream_util.hpp

示例6: encode_group

//-------------------------------------------------------------------------------------------------
size_t MessageBase::encode_group(const unsigned short fnum, std::ostream& to) const
{
	const std::ios::pos_type where(to.tellp());
	GroupBase *grpbase(find_group(fnum));
	if (!grpbase)
		throw InvalidRepeatingGroup(fnum, FILE_LINE);
	for (const auto *pp : grpbase->_msgs)
		pp->encode(to);
	return to.tellp() - where;
}
开发者ID:fix8,项目名称:fix8,代码行数:11,代码来源:message.cpp

示例7: encode_group

//-------------------------------------------------------------------------------------------------
size_t MessageBase::encode_group(const unsigned short fnum, std::ostream& to) const
{
	const std::ios::pos_type where(to.tellp());
	GroupBase *grpbase(find_group(fnum));
	if (!grpbase)
		throw InvalidRepeatingGroup(fnum);
	for (GroupElement::iterator itr(grpbase->_msgs.begin()); itr != grpbase->_msgs.end(); ++itr)
		(*itr)->encode(to);
	return to.tellp() - where;
}
开发者ID:6qat,项目名称:fix8,代码行数:11,代码来源:message.cpp

示例8: serialize

	int request::serialize(std::ostream& ostr) const
	{
		std::ostream::off_type len=ostr.tellp();
		if (len<0)len=0;
		BOOST_ASSERT(!host().empty());
		ostr << m_method << " " <<m_strUri<< " " << version() << "\r\n";
		if(header::serialize(ostr)<0)
			return -1;
		ostr << "\r\n";
		return static_cast<int>(ostr.tellp()-len);
	}
开发者ID:guangzhuwu,项目名称:p2streaming,代码行数:11,代码来源:request.cpp

示例9: writeStream

void ossimNitfTagInformation::writeStream(std::ostream &out)
{
   theTagOffset = out.tellp(); // Capture the offset.
   out.write(theTagName, 6);
   out.write(theTagLength, 5);
   if(theTagData.valid())
   {
      theTagDataOffset = out.tellp();
      theTagData->writeStream(out);
   }
}
开发者ID:Dukeke,项目名称:ossim,代码行数:11,代码来源:ossimNitfTagInformation.cpp

示例10: emit_padded

size_t emit_padded(std::ostream &out, T data, size_t size) {
    size_t pos = out.tellp();
    out << data;
    size_t written = (size_t)out.tellp() - pos;
    internal_assert(written <= size);
    while (written < size) {
        out << ' ';
        written++;
    }
    return pos;
}
开发者ID:darkbuck,项目名称:Halide,代码行数:11,代码来源:LLVM_Output.cpp

示例11: SaveProgram

void VSTPresets::SaveProgram(std::ostream &f, CVstPlugin &plugin)
//---------------------------------------------------------------
{
	bool writeChunk = plugin.ProgramsAreChunks();
	ChunkHeader header;
	header.chunkMagic = cMagic;
	header.version = 1;
	header.fxID = plugin.GetUID();
	header.fxVersion = plugin.GetVersion();

	// Write unfinished header... We need to update the size once we're done writing.
	std::streamoff start = f.tellp();
	Write(header, f);

	const uint32 numParams = plugin.GetNumParameters();
	WriteBE(numParams, f);

	char name[MAX(kVstMaxProgNameLen + 1, 256)];
	plugin.Dispatch(effGetProgramName, 0, 0, name, 0);
	f.write(name, 28);

	if(writeChunk)
	{
		char *chunk = nullptr;
		uint32 chunkSize = mpt::saturate_cast<uint32>(plugin.Dispatch(effGetChunk, 1, 0, &chunk, 0));
		if(chunkSize && chunk)
		{
			WriteBE(chunkSize, f);
			f.write(chunk, chunkSize);
		} else
		{
			// The plugin returned no chunk! Gracefully go back and save parameters instead...
			writeChunk = false;
		}
	}
	if(!writeChunk)
	{
		for(uint32 p = 0; p < numParams; p++)
		{
			WriteBE(plugin.GetParameter(p), f);
		}
	}

	// Now we know the correct chunk size.
	std::streamoff end = f.tellp();
	header.byteSize = static_cast<VstInt32>(end - start - 8);
	header.fxMagic = writeChunk ? chunkPresetMagic : fMagic;
	header.ConvertEndianness();
	f.seekp(start);
	Write(header, f);
	f.seekp(end);
}
开发者ID:ksnydertn,项目名称:modplug,代码行数:52,代码来源:VstPresets.cpp

示例12: SaveToStream

WError WMaterial::SaveToStream(WFile* file, std::ostream& outputStream) {
	if (!Valid())
		return WError(W_NOTVALID);

	VkDevice device = m_app->GetVulkanDevice();

	// write the UBO data
	uint tmp = m_uniformBuffers.size();
	outputStream.write((char*)&tmp, sizeof(tmp));
	for (uint i = 0; i < m_uniformBuffers.size(); i++) {
		UNIFORM_BUFFER_INFO* UBO = &m_uniformBuffers[i];
		outputStream.write((char*)&UBO->descriptor.range, sizeof(UBO->descriptor.range));
		void* data;
		VkResult vkRes = vkMapMemory(device, m_uniformBuffers[i].memory, 0, UBO->descriptor.range, 0, (void **)&data);
		if (vkRes)
			return WError(W_UNABLETOMAPBUFFER);
		outputStream.write((char*)data, UBO->descriptor.range);
		vkUnmapMemory(device, m_uniformBuffers[0].memory);
	}

	// write the texture data
	tmp = m_sampler_info.size();
	outputStream.write((char*)&tmp, sizeof(tmp));
	std::streampos texturesOffset = outputStream.tellp();
	for (uint i = 0; i < m_sampler_info.size(); i++) {
		SAMPLER_INFO* SI = &m_sampler_info[i];
		tmp = 0;
		outputStream.write((char*)&tmp, sizeof(tmp));
		outputStream.write((char*)&SI->sampler_info->binding_index, sizeof(SI->sampler_info->binding_index));
	}
	outputStream.write((char*)&tmp, sizeof(tmp)); // effect id
	_MarkFileEnd(file, outputStream.tellp());

	// save dependencies
	for (uint i = 0; i < m_sampler_info.size(); i++) {
		SAMPLER_INFO* SI = &m_sampler_info[i];
		if (SI->img) {
			WError err = file->SaveAsset(SI->img, &tmp);
			if (!err)
				return err;
			outputStream.seekp(texturesOffset + std::streamoff(i * (2 * sizeof(uint))));
			outputStream.write((char*)&tmp, sizeof(tmp));
		}
	}
	WError err = file->SaveAsset(m_effect, &tmp);
	if (!err)
		return err;
	outputStream.seekp(texturesOffset + std::streamoff(m_sampler_info.size() * (2 * sizeof(uint))));
	outputStream.write((char*)&tmp, sizeof(tmp));

	return WError(W_SUCCEEDED);
}
开发者ID:Hasan-Jawaheri,项目名称:Wasabi,代码行数:52,代码来源:WMaterial.cpp

示例13: write

void AVR::write(std::ostream& os, const AVRTexture& texture)
{
	os.write("TEXT", 4);
	auto sizePos = os.tellp();
	os.seekp(4, std::ios::cur);
	auto startPos = os.tellp();

	os.write(texture.mPath.c_str(), texture.mPath.length() + 1);

	auto endPos = os.tellp();
	uint32_t size = endPos - startPos;
	os.seekp(sizePos);
	os.write((char*) &size, 4);
	os.seekp(endPos);
}
开发者ID:MiKom,项目名称:vorticity,代码行数:15,代码来源:avrtexture.cpp

示例14: timestamp

// call from infitof2 - counting
void
threshold_result::write3( std::ostream& os, const threshold_result& t )
{
    if ( os.tellp() == std::streamoff(0) )
        os << "## trig#, prot#, timestamp(s), epoch_time(ns), events, threshold(mV), algo(0=absolute,1=average,2=differential)"
           "\t[time(s), peak-front(s), peak-front(mV), peak-end(s), peak-end(mV)]";

    if ( auto data = t.data() ) {

        os << boost::format( "\n%d, %d, %.8lf, %.8lf, 0x%08x, %.8lf, %d" )
           % data->serialnumber_
           % data->method_.protocolIndex()
           % data->meta_.initialXTimeSeconds
           % t.data()->timeSinceEpoch_
           % t.data()->wellKnownEvents_
           % ( t.threshold_level() * std::milli::den )
           % t.algo();

        if ( ! t.indecies2().empty() ) {
            for ( auto& idx : t.indecies2() ) {

                auto apex  = data->xy( idx.apex );

                os << boost::format( ",\t%.14le, %.6f, %d, %.6f, %d, %.6f" )
                   % apex.first    // apex (time)
                   % ( t.data()->toVolts( apex.second ) * std::milli::den )
                   % ( int( idx.first ) - int( idx.apex ) )   // front-apex distance
                   % ( t.data()->toVolts( int64_t( (*data)[ idx.first ] ) ) * std::milli::den )     // front intensity
                   % ( int( idx.second ) - int( idx.apex ) )
                   % ( t.data()->toVolts( int64_t( (*data)[ idx.second ] ) ) * std::milli::den );
            }
        }
    }
}
开发者ID:qtplatz,项目名称:qtplatz,代码行数:35,代码来源:threshold_result.cpp

示例15: dumpConfiguration

void bil::dumpConfiguration(const V5Configuration& cfg, std::ostream& cfgOut, std::ostream& indexOut)
{
    // collect list with all frame addresses and their frames
    V5Configuration::pairconstptrs_t pairs = cfg.contents();

    // loop over list
    size_t frameCount = pairs.size();
    for (size_t i = 0; i < frameCount; ++i)
    {
        // get pointer to current pair
        const V5Configuration::pair_t* pairPtr = pairs[i];

        // write one line with raw frame address info and frame data offset
        const V5FrameAddress& address = pairPtr->first;
        indexOut << toRawAddressString(address) << '\t';
        printHex(indexOut, cfgOut.tellp());
        indexOut << "\t(" << toSymbolicString(address) << "):";
        indexOut << V5CfgColumn::toString(address.columnType()) << '\n';
        if (!indexOut) throw IOException();

        // write frame data
        const V5CfgFrame& frame = pairPtr->second;
        cfgOut.write(reinterpret_cast<const char*>(frame.data()), V5CfgFrame::WORDCOUNT << 2);
        if (!cfgOut) throw IOException();
    }
}
开发者ID:florianbenz,项目名称:bil,代码行数:26,代码来源:V5ConfigurationDump.cpp


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