[Libreoffice-commits] .: Branch 'feature/currency-64bit' - tools/inc tools/source

Noel Power noelp at kemper.freedesktop.org
Tue Dec 14 13:50:39 PST 2010


 tools/inc/tools/stream.hxx     |    2 ++
 tools/source/stream/stream.cxx |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

New commits:
commit 38cd06705982ce14abc7cb9738b4966626e28dc3
Author: Noel Power <noel.power at novell.com>
Date:   Tue Dec 14 20:36:09 2010 +0000

    add stream operator for sal_uInt64

diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index abb1804..c7e3b32 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -354,6 +354,7 @@ public:
 
     SvStream&		operator>>( sal_uInt16& rUInt16 );
     SvStream&		operator>>( sal_uInt32& rUInt32 );
+    SvStream&		operator>>( sal_uInt64& rUInt64 );
     SvStream&		operator>>( long& rLong );
     SvStream&		operator>>( short& rShort );
     SvStream&		operator>>( int& rInt );
@@ -372,6 +373,7 @@ public:
 
     SvStream&		operator<<( sal_uInt16 nUInt16 );
     SvStream&		operator<<( sal_uInt32 nUInt32 );
+    SvStream&		operator<<( sal_uInt64 nuInt64 );
     SvStream&		operator<<( long nLong );
     SvStream&		operator<<( short nShort );
     SvStream&		operator<<( int nInt );
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 7794158..fbe54d2 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -93,6 +93,24 @@ inline static void SwapLongInt( int& r )
     {   r = SWAPLONG(r);   }
 inline static void SwapLongUInt( unsigned int& r )
     {   r = SWAPLONG(r);   }
+
+inline static void SwapUInt64( sal_uInt64& r )
+    {
+        union
+        {
+            sal_uInt64 n;
+            sal_uInt32 c[2];
+        } s;
+
+        s.n = r;
+        s.c[0] ^= s.c[1]; // swap the 32 bit words
+        s.c[1] ^= s.c[0];
+        s.c[0] ^= s.c[1];
+        // swap the bytes in the words
+        s.c[0] = SWAPLONG(s.c[0]);
+        s.c[1] = SWAPLONG(s.c[1]);
+        r = s.n;
+    }
 #ifdef UNX
 inline static void SwapFloat( float& r )
     {
@@ -106,6 +124,7 @@ inline static void SwapFloat( float& r )
         s.c = SWAPLONG( s.c );
         r = s.f;
     }
+
 inline static void SwapDouble( double& r )
     {
         if( sizeof(double) != 8 )
@@ -1224,6 +1243,15 @@ SvStream& SvStream::operator>> ( sal_uInt32& r )
     return *this;
 }
 
+
+SvStream& SvStream::operator>> ( sal_uInt64& r )
+{
+    READNUMBER_WITHOUT_SWAP(sal_uInt64,r)
+    if( bSwap )
+        SwapUInt64(r);
+    return *this;
+}
+
 SvStream& SvStream::operator >> ( long& r )
 {
 #if(SAL_TYPES_SIZEOFLONG != 4)
@@ -1364,6 +1392,14 @@ SvStream& SvStream::operator<<  ( sal_uInt32 v )
     return *this;
 }
 
+SvStream& SvStream::operator<<  ( sal_uInt64 v )
+{
+    if( bSwap )
+        SwapUInt64(v);
+    WRITENUMBER_WITHOUT_SWAP(sal_uInt64,v)
+    return *this;
+}
+
 SvStream& SvStream::operator<< ( long v )
 {
 #if(SAL_TYPES_SIZEOFLONG != 4)


More information about the Libreoffice-commits mailing list