• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ser函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ser函数的典型用法代码示例。如果您正苦于以下问题:C++ ser函数的具体用法?C++ ser怎么用?C++ ser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: ser

void ser(struct node* root,int search)
{
	if(root->data==search)
	{
		if(root->right!=NULL)
		{
			root=root->right;
			while(root->left!=NULL)
			{
				root=root->left;
			}
			printf("%d ",root->data);
		}
		else
		{
			while(root->par->left!=root)
			{
				root=root->par;
			}
			printf("%d ",root->par->data);
		}
	}
	else if(root->data>search)
	{
		ser(root->left,search);
	}
	else
	{
		ser(root->right,search);
	}
}
开发者ID:Bminus,项目名称:Algorithms,代码行数:31,代码来源:12.c


示例2: writer

// static
void Serdes::SerializeMapObjects(MapObjects const & mapObjects, std::vector<int8_t> & result)
{
  result.clear();
  using Sink = MemWriter<std::vector<int8_t>>;

  Sink writer(result);
  std::string const nextLine = "\n";
  MapObjectEvent event;

  mapObjects.ForEach([&writer, &event, &nextLine](MapObject const & item)
  {
    for (auto const & poiEvent : item.GetEvents())
    {
      // Additional scope is added because of the coding::SerializerJson dumps result at destruction.
      {
        coding::SerializerJson<Sink> ser(writer);
        event.m_bestPoiType = item.GetBestType();
        event.m_poiPos = item.GetPos();
        event.m_defaultName = item.GetDefaultName();
        event.m_readableName = item.GetReadableName();
        event.m_event = poiEvent;
        ser(event);
      }
      writer.Write(nextLine.data(), nextLine.size());
    }
  });
}
开发者ID:milchakov,项目名称:omim,代码行数:28,代码来源:eye_serdes.cpp


示例3: WriteObjectToArchive

///////////////////////////////////////////////////////////////////////////////
// WriteObjectToArchive -- called from WriteObject, does most of the work
///////////////////////////////////////////////////////////////////////////////
static void WriteObjectToArchive(cArchive&                 arch,
                                 const TCHAR*              filename, // filename is used only for issuing error messages
                                 const iTypedSerializable* pObjHeader,
                                 const iTypedSerializable& obj,
                                 cFileHeader&              fileHeader,
                                 bool                      bEncrypt,
                                 const cElGamalSigPrivateKey* pPrivateKey)
{
    try
    {
        // Set file version.
        // If we in the future we wish to support reading databases of different versions,
        // we will have to move this set to outside WriteObject().
        fileHeader.SetVersion(CURRENT_FIXED_VERSION);

        fileHeader.SetEncoding(bEncrypt ? cFileHeader::ASYM_ENCRYPTION : cFileHeader::COMPRESSED);

        {
            cSerializerImpl fhSer(arch, cSerializerImpl::S_WRITE, filename);
            fileHeader.Write(&fhSer);
        }

        if (bEncrypt)
        {
            cElGamalSigArchive cryptoArchive;
            cryptoArchive.SetWrite(&arch, pPrivateKey);
            cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_WRITE, filename);
            ser.Init();
            if (pObjHeader)
                ser.WriteObject(pObjHeader);
            ser.WriteObject(&obj);
            ser.Finit();
            cryptoArchive.FlushWrite();
        }
        else
        {
            // not encrypted
            cNullCryptoArchive cryptoArchive;
            cryptoArchive.Start(&arch);
            cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_WRITE, filename);
            ser.Init();
            if (pObjHeader)
                ser.WriteObject(pObjHeader);
            ser.WriteObject(&obj);
            ser.Finit();
            cryptoArchive.Finish();
        }
    }
    catch (eError& e)
    {
        throw ePoly(e.GetID(), cErrorUtil::MakeFileError(e.GetMsg(), filename), e.GetFlags());
    }
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:56,代码来源:twutil.cpp


示例4: GridSource

