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


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

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


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

示例1: writeRawPacket

void PositionPacket::writeRawPacket(BinaryWriter& stream) const {
  stream.write(reinterpret_cast<const char*>(&mNotUsed1), sizeof(mNotUsed1));
  stream << mGyro1 << mTemp1 << mAccel1X << mAccel1Y << mGyro2 << mTemp2 <<
    mAccel2X << mAccel2Y << mGyro3 << mTemp3 << mAccel3X << mAccel3Y;
  stream.write(reinterpret_cast<const char*>(&mNotUsed2), sizeof(mNotUsed2));
  stream << mGPSTimestamp;
  stream.write(reinterpret_cast<const char*>(&mNotUsed3), sizeof(mNotUsed3));
  stream.write(reinterpret_cast<const char*>(&mNMEASentence),
    sizeof(mNMEASentence));
  stream.write(reinterpret_cast<const char*>(&mNotUsed4), sizeof(mNotUsed4));
}
开发者ID:chen0510566,项目名称:libvelodyne,代码行数:11,代码来源:PositionPacket.cpp

示例2: sizeof

/*
 * 解析結果をバイナリ形式のファイルに出力する。
 * 内部コードを別ファイルにする用途で使用する。
 *
 * 各アセンブリは以下のフォーマット形式で保存される
 * [AssemblyName : string           ] アセンブリの名前
 * [StackFrame   : u32              ] スタックフレーム
 * [Address      : u32              ] 関数アドレス
 * [Args         : u32              ] 関数パラメータ数
 * [CodeSize     : u32              ] コード領域サイズ
 * [Code         : byte[ContentSize]] コード領域
 */
VMAssembleOutput::VMAssembleOutput( IAssembleReader* reader , const char* fileName ){
	BinaryWriter bw;
	int index = 0;
	AsmInfo* assemblyInfo = reader->getAssembly(0);
	while( assemblyInfo ){
		bw.writeString( assemblyInfo->name() );
		bw.writeUInt32( assemblyInfo->stackFrame() );
		bw.writeUInt32( assemblyInfo->addr() );
		bw.writeUInt32( assemblyInfo->Args() );
		bw.writeUInt32( assemblyInfo->CodeSize() );

		for( size_t i = 0 ; i < assemblyInfo->CodeSize() ; i++ ){
			bw.write( assemblyInfo->getCommand(i) );
		}
		assemblyInfo = reader->getAssembly(++index);
	}
	CStream stream = bw.getStream();
	FILE* fp = NULL;
	fopen_s( &fp , fileName , "wb" );
	assert( fp );
	while( stream->hasNext() ){
		unsigned char content[1];
		content[0] = static_cast<unsigned char>( stream->getByte() );
		fwrite( content , sizeof( unsigned char ) , sizeof( content ) , fp );
	}
	fclose( fp );
}
开发者ID:SenchaK,项目名称:ScriptEngine,代码行数:39,代码来源:vm_assemble_io.cpp

示例3: flush

void RTMFPWriter::flush(BinaryWriter& writer,UInt64 stage,UInt8 flags,bool header,const RTMFPMessage& message, UInt32 offset, UInt16 size) {
	if(_stageAck==0 && header)
		flags |= MESSAGE_HEADER;
	if(size==0)
		flags |= MESSAGE_ABANDONMENT;
	if(state()==CLOSED && _messages.size()==1) // On LAST message
		flags |= MESSAGE_END;

	// TRACE("RTMFPWriter ",id," stage ",stage);

	writer.write8(flags);

	if(header) {
		writer.write7BitLongValue(id);
		writer.write7BitLongValue(stage);
		writer.write7BitLongValue(stage-_stageAck);

		// signature
		if(_stageAck==0) {
			writer.write8((UInt8)signature.size()).write(signature);
			// No write this in the case where it's a new flow!
			if(flowId>0) {
				writer.write8(1+Util::Get7BitValueSize(flowId)); // following size
				writer.write8(0x0a); // Unknown!
				writer.write7BitLongValue(flowId);
			}
			writer.write8(0); // marker of end for this part
		}
	}

	if (size == 0)
		return;

	if (offset < message.frontSize()) {
		UInt8 count = message.frontSize()-offset;
		if (size<count)
			count = (UInt8)size;
		writer.write(message.front()+offset,count);
		size -= count;
		if (size == 0)
			return;
		offset += count;
	}

	writer.write(message.body()+offset-message.frontSize(), size);
}
开发者ID:8088,项目名称:MonaServer,代码行数:46,代码来源:RTMFPWriter.cpp

示例4: handshakeHandler

