From 62d270116bf34778bf581f21b27fa9cdbff7de0e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 3 Jun 2016 14:45:59 +0200 Subject: tools: rename SvStream::Read/Write to ReadBytes/WriteBytes Change-Id: Ib788a30d413436aa03f813aa2fddcbc4d6cd2f9a Reviewed-on: https://gerrit.libreoffice.org/25972 Tested-by: Jenkins Reviewed-by: Michael Stahl --- tools/qa/cppunit/test_stream.cxx | 2 +- tools/source/generic/poly.cxx | 8 ++--- tools/source/inet/inetstrm.cxx | 2 +- tools/source/rc/resmgr.cxx | 14 ++++----- tools/source/ref/globname.cxx | 4 +-- tools/source/ref/pstm.cxx | 4 +-- tools/source/stream/stream.cxx | 64 ++++++++++++++++++++-------------------- tools/source/zcodec/zcodec.cxx | 17 ++++++----- 8 files changed, 59 insertions(+), 56 deletions(-) (limited to 'tools') diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index 71981ae70df4..c9c97bf0760d 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -123,7 +123,7 @@ namespace aMemStream.Seek(0); CPPUNIT_ASSERT(aMemStream.good()); - sal_Size nRet = aMemStream.Read(buffer, sizeof(buffer)); + sal_Size nRet = aMemStream.ReadBytes(buffer, sizeof(buffer)); CPPUNIT_ASSERT(nRet == 3); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index f8df46df2057..6d70f8af0760 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -1587,7 +1587,7 @@ SvStream& ReadPolygon( SvStream& rIStream, tools::Polygon& rPoly ) #else if ( rIStream.GetEndian() == SvStreamEndian::LITTLE ) #endif - rIStream.Read( rPoly.mpImplPolygon->mpPointAry, nPoints*sizeof(Point) ); + rIStream.ReadBytes(rPoly.mpImplPolygon->mpPointAry, nPoints*sizeof(Point)); else #endif { @@ -1622,7 +1622,7 @@ SvStream& WritePolygon( SvStream& rOStream, const tools::Polygon& rPoly ) #endif { if ( nPoints ) - rOStream.Write( rPoly.mpImplPolygon->mpPointAry, nPoints*sizeof(Point) ); + rOStream.WriteBytes(rPoly.mpImplPolygon->mpPointAry, nPoints*sizeof(Point)); } else #endif @@ -1648,7 +1648,7 @@ void Polygon::ImplRead( SvStream& rIStream ) if ( bHasPolyFlags ) { mpImplPolygon->mpFlagAry = new sal_uInt8[ mpImplPolygon->mnPoints ]; - rIStream.Read( mpImplPolygon->mpFlagAry, mpImplPolygon->mnPoints ); + rIStream.ReadBytes(mpImplPolygon->mpFlagAry, mpImplPolygon->mnPoints); } } @@ -1666,7 +1666,7 @@ void Polygon::ImplWrite( SvStream& rOStream ) const rOStream.WriteBool(bHasPolyFlags); if ( bHasPolyFlags ) - rOStream.Write( mpImplPolygon->mpFlagAry, mpImplPolygon->mnPoints ); + rOStream.WriteBytes( mpImplPolygon->mpFlagAry, mpImplPolygon->mnPoints ); } void Polygon::Write( SvStream& rOStream ) const diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index af0e8e494307..f1082a1f0486 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -81,7 +81,7 @@ int INetMIMEMessageStream::GetBodyLine(sal_Char* pData, sal_uIntPtr nSize) if (pMsgStrm == nullptr) pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB()); - sal_uIntPtr nRead = pMsgStrm->Read(pWBuf, (pWEnd - pWBuf)); + sal_uIntPtr nRead = pMsgStrm->ReadBytes(pWBuf, (pWEnd - pWBuf)); pWBuf += nRead; } diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx index fb3ed921d168..078ad5bfbcf4 100644 --- a/tools/source/rc/resmgr.cxx +++ b/tools/source/rc/resmgr.cxx @@ -489,13 +489,13 @@ bool InternalResMgr::Create() fRes, 0 ) ) != (RSHEADER_TYPE *)-1) */ pStm->SeekRel( - (int)sizeof( lContLen ) ); - pStm->Read( &lContLen, sizeof( lContLen ) ); - // is bigendian, swab to the right endian + pStm->ReadBytes( &lContLen, sizeof( lContLen ) ); + // file is bigendian but SvStreamEndian not set, swab to the right endian lContLen = ResMgr::GetLong( &lContLen ); pStm->SeekRel( -lContLen ); // allocate stored ImpContent data (12 bytes per unit) sal_uInt8* pContentBuf = static_cast(rtl_allocateMemory( lContLen )); - pStm->Read( pContentBuf, lContLen ); + pStm->ReadBytes( pContentBuf, lContLen ); // allocate ImpContent space (sizeof(ImpContent) per unit, not necessarily 12) pContent = static_cast(rtl_allocateMemory( sizeof(ImpContent)*lContLen/12 )); // Shorten to number of ImpContent @@ -590,11 +590,11 @@ void* InternalResMgr::LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId, --pLast; pStm->Seek( pLast->nOffset ); RSHEADER_TYPE aHdr; - pStm->Read( &aHdr, sizeof( aHdr ) ); + pStm->ReadBytes( &aHdr, sizeof( aHdr ) ); nSize = pLast->nOffset + aHdr.GetGlobOff() - nOffCorrection; pStringBlock = static_cast(rtl_allocateMemory( nSize )); pStm->Seek( pFirst->nOffset ); - pStm->Read( pStringBlock, nSize ); + pStm->ReadBytes( pStringBlock, nSize ); } *pResHandle = pStringBlock; return pStringBlock + pFind->nOffset - nOffCorrection; @@ -604,10 +604,10 @@ void* InternalResMgr::LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId, *pResHandle = nullptr; RSHEADER_TYPE aHeader; pStm->Seek( pFind->nOffset ); - pStm->Read( &aHeader, sizeof( RSHEADER_TYPE ) ); + pStm->ReadBytes( &aHeader, sizeof( RSHEADER_TYPE ) ); void * pRes = rtl_allocateMemory( aHeader.GetGlobOff() ); memcpy( pRes, &aHeader, sizeof( RSHEADER_TYPE ) ); - pStm->Read( static_cast(pRes) + sizeof( RSHEADER_TYPE ), + pStm->ReadBytes(static_cast(pRes) + sizeof(RSHEADER_TYPE), aHeader.GetGlobOff() - sizeof( RSHEADER_TYPE ) ); return pRes; } diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx index edaf70548776..807af1774b9c 100644 --- a/tools/source/ref/globname.cxx +++ b/tools/source/ref/globname.cxx @@ -110,7 +110,7 @@ SvStream& WriteSvGlobalName( SvStream& rOStr, const SvGlobalName & rObj ) rOStr.WriteUInt32( rObj.pImp->szData.Data1 ); rOStr.WriteUInt16( rObj.pImp->szData.Data2 ); rOStr.WriteUInt16( rObj.pImp->szData.Data3 ); - rOStr.Write( &rObj.pImp->szData.Data4, 8 ); + rOStr.WriteBytes( &rObj.pImp->szData.Data4, 8 ); return rOStr; } @@ -121,7 +121,7 @@ SvStream& operator >> ( SvStream& rStr, SvGlobalName & rObj ) rStr.ReadUInt32( rObj.pImp->szData.Data1 ); rStr.ReadUInt16( rObj.pImp->szData.Data2 ); rStr.ReadUInt16( rObj.pImp->szData.Data3 ); - rStr.Read( &rObj.pImp->szData.Data4, 8 ); + rStr.ReadBytes( &rObj.pImp->szData.Data4, 8 ); return rStr; } diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index 3c15968c0699..74e6bc858108 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -93,7 +93,7 @@ void SvPersistStream::ResetError() sal_uIntPtr SvPersistStream::GetData( void* pData, sal_uIntPtr nSize ) { DBG_ASSERT( pStm, "stream not set" ); - sal_uIntPtr nRet = pStm->Read( pData, nSize ); + sal_Size const nRet = pStm->ReadBytes( pData, nSize ); SetError( pStm->GetError() ); return nRet; } @@ -101,7 +101,7 @@ sal_uIntPtr SvPersistStream::GetData( void* pData, sal_uIntPtr nSize ) sal_uIntPtr SvPersistStream::PutData( const void* pData, sal_uIntPtr nSize ) { DBG_ASSERT( pStm, "stream not set" ); - sal_uIntPtr nRet = pStm->Write( pData, nSize ); + sal_Size const nRet = pStm->WriteBytes( pData, nSize ); SetError( pStm->GetError() ); return nRet; } diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index b57cda22ffde..369ded58de01 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -142,13 +142,13 @@ static void SwapUnicode(sal_Unicode & r) { r = OSL_SWAPWORD(r); } } \ else \ { \ - Read( &value, sizeof(datatype) ); \ + ReadBytes( &value, sizeof(datatype) ); \ } \ #define WRITENUMBER_WITHOUT_SWAP(datatype,value) \ if (m_isIoWrite && sizeof(datatype) <= m_nBufFree) \ - { \ + { \ for (std::size_t i = 0; i < sizeof(datatype); i++) \ m_pBufPos[i] = reinterpret_cast(&value)[i]; \ m_nBufFree -= sizeof(datatype); \ @@ -160,7 +160,7 @@ static void SwapUnicode(sal_Unicode & r) { r = OSL_SWAPWORD(r); } } \ else \ { \ - Write( &value, sizeof(datatype) ); \ + WriteBytes( &value, sizeof(datatype) ); \ } \ // class SvLockBytes @@ -184,7 +184,7 @@ ErrCode SvLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, sal_Size nCou } m_pStream->Seek(nPos); - sal_Size nTheRead = m_pStream->Read(pBuffer, nCount); + sal_Size nTheRead = m_pStream->ReadBytes(pBuffer, nCount); if (pRead) *pRead = nTheRead; return m_pStream->GetErrorCode(); @@ -201,7 +201,7 @@ ErrCode SvLockBytes::WriteAt(sal_uInt64 const nPos, const void * pBuffer, sal_Si } m_pStream->Seek(nPos); - sal_Size nTheWritten = m_pStream->Write(pBuffer, nCount); + sal_Size nTheWritten = m_pStream->WriteBytes(pBuffer, nCount); if (pWritten) *pWritten = nTheWritten; return m_pStream->GetErrorCode(); @@ -462,7 +462,7 @@ bool SvStream::ReadLine( OString& rStr, sal_Int32 nMaxBytesToRead ) while( !bEnd && !GetError() ) // Don't test for EOF as we // are reading block-wise! { - sal_uInt16 nLen = (sal_uInt16)Read( buf, sizeof(buf)-1 ); + sal_uInt16 nLen = static_cast(ReadBytes(buf, sizeof(buf)-1)); if ( !nLen ) { if ( aBuf.isEmpty() ) @@ -511,7 +511,7 @@ bool SvStream::ReadLine( OString& rStr, sal_Int32 nMaxBytesToRead ) if ( bEnd && (c=='\r' || c=='\n') ) // Special treatment for DOS files { char cTemp; - sal_Size nLen = Read(&cTemp , sizeof(cTemp) ); + sal_Size nLen = ReadBytes(&cTemp, sizeof(cTemp)); if ( nLen ) { if( cTemp == c || (cTemp != '\n' && cTemp != '\r') ) Seek( nOldFilePos ); @@ -538,7 +538,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead while( !bEnd && !GetError() ) // Don't test for EOF as we // are reading block-wise! { - sal_uInt16 nLen = (sal_uInt16)Read( buf, sizeof(buf)-sizeof(sal_Unicode) ); + sal_uInt16 nLen = static_cast(ReadBytes( buf, sizeof(buf)-sizeof(sal_Unicode))); nLen /= sizeof(sal_Unicode); if ( !nLen ) { @@ -597,7 +597,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead if ( bEnd && (c=='\r' || c=='\n') ) // special treatment for DOS files { sal_Unicode cTemp; - Read( &cTemp, sizeof(cTemp) ); + ReadBytes( &cTemp, sizeof(cTemp) ); if (m_isSwap) SwapUnicode( cTemp ); if( cTemp == c || (cTemp != '\n' && cTemp != '\r') ) @@ -629,7 +629,7 @@ OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStream) while( !bEnd && !rStream.GetError() ) { - sal_Size nLen = rStream.Read(buf, sizeof(buf)-1); + sal_Size nLen = rStream.ReadBytes(buf, sizeof(buf)-1); if (!nLen) break; @@ -669,7 +669,7 @@ sal_Size write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr, DBG_ASSERT( sizeof(sal_Unicode) == sizeof(sal_uInt16), "write_uInt16s_FromOUString: swapping sizeof(sal_Unicode) not implemented" ); sal_Size nWritten; if (!rStrm.IsEndianSwap()) - nWritten = rStrm.Write( rStr.getStr(), nUnits * sizeof(sal_Unicode) ); + nWritten = rStrm.WriteBytes(rStr.getStr(), nUnits * sizeof(sal_Unicode)); else { sal_Size nLen = nUnits; @@ -683,7 +683,7 @@ sal_Size write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr, SwapUnicode( *p ); p++; } - nWritten = rStrm.Write( pTmp, nLen * sizeof(sal_Unicode) ); + nWritten = rStrm.WriteBytes( pTmp, nLen * sizeof(sal_Unicode) ); if ( pTmp != aBuf ) delete [] pTmp; } @@ -712,7 +712,7 @@ bool SvStream::WriteByteStringLine( const OUString& rStr, rtl_TextEncoding eDest bool SvStream::WriteLine(const OString& rStr) { - Write(rStr.getStr(), rStr.getLength()); + WriteBytes(rStr.getStr(), rStr.getLength()); endl(*this); return m_nError == SVSTREAM_OK; } @@ -724,7 +724,7 @@ bool SvStream::WriteUniOrByteChar( sal_Unicode ch, rtl_TextEncoding eDestCharSet else { OString aStr(&ch, 1, eDestCharSet); - Write(aStr.getStr(), aStr.getLength()); + WriteBytes(aStr.getStr(), aStr.getLength()); } return m_nError == SVSTREAM_OK; } @@ -902,7 +902,7 @@ SvStream& SvStream::ReadSChar( signed char& r ) m_nBufFree -= sizeof(signed char); } else - Read( &r, sizeof(signed char) ); + ReadBytes( &r, sizeof(signed char) ); return *this; } @@ -919,7 +919,7 @@ SvStream& SvStream::ReadChar( char& r ) m_nBufFree -= sizeof(char); } else - Read( &r, sizeof(char) ); + ReadBytes( &r, sizeof(char) ); return *this; } @@ -934,7 +934,7 @@ SvStream& SvStream::ReadUChar( unsigned char& r ) m_nBufFree -= sizeof(char); } else - Read( &r, sizeof(char) ); + ReadBytes( &r, sizeof(char) ); return *this; } @@ -966,7 +966,7 @@ SvStream& SvStream::ReadCharAsBool( bool& r ) else { unsigned char c; - if (Read(&c, 1) == 1) + if (ReadBytes(&c, 1) == 1) { SAL_WARN_IF(c > 1, "tools.stream", unsigned(c) << " not 0/1"); r = c != 0; @@ -1012,8 +1012,8 @@ SvStream& SvStream::ReadStream( SvStream& rStream ) sal_uInt32 nCount; do { - nCount = Read( pBuf, cBufLen ); - rStream.Write( pBuf, nCount ); + nCount = ReadBytes( pBuf, cBufLen ); + rStream.WriteBytes( pBuf, nCount ); } while( nCount == cBufLen ); delete[] pBuf; @@ -1082,7 +1082,7 @@ SvStream& SvStream::WriteSChar( signed char v ) m_isDirty = true; } else - Write( &v, sizeof(signed char) ); + WriteBytes( &v, sizeof(signed char) ); return *this; } @@ -1102,7 +1102,7 @@ SvStream& SvStream::WriteChar( char v ) m_isDirty = true; } else - Write( &v, sizeof(char) ); + WriteBytes( &v, sizeof(char) ); return *this; } @@ -1120,7 +1120,7 @@ SvStream& SvStream::WriteUChar( unsigned char v ) m_isDirty = true; } else - Write( &v, sizeof(char) ); + WriteBytes( &v, sizeof(char) ); return *this; } @@ -1164,7 +1164,7 @@ SvStream& SvStream::WriteDouble ( const double& r ) SvStream& SvStream::WriteCharPtr( const char* pBuf ) { - Write( pBuf, strlen( pBuf ) ); + WriteBytes( pBuf, strlen(pBuf) ); return *this; } @@ -1174,8 +1174,8 @@ SvStream& SvStream::WriteStream( SvStream& rStream ) char* pBuf = new char[ cBufLen ]; sal_uInt32 nCount; do { - nCount = rStream.Read( pBuf, cBufLen ); - Write( pBuf, nCount ); + nCount = rStream.ReadBytes( pBuf, cBufLen ); + WriteBytes( pBuf, nCount ); } while( nCount == cBufLen ); delete[] pBuf; @@ -1200,7 +1200,7 @@ SvStream& SvStream::WriteUniOrByteString( const OUString& rStr, rtl_TextEncoding return *this; } -sal_Size SvStream::Read( void* pData, sal_Size nCount ) +sal_Size SvStream::ReadBytes( void* pData, sal_Size nCount ) { sal_Size nSaveCount = nCount; if (!m_isConsistent) @@ -1287,7 +1287,7 @@ sal_Size SvStream::Read( void* pData, sal_Size nCount ) return nCount; } -sal_Size SvStream::Write( const void* pData, sal_Size nCount ) +sal_Size SvStream::WriteBytes( const void* pData, sal_Size nCount ) { if( !nCount ) return 0; @@ -1458,7 +1458,7 @@ SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32) { char buffer[12]; sal_Size nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32); - Write(buffer, nLen); + WriteBytes(buffer, nLen); return *this; } @@ -1466,7 +1466,7 @@ SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32) { char buffer[11]; sal_Size nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32); - Write(buffer, nLen); + WriteBytes(buffer, nLen); return *this; } @@ -1990,7 +1990,7 @@ OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen) SAL_WARN_IF(!pStr, "tools", "allocation failed"); if (pStr) { - sal_Size nWasRead = rStrm.Read(pStr->buffer, nLen); + sal_Size nWasRead = rStrm.ReadBytes(pStr->buffer, nLen); if (nWasRead != nLen) { //on (typically unlikely) short read set length to what we could @@ -2019,7 +2019,7 @@ OUString read_uInt16s_ToOUString(SvStream& rStrm, sal_Size nLen) SAL_WARN_IF(!pStr, "tools", "allocation failed"); if (pStr) { - sal_Size nWasRead = rStrm.Read(pStr->buffer, nLen*2)/2; + sal_Size nWasRead = rStrm.ReadBytes(pStr->buffer, nLen*2)/2; if (nWasRead != nLen) { //on (typically unlikely) short read set length to what we could diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index fcf8c2126a6b..e841888a54b7 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -118,7 +118,8 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm ) mpOStm = &rOStm; InitCompress(); mpInBuf = new sal_uInt8[ mnInBufSize ]; - while (( PZSTREAM->avail_in = rIStm.Read( PZSTREAM->next_in = mpInBuf, mnInBufSize )) != 0 ) + while ((PZSTREAM->avail_in = rIStm.ReadBytes( + PZSTREAM->next_in = mpInBuf, mnInBufSize )) != 0) { if ( PZSTREAM->avail_out == 0 ) ImplWriteBack(); @@ -146,7 +147,8 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm ) if ( PZSTREAM->avail_in == 0 && mnInToRead ) { nInToRead = ( mnInBufSize > mnInToRead ) ? mnInToRead : mnInBufSize; - PZSTREAM->avail_in = rIStm.Read( PZSTREAM->next_in = mpInBuf, nInToRead ); + PZSTREAM->next_in = mpInBuf; + PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead); mnInToRead -= nInToRead; if ( mbUpdateCrc ) @@ -211,8 +213,8 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize ) if ( PZSTREAM->avail_in == 0 && mnInToRead ) { nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize; - PZSTREAM->avail_in = rIStm.Read ( - PZSTREAM->next_in = mpInBuf, nInToRead); + PZSTREAM->next_in = mpInBuf; + PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead); mnInToRead -= nInToRead; if ( mbUpdateCrc ) @@ -264,8 +266,8 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize break; } - PZSTREAM->avail_in = rIStm.Read ( - PZSTREAM->next_in = mpInBuf, nInToRead); + PZSTREAM->next_in = mpInBuf; + PZSTREAM->avail_in = rIStm.ReadBytes(mpInBuf, nInToRead); mnInToRead -= nInToRead; if ( mbUpdateCrc ) @@ -297,7 +299,8 @@ void ZCodec::ImplWriteBack() { if (meState == STATE_COMPRESS && mbUpdateCrc) UpdateCRC( mpOutBuf, nAvail ); - mpOStm->Write( PZSTREAM->next_out = mpOutBuf, nAvail ); + PZSTREAM->next_out = mpOutBuf; + mpOStm->WriteBytes( mpOutBuf, nAvail ); PZSTREAM->avail_out = mnOutBufSize; } } -- cgit v1.2.3