summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2020-12-23 10:57:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-24 12:00:35 +0100
commit5dae4238ea6e21df42f4437a43d152954fc494fd (patch)
tree770f92f3c56cb954c7b764ad43a7dc93312d28ba /include
parent88c0e46e139fe44f7f2a6f9fbaa6b3fd7a827a8d (diff)
add sal*Int64 conversions to BigInt
we have the capability, so lets use it Change-Id: Ie5aa7999bb457d274bbcc07ba5c4e6ee2f286df1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108231 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/tools/bigint.hxx54
1 files changed, 17 insertions, 37 deletions
diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index a8d8575fb53b..ecf7ba05b96a 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -63,30 +63,23 @@ public:
{
}
-#if SAL_TYPES_SIZEOFLONG == 4
- BigInt(int nValue)
- : nVal(nValue)
- , nLen(0)
- , bIsNeg(false)
- , bIsBig(false)
- {
- }
-#endif
-
BigInt( double nVal );
BigInt( sal_uInt32 nVal );
BigInt( sal_Int64 nVal );
+ BigInt( sal_uInt64 nVal );
BigInt( const BigInt& rBigInt );
BigInt( const OUString& rString );
-
- operator sal_Int16() const;
- operator sal_uInt16() const;
- operator sal_Int32() const;
+// for some conversions, MSVC does not see int as being equivalent to sal_Int*
+#ifdef _WIN32
+ BigInt( int nVal ) : BigInt(static_cast<sal_Int64>(nVal)) {}
+#endif
+ inline operator sal_Int16() const;
+ inline operator sal_uInt16() const;
+ inline operator sal_Int32() const;
operator sal_uInt32() const;
+ operator sal_Int64() const;
+ operator sal_uInt64() const;
operator double() const;
-#if SAL_TYPES_SIZEOFPOINTER == 8
- operator tools::Long() const;
-#endif
bool IsNeg() const;
bool IsZero() const;
@@ -101,7 +94,13 @@ public:
BigInt& operator /=( const BigInt& rVal );
BigInt& operator %=( const BigInt& rVal );
- BigInt& operator =( sal_Int32 nValue );
+// for some conversions, MSVC does not see int as being equivalent to sal_Int*
+#ifdef _WIN32
+ inline BigInt& operator =( int nValue ) { return operator=(static_cast<sal_Int64>(nValue)); }
+#endif
+ inline BigInt& operator =( sal_Int32 nValue );
+ inline BigInt& operator =( sal_Int64 nValue ) { return *this = BigInt(nValue); }
+ inline BigInt& operator =( sal_uInt64 nValue ) { return *this = BigInt(nValue); }
friend inline BigInt operator +( const BigInt& rVal1, const BigInt& rVal2 );
friend inline BigInt operator -( const BigInt& rVal1, const BigInt& rVal2 );
@@ -143,25 +142,6 @@ inline BigInt::operator sal_Int32() const
return 0;
}
-inline BigInt::operator sal_uInt32() const
-{
- if ( !bIsBig && nVal >= 0 )
- return static_cast<sal_uInt32>(nVal);
- assert(false && "out of range");
- return 0;
-}
-
-#if SAL_TYPES_SIZEOFPOINTER == 8
-inline BigInt::operator tools::Long() const
-{
- // Clamp to int32 since long is int32 on Windows.
- if (!bIsBig)
- return nVal;
- assert(false && "out of range");
- return 0;
-}
-#endif
-
inline BigInt& BigInt::operator =( sal_Int32 nValue )
{
bIsBig = false;