UInt8 RTMFPHandshake::handshakeHandler(UInt8 id,const SocketAddress& address, BinaryReader& request,BinaryWriter& response) {

	switch(id){
		case 0x30: {
			
			request.read7BitValue(); // = epdLen + 2 (useless)
			UInt16 epdLen = request.read7BitValue()-1;
			UInt8 type = request.read8();
			string epd;
			request.read(epdLen,epd);

			string tag;
			request.read(16,tag);
			response.write7BitValue(tag.size()).write(tag);
		
			if(type == 0x0f) {

				const UInt8* peerId((const UInt8*)epd.c_str());
				
				RTMFPSession* pSessionWanted = _sessions.findByPeer<RTMFPSession>(peerId);
	
				if(pSessionWanted) {
					if(pSessionWanted->failed())
						return 0x00; // TODO no way in RTMFP to tell "died!"
					/// Udp hole punching
					UInt32 times = attempt(tag);
		
					RTMFPSession* pSession(NULL);
					if(times > 0 || address.host() == pSessionWanted->peer.address.host()) // try in first just with public address (excepting if the both peer are on the same machine)
						pSession = _sessions.findByAddress<RTMFPSession>(address,Socket::DATAGRAM);
					
					bool hasAnExteriorPeer(pSessionWanted->p2pHandshake(tag,address,times,pSession));
					
					// public address
					RTMFP::WriteAddress(response,pSessionWanted->peer.address, RTMFP::ADDRESS_PUBLIC);
					DEBUG("P2P address initiator exchange, ",pSessionWanted->peer.address.toString());

					if (hasAnExteriorPeer && pSession->peer.serverAddress.host()!=pSessionWanted->peer.address.host()) {
						// the both peer see the server in a different way (and serverAddress.host()!= public address host written above),
						// Means an exterior peer, but we can't know which one is the exterior peer
						// so add an interiorAddress build with how see eachone the server on the both side
						SocketAddress interiorAddress(pSession->peer.serverAddress.host(), pSessionWanted->peer.address.port());
						RTMFP::WriteAddress(response,interiorAddress, RTMFP::ADDRESS_PUBLIC);
						DEBUG("P2P address initiator exchange, ",interiorAddress.toString());
					}	

					// local address
					for(const SocketAddress& address : pSessionWanted->peer.localAddresses) {
						RTMFP::WriteAddress(response,address, RTMFP::ADDRESS_LOCAL);
						DEBUG("P2P address initiator exchange, ",address.toString());
					}

					// add the turn address (RelayServer) if possible and required
					if (pSession && times>0) {
						UInt8 timesBeforeTurn(0);
						if(pSession->peer.parameters().getNumber("timesBeforeTurn",timesBeforeTurn) && timesBeforeTurn>=times) {
							UInt16 port = invoker.relayer.relay(pSession->peer.address,pSessionWanted->peer.address,20); // 20 sec de timeout is enough for RTMFP!
							if (port > 0) {
								SocketAddress address(pSession->peer.serverAddress.host(), port);
								RTMFP::WriteAddress(response, address, RTMFP::ADDRESS_REDIRECTION);
							} // else ERROR already display by RelayServer class
						}
					}
					return 0x71;
				}


				DEBUG("UDP Hole punching, session ", Util::FormatHex(peerId, ID_SIZE, LOG_BUFFER), " wanted not found")
				set<SocketAddress> addresses;
				peer.onRendezVousUnknown(peerId,addresses);
				set<SocketAddress>::const_iterator it;
				for(it=addresses.begin();it!=addresses.end();++it) {
					if(it->host().isWildcard())
						continue;
					if(address == *it)
						WARN("A client tries to connect to himself (same ", address.toString()," address)");
					RTMFP::WriteAddress(response,*it,RTMFP::ADDRESS_REDIRECTION);
					DEBUG("P2P address initiator exchange, ",it->toString());
				}
				return addresses.empty() ? 0 : 0x71;
			}

			if(type == 0x0a){
				/// RTMFPHandshake
				HelloAttempt& attempt = AttemptCounter::attempt<HelloAttempt>(tag);

				Peer& peer(*_pPeer);

				// Fill peer infos
				peer.properties().clear();
				string serverAddress;
				Util::UnpackUrl(epd, serverAddress, (string&)peer.path,(string&)peer.query);
				peer.setServerAddress(serverAddress);
				Util::UnpackQuery(peer.query, peer.properties());

				Exception ex;

				set<SocketAddress> addresses;
				peer.onHandshake(attempt.count+1,addresses);
				if(!addresses.empty()) {
//.........这里部分代码省略.........
开发者ID:jslswjf,项目名称:MonaServer,代码行数:101,代码来源:RTMFPHandshake.cpp

示例5: write

void Physics::write(BinaryWriter & output) const
{
	output.write(centerOfMass);
	output.write(mass);
}
开发者ID:Autodesk,项目名称:synthesis,代码行数:5,代码来源:Physics.cpp


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