From 892f78823e865019577891fb2bec90952b761860 Mon Sep 17 00:00:00 2001 From: ptv Date: Tue, 7 Apr 2009 10:51:27 +0000 Subject: [PATCH] rename IMap to QtxMap --- src/Qtx/QtxMap.h | 91 ++++++++++++++++++++------------------ src/Qtx/QtxResourceMgr.cxx | 4 +- src/Qtx/QtxResourceMgr.h | 2 +- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/Qtx/QtxMap.h b/src/Qtx/QtxMap.h index 98dec2975..3a1ccafe8 100644 --- a/src/Qtx/QtxMap.h +++ b/src/Qtx/QtxMap.h @@ -23,23 +23,25 @@ #ifndef QTXMAP_H #define QTXMAP_H -template class IMap; -template class IMapIterator; -template class IMapConstIterator; +#include + +template class QtxMap; +template class QtxMapIterator; +template class QtxMapConstIterator; /*! \brief Indexed map template class. */ -template class IMap +template class QtxMap { public: - typedef IMapIterator Iterator; - typedef IMapConstIterator ConstIterator; + typedef QtxMapIterator Iterator; + typedef QtxMapConstIterator ConstIterator; public: - IMap() {} - IMap( const IMap& m ) : myKeys( m.myKeys ), myData( m.myData ) {} - IMap& operator=( const IMap& m ) { myKeys = m.myKeys; myData = m.myData; return *this; } + QtxMap() {} + QtxMap( const QtxMap& m ) : myKeys( m.myKeys ), myData( m.myData ) {} + QtxMap& operator=( const QtxMap& m ) { myKeys = m.myKeys; myData = m.myData; return *this; } int count() const { return myData.count(); } int size() const { return myData.count(); } @@ -88,14 +90,19 @@ public: return myKeys[index]; } - Value value( const int index ) + const Key findKey( const Value& val ) const + { + return myData.key( val ); + } + + Value& value( const int index ) { if ( index < 0 || index >= (int)myKeys.count() ) return dummyValue; return myData[ myKeys[index] ]; } - Value operator[]( const Key& key ) + Value& operator[]( const Key& key ) { if ( myData.find( key ) == myData.end() ) insert( key, Value() ); @@ -129,61 +136,61 @@ private: Key dummyKey; Value dummyValue; - friend class IMapIterator; - friend class IMapConstIterator; + friend class QtxMapIterator; + friend class QtxMapConstIterator; }; /*! \brief Indexed map iterator template class. */ -template class IMapIterator +template class QtxMapIterator { public: - IMapIterator() : myMap( 0 ), myIndex( 0 ) { init(); } - IMapIterator( const IMap* m ) : myMap( const_cast< IMap* >( m ) ), myIndex( 0 ) { init(); } - IMapIterator( const IMapIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } + QtxMapIterator() : myMap( 0 ), myIndex( 0 ) { init(); } + QtxMapIterator( const QtxMap* m ) : myMap( const_cast< QtxMap* >( m ) ), myIndex( 0 ) { init(); } + QtxMapIterator( const QtxMapIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } - bool operator==( const IMapIterator& i ) { return !operator!=( i ); } - bool operator!=( const IMapIterator& i ) { return !myMap || myMap != i.myMap || myIndex != i.myIndex; } + bool operator==( const QtxMapIterator& i ) { return !operator!=( i ); } + bool operator!=( const QtxMapIterator& i ) { return !myMap || myMap != i.myMap || myIndex != i.myIndex; } operator bool() const { return myIndex >= 0; } const Key& key() const { return myMap->key( myIndex ); } Value& value() { return myMap->value( myIndex ); } - const Value& value() const { return myMap->value( myIndex ); } + const Value value() const { return myMap->value( myIndex ); } Value& operator*() { return value(); } - IMapIterator& operator++() { myIndex++; init(); return *this; } - IMapIterator operator++( int ) { IMapIterator i = *this; myIndex++; init(); return i; } - IMapIterator& operator--() { myIndex--; init(); return *this; } - IMapIterator operator--( int ) { IMapIterator i = *this; myIndex--; init(); return i; } + QtxMapIterator& operator++() { myIndex++; init(); return *this; } + QtxMapIterator operator++( int ) { QtxMapIterator i = *this; myIndex++; init(); return i; } + QtxMapIterator& operator--() { myIndex--; init(); return *this; } + QtxMapIterator operator--( int ) { QtxMapIterator i = *this; myIndex--; init(); return i; } private: - IMapIterator( const IMap* m, const int index ) : myMap( const_cast< IMap* >( m ) ), myIndex( index ) { init(); } + QtxMapIterator( const QtxMap* m, const int index ) : myMap( const_cast< QtxMap* >( m ) ), myIndex( index ) { init(); } void init() { if ( !myMap || myIndex >= myMap->count() ) myIndex = -1; } private: - IMap* myMap; + QtxMap* myMap; int myIndex; - friend class IMap; - friend class IMapConstIterator; + friend class QtxMap; + friend class QtxMapConstIterator; }; /*! \brief Indexed map const iterator template class. */ -template class IMapConstIterator +template class QtxMapConstIterator { public: - IMapConstIterator() : myMap( 0 ), myIndex( 0 ) { init(); } - IMapConstIterator( const IMap* m ) : myMap( const_cast< IMap* >( m ) ), myIndex( 0 ) { init(); } - IMapConstIterator( const IMapConstIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } - IMapConstIterator( const IMapIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } + QtxMapConstIterator() : myMap( 0 ), myIndex( 0 ) { init(); } + QtxMapConstIterator( const QtxMap* m ) : myMap( const_cast< QtxMap* >( m ) ), myIndex( 0 ) { init(); } + QtxMapConstIterator( const QtxMapConstIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } + QtxMapConstIterator( const QtxMapIterator& i ) : myMap( i.myMap ), myIndex( i.myIndex ) { init(); } - bool operator==( const IMapConstIterator& i ) { return !operator!=( i ); } - bool operator!=( const IMapConstIterator& i ) { return !myMap || myMap != i.myMap || myIndex != i.myIndex; } + bool operator==( const QtxMapConstIterator& i ) { return !operator!=( i ); } + bool operator!=( const QtxMapConstIterator& i ) { return !myMap || myMap != i.myMap || myIndex != i.myIndex; } operator bool() const { return myIndex >= 0; } @@ -192,20 +199,20 @@ public: const Value operator*() const { return value(); } - IMapConstIterator& operator++() { myIndex++; init(); return *this; } - IMapConstIterator operator++( int ) { IMapConstIterator i = *this; myIndex++; init(); return i; } - IMapConstIterator& operator--() { myIndex--; init(); return *this; } - IMapConstIterator operator--( int ) { IMapConstIterator i = *this; myIndex--; init(); return i; } + QtxMapConstIterator& operator++() { myIndex++; init(); return *this; } + QtxMapConstIterator operator++( int ) { QtxMapConstIterator i = *this; myIndex++; init(); return i; } + QtxMapConstIterator& operator--() { myIndex--; init(); return *this; } + QtxMapConstIterator operator--( int ) { QtxMapConstIterator i = *this; myIndex--; init(); return i; } private: - IMapConstIterator( const IMap* m, const int index ): myMap( const_cast< IMap* >( m ) ), myIndex( index ) { init(); } + QtxMapConstIterator( const QtxMap* m, const int index ): myMap( const_cast< QtxMap* >( m ) ), myIndex( index ) { init(); } void init() { if ( !myMap || myIndex >= myMap->count() ) myIndex = -1; } private: - IMap* myMap; + QtxMap* myMap; int myIndex; - friend class IMap; + friend class QtxMap; }; #endif // QTXMAP_H diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 80812a2f1..f1764c024 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -2124,9 +2124,9 @@ QStringList QtxResourceMgr::parameters( const QString& sec ) const initialize(); #if defined(QTX_NO_INDEXED_MAP) - typedef QMap PMap; + typedef QMap PMap; #else - typedef IMap PMap; + typedef QtxMap PMap; #endif PMap pmap; diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index 550c14e30..4fb74b430 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -57,7 +57,7 @@ public: #ifdef QTX_NO_INDEXED_MAP typedef QMap Section; //!< resource section #else - typedef IMap Section; //!< resource section + typedef QtxMap Section; //!< resource section #endif public: -- 2.39.2