Ejemplo 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;
}
Ejemplo 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;
    }
};
Ejemplo 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);
   }
 }
Ejemplo 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;
 }
Ejemplo n.º 5
0
	size_t bodyBuffers(bool chunked, list<string> &chunkLines, const iovec* vec, int c, Buffers& buffers) {
		size_t rsize = 0;
		for (int i = 0; i < c; ++i)
			rsize += vec[i].iov_len;

		if (rsize != 0) {
			if (chunked) {
				chunkLines.push_back(hexSize(rsize));
				buffers.push_back(toBuffer(chunkLines.back()));
				buffers.push_back(blanklineBuffer());
				buffers.insert(buffers.end(), vec, vec + c);
				buffers.push_back(blanklineBuffer());
			}
			else {
				buffers.insert(buffers.end(), vec, vec + c);
			}
		}

		return rsize;
	}
Ejemplo n.º 6
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);
   }
 }
Ejemplo n.º 7
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();
 }
Ejemplo n.º 8
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;
}