ByteVector s2("f");
printResult(ByteVectorList::split(s2, " ").size() == 1);
+
+
+ printResult(ByteVector().size() == 0);
+ printResult(ByteVector("asdf").clear().size() == 0);
+ printResult(ByteVector("asdf").clear() == ByteVector());
}
void testSynchData()
delete d;
}
-void ByteVector::setData(const char *data, uint length)
+ByteVector &ByteVector::setData(const char *data, uint length)
{
detach();
resize(length);
::memcpy(DATA(d), data, length);
+
+ return *this;
}
-void ByteVector::setData(const char *data)
+ByteVector &ByteVector::setData(const char *data)
{
- setData(data, ::strlen(data));
+ return setData(data, ::strlen(data));
}
char *ByteVector::data()
return -1;
}
-void ByteVector::append(const ByteVector &v)
+ByteVector &ByteVector::append(const ByteVector &v)
{
detach();
uint originalSize = d->size;
resize(d->size + v.d->size);
::memcpy(DATA(d) + originalSize, DATA(v.d), v.size());
+
+ return *this;
}
-void ByteVector::clear()
+ByteVector &ByteVector::clear()
{
detach();
d->data.clear();
+ d->size = 0;
+
+ return *this;
}
TagLib::uint ByteVector::size() const
/*!
* Sets the data for the byte array using the first \a length bytes of \a data
*/
- void setData(const char *data, uint length);
+ ByteVector &setData(const char *data, uint length);
/*!
* Sets the data for the byte array copies \a data up to the first null
* byte. The behavior is undefined if \a data is not null terminated.
*/
- void setData(const char *data);
+ ByteVector &setData(const char *data);
/*!
* Returns a pointer to the internal data structure.
/*!
* Appends \a v to the end of the ByteVector.
*/
- void append(const ByteVector &v);
+ ByteVector &append(const ByteVector &v);
/*!
* Clears the data.
*/
- void clear();
+ ByteVector &clear();
/*!
* Returns the size of the array.
/*!
* Inserts a copy of \a value before \a it.
*/
- void insert(Iterator it, const T &value);
+ List<T> &insert(Iterator it, const T &value);
/*!
* Inserts the \a value into the list. This assumes that the list is
* currently sorted. If \a unique is true then the value will not
* be inserted if it is already in the list.
*/
- void sortedInsert(const T &value, bool unique = false);
+ List<T> &sortedInsert(const T &value, bool unique = false);
/*!
* Appends \a item to the end of the list and returns a reference to the
*
* \see setAutoDelete()
*/
- void clear();
+ List<T> &clear();
/*!
* Returns the number of elements in the list.
/*!
* Erase the item at \a it from the list.
*/
- void erase(Iterator it);
+ List<T> &erase(Iterator it);
/*!
* Returns a reference to the first item in the list.
}
template <class T>
-void List<T>::insert(Iterator it, const T &item)
+List<T> &List<T>::insert(Iterator it, const T &item)
{
detach();
d->list.insert(it, item);
+ return *this;
}
template <class T>
-void List<T>::sortedInsert(const T &value, bool unique)
+List<T> &List<T>::sortedInsert(const T &value, bool unique)
{
detach();
Iterator it = begin();
while(it != end() && *it < value)
++it;
if(unique && it != end() && *it == value)
- return;
+ return *this;
insert(it, value);
+ return *this;
}
template <class T>
}
template <class T>
-void List<T>::clear()
+List<T> &List<T>::clear()
{
detach();
d->clear();
+ return *this;
}
template <class T>
}
template <class T>
-void List<T>::erase(Iterator it)
+List<T> &List<T>::erase(Iterator it)
{
d->list.erase(it);
+ return *this;
}
template <class T>
* Inserts \a value under \a key in the map. If a value for \a key already
* exists it will be overwritten.
*/
- void insert(const Key &key, const T &value);
+ Map<Key, T> &insert(const Key &key, const T &value);
/*!
* Removes all of the elements from elements from the map. This however
* will not delete pointers if the mapped type is a pointer type.
*/
- void clear();
+ Map<Key, T> &clear();
/*!
* The number of elements in the map.
/*!
* Erase the item at \a it from the list.
*/
- void erase(Iterator it);
+ Map<Key, T> &erase(Iterator it);
/*!
* Returns a reference to the value associated with \a key.
}
template <class Key, class T>
-void Map<Key, T>::insert(const Key &key, const T &value)
+Map<Key, T> &Map<Key, T>::insert(const Key &key, const T &value)
{
detach();
std::pair<Key, T> item(key, value);
d->map.insert(item);
+ return *this;
}
template <class Key, class T>
-void Map<Key, T>::clear()
+Map<Key, T> &Map<Key, T>::clear()
{
detach();
d->map.clear();
+ return *this;
}
template <class Key, class T>
}
template <class Key, class T>
-void Map<Key,T>::erase(Iterator it)
+Map<Key, T> &Map<Key,T>::erase(Iterator it)
{
d->map.erase(it);
+ return *this;
}
template <class Key, class T>