Пример #1
0
 virtual typename base::int_type
     overflow(typename base::int_type __c = base::traits_type::eof())
     {
         if (__c != base::traits_type::eof())
         {
             int n = static_cast<int>(str_.size());
             str_.push_back(static_cast<CharT>(__c));
             str_.resize(str_.capacity());
             base::setp(const_cast<CharT*>(str_.data()),
                        const_cast<CharT*>(str_.data() + str_.size()));
             base::pbump(n+1);
         }
         return __c;
     }
Пример #2
0
 virtual typename base::int_type
     overflow(typename base::int_type ch = base::traits_type::eof())
     {
         if (ch != base::traits_type::eof())
         {
             std::size_t n = str_.size();
             str_.push_back(static_cast<CharT>(ch));
             str_.resize(str_.capacity());
             base::setp(const_cast<CharT*>(str_.data()),
                        const_cast<CharT*>(str_.data() + str_.size()));
             base::pbump(static_cast<int>(n+1));
         }
         return ch;
     }
Пример #3
0
    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));
        }

    }