HalfFloatGridSource::HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue, const bool trilinearGradient, const bool sobelGradient) :
    GridSource(trilinearValue, trilinearGradient, sobelGradient)
{

    Timer t;
    DataStreamPtr streamRead = Root::getSingleton().openFileStream(serializedVolumeFile);
#if OGRE_NO_ZIP_ARCHIVE == 0
    DataStreamPtr uncompressStream(OGRE_NEW DeflateStream(serializedVolumeFile, streamRead));
    StreamSerialiser ser(uncompressStream);
#else
    StreamSerialiser ser(streamRead);
#endif
    if (!ser.readChunkBegin(VOLUME_CHUNK_ID, VOLUME_CHUNK_VERSION))
    {
        OGRE_EXCEPT(Exception::ERR_INVALID_STATE,
                    "Invalid volume file given!",
                    __FUNCTION__);
    }

    // Read header
    Vector3 readFrom, readTo;
    ser.read(&readFrom);
    ser.read(&readTo);
    float voxelWidth;
    ser.read<float>(&voxelWidth);
    size_t width, height, depth;
    ser.read<size_t>(&width);
    ser.read<size_t>(&height);
    ser.read<size_t>(&depth);
    mWidth = static_cast<int>(width);
    mHeight = static_cast<int>(height);
    mDepth = static_cast<int>(depth);
    mDepthTimesHeight = static_cast<int>(mDepth * mHeight);

    Vector3 worldDimension = readTo - readFrom;
    mPosXScale = (Real)1.0 / (Real)worldDimension.x * (Real)mWidth;
    mPosYScale = (Real)1.0 / (Real)worldDimension.y * (Real)mHeight;
    mPosZScale = (Real)1.0 / (Real)worldDimension.z * (Real)mDepth;

    mVolumeSpaceToWorldSpaceFactor = (Real)worldDimension.x * (Real)mWidth;
    mMaxClampedAbsoluteDensity = 0;

    // Read data
    size_t elementCount = mWidth * mHeight * mDepth;
    mData = OGRE_ALLOC_T(uint16, elementCount, MEMCATEGORY_GENERAL);
    ser.read(mData, elementCount);

    ser.readChunkEnd(VOLUME_CHUNK_ID);

    LogManager::getSingleton().stream() << "Processed serialization in " << t.getMilliseconds() << "ms.";
}
开发者ID:quinsmpang,项目名称:xsilium-engine,代码行数:51,代码来源:OgreVolumeHalfFloatGridSource.cpp


示例5: controlc

void controlc()					// say ^C
{ cstring *sptr;				// string ptr
  u_char junk[10];
  short s;					// for returns
  sptr = (cstring *) junk;			// where to put it
  s = SQ_WriteFormat(SQ_LF);			// new line
  if (s < 0) ser(s);				// check for error
  bcopy("^C", sptr->buf, 2);			// copy in the prompt
  sptr->buf[3] = '\0';				// null terminate
  sptr->len = 2;				// and the length
  s = SQ_Write(sptr);				// write the prompt
  if (s < 0) ser(s);				// check for error
  return;					// exit
}
开发者ID:pahihu,项目名称:mumps,代码行数:14,代码来源:init_run.c


示例6: getManager

	//---------------------------------------------------------------------
	void Page::save(const String& filename)
	{
		DataStreamPtr stream = Root::getSingleton().createFileStream(filename, 
			getManager()->getPageResourceGroup(), true);
		StreamSerialiser ser(stream);
		save(ser);
	}
开发者ID:JangoOs,项目名称:kbengine_ogre_demo,代码行数:8,代码来源:OgrePage.cpp


示例7: assert

