buffer::list::iterator_impl<is_const>::iterator_impl(bl_t *l, unsigned o)
: bl(l), ls(&bl->_buffers), p(ls->begin()), off(0), p_off(0)
{
- advance(o);
+ *this += o;
}
template<bool is_const>
: iterator_impl<is_const>(i.bl, i.off, i.p, i.p_off) {}
template<bool is_const>
- void buffer::list::iterator_impl<is_const>::advance(unsigned o)
+ auto buffer::list::iterator_impl<is_const>::operator +=(unsigned o)
+ -> iterator_impl&
{
//cout << this << " advance " << o << " from " << off
// << " (p_off " << p_off << " in " << p->length() << ")"
throw end_of_buffer();
}
off += o;
+ return *this;
}
template<bool is_const>
{
p = ls->begin();
off = p_off = 0;
- advance(o);
+ *this += o;
}
template<bool is_const>
{
if (p == ls->end())
throw end_of_buffer();
- advance(1u);
+ *this += 1;
return *this;
}
dest += howmuch;
len -= howmuch;
- advance(howmuch);
+ *this += howmuch;
}
}
copy(len, dest.c_str());
} else {
dest = ptr(*p, p_off, len);
- advance(len);
+ *this += len;
}
}
dest.append(*p, p_off, howmuch);
len -= howmuch;
- advance(howmuch);
+ *this += howmuch;
}
}
dest.append(c_str + p_off, howmuch);
len -= howmuch;
- advance(howmuch);
+ *this += howmuch;
}
}
const char *c_str = p->c_str();
dest.append(c_str + p_off, howmuch);
- advance(howmuch);
+ *this += howmuch;
}
}
src += howmuch;
len -= howmuch;
- advance(howmuch);
+ *this += howmuch;
}
}
}
void Skip(size_t n) override {
ceph_assert(n <= remaining);
- pb.advance(n);
+ pb += n;
remaining -= n;
}
using pointer = typename std::conditional<is_const, const char*, char *>::type;
pointer get_pos_add(size_t n) {
auto r = pos;
- advance(n);
+ *this += n;
return r;
}
ptr get_ptr(size_t len) {
return buffer::copy(get_pos_add(len), len);
} else {
size_t off = pos - bp->c_str();
- advance(len);
+ *this += len;
return ptr(*bp, off, len);
}
}
- void advance(size_t len) {
+ iterator_impl& operator+=(size_t len) {
pos += len;
if (pos > end_ptr)
throw end_of_buffer();
- }
- iterator_impl& operator+=(size_t len) {
- advance(len);
return *this;
}
return p == ls->end();
//return off == bl->length();
}
- void advance(unsigned o);
void seek(unsigned o);
char operator*() const;
- iterator_impl& operator+=(unsigned o) {
- advance(o);
- return *this;
- }
+ iterator_impl& operator+=(unsigned o);
iterator_impl& operator++();
ptr get_current_ptr() const;
bool is_pointing_same_raw(const ptr& other) const;
t.copy_shallow(remaining, tmp);
auto cp = std::cbegin(tmp);
traits::decode(o, cp);
- p.advance(cp.get_offset());
+ p += cp.get_offset();
}
}
t.copy_shallow(p.get_bl().length() - p.get_off(), tmp);
auto cp = std::cbegin(tmp);
traits::decode(o, cp);
- p.advance(cp.get_offset());
+ p += cp.get_offset();
}
// nohead variants
}
auto cp = std::cbegin(tmp);
traits::decode_nohead(num, o, cp);
- p.advance(cp.get_offset());
+ p += cp.get_offset();
} else {
traits::decode_nohead(num, o, p);
}
char *end = *start_pos + *struct_len; \
ceph_assert(pos <= end); \
if (pos < end) { \
- p.advance(end - pos); \
+ p += end - pos; \
} \
}
} else if (skip_v) { \
if (bl.get_remaining() < skip_v) \
throw ::ceph::buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); \
- bl.advance(skip_v); \
+ bl += skip_v; \
} \
unsigned struct_end = 0; \
if (struct_v >= lenv) { \
if (bl.get_off() > struct_end) \
throw ::ceph::buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); \
if (bl.get_off() < struct_end) \
- bl.advance(struct_end - bl.get_off()); \
+ bl += struct_end - bl.get_off(); \
}
namespace ceph {
*bytes_needed = 0;
return false;
}
- iter.advance(HEADER_FIXED_SIZE - sizeof(bl_preamble));
+ iter += HEADER_FIXED_SIZE - sizeof(bl_preamble);
if (iter.get_remaining() < sizeof(uint32_t)) {
*bytes_needed = sizeof(uint32_t) - iter.get_remaining();
*bytes_needed = data_size - iter.get_remaining();
return false;
}
- iter.advance(data_size);
+ iter += data_size;
uint32_t end_off = iter.get_off();
if (iter.get_remaining() < sizeof(uint32_t)) {
// journal debug tools catch it and recognise a malformed entry.
throw buffer::end_of_buffer();
} else {
- bl.advance(pad_size);
+ bl += pad_size;
}
DECODE_FINISH(bl);
}
decode(delta_ub, p);
}
- p.advance(size);
+ p += size;
min_message_size = size + payload_mid_length;
}
void encode_payload(uint64_t features) override {
unsigned read_len = std::min(bp.length(), msg_left);
ceph_assert(read_len <
static_cast<unsigned>(std::numeric_limits<int>::max()));
- data_blp.advance(read_len);
+ data_blp += read_len;
data.append(bp, 0, read_len);
msg_left -= read_len;
while (n--) {
__u32 l;
decode(l, p);
- p.advance(l);
+ p += l;
len += 4 + l;
decode(l, p);
- p.advance(l);
+ p += l;
len += 4 + l;
}
start.copy(len, *out);
while (n--) {
__u32 l;
decode(l, p);
- p.advance(l);
+ p += l;
len += 4 + l;
}
start.copy(len, *out);
void bluestore_bdev_label_t::decode(bufferlist::const_iterator& p)
{
- p.advance(60u); // see above
+ p += 60u; // see above
DECODE_START(2, p);
decode(osd_uuid, p);
decode(size, p);
decode(v, bl);
if (v < 2) { // normally 0, but conceivably 1
// decode old header_t struct (pre v0.40).
- bl.advance(4u); // skip __u32 flags (it was unused by any old code)
+ bl += 4u; // skip __u32 flags (it was unused by any old code)
flags = 0;
uint64_t tfsid;
decode(tfsid, bl);
offsets[i].second = p.get_off() - start_off;
uint32_t vn;
decode(vn, p);
- p.advance(vn * sizeof(int32_t));
+ p += vn * sizeof(int32_t);
}
size_t len = p.get_off() - start_off;
pstart.copy(len, data);
bufferlist init_value_bl;
init_value_bl.substr_of(bl_it->get_bl(), bl_it->get_off(),
csum_init_value_size);
- bl_it->advance(csum_init_value_size);
+ *bl_it += csum_init_value_size;
if (pool.info.is_erasure() && op.checksum.length > 0) {
// If there is a data digest and it is possible we are reading
decode(redirect_object, bl);
decode(legacy_osd_instructions_len, bl);
if (legacy_osd_instructions_len) {
- bl.advance(legacy_osd_instructions_len);
+ bl += legacy_osd_instructions_len;
}
DECODE_FINISH(bl);
}
{
DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
decode(seq, bl);
- bl.advance(1u); // skip legacy head_exists (always true)
+ bl += 1u; // skip legacy head_exists (always true)
decode(snaps, bl);
decode(clones, bl);
decode(clone_overlap, bl);
decode(v, bl);
decode(m_pool, bl);
decode(m_seed, bl);
- bl.advance(sizeof(int32_t)); // was preferred
+ bl += sizeof(int32_t); // was preferred
}
void decode_old(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
ldout(cct, 20) << "robust_notify: acked by " << id << dendl;
uint32_t blen;
decode(blen, p);
- p.advance(blen);
+ p += blen;
}
} catch (const buffer::error& e) {
ldout(cct, 0) << "robust_notify: notify response parse failed: "
}
uint32_t blen;
decode(blen, p);
- p.advance(blen);
+ p += blen;
}
uint32_t num_timeouts;
utime_t start = ceph_clock_now();
bufferlist::iterator iter = bl.begin();
while (iter != bl.end()) {
- iter.advance(step);
+ iter += step;
}
utime_t end = ceph_clock_now();
cout << bufsize * bufnum << " derefs over bl with " << bufnum
{
bufferlist::iterator i(&bl);
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
}
{
bufferlist::iterator i(&bl);
EXPECT_EQ('A', *i);
- i.advance(1u);
+ i += 1u;
EXPECT_EQ('B', *i);
- i.advance(3u);
+ i += 3u;
EXPECT_EQ('E', *i);
}
}
bl3.append(s.substr(98, 55));
it = bl1.begin();
- it.advance(98u);
+ it += 98u;
ASSERT_EQ(bl3.crc32c(0), it.crc32c(55, 0));
ASSERT_EQ(4u, it.get_remaining());
bl3.clear();
bl3.append(s.substr(98 + 55));
it = bl1.begin();
- it.advance(98u + 55u);
+ it += 98u + 55u;
ASSERT_EQ(bl3.crc32c(0), it.crc32c(10, 0));
ASSERT_EQ(0u, it.get_remaining());
}
{
bufferlist::iterator i(&bl);
EXPECT_EQ('A', *i);
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
EXPECT_THROW(*i, buffer::end_of_buffer);
}
}
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
i.copy(2, copy);
EXPECT_EQ(0, ::memcmp(copy, expected, 2));
EXPECT_EQ('X', copy[2]);
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
i.copy(2, copy);
EXPECT_EQ(0, ::memcmp(copy.c_str(), expected, 2));
i.seek(0);
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
i.copy_all(copy);
EXPECT_EQ('A', copy[0]);
EXPECT_EQ('B', copy[1]);
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
i.copy(2, copy);
EXPECT_EQ(0, ::memcmp(copy.c_str(), expected, 2));
i.seek(0);
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
const char *expected = "ABC";
i.copy_in(3, expected);
EXPECT_EQ(0, ::memcmp(bl.c_str(), expected, 3));
//
// demonstrates that it seeks back to offset if p == ls->end()
//
- EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+ EXPECT_THROW(i += 200u, buffer::end_of_buffer);
bufferlist expected;
expected.append("ABC", 3);
i.copy_in(3, expected);
prefix.claim_append(out);
out.swap(prefix);
it = out.cbegin();
- it.advance(prefix_len);
+ it += prefix_len;
res = compressor->decompress(it, compressed_len, after);
EXPECT_EQ(res, 0);
EXPECT_TRUE(exp.contents_equal(after));
ASSERT_FALSE(journal::Entry::is_readable(it, &bytes_needed));
ASSERT_EQ(0U, bytes_needed);
- it.advance(sizeof(stray_bytes));
+ it += sizeof(stray_bytes);
ASSERT_TRUE(journal::Entry::is_readable(it, &bytes_needed));
ASSERT_EQ(0U, bytes_needed);
}
++counts.num_encode;
}
void decode(buffer::ptr::const_iterator &p) {
- p.advance(1);
+ p += 1;
++counts.num_decode;
}
};
++counts.num_encode;
}
void decode(buffer::ptr::const_iterator &p) {
- p.advance(1);
+ p += 1;
++counts.num_decode;
}
};
ASSERT_GT(segmented.get_num_buffers(), 1u);
ASSERT_GT(segmented.length(), CEPH_PAGE_SIZE);
auto p = segmented.cbegin();
- p.advance(large_bl.length());
+ p += large_bl.length();
ASSERT_LT(segmented.length() - p.get_off(), CEPH_PAGE_SIZE);
vector<Legacy> v;
Legacy::reset();
ASSERT_GT(segmented.get_num_buffers(), 1u);
ASSERT_GT(segmented.length(), CEPH_PAGE_SIZE);
auto p = segmented.cbegin();
- p.advance(small_bl.length());
+ p += small_bl.length();
ASSERT_GT(segmented.length() - p.get_off(), CEPH_PAGE_SIZE);
vector<Legacy> v;
Legacy::reset();