diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:21:02 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:51:05 +0100 |
commit | f00967cf38ed0c2c197284391fc521825bb3c2ac (patch) | |
tree | d1505cfff1707c51a74ece3091dcc25afbc5d778 /include/tools | |
parent | 4845155e0126571e4176819c5f27b76160146ce0 (diff) |
sal_uIntPtr/sal_uLong to Index (aka sal_uInt32) in UniqueIndex
Change-Id: I212cb3bb9d920741629fc4564bbd28b393e8fe00
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/pstm.hxx | 16 | ||||
-rw-r--r-- | include/tools/unqidx.hxx | 47 |
2 files changed, 37 insertions, 26 deletions
diff --git a/include/tools/pstm.hxx b/include/tools/pstm.hxx index 92b5349e493e..ab7541682340 100644 --- a/include/tools/pstm.hxx +++ b/include/tools/pstm.hxx @@ -91,8 +91,6 @@ public: SvPersistBase *& rpObj ); }; -typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap; - class SvStream; /** Persistent Stream @@ -130,12 +128,18 @@ class SvStream; */ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream { +public: + typedef UniqueIndex<SvPersistBase>::Index Index; + +private: + typedef std::map<SvPersistBase*, Index> PersistBaseMap; + SvClassManager & rClassMgr; SvStream * pStm; PersistBaseMap aPTable; // reversed pointer and key UniqueIndex<SvPersistBase> aPUIdx; - sal_uIntPtr nStartIdx; + Index nStartIdx; const SvPersistStream * pRefStm; virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize ) override; @@ -151,13 +155,13 @@ public: virtual void ResetError() override; SvPersistStream( SvClassManager &, SvStream * pStream, - sal_uInt32 nStartIdx = 1 ); + Index nStartIdx = 1 ); virtual ~SvPersistStream(); void SetStream( SvStream * pStream ); - SvPersistBase * GetObject( sal_uIntPtr nIdx ) const; - sal_uIntPtr GetIndex( SvPersistBase * ) const; + SvPersistBase * GetObject( Index nIdx ) const; + Index GetIndex( SvPersistBase * ) const; static void WriteCompressed( SvStream & rStm, sal_uInt32 nVal ); static sal_uInt32 ReadCompressed( SvStream & rStm ); diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx index 03a30c6fe0f0..c783151c12b8 100644 --- a/include/tools/unqidx.hxx +++ b/include/tools/unqidx.hxx @@ -20,45 +20,52 @@ #define INCLUDED_TOOLS_UNQIDX_HXX #include <tools/toolsdllapi.h> -#include <tools/contnr.hxx> +#include <limits> #include <map> -#define UNIQUEINDEX_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND - class SAL_WARN_UNUSED TOOLS_DLLPUBLIC UniqueIndexImpl { +public: + typedef sal_uInt32 Index; + enum { + IndexNotFound = std::numeric_limits<Index>::max() + }; + private: - std::map<sal_uInt32, void*> maMap; - sal_uIntPtr nStartIndex; - sal_uIntPtr nUniqIndex; - sal_uIntPtr nCount; + std::map<Index, void*> maMap; + Index nStartIndex; + Index nUniqIndex; + Index nCount; public: - UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 ) + UniqueIndexImpl( Index _nStartIndex = 0 ) : maMap(), nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {} - sal_uIntPtr Insert( void* p ); + Index Insert( void* p ); // insert value with key, replacing existing entry if necessary - void* Remove( sal_uIntPtr aIndex ); - void* Get( sal_uIntPtr aIndex ) const; + void* Remove( Index aIndex ); + void* Get( Index aIndex ) const; - sal_uIntPtr GetIndexOf( void* p ) const; - sal_uIntPtr FirstIndex() const; - sal_uIntPtr LastIndex() const; - sal_uIntPtr NextIndex( sal_uIntPtr aCurrIndex ) const; + Index GetIndexOf( void* p ) const; + Index FirstIndex() const; + Index LastIndex() const; + Index NextIndex( Index aCurrIndex ) const; }; template<typename T> class UniqueIndex : private UniqueIndexImpl { public: - UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} + using UniqueIndexImpl::Index; + using UniqueIndexImpl::IndexNotFound; + + UniqueIndex<T>( Index _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} - sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); } - T* Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } - T* Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } - sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } + Index Insert(T* p) { return UniqueIndexImpl::Insert(p); } + T* Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } + T* Remove(Index idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } + Index GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } using UniqueIndexImpl::FirstIndex; using UniqueIndexImpl::LastIndex; |