Kaydet (Commit) 51eb04a1 authored tarafından Michael Stahl's avatar Michael Stahl

basic: replace boost::ptr_vector with std::vector<std::unique_ptr>

Change-Id: I98c4ac860fbdb55a61f9be0e9d2d5f29fb849e05
üst 71f6aab0
...@@ -107,33 +107,33 @@ SbiSymDef* SbiSymPool::First() ...@@ -107,33 +107,33 @@ SbiSymDef* SbiSymPool::First()
SbiSymDef* SbiSymPool::Next() SbiSymDef* SbiSymPool::Next()
{ {
if( ++nCur >= aData.size() ) if (m_Data.size() <= ++nCur)
return NULL; return NULL;
else else
return &aData[ nCur ]; return m_Data[ nCur ].get();
} }
SbiSymDef* SbiSymPool::AddSym( const OUString& rName ) SbiSymDef* SbiSymPool::AddSym( const OUString& rName )
{ {
SbiSymDef* p = new SbiSymDef( rName ); SbiSymDef* p = new SbiSymDef( rName );
p->nPos = aData.size(); p->nPos = m_Data.size();
p->nId = rStrings.Add( rName ); p->nId = rStrings.Add( rName );
p->nProcId = nProcId; p->nProcId = nProcId;
p->pIn = this; p->pIn = this;
aData.insert( aData.begin() + p->nPos, p ); m_Data.insert( m_Data.begin() + p->nPos, std::unique_ptr<SbiSymDef>(p) );
return p; return p;
} }
SbiProcDef* SbiSymPool::AddProc( const OUString& rName ) SbiProcDef* SbiSymPool::AddProc( const OUString& rName )
{ {
SbiProcDef* p = new SbiProcDef( pParser, rName ); SbiProcDef* p = new SbiProcDef( pParser, rName );
p->nPos = aData.size(); p->nPos = m_Data.size();
p->nId = rStrings.Add( rName ); p->nId = rStrings.Add( rName );
// procs are always local // procs are always local
p->nProcId = 0; p->nProcId = 0;
p->pIn = this; p->pIn = this;
aData.insert( aData.begin() + p->nPos, p ); m_Data.insert( m_Data.begin() + p->nPos, std::unique_ptr<SbiProcDef>(p) );
return p; return p;
} }
...@@ -152,7 +152,7 @@ void SbiSymPool::Add( SbiSymDef* pDef ) ...@@ -152,7 +152,7 @@ void SbiSymPool::Add( SbiSymDef* pDef )
return; return;
} }
pDef->nPos = aData.size(); pDef->nPos = m_Data.size();
if( !pDef->nId ) if( !pDef->nId )
{ {
// A unique name must be created in the string pool // A unique name must be created in the string pool
...@@ -172,17 +172,17 @@ void SbiSymPool::Add( SbiSymDef* pDef ) ...@@ -172,17 +172,17 @@ void SbiSymPool::Add( SbiSymDef* pDef )
pDef->nProcId = nProcId; pDef->nProcId = nProcId;
} }
pDef->pIn = this; pDef->pIn = this;
aData.insert( aData.begin() + pDef->nPos, pDef ); m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) );
} }
} }
SbiSymDef* SbiSymPool::Find( const OUString& rName ) SbiSymDef* SbiSymPool::Find( const OUString& rName )
{ {
sal_uInt16 nCount = aData.size(); sal_uInt16 nCount = m_Data.size();
for( sal_uInt16 i = 0; i < nCount; i++ ) for( sal_uInt16 i = 0; i < nCount; i++ )
{ {
SbiSymDef &r = aData[ nCount - i - 1 ]; SbiSymDef &r = *m_Data[ nCount - i - 1 ];
if( ( !r.nProcId || ( r.nProcId == nProcId)) && if( ( !r.nProcId || ( r.nProcId == nProcId)) &&
( r.aName.equalsIgnoreAsciiCase(rName))) ( r.aName.equalsIgnoreAsciiCase(rName)))
{ {
...@@ -204,13 +204,13 @@ SbiSymDef* SbiSymPool::Find( const OUString& rName ) ...@@ -204,13 +204,13 @@ SbiSymDef* SbiSymPool::Find( const OUString& rName )
SbiSymDef* SbiSymPool::Get( sal_uInt16 n ) SbiSymDef* SbiSymPool::Get( sal_uInt16 n )
{ {
if( n >= aData.size() ) if (m_Data.size() <= n)
{ {
return NULL; return NULL;
} }
else else
{ {
return &aData[ n ]; return m_Data[ n ].get();
} }
} }
...@@ -246,9 +246,9 @@ sal_uInt32 SbiSymPool::Reference( const OUString& rName ) ...@@ -246,9 +246,9 @@ sal_uInt32 SbiSymPool::Reference( const OUString& rName )
void SbiSymPool::CheckRefs() void SbiSymPool::CheckRefs()
{ {
for( size_t i = 0; i < aData.size(); i++ ) for (size_t i = 0; i < m_Data.size(); ++i)
{ {
SbiSymDef &r = aData[ i ]; SbiSymDef &r = *m_Data[ i ];
if( !r.IsDefined() ) if( !r.IsDefined() )
{ {
pParser->Error( ERRCODE_BASIC_UNDEF_LABEL, r.GetName() ); pParser->Error( ERRCODE_BASIC_UNDEF_LABEL, r.GetName() );
...@@ -459,7 +459,9 @@ void SbiProcDef::Match( SbiProcDef* pOld ) ...@@ -459,7 +459,9 @@ void SbiProcDef::Match( SbiProcDef* pOld )
nPos = pOld->nPos; nPos = pOld->nPos;
nId = pOld->nId; nId = pOld->nId;
pIn = pOld->pIn; pIn = pOld->pIn;
pIn->aData.replace( nPos, this ).release(); std::unique_ptr<SbiSymDef> tmp(this);
std::swap(pIn->m_Data[nPos], tmp);
tmp.release();
} }
delete pOld; delete pOld;
} }
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#ifndef INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX #ifndef INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
#define INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX #define INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
#include <memory>
#include <vector> #include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
class SbiConstDef; class SbiConstDef;
class SbiParser; class SbiParser;
...@@ -54,8 +54,7 @@ class SbiSymPool { ...@@ -54,8 +54,7 @@ class SbiSymPool {
friend class SbiProcDef; friend class SbiProcDef;
protected: protected:
SbiStringPool& rStrings; SbiStringPool& rStrings;
boost::ptr_vector<SbiSymDef> std::vector<std::unique_ptr<SbiSymDef>> m_Data;
aData;
SbiSymPool* pParent; SbiSymPool* pParent;
SbiParser* pParser; SbiParser* pParser;
SbiSymScope eScope; SbiSymScope eScope;
...@@ -67,7 +66,7 @@ public: ...@@ -67,7 +66,7 @@ public:
void SetParent( SbiSymPool* p ) { pParent = p; } void SetParent( SbiSymPool* p ) { pParent = p; }
void SetProcId( short n ) { nProcId = n; } void SetProcId( short n ) { nProcId = n; }
sal_uInt16 GetSize() const { return aData.size(); } sal_uInt16 GetSize() const { return m_Data.size(); }
SbiSymScope GetScope() const { return eScope; } SbiSymScope GetScope() const { return eScope; }
void SetScope( SbiSymScope s ) { eScope = s; } void SetScope( SbiSymScope s ) { eScope = s; }
SbiParser* GetParser() { return pParser; } SbiParser* GetParser() { return pParser; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment