Esempio n. 1
0
bool MemoryFileImpl::Rewind()
{
    mActBufferId = 0;
    for( Buffers::iterator i = mBuffers.begin(), e = mBuffers.end(); i != e; ++i )
    {
        i->pos = 0;
    }
    return true;
}
Esempio n. 2
0
void dump_buffers(Buffers const & buffers)
{
    std::cout << "dump_buffers:" << std::endl;
    typedef typename Buffers::const_iterator const_iterator;
    for (const_iterator iter = buffers.begin(); iter != buffers.end(); ++iter) {
        boost::asio::const_buffer buffer(*iter);
        std::cout << buffer_cast<char const *>(buffer) - buf << ":" << buffer_size(buffer) << std::endl;
    }
};
Esempio n. 3
0
 static void validate(const Buffers& buffer_sequence)
 {
   typename Buffers::const_iterator iter = buffer_sequence.begin();
   typename Buffers::const_iterator end = buffer_sequence.end();
   for (; iter != end; ++iter)
   {
     Buffer buffer(*iter);
     riakboost::asio::buffer_cast<const void*>(buffer);
   }
 }
Esempio n. 4
0
 static bool all_empty(const Buffers& buffer_sequence)
 {
   typename Buffers::const_iterator iter = buffer_sequence.begin();
   typename Buffers::const_iterator end = buffer_sequence.end();
   std::size_t i = 0;
   for (; iter != end && i < max_buffers; ++iter, ++i)
     if (riakboost::asio::buffer_size(Buffer(*iter)) > 0)
       return false;
   return true;
 }
Esempio n. 5
0
 explicit buffer_sequence_adapter(const Buffers& buffer_sequence)
   : count_(0), total_buffer_size_(0)
 {
   typename Buffers::const_iterator iter = buffer_sequence.begin();
   typename Buffers::const_iterator end = buffer_sequence.end();
   for (; iter != end && count_ < max_buffers; ++iter, ++count_)
   {
     Buffer buffer(*iter);
     init_native_buffer(buffers_[count_], buffer);
     total_buffer_size_ += riakboost::asio::buffer_size(buffer);
   }
 }
Esempio n. 6
0
 static Buffer first(const Buffers& buffer_sequence)
 {
   typename Buffers::const_iterator iter = buffer_sequence.begin();
   typename Buffers::const_iterator end = buffer_sequence.end();
   for (; iter != end; ++iter)
   {
     Buffer buffer(*iter);
     if (riakboost::asio::buffer_size(buffer) != 0)
       return buffer;
   }
   return Buffer();
 }
Esempio n. 7
0
bool MemoryFileImpl::CopyTo( File& Other )
{
    for( Buffers::const_iterator i = mBuffers.begin(), e = mBuffers.end(); i != e; ++i )
    {
        if( !i->size )
        {
            break;
        }
        std::string Data( i->data, i->size );
        if( !Other.Write( Data ) )
        {
            return false;
        }
    }
    return true;
}