netBool UnreliableListener::Push(SerializerLess &_ser, const Peer& _peer)
{
	assert(m_stream != nullptr);

	Channel& channel = GetChannel(m_sendChannels, _peer);

	SerializerLess *back = channel.Back();

	// bundling
	if(channel.IsEmpty() || back->GetSize() + _ser.GetSize() > back->GetBufferSize())
	{
		SerializerLess ser(m_pool.GetSerializer());
		// prepare serializer
		ser.Write(m_stream->GetType());

		SerializerLess stream_ser(ser, m_stream->GetHeaderSize(), ser.GetBufferSize());
		stream_ser.Write(GetType());
		stream_ser.Close();

		ser.SetCursor(ser.GetCursor() + stream_ser.GetSize());
		ser.Close();
		channel.Push(ser);
	}

	return Pack(_ser, _peer);
}
开发者ID:ricklesauceur,项目名称:netduke,代码行数:26,代码来源:unreliablelistener.cpp


示例8: ASSERT

///////////////////////////////////////////////////////////////////////////////
// SetFCOData
///////////////////////////////////////////////////////////////////////////////
void cDbDataSourceIter::SetFCOData( const iFCO* pFCO ) //throw (eError)
{
	ASSERT( ! Done() );
	if( Done() )
	{
		throw eHierDatabase( _T("Attempt to set FCO data when the iterator is done.") );
	}
	// TODO -- assert and throw if the fco's type is not the same as our creation function
	//		There is no way to do this through the serializable interface, but when there is,
	//		we should do the above assertion.
	//
	// if data already exists here, we first remove it; 
	//
	if( mDbIter.HasData() )
	{
		mDbIter.RemoveData();
	}
	//
	// write the fco's property set to a memory archive...
	//
	// TODO -- does this need to be static?
	static cMemoryArchive arch;
	arch.Seek			( 0, cBidirArchive::BEGINNING );
	cSerializerImpl ser	(arch, cSerializerImpl::S_WRITE);
	ser.Init();
	ser.WriteObject		( pFCO->GetPropSet() );
	ser.Finit();
	//
	// write this to the archive...
	//
	mDbIter.SetData( arch.GetMemory(), arch.CurrentPos() );
}
开发者ID:jiangzhw,项目名称:tripwire-open-source,代码行数:35,代码来源:dbdatasource.cpp


示例9: Sys_Milliseconds

/*
===============
idCommonLocal::SendUsercmd
===============
*/
void idCommonLocal::SendUsercmds( int localClientNum ) {
    if ( !mapSpawned ) {
        return;
    }
    int currentTime = Sys_Milliseconds();
    if ( currentTime < nextUsercmdSendTime ) {
        return;
    }
    idLobbyBase & lobby = session->GetActingGameStateLobbyBase();
    if ( lobby.IsHost() ) {
        return;
    }
    // We always send the last NUM_USERCMD_SEND usercmds
    // Which may result in duplicate usercmds being sent in the case of a low net_ucmdRate
    // But the LZW compressor means the extra usercmds are not large and the redundancy can smooth packet loss
    byte buffer[idPacketProcessor::MAX_FINAL_PACKET_SIZE];
    idBitMsg msg( buffer, sizeof( buffer ) );
    idSerializer ser( msg, true );
    usercmd_t empty;
    usercmd_t * last = &empty;

    usercmd_t * cmdBuffer[NUM_USERCMD_SEND];
    const int numCmds = userCmdMgr.GetPlayerCmds( localClientNum, cmdBuffer, NUM_USERCMD_SEND );
    msg.WriteByte( numCmds );
    for ( int i = 0; i < numCmds; i++ ) {
        cmdBuffer[i]->Serialize( ser, *last );

        last = cmdBuffer[i];
    }
    session->SendUsercmds( msg );

    nextUsercmdSendTime = MSEC_ALIGN_TO_FRAME( currentTime + net_ucmdRate.GetInteger() );
}
开发者ID:Nekel-Seyew,项目名称:OregonState-idTech4,代码行数:38,代码来源:Common_network.cpp


示例10: fastbuffer

