X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a4d2944e64d800134e26e36d7883b0914bc1f78d..03773e400b6ff2692f2a9ba045d652c3b7b7109d:/include/wx/longlong.h?ds=inline diff --git a/include/wx/longlong.h b/include/wx/longlong.h index 366ba7270f..71cb62bd4a 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -67,8 +67,8 @@ #define wxUSE_LONGLONG_NATIVE 0 #endif - class WXDLLIMPEXP_BASE wxLongLongWx; - class WXDLLIMPEXP_BASE wxULongLongWx; + class WXDLLIMPEXP_FWD_BASE wxLongLongWx; + class WXDLLIMPEXP_FWD_BASE wxULongLongWx; #if defined(__VISUALC__) && !defined(__WIN32__) #define wxLongLong wxLongLongWx #define wxULongLong wxULongLongWx @@ -86,8 +86,8 @@ #ifndef wxUSE_LONGLONG_WX #define wxUSE_LONGLONG_WX 0 - class WXDLLIMPEXP_BASE wxLongLongNative; - class WXDLLIMPEXP_BASE wxULongLongNative; + class WXDLLIMPEXP_FWD_BASE wxLongLongNative; + class WXDLLIMPEXP_FWD_BASE wxULongLongNative; typedef wxLongLongNative wxLongLong; typedef wxULongLongNative wxULongLong; #endif @@ -113,9 +113,9 @@ public: // from long long wxLongLongNative(wxLongLong_t ll) : m_ll(ll) { } // from 2 longs - wxLongLongNative(long hi, unsigned long lo) : m_ll(0) + wxLongLongNative(wxInt32 hi, wxUint32 lo) { - // assign first to avoid precision loss! + // cast to wxLongLong_t first to avoid precision loss! m_ll = ((wxLongLong_t) hi) << 32; m_ll |= (wxLongLong_t) lo; } @@ -129,15 +129,19 @@ public: // assignment operators // from native 64 bit integer +#ifndef wxLongLongIsLong wxLongLongNative& operator=(wxLongLong_t ll) { m_ll = ll; return *this; } wxLongLongNative& operator=(wxULongLong_t ll) { m_ll = ll; return *this; } +#endif // !wxLongLongNative wxLongLongNative& operator=(const wxULongLongNative &ll); wxLongLongNative& operator=(int l) { m_ll = l; return *this; } wxLongLongNative& operator=(long l) { m_ll = l; return *this; } + wxLongLongNative& operator=(unsigned int l) + { m_ll = l; return *this; } wxLongLongNative& operator=(unsigned long l) { m_ll = l; return *this; } #if wxUSE_LONGLONG_WX @@ -156,11 +160,11 @@ public: // accessors // get high part - long GetHi() const - { return wx_truncate_cast(long, m_ll >> 32); } + wxInt32 GetHi() const + { return wx_truncate_cast(wxInt32, m_ll >> 32); } // get low part - unsigned long GetLo() const - { return wx_truncate_cast(unsigned long, m_ll); } + wxUint32 GetLo() const + { return wx_truncate_cast(wxUint32, m_ll); } // get absolute value wxLongLongNative Abs() const { return wxLongLongNative(*this).Abs(); } @@ -173,7 +177,7 @@ public: long ToLong() const { wxASSERT_MSG( (m_ll >= LONG_MIN) && (m_ll <= LONG_MAX), - _T("wxLongLong to long conversion loss of precision") ); + wxT("wxLongLong to long conversion loss of precision") ); return wx_truncate_cast(long, m_ll); } @@ -346,9 +350,9 @@ public: // from long long wxULongLongNative(wxULongLong_t ll) : m_ll(ll) { } // from 2 longs - wxULongLongNative(unsigned long hi, unsigned long lo) : m_ll(0) + wxULongLongNative(wxUint32 hi, wxUint32 lo) : m_ll(0) { - // assign first to avoid precision loss! + // cast to wxLongLong_t first to avoid precision loss! m_ll = ((wxULongLong_t) hi) << 32; m_ll |= (wxULongLong_t) lo; } @@ -363,14 +367,18 @@ public: // assignment operators // from native 64 bit integer +#ifndef wxLongLongIsLong wxULongLongNative& operator=(wxULongLong_t ll) { m_ll = ll; return *this; } wxULongLongNative& operator=(wxLongLong_t ll) { m_ll = ll; return *this; } +#endif // !wxLongLongNative wxULongLongNative& operator=(int l) { m_ll = l; return *this; } wxULongLongNative& operator=(long l) { m_ll = l; return *this; } + wxULongLongNative& operator=(unsigned int l) + { m_ll = l; return *this; } wxULongLongNative& operator=(unsigned long l) { m_ll = l; return *this; } wxULongLongNative& operator=(const wxLongLongNative &ll) @@ -384,11 +392,11 @@ public: // accessors // get high part - unsigned long GetHi() const - { return wx_truncate_cast(unsigned long, m_ll >> 32); } + wxUint32 GetHi() const + { return wx_truncate_cast(wxUint32, m_ll >> 32); } // get low part - unsigned long GetLo() const - { return wx_truncate_cast(unsigned long, m_ll); } + wxUint32 GetLo() const + { return wx_truncate_cast(wxUint32, m_ll); } // convert to native ulong long wxULongLong_t GetValue() const { return m_ll; } @@ -397,11 +405,18 @@ public: unsigned long ToULong() const { wxASSERT_MSG( m_ll <= LONG_MAX, - _T("wxULongLong to long conversion loss of precision") ); + wxT("wxULongLong to long conversion loss of precision") ); return wx_truncate_cast(unsigned long, m_ll); } + // convert to double +#ifdef _MSC_VER + double ToDouble() const { return wx_truncate_cast(double, (__int64) m_ll); } +#else + double ToDouble() const { return wx_truncate_cast(double, m_ll); } +#endif + // operations // addition wxULongLongNative operator+(const wxULongLongNative& ll) const @@ -629,6 +644,12 @@ public: return *this; } + + wxLongLongWx& operator=(unsigned int l) + { + return operator=((unsigned long)l); + } + wxLongLongWx& operator=(const class wxULongLongWx &ll); // from double @@ -662,7 +683,7 @@ public: long ToLong() const { wxASSERT_MSG( (m_hi == 0l) || (m_hi == -1l), - _T("wxLongLong to long conversion loss of precision") ); + wxT("wxLongLong to long conversion loss of precision") ); return (long)m_lo; } @@ -887,11 +908,14 @@ public: unsigned long ToULong() const { wxASSERT_MSG( m_hi == 0ul, - _T("wxULongLong to long conversion loss of precision") ); + wxT("wxULongLong to long conversion loss of precision") ); return (unsigned long)m_lo; } + // convert to double + double ToDouble() const; + // operations // addition wxULongLongWx operator+(const wxULongLongWx& ll) const;