summaryrefslogtreecommitdiff
path: root/idl
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2011-03-25 15:52:55 -0430
committerThorsten Behrens <tbehrens@novell.com>2011-04-11 16:31:55 +0200
commite67f849928a00062f4ad0897101c18b89f66985e (patch)
tree1c048e1fe05a90b5604eaca57c96068192d6bfb0 /idl
parentd57e94e8ae05d47c85ff6e969ae5faef649583d0 (diff)
Remove DECLARE_LIST( SvTokenList, SvToken * )
Diffstat (limited to 'idl')
-rw-r--r--idl/inc/lex.hxx102
-rw-r--r--idl/source/cmptools/lex.cxx26
2 files changed, 67 insertions, 61 deletions
diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx
index 253083d7e9e8..3aa22139a4dd 100644
--- a/idl/inc/lex.hxx
+++ b/idl/inc/lex.hxx
@@ -29,10 +29,11 @@
#ifndef _LEX_HXX
#define _LEX_HXX
+#include <boost/ptr_container/ptr_vector.hpp>
+
#include <hash.hxx>
#include <tools/gen.hxx>
#include <tools/stream.hxx>
-#include <tools/list.hxx>
enum SVTOKEN_ENUM { SVTOKEN_EMPTY, SVTOKEN_COMMENT,
SVTOKEN_INTEGER, SVTOKEN_STRING,
@@ -127,8 +128,6 @@ inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr )
inline SvToken::SvToken( SVTOKEN_ENUM nTypeP )
: nType( nTypeP ) {}
-DECLARE_LIST( SvTokenList, SvToken * )
-
class SvTokenStream
{
sal_uLong nLine, nColumn;
@@ -144,8 +143,8 @@ class SvTokenStream
SvFileStream * pInStream;
SvStream & rInStream;
String aFileName;
- SvTokenList aTokList;
- SvToken * pCurToken;
+ boost::ptr_vector<SvToken> aTokList;
+ boost::ptr_vector<SvToken>::iterator pCurToken;
void InitCtor();
@@ -192,30 +191,37 @@ public:
{ nTabSize = nTabSizeP; }
sal_uInt16 GetTabSize() const { return nTabSize; }
- SvToken * GetToken_PrevAll()
- {
- SvToken * pRetToken = pCurToken;
- if( NULL == (pCurToken = aTokList.Prev()) )
- // current pointer never null
- pCurToken = pRetToken;
+ SvToken* GetToken_PrevAll()
+ {
+ boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken;
+
+ // current iterator always valid
+ if(pCurToken != aTokList.begin())
+ --pCurToken;
+
+ return &(*pRetToken);
+ }
+
+ SvToken* GetToken_NextAll()
+ {
+ boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken++;
+
+ if (pCurToken == aTokList.end())
+ pCurToken = pRetToken;
+
+ SetMax();
+
+ return &(*pRetToken);
+ }
+
+ SvToken* GetToken_Next()
+ {
+ // comments get removed initially
+ return GetToken_NextAll();
+ }
+
+ SvToken* GetToken() const { return &(*pCurToken); }
- return pRetToken;
- }
- SvToken * GetToken_NextAll()
- {
- SvToken * pRetToken = pCurToken;
- if( NULL == (pCurToken = aTokList.Next()) )
- // current pointer never null
- pCurToken = pRetToken;
- SetMax();
- return pRetToken;
- }
- SvToken * GetToken_Next()
- {
- // comments get removed initially
- return GetToken_NextAll();
- }
- SvToken * GetToken() const { return pCurToken; }
sal_Bool Read( char cChar )
{
if( pCurToken->IsChar()
@@ -227,6 +233,7 @@ public:
else
return sal_False;
}
+
void ReadDelemiter()
{
if( pCurToken->IsChar()
@@ -237,22 +244,29 @@ public:
}
}
- sal_uInt32 Tell() const
- { return aTokList.GetCurPos(); }
- void Seek( sal_uInt32 nPos )
- {
- pCurToken = aTokList.Seek( nPos );
- SetMax();
- }
- void SeekRel( sal_Int32 nRelPos )
- {
- pCurToken = aTokList.Seek( Tell() + nRelPos );
- SetMax();
- }
- void SeekEnd()
- {
- pCurToken = aTokList.Seek( nMaxPos );
- }
+ sal_uInt32 Tell() const { return pCurToken-aTokList.begin(); }
+
+ void Seek( sal_uInt32 nPos )
+ {
+ pCurToken = aTokList.begin() + nPos;
+ SetMax();
+ }
+
+ void SeekRel( sal_uInt32 nRelPos )
+ {
+ sal_uInt32 relIdx = Tell() + nRelPos;
+
+ if ( relIdx < aTokList.size())
+ {
+ pCurToken = aTokList.begin()+ (Tell() + nRelPos );
+ SetMax();
+ }
+ }
+
+ void SeekEnd()
+ {
+ pCurToken = aTokList.begin()+nMaxPos;
+ }
};
diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx
index f02361d57200..04281e3fcff7 100644
--- a/idl/source/cmptools/lex.cxx
+++ b/idl/source/cmptools/lex.cxx
@@ -105,7 +105,6 @@ void SvTokenStream::InitCtor()
nLine = nColumn = 0;
nBufPos = 0;
nTabSize = 4;
- pCurToken = NULL;
nMaxPos = 0;
c = GetNextChar();
FillTokenList();
@@ -115,7 +114,6 @@ SvTokenStream::SvTokenStream( const String & rFileName )
: pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) )
, rInStream( *pInStream )
, aFileName( rFileName )
- , aTokList( 0x8000, 0x8000 )
{
InitCtor();
}
@@ -124,7 +122,6 @@ SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName )
: pInStream( NULL )
, rInStream( rStream )
, aFileName( rFileName )
- , aTokList( 0x8000, 0x8000 )
{
InitCtor();
}
@@ -132,28 +129,23 @@ SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName )
SvTokenStream::~SvTokenStream()
{
delete pInStream;
- SvToken * pTok = aTokList.Last();
- while( pTok )
- {
- delete pTok;
- pTok = aTokList.Prev();
- }
}
void SvTokenStream::FillTokenList()
{
SvToken * pToken = new SvToken();
- aTokList.Insert( pToken, LIST_APPEND );
+ aTokList.push_back(pToken);
do
{
if( !MakeToken( *pToken ) )
{
- SvToken * p = aTokList.Prev();
- *pToken = SvToken();
- if( p )
+ if (!aTokList.empty())
{
- pToken->SetLine( p->GetLine() );
- pToken->SetColumn( p->GetColumn() );
+ *pToken = SvToken();
+ boost::ptr_vector<SvToken>::const_iterator it = aTokList.begin();
+
+ pToken->SetLine(it->GetLine());
+ pToken->SetColumn(it->GetColumn());
}
break;
}
@@ -164,11 +156,11 @@ void SvTokenStream::FillTokenList()
else
{
pToken = new SvToken();
- aTokList.Insert( pToken, LIST_APPEND );
+ aTokList.push_back(pToken);
}
}
while( !pToken->IsEof() );
- pCurToken = aTokList.First();
+ pCurToken = aTokList.begin();
}
void SvTokenStream::SetCharSet( CharSet nSet )