bool MetaTestTypesPubSubType::getKey(void *data, InstanceHandle_t* handle)
{
    if(!m_isGetKeyDefined)
        return false;

    MetaTestType* p_type = (MetaTestType*) data;

    // Object that manages the raw buffer.
    eprosima::fastcdr::FastBuffer fastbuffer((char*)m_keyBuffer,MetaTestType::getKeyMaxCdrSerializedSize());
    // Object that serializes the data.
    eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS);

    p_type->serializeKey(ser);
    if(MetaTestType::getKeyMaxCdrSerializedSize()>16)
    {
        m_md5.init();
        m_md5.update(m_keyBuffer,(unsigned int)ser.getSerializedDataLength());
        m_md5.finalize();
        for(uint8_t i = 0; i<16; ++i)
        {
            handle->value[i] = m_md5.digest[i];
        }
    }
    else
    {
        for(uint8_t i = 0; i<16; ++i)
        {
            handle->value[i] = m_keyBuffer[i];
        }
    }

    return true;
}
开发者ID:showna,项目名称:Fast-RTPS,代码行数:33,代码来源:MetaTestTypesPubSubType.cpp


示例11: ser

void MeshSaverImplv1_0::WriteVersion(OutputStreamPtr& out) {
	OutputSerializer ser(out);
	uint32 meshMagic = FILE_MAGIC_MESH;
	VersionID ver = NEX_MAKE_VERSION(1, 0, 0);
	String versionInfo = Convert::ToVersionString(ver);
	ser << meshMagic << versionInfo;
}
开发者ID:obhi-d,项目名称:nextar,代码行数:7,代码来源:MeshSaverImplv10.cpp


示例12: serialize_gc

void serialize_gc(int fd, const vector<GarbledGate>& gc) {
    struct serializer : public boost::static_visitor<> {
        int fd;
        serializer(int fd_) : fd(fd_) {}
        void operator()(const InputWire& w) {
            char who = tag_to_bool(w.who) ? 'S' : 'R';
            dbgprintf(stderr, "Serializing InputWire(%c, %lu)\n", who, w.index);
            write_aon(fd, "0", sizeof(char));
            write_aon(fd, &who, sizeof(char));
            write_aon(fd, (char*)&w.index, sizeof(size_t));
        }
        void operator()(const GarbledWire& w) {
            dbgprintf(stderr, "Serializing GarbledWire(%lu, %lu)\n", w.l, w.r);
            write_aon(fd, "1", sizeof(char));
            write_aon(fd, (char*)&w.values[0][0][0], 2 * 2 * (SEC_PARAM+1)*sizeof(uint8_t));
            write_aon(fd, (char*)&w.l, sizeof(size_t));
            write_aon(fd, (char*)&w.r, sizeof(size_t));
        }
        void operator()(const OutputWire& w) {
            dbgprintf(stderr, "Serializing OutputWire(%lu)\n", w.index);
            write_aon(fd, "2", sizeof(char));
            write_aon(fd, (char*)&w.index, sizeof(w.index));
        }
    };
    size_t i, n = gc.size();
    serializer ser(fd);
    write_aon(fd, (char*)&n, sizeof(size_t));
    for(i=0; i<n; i++) {
        boost::apply_visitor(ser, gc[i]);
    }
}
开发者ID:aweinstock314,项目名称:weinsa_sheedb_tinkhj_ifillj_crypto2016_yaoprotocol,代码行数:31,代码来源:GarbledCircuit.cpp


示例13: makeDiscoveryClusterInfo

