diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-27 08:21:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-28 09:55:02 +0000 |
commit | 3fd28200f1c1a46970789f21ee6fce3f6f3ac1ec (patch) | |
tree | 18600b1b78ed5ede7f7068a98fe3fe7b6962b311 /tools/bootstrp | |
parent | 48221d6a2bf4c327b6cadcdc65169997f7d7408d (diff) |
ByteString->rtl::OString[Buffer]
Diffstat (limited to 'tools/bootstrp')
-rw-r--r-- | tools/bootstrp/cppdep.cxx | 70 | ||||
-rw-r--r-- | tools/bootstrp/cppdep.hxx | 12 | ||||
-rw-r--r-- | tools/bootstrp/mkunroll/mkunroll.cxx | 12 | ||||
-rw-r--r-- | tools/bootstrp/rscdep.cxx | 39 |
4 files changed, 52 insertions, 81 deletions
diff --git a/tools/bootstrp/cppdep.cxx b/tools/bootstrp/cppdep.cxx index 093208cc1706..ea9179d2a071 100644 --- a/tools/bootstrp/cppdep.cxx +++ b/tools/bootstrp/cppdep.cxx @@ -39,50 +39,31 @@ CppDep::CppDep() { - pSources = new ByteStringList; - pSearchPath = new ByteStringList; - pFileList = new ByteStringList; } CppDep::~CppDep() { - for ( size_t i = 0, n = pSources->size(); i < n; ++i ) { - delete (*pSources)[ i ]; - } - delete pSources; - - for ( size_t i = 0, n = pSearchPath->size(); i < n; ++i ) { - delete (*pSearchPath)[ i ]; - } - delete pSearchPath; - - for ( size_t i = 0, n = pFileList->size(); i < n; ++i ) { - delete (*pFileList)[ i ]; - } - delete pFileList; } void CppDep::Execute() { - size_t nCount = pSources->size(); - for ( size_t n = 0; n < nCount; n++ ) + size_t nCount = m_aSources.size(); + for ( size_t n = 0; n < nCount; ++n ) { - ByteString *pStr = (*pSources)[ n ]; - Search( *pStr ); + const rtl::OString &rStr = m_aSources[n]; + Search(rStr); } } -sal_Bool CppDep::AddSearchPath( const char* aPath ) +sal_Bool CppDep::AddSearchPath( const char* pPath ) { - ByteString *pStr = new ByteString( aPath ); - pSearchPath->push_back( pStr ); + m_aSearchPath.push_back( rtl::OString(pPath) ); return sal_False; } -sal_Bool CppDep::AddSource( const char* aSource ) +sal_Bool CppDep::AddSource( const char* pSource ) { - ByteString *pStr = new ByteString( aSource ); - pSources->push_back( pStr ); + m_aSources.push_back( rtl::OString(pSource) ); return sal_False; } @@ -114,16 +95,16 @@ sal_Bool CppDep::Search( ByteString aFileName ) fprintf( stderr, "Result : %s\n", aResult.GetBuffer() ); #endif - ByteString aNewFile; + rtl::OString aNewFile; if ( aResult !="") - if ( (aNewFile = Exists( aResult )) != "" ) + if ( (aNewFile = Exists( aResult )).getLength() ) { sal_Bool bFound = sal_False; - size_t nCount = pFileList->size(); - for ( size_t i = 0; i < nCount; i++ ) + size_t nCount = m_aFileList.size(); + for ( size_t i = 0; i < nCount; ++i ) { - ByteString *pStr = (*pFileList)[ i ]; - if ( *pStr == aNewFile ) + const rtl::OString &rStr = m_aFileList[i]; + if ( rStr == aNewFile ) bFound = sal_True; } #ifdef DEBUG_VERBOSE @@ -131,9 +112,9 @@ sal_Bool CppDep::Search( ByteString aFileName ) #endif if ( !bFound ) { - pFileList->push_back( new ByteString( aNewFile ) ); + m_aFileList.push_back(aNewFile); #ifdef DEBUG_VERBOSE - fprintf( stderr, " CppDep %s\\\n", aNewFile.GetBuffer() ); + fprintf( stderr, " CppDep %s\\\n", aNewFile.getStr() ); #endif Search(aNewFile); } @@ -145,24 +126,23 @@ sal_Bool CppDep::Search( ByteString aFileName ) return bRet; } -ByteString CppDep::Exists( ByteString aFileName ) +rtl::OString CppDep::Exists( rtl::OString aFileName ) { char pFullName[1023]; - ByteString aString; #ifdef DEBUG_VERBOSE - fprintf( stderr, "Searching %s \n", aFileName.GetBuffer() ); + fprintf( stderr, "Searching %s \n", aFileName.getStr() ); #endif - size_t nCount = pSearchPath->size(); - for ( size_t n = 0; n < nCount; n++ ) + size_t nCount = m_aSearchPath.size(); + for ( size_t n = 0; n < nCount; ++n ) { struct stat aBuf; - ByteString *pPathName = (*pSearchPath)[ n ]; + const rtl::OString &rPathName = m_aSearchPath[n]; - strcpy( pFullName, pPathName->GetBuffer()); + strcpy( pFullName, rPathName.getStr()); strcat( pFullName, DIR_SEP ); - strcat( pFullName, aFileName.GetBuffer()); + strcat( pFullName, aFileName.getStr()); #ifdef DEBUG_VERBOSE fprintf( stderr, "looking for %s\t ", pFullName ); @@ -176,10 +156,10 @@ ByteString CppDep::Exists( ByteString aFileName ) fprintf( stderr, "%s \\\n", pFullName ); #endif - return ByteString(pFullName); + return rtl::OString(pFullName); } } - return aString; + return rtl::OString(); } rtl::OString CppDep::IsIncludeStatement(rtl::OString aLine) diff --git a/tools/bootstrp/cppdep.hxx b/tools/bootstrp/cppdep.hxx index ca41dea188ac..d71e38f01855 100644 --- a/tools/bootstrp/cppdep.hxx +++ b/tools/bootstrp/cppdep.hxx @@ -31,19 +31,17 @@ #define PATH_SEP ":" #define DIR_SEP "/" -typedef ::std::vector< ByteString* > ByteStringList; - class CppDep { ByteString aSourceFile; - ByteStringList *pSearchPath; + std::vector<rtl::OString> m_aSearchPath; protected: - ByteStringList *pFileList; - ByteStringList *pSources; + std::vector<rtl::OString> m_aFileList; + std::vector<rtl::OString> m_aSources; sal_Bool Search( ByteString aFileName ); - ByteString Exists( ByteString aFileName ); + rtl::OString Exists( rtl::OString aFileName ); rtl::OString IsIncludeStatement(rtl::OString aLine); public: @@ -51,7 +49,7 @@ public: virtual ~CppDep(); virtual void Execute(); - ByteStringList* GetDepList(){return pFileList;} + std::vector<rtl::OString>& GetDepList() { return m_aFileList; } sal_Bool AddSearchPath( const char* aPath ); sal_Bool AddSource( const char * aSource ); }; diff --git a/tools/bootstrp/mkunroll/mkunroll.cxx b/tools/bootstrp/mkunroll/mkunroll.cxx index 524ac19ea3c8..694645745658 100644 --- a/tools/bootstrp/mkunroll/mkunroll.cxx +++ b/tools/bootstrp/mkunroll/mkunroll.cxx @@ -104,7 +104,7 @@ MkLine::MkLine() class MkFilter : public TextFilter { - static ByteString aTnr; + static rtl::OString aTnr; ByteStringList *pLst; ByteStringList *pTnrLst; protected: @@ -133,7 +133,7 @@ MkFilter::~MkFilter() delete pLst; } -ByteString MkFilter::aTnr="$(TNR)"; +rtl::OString MkFilter::aTnr(RTL_CONSTASCII_STRINGPARAM("$(TNR)")); void MkFilter::Filter() { @@ -142,14 +142,14 @@ void MkFilter::Filter() while(( fgets(aLineBuf, LINE_LEN, pIn)) != NULL ) { - ByteString aLine( aLineBuf ); - if ( aLine.Search("mkfilter1" ) != STRING_NOTFOUND ) + rtl::OString aLine(aLineBuf); + if (aLine.indexOf(rtl::OString(RTL_CONSTASCII_STRINGPARAM("mkfilter1"))) != -1) { // Zeilen unterdruecken fprintf( stderr, "mkfilter1\n" ); nState = 0; } - else if ( aLine.Search("unroll begin" ) != STRING_NOTFOUND ) + else if (aLine.indexOf(rtl::OString(RTL_CONSTASCII_STRINGPARAM("unroll begin"))) != -1) { // Zeilen raus schreiben mit ersetzen von $(TNR) nach int n fprintf( stderr, "\nunroll begin\n" ); @@ -170,7 +170,7 @@ void MkFilter::Filter() sal_Bool bInTnrList = sal_True; fprintf( stderr, ":" ); MkLine *pMkLine = new MkLine(); - if ( aLine.Search("unroll end") != STRING_NOTFOUND ) + if (aLine.indexOf(rtl::OString(RTL_CONSTASCII_STRINGPARAM("unroll end"))) != -1) { fprintf( stderr, ";\nunroll end\n" ); MkLine *p_MkLine = new MkLine(); diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx index d26ffd418f65..eb6993e8498d 100644 --- a/tools/bootstrp/rscdep.cxx +++ b/tools/bootstrp/rscdep.cxx @@ -36,6 +36,7 @@ #include "bootstrp/prj.hxx" +#include <rtl/strbuf.hxx> #include <tools/string.hxx> #include <tools/fsys.hxx> #include <tools/stream.hxx> @@ -215,22 +216,21 @@ int main( int argc, char** argv ) aFileName += String(".dprr", osl_getThreadTextEncoding()); aOutStream.Open( aFileName, STREAM_WRITE ); - ByteString aString; + rtl::OStringBuffer aString; if ( optind < argc ) { #ifdef DEBUG_VERBOSE printf("further arguments : "); #endif - aString = ByteString( pSrsFileName ); - aString.SearchAndReplaceAll('\\', cDelim); - aString += ByteString(" : " ); + aString.append(rtl::OString(pSrsFileName).replace('\\', cDelim)); + aString.append(RTL_CONSTASCII_STRINGPARAM(" : " )); while ( optind < argc ) { if (!bSource ) { - aString += ByteString(" " ); - aString += ByteString( argv[optind]); + aString.append(' '); + aString.append(argv[optind]); pDep->AddSource( argv[optind++]); } else @@ -239,27 +239,20 @@ int main( int argc, char** argv ) } } } - aString += aRespArg; + aString.append(aRespArg); pDep->Execute(); - ByteStringList *pLst = pDep->GetDepList(); - size_t nCount = pLst->size(); - if ( nCount == 0 ) - { - aOutStream.WriteLine( aString ); - } - else - { - aString += ByteString( "\\" ); - aOutStream.WriteLine( aString ); - } + std::vector<rtl::OString>& rLst = pDep->GetDepList(); + size_t nCount = rLst.size(); + if ( nCount != 0 ) + aString.append('\\'); + aOutStream.WriteLine( aString.makeStringAndClear() ); - for ( size_t j = 0; j < nCount; j++ ) + for ( size_t j = 0; j < nCount; ++j ) { - ByteString *pStr = (*pLst)[ j ]; - pStr->SearchAndReplaceAll('\\', cDelim); + rtl::OStringBuffer aStr(rLst[j].replace('\\', cDelim)); if ( j != (nCount-1) ) - *pStr += ByteString( "\\" ); - aOutStream.WriteLine( *pStr ); + aStr.append('\\'); + aOutStream.WriteLine(aStr.makeStringAndClear()); } delete pDep; aOutStream.Close(); |