// file : odb/qt/containers/list.ixx // copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file // // QOdbList // template inline QOdbList& QOdbList:: operator= (const QOdbList& x) { l_ = x.l_; if (_tracking ()) impl_.assign (static_cast (l_.size ())); return *this; } template inline QOdbList& QOdbList:: operator= (const base_list_type& x) { l_ = x; if (_tracking ()) impl_.assign (static_cast (l_.size ())); return *this; } #ifdef ODB_CXX11 template inline QOdbList& QOdbList:: operator= (QOdbList&& x) { l_ = std::move (x.l_); if (_tracking ()) impl_.assign (static_cast (l_.size ())); return *this; } template inline QOdbList& QOdbList:: operator= (base_list_type&& x) { l_ = std::move (x); if (_tracking ()) impl_.assign (static_cast (l_.size ())); return *this; } #endif #if QT_VERSION >= 0x040800 template inline void QOdbList:: swap (QOdbList& x) { l_.swap (x.l_); vector_base::swap (x); } #endif template inline void QOdbList:: clear() { l_.clear (); if (_tracking ()) impl_.clear (); } template inline T& QOdbList:: modify (int i) { T& r (l_[i]); if (_tracking ()) impl_.modify (static_cast (i)); return r; } template inline void QOdbList:: reserve (int n) { l_.reserve (n); if (_tracking ()) impl_.reserve (static_cast (n)); } template inline void QOdbList:: append (const T& x) { l_.append (x); if (_tracking ()) impl_.push_back (); } template inline void QOdbList:: append (const QList& x) { l_.append (x); if (_tracking ()) impl_.push_back (static_cast (x.size ())); } template inline void QOdbList:: prepend (const T& x) { l_.prepend (x); if (_tracking ()) impl_.insert (0); } template inline void QOdbList:: insert (int i, const T& x) { l_.insert (i, x); if (_tracking ()) impl_.insert (static_cast (i)); } template inline void QOdbList:: replace (int i, const T& x) { l_.insert (i, x); if (_tracking ()) impl_.modify (static_cast (i)); } template inline void QOdbList:: removeAt (int i) { l_.removeAt (i); if (_tracking ()) impl_.erase (static_cast (i)); } template inline int QOdbList:: removeAll (const T& x) { // We have to re-implement this one ourselves since we need to // know the indexes of the removed elements. // int r (0); for (int i (l_.indexOf (x)); i != -1; i = l_.indexOf (x, i)) { removeAt (i); r++; } return r; } template inline bool QOdbList:: removeOne (const T& x) { // We have to re-implement this one ourselves since we need to // know the index of the removed element. // int i (l_.indexOf (x)); if (i != -1) removeAt (i); return i != -1; } template inline T QOdbList:: takeAt (int i) { if (_tracking ()) impl_.erase (static_cast (i)); return l_.takeAt (i); } template inline T QOdbList:: takeFirst () { if (_tracking ()) impl_.erase (0); return l_.takeFirst (); } template inline T QOdbList:: takeLast () { if (_tracking ()) impl_.pop_back (); return l_.takeLast (); } template inline void QOdbList:: move (int from, int to) { l_.move (from, to); if (_tracking ()) { impl_.erase (static_cast (from)); impl_.insert (static_cast (to)); } } template inline void QOdbList:: swap (int i, int j) { l_.swap (i, j); if (_tracking ()) { impl_.modify (static_cast (i)); impl_.modify (static_cast (j)); } } template inline typename QOdbList::base_iterator_type QOdbList:: mbegin () { if (_tracking ()) impl_.modify (0, static_cast (l_.size ())); return l_.begin (); } template inline typename QOdbList::iterator QOdbList:: insert (iterator p, const T& x) { if (_tracking ()) impl_.insert (static_cast (p.base () - l_.begin ())); return iterator (this, l_.insert (p.base (), x)); } template inline typename QOdbList::iterator QOdbList:: erase (iterator p) { if (_tracking ()) impl_.erase (static_cast (p.base () - l_.begin ())); return iterator (this, l_.erase (p.base ())); } template inline typename QOdbList::iterator QOdbList:: erase (iterator f, iterator l) { if (_tracking ()) impl_.erase (static_cast (f.base () - l_.begin ()), static_cast (l - f)); return iterator (this, l_.erase (f.base (), l.base ())); } template inline T& QOdbList:: modifyFirst () { T& r (l_.first ()); if (_tracking ()) impl_.modify (0); return r; } template inline T& QOdbList:: modifyLast () { T& r (l_.last ()); if (_tracking ()) impl_.modify (static_cast (l_.size () - 1)); return r; } template inline void QOdbList:: removeFirst () { l_.removeFirst (); if (_tracking ()) impl_.erase (0); } template inline void QOdbList:: removeLast () { l_.removeLast (); if (_tracking ()) impl_.pop_back (); } // // QOdbListIteratorImpl // template inline typename QOdbListIteratorImpl::reference QOdbListIteratorImpl:: modify () const { if (l_->_tracking ()) l_->_impl ().modify (static_cast (i_ - l_->base ().begin ())); return *i_; } template inline typename QOdbListIteratorImpl::reference QOdbListIteratorImpl:: modify (difference_type n) const { if (l_->_tracking ()) l_->_impl ().modify ( static_cast (i_ - l_->base ().begin () + n)); return i_[n]; }