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:
committed by
Tor Lillqvist
parent
14ca52086b
commit
e36a9a64f1
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <rtl/strbuf.hxx>
|
#include <rtl/strbuf.hxx>
|
||||||
#include <tools/ref.hxx>
|
#include <tools/ref.hxx>
|
||||||
|
#include <tools/table.hxx>
|
||||||
#include <basobj.hxx>
|
#include <basobj.hxx>
|
||||||
|
|
||||||
struct SvSlotElement;
|
struct SvSlotElement;
|
||||||
|
@@ -31,12 +31,11 @@
|
|||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include "tools/toolsdllapi.h"
|
#include "tools/toolsdllapi.h"
|
||||||
|
|
||||||
#include <tools/table.hxx>
|
|
||||||
|
|
||||||
#include <tools/unqidx.hxx>
|
#include <tools/unqidx.hxx>
|
||||||
#include <tools/ref.hxx>
|
#include <tools/ref.hxx>
|
||||||
#include <tools/rtti.hxx>
|
#include <tools/rtti.hxx>
|
||||||
#include <tools/stream.hxx>
|
#include <tools/stream.hxx>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT
|
#define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT
|
||||||
|
|
||||||
@@ -150,6 +149,8 @@ SV_IMPL_PERSIST_LIST(ClassName,EntryName)
|
|||||||
|
|
||||||
DECLARE_UNIQUEINDEX( SvPersistUIdx,SvPersistBase *)
|
DECLARE_UNIQUEINDEX( SvPersistUIdx,SvPersistBase *)
|
||||||
|
|
||||||
|
typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap;
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
class SvStream;
|
class SvStream;
|
||||||
class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
|
class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
|
||||||
@@ -191,7 +192,7 @@ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
|
|||||||
{
|
{
|
||||||
SvClassManager & rClassMgr;
|
SvClassManager & rClassMgr;
|
||||||
SvStream * pStm;
|
SvStream * pStm;
|
||||||
Table aPTable; // Pointer und Key gedreht
|
PersistBaseMap aPTable; // Pointer und Key gedreht
|
||||||
SvPersistUIdx aPUIdx;
|
SvPersistUIdx aPUIdx;
|
||||||
sal_uIntPtr nStartIdx;
|
sal_uIntPtr nStartIdx;
|
||||||
const SvPersistStream * pRefStm;
|
const SvPersistStream * pRefStm;
|
||||||
|
@@ -315,10 +315,15 @@ void SvPersistStream::FlushData()
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
|
sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
|
||||||
{
|
{
|
||||||
sal_uIntPtr nId = (sal_uIntPtr)aPTable.Get( (sal_uIntPtr)pObj );
|
PersistBaseMap::const_iterator it = aPTable.find( pObj );
|
||||||
if( !nId && pRefStm )
|
if( it == aPTable.end() )
|
||||||
|
{
|
||||||
|
if ( pRefStm )
|
||||||
return pRefStm->GetIndex( pObj );
|
return pRefStm->GetIndex( pObj );
|
||||||
return nId;
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -653,7 +658,7 @@ SvPersistStream& SvPersistStream::WritePointer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nId = aPUIdx.Insert( pObj );
|
nId = aPUIdx.Insert( pObj );
|
||||||
aPTable.Insert( (sal_uIntPtr)pObj, (void *)nId );
|
aPTable[ pObj ] = nId;
|
||||||
nP |= P_OBJ;
|
nP |= P_OBJ;
|
||||||
}
|
}
|
||||||
WriteId( *this, nP, nId, pObj->GetClassId() );
|
WriteId( *this, nP, nId, pObj->GetClassId() );
|
||||||
@@ -722,7 +727,7 @@ sal_uInt32 SvPersistStream::ReadObj
|
|||||||
// unbedingt erst in Tabelle eintragen
|
// unbedingt erst in Tabelle eintragen
|
||||||
sal_uIntPtr nNewId = aPUIdx.Insert( rpObj );
|
sal_uIntPtr nNewId = aPUIdx.Insert( rpObj );
|
||||||
// um den gleichen Zustand, wie nach dem Speichern herzustellen
|
// 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,
|
DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId,
|
||||||
"read write id conflict: not the same" );
|
"read write id conflict: not the same" );
|
||||||
}
|
}
|
||||||
@@ -835,7 +840,7 @@ SvStream& operator >>
|
|||||||
|
|
||||||
// Die Id eines Objektes wird nie modifiziert
|
// Die Id eines Objektes wird nie modifiziert
|
||||||
rThis.aPUIdx.Insert( nId, pEle );
|
rThis.aPUIdx.Insert( nId, pEle );
|
||||||
rThis.aPTable.Insert( (sal_uIntPtr)pEle, (void *)nId );
|
rThis.aPTable[ pEle ] = nId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user