diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-09-14 17:01:50 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-09-15 12:01:11 +0200 |
commit | b647996a9babbee7b33cf45192e57df6a124628b (patch) | |
tree | ddc6dfe8a62ec53fbacc4eeccfeb20019f3ef4f0 /tools/source | |
parent | a19a67e20e847a42063559694ec5beec71abcfb3 (diff) |
replace sal_Size with std::size_t (or sal_uInt64 for SvStream pos)
... except in include/rtl, include/sal, include/uno, where sal_Size is
retained for compatibility, and where callers of rtl functions pass in
pointers that are incompatible on MSVC.
Change-Id: I8344453780689f5120ba0870e44965b6d292450c
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/generic/config.cxx | 2 | ||||
-rw-r--r-- | tools/source/ref/pstm.cxx | 8 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 134 | ||||
-rw-r--r-- | tools/source/stream/strmunx.cxx | 28 | ||||
-rw-r--r-- | tools/source/stream/strmwnt.cxx | 20 |
5 files changed, 96 insertions, 96 deletions
diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index ab7c6234c557..879678f25b09 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -117,7 +117,7 @@ static sal_uInt8* ImplSysReadConfig( const OUString& rFileName, if (nRead > 2 && memcmp(pBuf, BOM, 3) == 0) { nRead -= 3; - memmove(pBuf, pBuf + 3, sal::static_int_cast<sal_Size>(nRead * sizeof(sal_uInt8)) ); + memmove(pBuf, pBuf + 3, sal::static_int_cast<std::size_t>(nRead * sizeof(sal_uInt8)) ); rbIsUTF8BOM = true; } diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index 74e6bc858108..c63459209a7d 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -90,18 +90,18 @@ void SvPersistStream::ResetError() pStm->ResetError(); } -sal_uIntPtr SvPersistStream::GetData( void* pData, sal_uIntPtr nSize ) +std::size_t SvPersistStream::GetData( void* pData, std::size_t nSize ) { DBG_ASSERT( pStm, "stream not set" ); - sal_Size const nRet = pStm->ReadBytes( pData, nSize ); + std::size_t const nRet = pStm->ReadBytes( pData, nSize ); SetError( pStm->GetError() ); return nRet; } -sal_uIntPtr SvPersistStream::PutData( const void* pData, sal_uIntPtr nSize ) +std::size_t SvPersistStream::PutData( const void* pData, std::size_t nSize ) { DBG_ASSERT( pStm, "stream not set" ); - sal_Size const nRet = pStm->WriteBytes( pData, nSize ); + std::size_t 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 befd9349a2dd..cca67de48127 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -174,8 +174,8 @@ void SvLockBytes::close() // virtual -ErrCode SvLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, sal_Size nCount, - sal_Size * pRead) const +ErrCode SvLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, std::size_t nCount, + std::size_t * pRead) const { if (!m_pStream) { @@ -184,15 +184,15 @@ ErrCode SvLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, sal_Size nCou } m_pStream->Seek(nPos); - sal_Size nTheRead = m_pStream->ReadBytes(pBuffer, nCount); + std::size_t nTheRead = m_pStream->ReadBytes(pBuffer, nCount); if (pRead) *pRead = nTheRead; return m_pStream->GetErrorCode(); } // virtual -ErrCode SvLockBytes::WriteAt(sal_uInt64 const nPos, const void * pBuffer, sal_Size nCount, - sal_Size * pWritten) +ErrCode SvLockBytes::WriteAt(sal_uInt64 const nPos, const void * pBuffer, std::size_t nCount, + std::size_t * pWritten) { if (!m_pStream) { @@ -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->WriteBytes(pBuffer, nCount); + std::size_t nTheWritten = m_pStream->WriteBytes(pBuffer, nCount); if (pWritten) *pWritten = nTheWritten; return m_pStream->GetErrorCode(); @@ -252,12 +252,12 @@ ErrCode SvLockBytes::Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag) const // class SvStream -sal_Size SvStream::GetData( void* pData, sal_Size nSize ) +std::size_t SvStream::GetData( void* pData, std::size_t nSize ) { if( !GetError() ) { DBG_ASSERT( m_xLockBytes.Is(), "pure virtual function" ); - sal_Size nRet(0); + std::size_t nRet(0); m_nError = m_xLockBytes->ReadAt(m_nActPos, pData, nSize, &nRet); m_nActPos += nRet; return nRet; @@ -265,12 +265,12 @@ sal_Size SvStream::GetData( void* pData, sal_Size nSize ) else return 0; } -sal_Size SvStream::PutData( const void* pData, sal_Size nSize ) +std::size_t SvStream::PutData( const void* pData, std::size_t nSize ) { if( !GetError() ) { DBG_ASSERT( m_xLockBytes.Is(), "pure virtual function" ); - sal_Size nRet(0); + std::size_t nRet(0); m_nError = m_xLockBytes->WriteAt(m_nActPos, pData, nSize, &nRet); m_nActPos += nRet; return nRet; @@ -456,7 +456,7 @@ bool SvStream::ReadLine( OString& rStr, sal_Int32 nMaxBytesToRead ) bool bEnd = false; sal_uInt64 nOldFilePos = Tell(); sal_Char c = 0; - sal_Size nTotalLen = 0; + std::size_t nTotalLen = 0; OStringBuffer aBuf(4096); while( !bEnd && !GetError() ) // Don't test for EOF as we @@ -490,7 +490,7 @@ bool SvStream::ReadLine( OString& rStr, sal_Int32 nMaxBytesToRead ) ++n; } nTotalLen += j; - if (nTotalLen > static_cast<sal_Size>(nMaxBytesToRead)) + if (nTotalLen > static_cast<std::size_t>(nMaxBytesToRead)) { n -= nTotalLen - nMaxBytesToRead; nTotalLen = nMaxBytesToRead; @@ -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 = ReadBytes(&cTemp, sizeof(cTemp)); + std::size_t nLen = ReadBytes(&cTemp, sizeof(cTemp)); if ( nLen ) { if( cTemp == c || (cTemp != '\n' && cTemp != '\r') ) Seek( nOldFilePos ); @@ -530,7 +530,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead bool bEnd = false; sal_uInt64 nOldFilePos = Tell(); sal_Unicode c = 0; - sal_Size nTotalLen = 0; + std::size_t nTotalLen = 0; DBG_ASSERT( sizeof(sal_Unicode) == sizeof(sal_uInt16), "ReadUniStringLine: swapping sizeof(sal_Unicode) not implemented" ); @@ -576,7 +576,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead } } nTotalLen += j; - if (nTotalLen > static_cast<sal_Size>(nMaxCodepointsToRead)) + if (nTotalLen > static_cast<std::size_t>(nMaxCodepointsToRead)) { n -= nTotalLen - nMaxCodepointsToRead; nTotalLen = nMaxCodepointsToRead; @@ -629,11 +629,11 @@ OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStream) while( !bEnd && !rStream.GetError() ) { - sal_Size nLen = rStream.ReadBytes(buf, sizeof(buf)-1); + std::size_t nLen = rStream.ReadBytes(buf, sizeof(buf)-1); if (!nLen) break; - sal_Size nReallyRead = nLen; + std::size_t nReallyRead = nLen; const sal_Char* pPtr = buf; while (nLen && *pPtr) { @@ -663,16 +663,16 @@ OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStream, rtl_TextEncodi /** Attempt to write a prefixed sequence of nUnits 16bit units from an OUString, returned value is number of bytes written */ -sal_Size write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr, - sal_Size nUnits) +std::size_t write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr, + std::size_t nUnits) { DBG_ASSERT( sizeof(sal_Unicode) == sizeof(sal_uInt16), "write_uInt16s_FromOUString: swapping sizeof(sal_Unicode) not implemented" ); - sal_Size nWritten; + std::size_t nWritten; if (!rStrm.IsEndianSwap()) nWritten = rStrm.WriteBytes(rStr.getStr(), nUnits * sizeof(sal_Unicode)); else { - sal_Size nLen = nUnits; + std::size_t nLen = nUnits; sal_Unicode aBuf[384]; sal_Unicode* const pTmp = ( nLen > 384 ? new sal_Unicode[nLen] : aBuf); memcpy( pTmp, rStr.getStr(), nLen * sizeof(sal_Unicode) ); @@ -1200,9 +1200,9 @@ SvStream& SvStream::WriteUniOrByteString( const OUString& rStr, rtl_TextEncoding return *this; } -sal_Size SvStream::ReadBytes( void* pData, sal_Size nCount ) +std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount ) { - sal_Size nSaveCount = nCount; + std::size_t nSaveCount = nCount; if (!m_isConsistent) RefreshBuffer(); @@ -1218,7 +1218,7 @@ sal_Size SvStream::ReadBytes( void* pData, sal_Size nCount ) // check if block is completely within buffer m_isIoRead = true; m_isIoWrite = false; - if (nCount <= static_cast<sal_Size>(m_nBufActualLen - m_nBufActualPos)) + if (nCount <= static_cast<std::size_t>(m_nBufActualLen - m_nBufActualPos)) { // => yes memcpy(pData, m_pBufPos, (size_t) nCount); @@ -1264,7 +1264,7 @@ sal_Size SvStream::ReadBytes( void* pData, sal_Size nCount ) SeekPos(m_nBufFilePos); // TODO: Typecast before GetData, sal_uInt16 nCountTmp - sal_Size nCountTmp = GetData( m_pRWBuf, m_nBufSize ); + std::size_t nCountTmp = GetData( m_pRWBuf, m_nBufSize ); if (m_nCryptMask) EncryptBuffer(m_pRWBuf, nCountTmp); m_nBufActualLen = (sal_uInt16)nCountTmp; @@ -1287,7 +1287,7 @@ sal_Size SvStream::ReadBytes( void* pData, sal_Size nCount ) return nCount; } -sal_Size SvStream::WriteBytes( const void* pData, sal_Size nCount ) +std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount ) { if( !nCount ) return 0; @@ -1311,7 +1311,7 @@ sal_Size SvStream::WriteBytes( const void* pData, sal_Size nCount ) m_isIoRead = false; m_isIoWrite = true; - if (nCount <= static_cast<sal_Size>(m_nBufSize - m_nBufActualPos)) + if (nCount <= static_cast<std::size_t>(m_nBufSize - m_nBufActualPos)) { memcpy( m_pBufPos, pData, (size_t)nCount ); m_nBufActualPos = m_nBufActualPos + (sal_uInt16)nCount; @@ -1329,7 +1329,7 @@ sal_Size SvStream::WriteBytes( const void* pData, sal_Size nCount ) { SeekPos(m_nBufFilePos); if (m_nCryptMask) - CryptAndWriteBuffer( m_pRWBuf, (sal_Size)m_nBufActualLen ); + CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen ); else PutData( m_pRWBuf, m_nBufActualLen ); m_isDirty = false; @@ -1423,7 +1423,7 @@ void SvStream::Flush() { SeekPos(m_nBufFilePos); if (m_nCryptMask) - CryptAndWriteBuffer( m_pRWBuf, (sal_Size)m_nBufActualLen ); + CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen ); else if (PutData( m_pRWBuf, m_nBufActualLen ) != m_nBufActualLen) SetError( SVSTREAM_WRITE_ERROR ); @@ -1439,7 +1439,7 @@ void SvStream::RefreshBuffer() { SeekPos(m_nBufFilePos); if (m_nCryptMask) - CryptAndWriteBuffer( m_pRWBuf, (sal_Size)m_nBufActualLen ); + CryptAndWriteBuffer( m_pRWBuf, (std::size_t)m_nBufActualLen ); else PutData( m_pRWBuf, m_nBufActualLen ); m_isDirty = false; @@ -1449,7 +1449,7 @@ void SvStream::RefreshBuffer() if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING) m_nError = ERRCODE_NONE; if (m_nCryptMask) - EncryptBuffer(m_pRWBuf, (sal_Size)m_nBufActualLen); + EncryptBuffer(m_pRWBuf, (std::size_t)m_nBufActualLen); m_isConsistent = true; m_isIoRead = m_isIoWrite = false; } @@ -1457,7 +1457,7 @@ void SvStream::RefreshBuffer() SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32) { char buffer[12]; - sal_Size nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32); + std::size_t nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32); WriteBytes(buffer, nLen); return *this; } @@ -1465,7 +1465,7 @@ SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32) SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32) { char buffer[11]; - sal_Size nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32); + std::size_t nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32); WriteBytes(buffer, nLen); return *this; } @@ -1473,12 +1473,12 @@ SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32) #define CRYPT_BUFSIZE 1024 /// Encrypt and write -sal_Size SvStream::CryptAndWriteBuffer( const void* pStart, sal_Size nLen) +std::size_t SvStream::CryptAndWriteBuffer( const void* pStart, std::size_t nLen) { unsigned char pTemp[CRYPT_BUFSIZE]; unsigned char const * pDataPtr = static_cast<unsigned char const *>(pStart); - sal_Size nCount = 0; - sal_Size nBufCount; + std::size_t nCount = 0; + std::size_t nBufCount; unsigned char nMask = m_nCryptMask; do { @@ -1504,12 +1504,12 @@ sal_Size SvStream::CryptAndWriteBuffer( const void* pStart, sal_Size nLen) return nCount; } -bool SvStream::EncryptBuffer(void* pStart, sal_Size nLen) +bool SvStream::EncryptBuffer(void* pStart, std::size_t nLen) { unsigned char* pTemp = static_cast<unsigned char*>(pStart); unsigned char nMask = m_nCryptMask; - for ( sal_Size n=0; n < nLen; n++, pTemp++ ) + for ( std::size_t n=0; n < nLen; n++, pTemp++ ) { unsigned char aCh = *pTemp; SWAPNIBBLES(aCh) @@ -1561,7 +1561,7 @@ void SvStream::SetCryptMaskKey(const OString& rCryptMaskKey) m_aCryptMaskKey.getLength(), GetVersion()); } -void SvStream::SyncSvStream( sal_Size nNewStreamPos ) +void SvStream::SyncSvStream( std::size_t nNewStreamPos ) { ClearBuffer(); SvStream::m_nBufFilePos = nNewStreamPos; @@ -1624,7 +1624,7 @@ SvStream& endlub( SvStream& rStrm ) return endl( rStrm ); } -SvMemoryStream::SvMemoryStream( void* pBuffer, sal_Size bufSize, +SvMemoryStream::SvMemoryStream( void* pBuffer, std::size_t bufSize, StreamMode eMode ) { if( eMode & StreamMode::WRITE ) @@ -1640,7 +1640,7 @@ SvMemoryStream::SvMemoryStream( void* pBuffer, sal_Size bufSize, SetBufferSize( 0 ); } -SvMemoryStream::SvMemoryStream( sal_Size nInitSize, sal_Size nResizeOffset ) +SvMemoryStream::SvMemoryStream( std::size_t nInitSize, std::size_t nResizeOffset ) { m_isWritable = true; bOwnsData = true; @@ -1685,8 +1685,8 @@ sal_uInt64 SvMemoryStream::GetSize() return nLength; } -void SvMemoryStream::SetBuffer( void* pNewBuf, sal_Size nCount, - sal_Size nEOF ) +void SvMemoryStream::SetBuffer( void* pNewBuf, std::size_t nCount, + std::size_t nEOF ) { SetBufferSize( 0 ); // Buffering in der Basisklasse initialisieren Seek( 0 ); @@ -1709,9 +1709,9 @@ void SvMemoryStream::SetBuffer( void* pNewBuf, sal_Size nCount, ResetError(); } -sal_Size SvMemoryStream::GetData( void* pData, sal_Size nCount ) +std::size_t SvMemoryStream::GetData( void* pData, std::size_t nCount ) { - sal_Size nMaxCount = nEndOfData-nPos; + std::size_t nMaxCount = nEndOfData-nPos; if( nCount > nMaxCount ) nCount = nMaxCount; if (nCount != 0) @@ -1722,12 +1722,12 @@ sal_Size SvMemoryStream::GetData( void* pData, sal_Size nCount ) return nCount; } -sal_Size SvMemoryStream::PutData( const void* pData, sal_Size nCount ) +std::size_t SvMemoryStream::PutData( const void* pData, std::size_t nCount ) { if( GetError() ) return 0L; - sal_Size nMaxCount = nSize-nPos; + std::size_t nMaxCount = nSize-nPos; // check for overflow if( nCount > nMaxCount ) @@ -1824,7 +1824,7 @@ void SvMemoryStream::ResetError() SvStream::ClearError(); } -bool SvMemoryStream::AllocateMemory( sal_Size nNewSize ) +bool SvMemoryStream::AllocateMemory( std::size_t nNewSize ) { pBuf = new sal_uInt8[nNewSize]; return( pBuf != nullptr ); @@ -1836,7 +1836,7 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff ) bool bRetVal = false; long nTemp = (long)nSize; nTemp += nDiff; - sal_Size nNewSize = (sal_Size)nTemp; + std::size_t nNewSize = (std::size_t)nTemp; if( nNewSize ) { @@ -1901,7 +1901,7 @@ void* SvMemoryStream::SwitchBuffer() ResetError(); - sal_Size nInitSize = 512; + std::size_t nInitSize = 512; if( !AllocateMemory(nInitSize) ) { SetError( SVSTREAM_OUTOFMEMORY ); @@ -1978,19 +1978,19 @@ bool SvScriptStream::good() const } //Create a OString of nLen bytes from rStream -OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen) +OString read_uInt8s_ToOString(SvStream& rStrm, std::size_t nLen) { rtl_String *pStr = nullptr; if (nLen) { - nLen = std::min(nLen, static_cast<sal_Size>(SAL_MAX_INT32)); + nLen = std::min(nLen, static_cast<std::size_t>(SAL_MAX_INT32)); //alloc a (ref-count 1) rtl_String of the desired length. //rtl_String's buffer is uninitialized, except for null termination pStr = rtl_string_alloc(sal::static_int_cast<sal_Int32>(nLen)); SAL_WARN_IF(!pStr, "tools", "allocation failed"); if (pStr) { - sal_Size nWasRead = rStrm.ReadBytes(pStr->buffer, nLen); + std::size_t nWasRead = rStrm.ReadBytes(pStr->buffer, nLen); if (nWasRead != nLen) { //on (typically unlikely) short read set length to what we could @@ -2007,19 +2007,19 @@ OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen) } //Create a OUString of nLen sal_Unicodes from rStream -OUString read_uInt16s_ToOUString(SvStream& rStrm, sal_Size nLen) +OUString read_uInt16s_ToOUString(SvStream& rStrm, std::size_t nLen) { rtl_uString *pStr = nullptr; if (nLen) { - nLen = std::min(nLen, static_cast<sal_Size>(SAL_MAX_INT32)); + nLen = std::min(nLen, static_cast<std::size_t>(SAL_MAX_INT32)); //alloc a (ref-count 1) rtl_uString of the desired length. //rtl_String's buffer is uninitialized, except for null termination pStr = rtl_uString_alloc(sal::static_int_cast<sal_Int32>(nLen)); SAL_WARN_IF(!pStr, "tools", "allocation failed"); if (pStr) { - sal_Size nWasRead = rStrm.ReadBytes(pStr->buffer, nLen*2)/2; + std::size_t nWasRead = rStrm.ReadBytes(pStr->buffer, nLen*2)/2; if (nWasRead != nLen) { //on (typically unlikely) short read set length to what we could @@ -2131,12 +2131,12 @@ OUString convertLineEnd(const OUString &rIn, LineEnd eLineEnd) return tmpl_convertLineEnd<OUString, OUStringBuffer>(rIn, eLineEnd); } -sal_Size write_uInt32_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, +std::size_t write_uInt32_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, const OUString &rStr) { - sal_Size nWritten = 0; - sal_uInt32 nUnits = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<sal_uInt32>::max()); - SAL_WARN_IF(static_cast<sal_Size>(nUnits) != static_cast<sal_Size>(rStr.getLength()), + std::size_t nWritten = 0; + sal_uInt32 nUnits = std::min<std::size_t>(rStr.getLength(), std::numeric_limits<sal_uInt32>::max()); + SAL_WARN_IF(static_cast<std::size_t>(nUnits) != static_cast<std::size_t>(rStr.getLength()), "tools.stream", "string too long for prefix count to fit in output type"); rStrm.WriteUInt32(nUnits); @@ -2148,11 +2148,11 @@ sal_Size write_uInt32_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, return nWritten; } -sal_Size write_uInt16_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, +std::size_t write_uInt16_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, const OUString &rStr) { - sal_Size nWritten = 0; - sal_uInt16 nUnits = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<sal_uInt16>::max()); + std::size_t nWritten = 0; + sal_uInt16 nUnits = std::min<std::size_t>(rStr.getLength(), std::numeric_limits<sal_uInt16>::max()); SAL_WARN_IF(nUnits != rStr.getLength(), "tools.stream", "string too long for prefix count to fit in output type"); @@ -2165,12 +2165,12 @@ sal_Size write_uInt16_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, return nWritten; } -sal_Size write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm, +std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm, const OString &rStr) { - sal_Size nWritten = 0; - sal_uInt16 nUnits = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<sal_uInt16>::max()); - SAL_WARN_IF(static_cast<sal_Size>(nUnits) != static_cast<sal_Size>(rStr.getLength()), + std::size_t nWritten = 0; + sal_uInt16 nUnits = std::min<std::size_t>(rStr.getLength(), std::numeric_limits<sal_uInt16>::max()); + SAL_WARN_IF(static_cast<std::size_t>(nUnits) != static_cast<std::size_t>(rStr.getLength()), "tools.stream", "string too long for sal_uInt16 count to fit in output type"); rStrm.WriteUInt16( nUnits ); diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index e26237e69606..36ed303b81cc 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -48,20 +48,20 @@ struct LockMutex : public rtl::Static< osl::Mutex, LockMutex > {}; struct InternalStreamLock { - sal_Size m_nStartPos; - sal_Size m_nEndPos; + std::size_t m_nStartPos; + std::size_t m_nEndPos; SvFileStream* m_pStream; osl::DirectoryItem m_aItem; - InternalStreamLock( sal_Size, sal_Size, SvFileStream* ); + InternalStreamLock( std::size_t, std::size_t, SvFileStream* ); ~InternalStreamLock(); }; struct LockList : public rtl::Static< std::vector<InternalStreamLock>, LockList > {}; InternalStreamLock::InternalStreamLock( - sal_Size nStart, - sal_Size nEnd, + std::size_t nStart, + std::size_t nEnd, SvFileStream* pStream ) : m_nStartPos( nStart ), m_nEndPos( nEnd ), @@ -90,7 +90,7 @@ InternalStreamLock::~InternalStreamLock() #endif } -bool lockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* pStream ) +bool lockFile( std::size_t nStart, std::size_t nEnd, SvFileStream* pStream ) { osl::DirectoryItem aItem; if (osl::DirectoryItem::get( pStream->GetFileName(), aItem) != osl::FileBase::E_None ) @@ -145,7 +145,7 @@ bool lockFile( sal_Size nStart, sal_Size nEnd, SvFileStream* pStream ) return true; } -void unlockFile( sal_Size nStart, sal_Size nEnd, SvFileStream const * pStream ) +void unlockFile( std::size_t nStart, std::size_t nEnd, SvFileStream const * pStream ) { osl::MutexGuard aGuard( LockMutex::get() ); std::vector<InternalStreamLock> &rLockList = LockList::get(); @@ -305,7 +305,7 @@ SvFileStream::~SvFileStream() delete pInstanceData; } -sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) +std::size_t SvFileStream::GetData( void* pData, std::size_t nSize ) { #ifdef DBG_UTIL OString aTraceStr("SvFileStream::GetData(): " + OString::number(static_cast<sal_Int64>(nSize)) + " Bytes from " + OUStringToOString(aFilename, osl_getThreadTextEncoding())); @@ -322,10 +322,10 @@ sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) return -1; } } - return (sal_Size)nRead; + return (std::size_t)nRead; } -sal_Size SvFileStream::PutData( const void* pData, sal_Size nSize ) +std::size_t SvFileStream::PutData( const void* pData, std::size_t nSize ) { #ifdef DBG_UTIL OString aTraceStr("SvFileStream::PutData(): " + OString::number(static_cast<sal_Int64>(nSize)) + " Bytes to " + OUStringToOString(aFilename, osl_getThreadTextEncoding())); @@ -344,7 +344,7 @@ sal_Size SvFileStream::PutData( const void* pData, sal_Size nSize ) else if( !nWrite ) SetError( SVSTREAM_DISK_FULL ); } - return (sal_Size)nWrite; + return (std::size_t)nWrite; } sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos) @@ -368,7 +368,7 @@ sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos) if ( nPos != STREAM_SEEK_TO_END ) return nPos; rc = osl_getFilePos( pInstanceData->rHandle, &nNewPos ); - return (sal_Size) nNewPos; + return nNewPos; } SetError( SVSTREAM_GENERALERROR ); return 0L; @@ -379,7 +379,7 @@ void SvFileStream::FlushData() // does not exist locally } -bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes ) +bool SvFileStream::LockRange( std::size_t nByteOffset, std::size_t nBytes ) { int nLockMode = 0; @@ -428,7 +428,7 @@ bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes ) return true; } -bool SvFileStream::UnlockRange( sal_Size nByteOffset, sal_Size nBytes ) +bool SvFileStream::UnlockRange( std::size_t nByteOffset, std::size_t nBytes ) { if ( ! IsOpen() ) return false; diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index 3618d217f427..22c10665211a 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -44,9 +44,9 @@ public: } }; -static sal_Size GetSvError( DWORD nWntError ) +static std::size_t GetSvError( DWORD nWntError ) { - static struct { DWORD wnt; sal_Size sv; } errArr[] = + static struct { DWORD wnt; std::size_t sv; } errArr[] = { { ERROR_SUCCESS, SVSTREAM_OK }, { ERROR_ACCESS_DENIED, SVSTREAM_ACCESS_DENIED }, @@ -86,7 +86,7 @@ static sal_Size GetSvError( DWORD nWntError ) { (DWORD)0xFFFFFFFF, SVSTREAM_GENERALERROR } }; - sal_Size nRetVal = SVSTREAM_GENERALERROR; // default error + std::size_t nRetVal = SVSTREAM_GENERALERROR; // default error int i=0; do { @@ -133,7 +133,7 @@ SvFileStream::~SvFileStream() } /// Does not check for EOF, makes isEof callable -sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) +std::size_t SvFileStream::GetData( void* pData, std::size_t nSize ) { DWORD nCount = 0; if( IsOpen() ) @@ -141,14 +141,14 @@ sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) bool bResult = ReadFile(pInstanceData->hFile,(LPVOID)pData,nSize,&nCount,NULL); if( !bResult ) { - sal_Size nTestError = GetLastError(); + std::size_t nTestError = GetLastError(); SetError(::GetSvError( nTestError ) ); } } return (DWORD)nCount; } -sal_Size SvFileStream::PutData( const void* pData, sal_Size nSize ) +std::size_t SvFileStream::PutData( const void* pData, std::size_t nSize ) { DWORD nCount = 0; if( IsOpen() ) @@ -192,7 +192,7 @@ void SvFileStream::FlushData() } } -bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes ) +bool SvFileStream::LockRange( std::size_t nByteOffset, std::size_t nBytes ) { bool bRetVal = false; if( IsOpen() ) @@ -204,7 +204,7 @@ bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes ) return bRetVal; } -bool SvFileStream::UnlockRange( sal_Size nByteOffset, sal_Size nBytes ) +bool SvFileStream::UnlockRange( std::size_t nByteOffset, std::size_t nBytes ) { bool bRetVal = false; if( IsOpen() ) @@ -339,7 +339,7 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) if( (pInstanceData->hFile==INVALID_HANDLE_VALUE) && (nAccessMode & GENERIC_WRITE)) { - sal_Size nErr = ::GetSvError( GetLastError() ); + std::size_t nErr = ::GetSvError( GetLastError() ); if(nErr==SVSTREAM_ACCESS_DENIED || nErr==SVSTREAM_SHARING_VIOLATION) { nMode &= (~StreamMode::WRITE); @@ -409,7 +409,7 @@ void SvFileStream::SetSize(sal_uInt64 const nSize) { int bError = false; HANDLE hFile = pInstanceData->hFile; - sal_Size nOld = SetFilePointer( hFile, 0L, NULL, FILE_CURRENT ); + DWORD const nOld = SetFilePointer( hFile, 0L, NULL, FILE_CURRENT ); if( nOld != 0xffffffff ) { if( SetFilePointer(hFile,nSize,NULL,FILE_BEGIN ) != 0xffffffff) |