common::Error makeDiscoveryClusterInfo(const common::net::HostAndPort& parentHost,
                                       const std::string& text,
                                       std::vector<ServerDiscoveryClusterInfoSPtr>* infos) {
  if (text.empty() || !infos) {
    return common::make_error_value("Invalid input argument(s)", common::ErrorValue::E_ERROR);
    ;
  }

  size_t pos = 0;
  size_t start = 0;

  while ((pos = text.find(MARKER, start)) != std::string::npos) {
    std::string line = text.substr(start, pos - start);

    ServerCommonInfo inf;
    bool self = false;
    common::Error lerr = MakeServerCommonInfoFromLine(line, &inf, &self);
    if (lerr && lerr->isError()) {
      continue;
    }
    if (common::net::isLocalHost(inf.host.host)) {  // for direct connection
      inf.host.host = parentHost.host;
    }

    ServerDiscoveryClusterInfoSPtr ser(new DiscoveryClusterInfo(inf, self));
    infos->push_back(ser);
    start = pos + 1;
  }

  return common::Error();
}
开发者ID:fastogt,项目名称:fastonosql,代码行数:31,代码来源:cluster_infos.cpp


示例14: compressStream

    void Source::serialize(const Vector3 &from, const Vector3 &to, float voxelWidth, Real maxClampedAbsoluteDensity, const String &file)
    {
     
        Timer t;

        // Compress
        DataStreamPtr stream = Root::getSingleton().createFileStream(file);
        DataStreamPtr compressStream(OGRE_NEW DeflateStream(file, stream));
        StreamSerialiser ser(compressStream);
        ser.writeChunkBegin(VOLUME_CHUNK_ID, VOLUME_CHUNK_VERSION);

        // Write Metadata
        ser.write(&from);
        ser.write(&to);
        ser.write<float>(&voxelWidth);
        Vector3 diagonal = to - from;
        size_t gridWidth = (size_t)(diagonal.x / voxelWidth);
        size_t gridHeight = (size_t)(diagonal.y / voxelWidth);
        size_t gridDepth = (size_t)(diagonal.z / voxelWidth);
        ser.write<size_t>(&gridWidth);
        ser.write<size_t>(&gridHeight);
        ser.write<size_t>(&gridDepth);

        // Go over the volume and write the density data.
        Vector3 pos;
        Real realVal;
        size_t x;
        size_t y;
        uint16 buffer[SERIALIZATION_CHUNK_SIZE];
        size_t bufferI = 0;
        for (size_t z = 0; z < gridDepth; ++z)
        {
            for (x = 0; x < gridWidth; ++x)
            {
                for (y = 0; y < gridHeight; ++y)
                {
                    pos.x = x * voxelWidth + from.x;
                    pos.y = y * voxelWidth + from.y;
                    pos.z = z * voxelWidth + from.z;
                    realVal = Math::Clamp<Real>(getValue(pos), -maxClampedAbsoluteDensity, maxClampedAbsoluteDensity);
                    buffer[bufferI] = Bitwise::floatToHalf(realVal);
                    bufferI++;
                    if (bufferI == SERIALIZATION_CHUNK_SIZE)
                    {
                        ser.write<uint16>(buffer, SERIALIZATION_CHUNK_SIZE);
                        bufferI = 0;
                    }
                }
            }
        }
        if (bufferI > 0)
        {
            ser.write<uint16>(buffer, bufferI);
        }
        LogManager::getSingleton().stream() << "Time for serialization: " << t.getMilliseconds() << "ms";

        ser.writeChunkEnd(VOLUME_CHUNK_ID);
        
    }
开发者ID:vancepym,项目名称:ogre,代码行数:59,代码来源:OgreVolumeSource.cpp


示例15: ser

void ext_list::ext::serialise(xml::serializer &serialiser, const std::string& ns)
{
    std::istringstream ser(serialised_value_);
    xml::parser p(ser, "", xml::parser::receive_default);
    p.next_expect(xml::parser::event_type::start_element, xml::qname(ns, "wrap"));
    roundtrip(p, serialiser);
    p.next_expect(xml::parser::event_type::end_element, xml::qname(ns, "wrap"));
}
开发者ID:tfussell,项目名称:xlnt,代码行数:8,代码来源:ext_list.cpp


示例16: fastbuffer

