mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Fix ByteVector to return correct iterators after detached.
This commit is contained in:
parent
5bad35c4cb
commit
ab047f6054
@ -712,7 +712,7 @@ ByteVector &ByteVector::resize(uint size, char padding)
|
||||
ByteVector::Iterator ByteVector::begin()
|
||||
{
|
||||
detach();
|
||||
return d->data->data.begin();
|
||||
return d->data->data.begin() + d->offset;
|
||||
}
|
||||
|
||||
ByteVector::ConstIterator ByteVector::begin() const
|
||||
@ -723,7 +723,7 @@ ByteVector::ConstIterator ByteVector::begin() const
|
||||
ByteVector::Iterator ByteVector::end()
|
||||
{
|
||||
detach();
|
||||
return d->data->data.end();
|
||||
return d->data->data.begin() + d->offset + d->length;
|
||||
}
|
||||
|
||||
ByteVector::ConstIterator ByteVector::end() const
|
||||
@ -734,25 +734,23 @@ ByteVector::ConstIterator ByteVector::end() const
|
||||
ByteVector::ReverseIterator ByteVector::rbegin()
|
||||
{
|
||||
detach();
|
||||
return d->data->data.rbegin();
|
||||
return d->data->data.rbegin() + (d->data->data.size() - (d->offset + d->length));
|
||||
}
|
||||
|
||||
ByteVector::ConstReverseIterator ByteVector::rbegin() const
|
||||
{
|
||||
std::vector<char> &v = d->data->data;
|
||||
return v.rbegin() + (v.size() - (d->offset + d->length));
|
||||
return d->data->data.rbegin() + (d->data->data.size() - (d->offset + d->length));
|
||||
}
|
||||
|
||||
ByteVector::ReverseIterator ByteVector::rend()
|
||||
{
|
||||
detach();
|
||||
return d->data->data.rend();
|
||||
return d->data->data.rbegin() + (d->data->data.size() - d->offset);
|
||||
}
|
||||
|
||||
ByteVector::ConstReverseIterator ByteVector::rend() const
|
||||
{
|
||||
std::vector<char> &v = d->data->data;
|
||||
return v.rbegin() + (v.size() - d->offset);
|
||||
return d->data->data.rbegin() + (d->data->data.size() - d->offset);
|
||||
}
|
||||
|
||||
bool ByteVector::isNull() const
|
||||
|
@ -319,6 +319,10 @@ public:
|
||||
*it4 = 'A';
|
||||
CPPUNIT_ASSERT_EQUAL('a', *it3);
|
||||
CPPUNIT_ASSERT_EQUAL('A', *it4);
|
||||
|
||||
ByteVector v3;
|
||||
v3 = ByteVector("taglib").mid(3);
|
||||
CPPUNIT_ASSERT_EQUAL('l', *v3.begin());
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user