Some more loplugin:cstylecast: io
Change-Id: Iefd3268299b43ba08b9bc7699aa104288119ff4a
This commit is contained in:
@@ -310,7 +310,7 @@ sal_Int32 OTextInputStream::implReadNext()
|
||||
nTargetCount += rtl_convertTextToUnicode(
|
||||
mConvText2Unicode,
|
||||
mContextText2Unicode,
|
||||
(const sal_Char*) &( pbSource[nSourceCount] ),
|
||||
reinterpret_cast<const char*>(&( pbSource[nSourceCount] )),
|
||||
nTotalRead - nSourceCount,
|
||||
mpBuffer + mnCharsInBuffer + nTargetCount,
|
||||
nFreeBufferSize - nTargetCount,
|
||||
|
@@ -128,7 +128,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
|
||||
sal_Int32 nSeqSize = nSourceSize * 3;
|
||||
|
||||
Sequence<sal_Int8> seqText( nSeqSize );
|
||||
sal_Char *pTarget = (sal_Char *) seqText.getArray();
|
||||
sal_Char *pTarget = reinterpret_cast<char *>(seqText.getArray());
|
||||
while( true )
|
||||
{
|
||||
nTargetCount += rtl_convertUnicodeToText(
|
||||
@@ -148,7 +148,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
|
||||
{
|
||||
nSeqSize *= 2;
|
||||
seqText.realloc( nSeqSize ); // double array size
|
||||
pTarget = (sal_Char*) seqText.getArray();
|
||||
pTarget = reinterpret_cast<char*>(seqText.getArray());
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <cppuhelper/implbase2.hxx>
|
||||
#include <cppuhelper/implbase4.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <osl/endian.h>
|
||||
|
||||
#include <com/sun/star/io/XObjectInputStream.hpp>
|
||||
#include <com/sun/star/io/XObjectOutputStream.hpp>
|
||||
@@ -235,7 +236,7 @@ sal_Unicode ODataInputStream::readChar(void) throw (IOException, RuntimeExceptio
|
||||
throw UnexpectedEOFException();
|
||||
}
|
||||
|
||||
const sal_uInt8 * pBytes = ( const sal_uInt8 * )aTmp.getConstArray();
|
||||
const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
|
||||
return ((sal_Unicode)pBytes[0] << 8) + pBytes[1];
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ sal_Int16 ODataInputStream::readShort(void) throw (IOException, RuntimeException
|
||||
throw UnexpectedEOFException();
|
||||
}
|
||||
|
||||
const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
|
||||
const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
|
||||
return ((sal_Int16)pBytes[0] << 8) + pBytes[1];
|
||||
}
|
||||
|
||||
@@ -260,7 +261,7 @@ sal_Int32 ODataInputStream::readLong(void) throw (IOException, RuntimeException,
|
||||
throw UnexpectedEOFException( );
|
||||
}
|
||||
|
||||
const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
|
||||
const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
|
||||
return ((sal_Int32)pBytes[0] << 24) + ((sal_Int32)pBytes[1] << 16) + ((sal_Int32)pBytes[2] << 8) + pBytes[3];
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ sal_Int64 ODataInputStream::readHyper(void) throw (IOException, RuntimeException
|
||||
throw UnexpectedEOFException( );
|
||||
}
|
||||
|
||||
const sal_uInt8 * pBytes = ( const sal_uInt8 * ) aTmp.getConstArray();
|
||||
const sal_uInt8 * pBytes = reinterpret_cast<const sal_uInt8 *>(aTmp.getConstArray());
|
||||
return
|
||||
(((sal_Int64)pBytes[0]) << 56) +
|
||||
(((sal_Int64)pBytes[1]) << 48) +
|
||||
@@ -294,20 +295,14 @@ float ODataInputStream::readFloat(void) throw (IOException, RuntimeException, st
|
||||
|
||||
double ODataInputStream::readDouble(void) throw (IOException, RuntimeException, std::exception)
|
||||
{
|
||||
sal_uInt32 n = 1;
|
||||
union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
|
||||
if( *(sal_uInt8 *)&n == 1 )
|
||||
{
|
||||
// little endian
|
||||
a.ad.n2 = readLong();
|
||||
a.ad.n1 = readLong();
|
||||
}
|
||||
else
|
||||
{
|
||||
// big endian
|
||||
a.ad.n1 = readLong();
|
||||
a.ad.n2 = readLong();
|
||||
}
|
||||
#if defined OSL_LITENDIAN
|
||||
a.ad.n2 = readLong();
|
||||
a.ad.n1 = readLong();
|
||||
#else
|
||||
a.ad.n1 = readLong();
|
||||
a.ad.n2 = readLong();
|
||||
#endif
|
||||
return a.d;
|
||||
}
|
||||
|
||||
@@ -713,21 +708,15 @@ void ODataOutputStream::writeDouble(double Value)
|
||||
throw ( IOException,
|
||||
RuntimeException, std::exception)
|
||||
{
|
||||
sal_uInt32 n = 1;
|
||||
union { double d; struct { sal_uInt32 n1; sal_uInt32 n2; } ad; } a;
|
||||
a.d = Value;
|
||||
if( *(sal_Int8 *)&n == 1 )
|
||||
{
|
||||
// little endian
|
||||
writeLong( a.ad.n2 );
|
||||
writeLong( a.ad.n1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// big endian
|
||||
writeLong( a.ad.n1 );
|
||||
writeLong( a.ad.n2 );
|
||||
}
|
||||
#if defined OSL_LITENDIAN
|
||||
writeLong( a.ad.n2 );
|
||||
writeLong( a.ad.n1 );
|
||||
#else
|
||||
writeLong( a.ad.n1 );
|
||||
writeLong( a.ad.n2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ODataOutputStream::writeUTF(const OUString& Value)
|
||||
|
Reference in New Issue
Block a user