bool Data64kbType::serialize(void *data, SerializedPayload_t *payload) {
	Data64kb *p_type = (Data64kb*) data;
	eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size); // Object that manages the raw buffer.
	eprosima::fastcdr::Cdr ser(fastbuffer,eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS); 	// Object that serializes the data.
	payload->encapsulation = CDR_LE;  	//Select the correct endianess
	p_type->serialize(ser); 	// Serialize the object:
    payload->length = (uint16_t)ser.getSerializedDataLength(); 	//Get the serialized length
	return true;
}
开发者ID:codebot,项目名称:Fast-RTPS,代码行数:9,代码来源:Data64kbType.cpp


示例17: ser

/*
========================
idCommonLocal::NetReadUsercmds
========================
*/
void idCommonLocal::NetReadUsercmds( int clientNum, idBitMsg& msg )
{
	if( clientNum == -1 )
	{
		idLib::Warning( "NetReadUsercmds: Trying to read commands from invalid clientNum %d", clientNum );
		return;
	}
	
	// TODO: This shouldn't actually happen. Figure out why it does.
	// Seen on clients when another client leaves a match.
	if( msg.GetReadData() == NULL )
	{
		return;
	}
	
	idSerializer ser( msg, false );
	
	usercmd_t fakeCmd;
	usercmd_t* base = &fakeCmd;
	
	usercmd_t lastCmd;
	
	bool										gotNewCmd = false;
	idStaticList< usercmd_t, NUM_USERCMD_RELAY >	newCmdBuffer;
	
	usercmd_t baseCmd = userCmdMgr.NewestUserCmdForPlayer( clientNum );
	int curMilliseconds = baseCmd.clientGameMilliseconds;
	
	const int numCmds = msg.ReadByte();
	
	for( int i = 0; i < numCmds; i++ )
	{
		usercmd_t newCmd;
		newCmd.Serialize( ser, *base );
		
		lastCmd = newCmd;
		base = &lastCmd;
		
		int newMilliseconds = newCmd.clientGameMilliseconds;
		
		if( newMilliseconds > curMilliseconds )
		{
			if( verify( i < NUM_USERCMD_RELAY ) )
			{
				newCmdBuffer.Append( newCmd );
				gotNewCmd = true;
				curMilliseconds = newMilliseconds;
			}
		}
	}
	
	// Push the commands into the buffer.
	for( int i = 0; i < newCmdBuffer.Num(); ++i )
	{
		userCmdMgr.PutUserCmdForPlayer( clientNum, newCmdBuffer[i] );
	}
}
开发者ID:BielBdeLuna,项目名称:RBDoom3BFG-mirrored,代码行数:62,代码来源:Common_network.cpp


示例18: initStream

//////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////
void SaveLoad::create(GameId id) {
	initStream();

	Common::Serializer ser(NULL, _savegame);
	SavegameMainHeader header;
	header.saveLoadWithSerializer(ser);

	flushStream(id);
}
开发者ID:peres,项目名称:scummvm,代码行数:12,代码来源:savegame.cpp


示例19: ser

node *ser(node*head,int key)
{
    if(head->next->roll==key)
	    return head;
    else
    {
	    head = ser(head->next,key);
	    return head;
    }
}
开发者ID:vaibhavdangayachvd,项目名称:C-Programming,代码行数:10,代码来源:DBMS+by+VD+-+L.C


示例20: buffer

/**
 *  liest die GlobalGameSettings aus der Datei.
 *
 *  @author OLiver
 */
void SavedFile::ReadGGS(BinaryFile& file)
{
    unsigned length = file.ReadUnsignedInt();
    boost::interprocess::unique_ptr<unsigned char, Deleter<unsigned char[]> > buffer(new unsigned char[length]);

    file.ReadRawData(buffer.get(), length);
    Serializer ser(buffer.get(), length);

    ggs.Deserialize(ser);
}
开发者ID:jonathan-reisdorf,项目名称:s25client,代码行数:15,代码来源:GameSavedFile.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ser_sd_transport_cmd_write函数代码示例发布时间:2022-05-30
下一篇:
C++ sequence函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap