diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-07 14:36:26 +0200 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-08-08 10:47:31 +0300 |
commit | 7a597eb6248ef48ebeb23daa40d2c75e5a24d9ee (patch) | |
tree | b3cbd0db774b6dc5c06466b85ed2c4b42868afac /rsc | |
parent | MSVC warning C4510: default constructor could not be generated (diff) | |
download | core-7a597eb6248ef48ebeb23daa40d2c75e5a24d9ee.tar.gz core-7a597eb6248ef48ebeb23daa40d2c75e5a24d9ee.zip |
STL'ify UniqueIndex
Convert the UniqueIndex code from a macro to a C++ template. Also use
std::map as the underlying container instead of tools/contnr.hxx.
Change-Id: I0b7b37dd7160ae019aaecdacd1e973ac6d8498e2
Diffstat (limited to 'rsc')
-rw-r--r-- | rsc/inc/rscdef.hxx | 2 | ||||
-rw-r--r-- | rsc/source/parser/rscdb.cxx | 49 | ||||
-rw-r--r-- | rsc/source/rsc/rsc.cxx | 52 | ||||
-rw-r--r-- | rsc/source/tools/rscdef.cxx | 31 |
4 files changed, 69 insertions, 65 deletions
diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx index 3eeb8ec31712..be54ad756daa 100644 --- a/rsc/inc/rscdef.hxx +++ b/rsc/inc/rscdef.hxx @@ -210,7 +210,7 @@ public: sal_Bool IsIncFile(){ return bIncFile; }; }; -DECLARE_UNIQUEINDEX( RscSubFileTab, RscFile * ) +typedef UniqueIndex<RscFile> RscSubFileTab; #define NOFILE_INDEX UNIQUEINDEX_ENTRY_NOTFOUND class RscDefTree { diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx index 42fd1bd9c7c2..93a3281bdc69 100644 --- a/rsc/source/parser/rscdb.cxx +++ b/rsc/source/parser/rscdb.cxx @@ -357,20 +357,20 @@ sal_uInt32 RscTypCont :: PutSysName( sal_uInt32 nRscTyp, char * pFileName, *************************************************************************/ void RscTypCont :: WriteInc( FILE * fOutput, sal_uLong lFileKey ) { - RscFile * pFName; if( NOFILE_INDEX == lFileKey ) { - pFName = aFileTab.First(); - while( pFName ) + sal_uIntPtr aIndex = aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { - if( pFName && pFName->IsIncFile() ) + RscFile * pFName = aFileTab.Get( aIndex ); + if( pFName->IsIncFile() ) { fprintf( fOutput, "#include " ); fprintf( fOutput, "\"%s\"\n", pFName->aFileName.getStr() ); } - pFName = aFileTab.Next(); + aIndex = aFileTab.NextIndex( aIndex ); } } else @@ -378,7 +378,7 @@ void RscTypCont :: WriteInc( FILE * fOutput, sal_uLong lFileKey ) RscDepend * pDep; RscFile * pFile; - pFName = aFileTab.Get( lFileKey ); + RscFile * pFName = aFileTab.Get( lFileKey ); if( pFName ) { for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i ) @@ -723,12 +723,13 @@ void RscTypCont :: WriteSrc( FILE * fOutput, sal_uLong nFileKey, if( NOFILE_INDEX == nFileKey ) { - pFName = aFileTab.First(); - while( pFName ){ + sal_uIntPtr aIndex = aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { + pFName = aFileTab.Get( aIndex ); if( !pFName->IsIncFile() ) pFName->aDefLst.WriteAll( fOutput ); - aEnumRef.WriteSrc( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); + aEnumRef.WriteSrc( aIndex ); + aIndex = aFileTab.NextIndex( aIndex ); }; } else @@ -745,11 +746,11 @@ void RscTypCont :: WriteSrc( FILE * fOutput, sal_uLong nFileKey, RscId::SetNames( sal_False ); if( NOFILE_INDEX == nFileKey ) { - pFName = aFileTab.First(); - while( pFName ) + sal_uIntPtr aIndex = aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { - aEnumRef.WriteSrc( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); + aEnumRef.WriteSrc( aIndex ); + aIndex = aFileTab.NextIndex( aIndex ); }; } else @@ -805,13 +806,11 @@ ERRTYPE RscTypCont :: WriteHxx( FILE * fOutput, sal_uLong nFileKey ) if( NOFILE_INDEX == nFileKey ) { - RscFile * pFName; - - pFName = aFileTab.First(); - while( pFName ) + sal_uIntPtr aIndex = aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { - aError = aEnumRef.WriteHxx( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); + aError = aEnumRef.WriteHxx( aIndex ); + aIndex = aFileTab.NextIndex( aIndex ); }; } else @@ -838,13 +837,11 @@ ERRTYPE RscTypCont::WriteCxx( FILE * fOutput, sal_uLong nFileKey, if( NOFILE_INDEX == nFileKey ) { - RscFile * pFName; - - pFName = aFileTab.First(); - while( pFName ) + sal_uIntPtr aIndex = aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { - aError = aEnumRef.WriteCxx( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); + aError = aEnumRef.WriteCxx( aIndex ); + aIndex = aFileTab.NextIndex( aIndex ); }; } else diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index d422de9e4380..919965943912 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -453,18 +453,17 @@ ERRTYPE RscCompiler::Start() pTC->pEH->SetListFile( NULL ); - pFName = pTC->aFileTab.First(); - while( pFName && aError.IsOk() ) + sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk() ) { + pFName = pTC->aFileTab.Get( aIndex ); if( !pFName->bScanned && !pFName->IsIncFile() ) { - aError = IncludeParser( - pTC->aFileTab.GetIndex( pFName ) - ); + aError = IncludeParser( aIndex ); // Currentzeiger richtig setzen - pTC->aFileTab.Seek( pFName ); + aIndex = pTC->aFileTab.GetIndexOf( pFName ); }; - pFName = pTC->aFileTab.Next(); + aIndex = pTC->aFileTab.NextIndex( aIndex ); }; pTC->pEH->SetListFile( fListing ); @@ -474,12 +473,13 @@ ERRTYPE RscCompiler::Start() if ( pTC->pEH->GetVerbosity() >= RscVerbosityVerbose ) { pTC->pEH->StdOut( "Files: " ); - pFName = pTC->aFileTab.First(); - while( pFName ) + sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { + pFName = pTC->aFileTab.Get( aIndex ); pTC->pEH->StdOut( pFName->aFileName.getStr() ); pTC->pEH->StdOut( " " ); - pFName = pTC->aFileTab.Next(); + aIndex = pTC->aFileTab.NextIndex( aIndex ); }; pTC->pEH->StdOut( "\n" ); } @@ -522,9 +522,10 @@ void RscCompiler::EndCompile() else { // Schreibe Datei - pFN = pTC->aFileTab.First(); - while( pFN ) + sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { + pFN = pTC->aFileTab.Get( aIndex ); if( !pFN->IsIncFile() ) { pTC->WriteSrc( foutput, NOFILE_INDEX, sal_False ); @@ -788,12 +789,15 @@ ERRTYPE RscCompiler::Link() for( it = pCL->m_aOutputFiles.begin(); it != pCL->m_aOutputFiles.end(); ++it ) { // cleanup nodes - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) + for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { + pFName = pTC->aFileTab.Get( aIndex ); if( !pFName->IsIncFile() ) { - pTC->Delete( pTC->aFileTab.GetIndex( pFName ) ); - pTC->aFileTab.Seek( pFName ); + pTC->Delete( aIndex ); + aIndex = pTC->aFileTab.GetIndexOf( pFName ); pFName->bLoaded = sal_False; } } @@ -886,12 +890,15 @@ ERRTYPE RscCompiler::Link() } // parse files for specific language - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) + for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { + pFName = pTC->aFileTab.Get( aIndex ); if( !pFName->IsIncFile() ) { - aError = ParseOneFile( pTC->aFileTab.GetIndex( pFName ), &*it, &aContext ); - pTC->aFileTab.Seek( pFName ); + aError = ParseOneFile( aIndex, &*it, &aContext ); + aIndex = pTC->aFileTab.GetIndexOf( pFName ); } }; @@ -935,12 +942,15 @@ ERRTYPE RscCompiler::Link() else { // parse files - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) + for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); + aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { + pFName = pTC->aFileTab.Get( aIndex ); if( !pFName->IsIncFile() ) { - aError = ParseOneFile( pTC->aFileTab.GetIndex( pFName ), NULL, NULL ); - pTC->aFileTab.Seek( pFName ); + aError = ParseOneFile( aIndex, NULL, NULL ); + aIndex = pTC->aFileTab.GetIndexOf( pFName ); } }; } diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx index 6c11ec970d5b..6f120221f194 100644 --- a/rsc/source/tools/rscdef.cxx +++ b/rsc/source/tools/rscdef.cxx @@ -653,15 +653,13 @@ RscFileTab::RscFileTab(){ |* *************************************************************************/ RscFileTab :: ~RscFileTab(){ - RscFile * pFile; aDefTree.Remove(); - pFile = Last(); - while( pFile ){ - Remove( GetIndex( pFile ) ); - delete pFile; - pFile = Prev(); + sal_uIntPtr aIndex = LastIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) { + delete Remove( aIndex ); + aIndex = LastIndex(); }; } @@ -672,16 +670,14 @@ RscFileTab :: ~RscFileTab(){ *************************************************************************/ sal_uLong RscFileTab :: Find( const rtl::OString& rName ) { - RscFile * pFName; - - pFName = First(); - while( pFName && (pFName->aFileName != rName) ) - pFName = Next(); + sal_uIntPtr aIndex = FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && (Get(aIndex)->aFileName != rName) ) + aIndex = NextIndex(aIndex); - if( pFName ) - return( GetIndex( pFName ) ); + if( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + return aIndex; else - return( NOFILE_INDEX ); + return NOFILE_INDEX; } /************************************************************************* @@ -702,13 +698,14 @@ sal_Bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree ){ if( lDepend == lFree ) return sal_True; - RscFile * pFile = First(); - while( pFile ){ + sal_uIntPtr aIndex = FirstIndex(); + while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ){ + RscFile * pFile = Get(aIndex); if( !pFile->IsIncFile() ){ if( !pFile->Depend( lDepend, lFree ) ) return sal_False; }; - pFile = Next(); + aIndex = NextIndex(aIndex); }; return sal_True; |