-rw-r--r-- | qmake/include/qmap.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/qmake/include/qmap.h b/qmake/include/qmap.h index 269bd6b..4bc0a2f 100644 --- a/qmake/include/qmap.h +++ b/qmake/include/qmap.h @@ -627,257 +627,261 @@ public: } #ifndef QT_NO_STL # ifdef Q_CC_HPACC // HP-UX aCC does require typename in some place # undef Q_TYPENAME // but not accept them at others. # define Q_TYPENAME // also doesn't like re-defines ... # endif QMap( const Q_TYPENAME std::map<Key,T>& m ) { sh = new QMapPrivate<Key,T>; #if defined(Q_OS_WIN32) std::map<Key,T>::const_iterator it = m.begin(); #else QMapConstIterator<Key,T> it = m.begin(); #endif for ( ; it != m.end(); ++it ) { value_type p( (*it).first, (*it).second ); insert( p ); } } #endif ~QMap() { if ( sh->deref() ) delete sh; } QMap<Key,T>& operator= ( const QMap<Key,T>& m ); #ifndef QT_NO_STL QMap<Key,T>& operator= ( const Q_TYPENAME std::map<Key,T>& m ) { clear(); #if defined(Q_OS_WIN32) std::map<Key,T>::const_iterator it = m.begin(); #else QMapConstIterator<Key,T> it = m.begin(); #endif for ( ; it != m.end(); ++it ) { value_type p( (*it).first, (*it).second ); insert( p ); } return *this; } # ifdef Q_CC_HPACC // undo the HP-UX aCC hackery done above # undef Q_TYPENAME # define Q_TYPENAME typename # endif #endif iterator begin() { detach(); return sh->begin(); } iterator end() { detach(); return sh->end(); } const_iterator begin() const { return ((const Priv*)sh)->begin(); } const_iterator end() const { return ((const Priv*)sh)->end(); } iterator replace( const Key& k, const T& v ) { remove( k ); return insert( k, v ); } size_type size() const { return sh->node_count; } bool empty() const { return sh->node_count == 0; } QPair<iterator,bool> insert( const value_type& x ); void erase( iterator it ) { detach(); sh->remove( it ); } void erase( const key_type& k ); size_type count( const key_type& k ) const; T& operator[] ( const Key& k ); void clear(); iterator find ( const Key& k ) { detach(); return iterator( sh->find( k ).node ); } const_iterator find ( const Key& k ) const { return sh->find( k ); } const T& operator[] ( const Key& k ) const { QT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } bool contains ( const Key& k ) const { return find( k ) != end(); } //{ return sh->find( k ) != ((const Priv*)sh)->end(); } size_type count() const { return sh->node_count; } QValueList<Key> keys() const { QValueList<Key> r; for (const_iterator i=begin(); i!=end(); ++i) r.append(i.key()); return r; } QValueList<T> values() const { QValueList<T> r; for (const_iterator i=begin(); i!=end(); ++i) r.append(*i); return r; } bool isEmpty() const { return sh->node_count == 0; } iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); void remove( iterator it ) { detach(); sh->remove( it ); } void remove( const Key& k ); #if defined(Q_FULL_TEMPLATE_INSTANTIATION) bool operator==( const QMap<Key,T>& ) const { return FALSE; } #ifndef QT_NO_STL bool operator==( const Q_TYPENAME std::map<Key,T>& ) const { return FALSE; } #endif #endif protected: /** * Helpers */ void detach() { if ( sh->count > 1 ) detachInternal(); } Priv* sh; private: void detachInternal(); friend class QDeepCopy< QMap<Key,T> >; }; template<class Key, class T> Q_INLINE_TEMPLATES QMap<Key,T>& QMap<Key,T>::operator= ( const QMap<Key,T>& m ) { m.sh->ref(); if ( sh->deref() ) delete sh; sh = m.sh; return *this; } template<class Key, class T> Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::insert_pair QMap<Key,T>::insert( const Q_TYPENAME QMap<Key,T>::value_type& x ) { detach(); size_type n = size(); iterator it = sh->insertSingle( x.first ); bool inserted = FALSE; if ( n < size() ) { inserted = TRUE; it.data() = x.second; } return QPair<iterator,bool>( it, inserted ); } template<class Key, class T> Q_INLINE_TEMPLATES void QMap<Key,T>::erase( const Key& k ) { detach(); iterator it( sh->find( k ).node ); if ( it != end() ) sh->remove( it ); } template<class Key, class T> Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::size_type QMap<Key,T>::count( const Key& k ) const { const_iterator it( sh->find( k ).node ); if ( it != end() ) { size_type c = 0; while ( it != end() ) { ++it; ++c; } return c; } return 0; } template<class Key, class T> Q_INLINE_TEMPLATES T& QMap<Key,T>::operator[] ( const Key& k ) { detach(); QMapNode<Key,T>* p = sh->find( k ).node; if ( p != sh->end().node ) return p->data; return insert( k, T() ).data(); } template<class Key, class T> Q_INLINE_TEMPLATES void QMap<Key,T>::clear() { if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new QMapPrivate<Key,T>; } } template<class Key, class T> Q_INLINE_TEMPLATES Q_TYPENAME QMap<Key,T>::iterator QMap<Key,T>::insert( const Key& key, const T& value, bool overwrite ) { detach(); size_type n = size(); iterator it = sh->insertSingle( key ); if ( overwrite || n < size() ) it.data() = value; return it; } template<class Key, class T> Q_INLINE_TEMPLATES void QMap<Key,T>::remove( const Key& k ) { detach(); iterator it( sh->find( k ).node ); if ( it != end() ) sh->remove( it ); } template<class Key, class T> Q_INLINE_TEMPLATES void QMap<Key,T>::detachInternal() { sh->deref(); sh = new QMapPrivate<Key,T>( sh ); } #ifndef QT_NO_DATASTREAM template<class Key, class T> Q_INLINE_TEMPLATES QDataStream& operator>>( QDataStream& s, QMap<Key,T>& m ) { m.clear(); Q_UINT32 c; s >> c; for( Q_UINT32 i = 0; i < c; ++i ) { Key k; T t; s >> k >> t; m.insert( k, t ); if ( s.atEnd() ) break; } return s; } template<class Key, class T> Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QMap<Key,T>& m ) { s << (Q_UINT32)m.size(); QMapConstIterator<Key,T> it = m.begin(); for( ; it != m.end(); ++it ) s << it.key() << it.data(); return s; } #endif +#ifdef QT_QWINEXPORT +#define Q_DEFINED_QMAP +#include "qwinexport.h" +#endif /* QT_QWINEXPORT */ #endif // QMAP_H |