dest = create(len);
copy(len, dest.c_str());
}
+ template<bool is_const>
+ void buffer::list::iterator_impl<is_const>::copy_shallow(unsigned len,
+ ptr &dest)
+ {
+ if (p == ls->end())
+ throw end_of_buffer();
+ assert(p->length() > 0);
+ unsigned howmuch = p->length() - p_off;
+ if (howmuch < len) {
+ dest = create(len);
+ copy(len, dest.c_str());
+ } else {
+ dest = ptr(*p, p_off, len);
+ advance(len);
+ }
+ }
template<bool is_const>
void buffer::list::iterator_impl<is_const>::copy(unsigned len, list &dest)
// note that these all _append_ to dest!
void copy(unsigned len, char *dest);
void copy_deep(unsigned len, ptr &dest);
+ void copy_shallow(unsigned len, ptr &dest);
void copy(unsigned len, list &dest);
void copy(unsigned len, std::string &dest);
void copy_all(list &dest);
// copy data out
void copy(unsigned len, char *dest);
void copy_deep(unsigned len, ptr &dest);
+ void copy_shallow(unsigned len, ptr &dest);
void copy(unsigned len, list &dest);
void copy(unsigned len, std::string &dest);
void copy_all(list &dest);
EXPECT_EQ('B', ptr[1]);
}
//
+ // void buffer::list::iterator::copy_shallow(unsigned len, ptr &dest)
+ //
+ {
+ bufferptr ptr;
+ bufferlist::iterator i(&bl);
+ i.copy_shallow(2, ptr);
+ EXPECT_EQ((unsigned)2, ptr.length());
+ EXPECT_EQ('A', ptr[0]);
+ EXPECT_EQ('B', ptr[1]);
+ }
+ //
// void buffer::list::iterator::copy(unsigned len, list &dest)
//
{