Convert tools/table.hxx to std::map

Convert usage of tools/table.hxx to std::map in aPTable field of
SvPersistStream class.
This commit is contained in:
Noel Grandin 2012-03-08 13:36:58 +02:00 committed by Tor Lillqvist
parent 14ca52086b
commit e36a9a64f1
3 changed files with 17 additions and 10 deletions

View File

@ -31,6 +31,7 @@
#include <rtl/strbuf.hxx>
#include <tools/ref.hxx>
#include <tools/table.hxx>
#include <basobj.hxx>
struct SvSlotElement;

View File

@ -31,12 +31,11 @@
#include <boost/unordered_map.hpp>
#include "tools/toolsdllapi.h"
#include <tools/table.hxx>
#include <tools/unqidx.hxx>
#include <tools/ref.hxx>
#include <tools/rtti.hxx>
#include <tools/stream.hxx>
#include <map>
#define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT
@ -150,6 +149,8 @@ SV_IMPL_PERSIST_LIST(ClassName,EntryName)
DECLARE_UNIQUEINDEX( SvPersistUIdx,SvPersistBase *)
typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap;
//=========================================================================
class SvStream;
class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
@ -191,7 +192,7 @@ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
{
SvClassManager & rClassMgr;
SvStream * pStm;
Table aPTable; // Pointer und Key gedreht
PersistBaseMap aPTable; // Pointer und Key gedreht
SvPersistUIdx aPUIdx;
sal_uIntPtr nStartIdx;
const SvPersistStream * pRefStm;

View File

@ -315,10 +315,15 @@ void SvPersistStream::FlushData()
*************************************************************************/
sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
{
sal_uIntPtr nId = (sal_uIntPtr)aPTable.Get( (sal_uIntPtr)pObj );
if( !nId && pRefStm )
return pRefStm->GetIndex( pObj );
return nId;
PersistBaseMap::const_iterator it = aPTable.find( pObj );
if( it == aPTable.end() )
{
if ( pRefStm )
return pRefStm->GetIndex( pObj );
else
return 0;
}
return it->second;
}
/*************************************************************************
@ -653,7 +658,7 @@ SvPersistStream& SvPersistStream::WritePointer
else
{
nId = aPUIdx.Insert( pObj );
aPTable.Insert( (sal_uIntPtr)pObj, (void *)nId );
aPTable[ pObj ] = nId;
nP |= P_OBJ;
}
WriteId( *this, nP, nId, pObj->GetClassId() );
@ -722,7 +727,7 @@ sal_uInt32 SvPersistStream::ReadObj
// unbedingt erst in Tabelle eintragen
sal_uIntPtr nNewId = aPUIdx.Insert( rpObj );
// um den gleichen Zustand, wie nach dem Speichern herzustellen
aPTable.Insert( (sal_uIntPtr)rpObj, (void *)nNewId );
aPTable[ rpObj ] = nNewId;
DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId,
"read write id conflict: not the same" );
}
@ -835,7 +840,7 @@ SvStream& operator >>
// Die Id eines Objektes wird nie modifiziert
rThis.aPUIdx.Insert( nId, pEle );
rThis.aPTable.Insert( (sal_uIntPtr)pEle, (void *)nId );
rThis.aPTable[ pEle ] = nId;
}
}
else