bool MemoryFileImpl::Rewind() { mActBufferId = 0; for( Buffers::iterator i = mBuffers.begin(), e = mBuffers.end(); i != e; ++i ) { i->pos = 0; } return true; }
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; } };
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); } }
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; }
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); } }
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(); }
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; }