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


C++ Archive::getOstream方法代码示例

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


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

示例1: serializeFundamental

    inline void serializeFundamental(
        SF::Archive &ar, 
        T &t,
        unsigned int count = 1)
    {
        typedef typename RCF::RemoveCv<T>::type U;
        BOOST_STATIC_ASSERT( RCF::IsFundamental<U>::value );
        U * pt = const_cast<U *>(&t);

        if (ar.isRead())
        {
            I_Encoding &encoding = ar.getIstream()->getEncoding();
            DataPtr data;
            ar.getIstream()->get(data);
            if (count > 1 && count != encoding.getCount(data, pt) )
            {
                // static array size mismatch
                RCF::Exception e(RCF::_SfError_DataFormat());
                RCF_THROW(e)(typeid(U).name())(count)(encoding.getCount(data, pt));
            }
            encoding.toObject(data, pt, count);
        }
        else if (ar.isWrite())
        {
            I_Encoding &encoding = ar.getOstream()->getEncoding();
            DataPtr data;
            encoding.toData(data, pt, count );
            ar.getOstream()->put(data);
        }
    }
开发者ID:MorelM35,项目名称:ESIR_MorKaneGame,代码行数:30,代码来源:SerializeFundamental.hpp

示例2: serializeString

    inline void serializeString(SF::Archive & ar, std::basic_string<C,T,A> & s)
    {
        if (ar.isRead())
        {
            boost::uint32_t count = 0;
            ar & count;

            SF::IStream &is = *ar.getIstream();

            s.resize(0);

            std::size_t minSerializedLength = sizeof(C);
            if (ar.verifyAgainstArchiveSize(count*minSerializedLength))
            {
                if (count > s.capacity())
                {
                    s.reserve(count);
                }
            }

            boost::uint32_t charsRemaining = count;
            const boost::uint32_t BufferSize = 512;
            C buffer[BufferSize];
            while (charsRemaining)
            {
                boost::uint32_t charsToRead = RCF_MIN(BufferSize, charsRemaining);
                boost::uint32_t bytesToRead = charsToRead*sizeof(C);

                RCF_VERIFY(
                    is.read( (char *) buffer, bytesToRead) == bytesToRead,
                    RCF::Exception(RCF::_SfError_ReadFailure()))
                    (bytesToRead)(BufferSize)(count);

                s.append(buffer, charsToRead);
                charsRemaining -= charsToRead;
            }
        }
        else if (ar.isWrite())
        {
            boost::uint32_t count = static_cast<boost::uint32_t >(s.length());
            ar & count;
            ar.getOstream()->writeRaw(
                (char *) s.c_str(),
                count*sizeof(C));
        }

    }
开发者ID:mkotsbak,项目名称:librcf-cpp,代码行数:47,代码来源:string.hpp

示例3: serialize

    void serialize(SF::Archive &ar, RCF::ByteBuffer &byteBuffer)
    {
        if (ar.isRead())
        {
            boost::uint32_t len = 0;
            ar & len;

            byteBuffer.clear();

            // See if we have a remote call context.
            RCF::SerializationProtocolIn *pIn = 
                ar.getIstream()->getRemoteCallContext();

            if (pIn && len)
            {
                pIn->extractSlice(byteBuffer, len);
            }
            else if (len)
            {
                if (byteBuffer.getLength() >= len)
                {
                    byteBuffer = RCF::ByteBuffer(byteBuffer, 0, len);
                }
                else
                {
                    byteBuffer = RCF::ByteBuffer(len);
                }

                SF::IStream &is = *ar.getIstream();

                boost::uint32_t bytesToRead = len;
                boost::uint32_t bytesRead = is.read( (SF::Byte8 *) byteBuffer.getPtr(), bytesToRead);

                RCF_VERIFY(
                    bytesRead == bytesToRead,
                    RCF::Exception(RCF::_SfError_ReadFailure()))
                    (bytesToRead)(bytesRead);
            }
        }
        else if (ar.isWrite())
        {
            boost::uint32_t len = static_cast<boost::uint32_t>(byteBuffer.getLength());
            ar & len;

            // See if we have a remote call context.
            RCF::SerializationProtocolOut *pOut = 
                ar.getOstream()->getRemoteCallContext();

            if (pOut && len)
            {
                pOut->insert(byteBuffer);
            }
            else if (len)
            {
                boost::uint32_t bytesToWrite = len;
                ar.getOstream()->writeRaw(
                    (SF::Byte8 *) byteBuffer.getPtr(),
                    bytesToWrite);
            }
        }
    }
开发者ID:huangjunfeng2000,项目名称:Rcf,代码行数:61,代码来源:ByteBuffer.cpp

示例4: serialize

    void serialize(SF::Archive &ar, RCF::ByteBuffer &byteBuffer)
    {
        RCF::SerializationProtocolIn *pIn = NULL;
        RCF::SerializationProtocolOut *pOut = NULL;

        RCF::ClientStub * pClientStub = RCF::getCurrentClientStubPtr();
        RCF::RcfSession * pRcfSession = RCF::getCurrentRcfSessionPtr();
        if (pClientStub)
        {
            pIn = &pClientStub->getSpIn();
            pOut = &pClientStub->getSpOut();
        }
        else if (pRcfSession)
        {
            pIn = &pRcfSession->getSpIn();
            pOut = &pRcfSession->getSpOut();
        }

        if (ar.isRead())
        {
            boost::uint32_t len = 0;
            ar & len;

            byteBuffer.clear();

            RCF::SerializationProtocolIn *pIn = 
                RCF::getCurrentSerializationProtocolIn();

            if (pIn && len)
            {
                pIn->extractSlice(byteBuffer, len);
            }
            else if (len)
            {
                byteBuffer = RCF::ByteBuffer(len);

                SF::IStream &is = *ar.getIstream();

                boost::uint32_t bytesToRead = len;
                boost::uint32_t bytesRead = is.read( (SF::Byte8 *) byteBuffer.getPtr(), bytesToRead);

                RCF_VERIFY(
                    bytesRead == bytesToRead,
                    RCF::Exception(RCF::_SfError_ReadFailure()))
                    (bytesToRead)(bytesRead);
            }
        }
        else if (ar.isWrite())
        {
            boost::uint32_t len = static_cast<boost::uint32_t>(byteBuffer.getLength());
            ar & len;

            RCF::SerializationProtocolOut *pOut = 
                RCF::getCurrentSerializationProtocolOut();

            if (pOut && len)
            {
                pOut->insert(byteBuffer);
            }
            else if (len)
            {
                boost::uint32_t bytesToWrite = len;
                ar.getOstream()->writeRaw(
                    (SF::Byte8 *) byteBuffer.getPtr(),
                    bytesToWrite);
            }
        }
    }
开发者ID:mkotsbak,项目名称:librcf-cpp,代码行数:68,代码来源:ByteBuffer.cpp


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