]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/longlong.h
A bugfix in the wxTreeCtrl.GetItem wrapper
[wxWidgets.git] / include / wx / longlong.h
index 3a502e70d79db0dabdba831ae8383d9122fcb698..454d7e5b8d0b9ecd4a1fdc0994b4fcde41fe1ac3 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <limits.h>     // for LONG_MAX
 
+#define wxUSE_LONGLONG_WX 1
+
 // ----------------------------------------------------------------------------
 // decide upon which class we will use
 // ----------------------------------------------------------------------------
@@ -41,6 +43,8 @@
     #define wxLongLongIsLong
 #elif (defined(__VISUALC__) && defined(__WIN32__)) || defined( __VMS__ )
     #define wxLongLong_t __int64
+#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x530)
+    #define wxLongLong_t __int64
 #elif defined(__GNUG__)
     #define wxLongLong_t long long
 #elif defined(__MWERKS__)
@@ -53,7 +57,9 @@
 #else // no native long long type
     // we don't give warnings for the compilers we know about that they don't
     // have any 64 bit integer type
-    #if !defined(__VISAGECPP__) && !defined(__VISUALC__)
+    #if !defined(__VISAGECPP__) && \
+        !defined(__VISUALC__) && \
+        !defined(__BORLANDC__
         #warning "Your compiler does not appear to support 64 bit integers, "\
                  "using emulation class instead."
     #endif // known compilers without long long
@@ -64,7 +70,7 @@
 // the user may predefine wxUSE_LONGLONG_NATIVE and/or wxUSE_LONGLONG_NATIVE
 // to disable automatic testing (useful for the test program which defines
 // both classes) but by default we only use one class
-#ifndef wxLongLong_t
+#if (defined(wxUSE_LONGLONG_WX) && wxUSE_LONGLONG_WX) || !defined(wxLongLong_t)
     #undef wxUSE_LONGLONG_NATIVE
     #define wxUSE_LONGLONG_NATIVE 0
     class WXDLLEXPORT wxLongLongWx;
@@ -136,6 +142,7 @@ public:
         { return (unsigned long)m_ll; }
 
         // get absolute value
+    wxLongLongNative Abs() const { return wxLongLongNative(*this).Abs(); }
     wxLongLongNative& Abs() { if ( m_ll < 0 ) m_ll = -m_ll; return *this; }
 
         // convert to native long long
@@ -325,6 +332,7 @@ public:
     unsigned long GetLo() const { return m_lo; }
 
         // get absolute value
+    wxLongLongWx Abs() const { return wxLongLongWx(*this).Abs(); }
     wxLongLongWx& Abs() { if ( m_hi < 0 ) m_hi = -m_hi; return *this; }
 
         // convert to long with range checking in the debug mode (only!)
@@ -381,12 +389,16 @@ public:
     wxLongLongWx operator~() const;
 
     // comparison
-    bool operator==(const wxLongLongWx& ll) const;
-    bool operator!=(const wxLongLongWx& ll) const;
+    bool operator==(const wxLongLongWx& ll) const
+        { return m_lo == ll.m_lo && m_hi == ll.m_hi; }
+    bool operator!=(const wxLongLongWx& ll) const
+        { return !(*this == ll); }
     bool operator<(const wxLongLongWx& ll) const;
     bool operator>(const wxLongLongWx& ll) const;
-    bool operator<=(const wxLongLongWx& ll) const;
-    bool operator>=(const wxLongLongWx& ll) const;
+    bool operator<=(const wxLongLongWx& ll) const
+        { return *this < ll || *this == ll; }
+    bool operator>=(const wxLongLongWx& ll) const
+        { return *this > ll || *this == ll; }
 
     // multiplication
     wxLongLongWx operator*(const wxLongLongWx& ll) const;
@@ -418,4 +430,18 @@ private:
 
 #endif // wxUSE_LONGLONG_WX
 
+// ----------------------------------------------------------------------------
+// binary operators
+// ----------------------------------------------------------------------------
+
+inline bool WXDLLEXPORT operator<(long l, const wxLongLong& ll) { return ll > l; }
+inline bool WXDLLEXPORT operator>(long l, const wxLongLong& ll) { return ll > l; }
+inline bool WXDLLEXPORT operator<=(long l, const wxLongLong& ll) { return ll > l; }
+inline bool WXDLLEXPORT operator>=(long l, const wxLongLong& ll) { return ll > l; }
+inline bool WXDLLEXPORT operator==(long l, const wxLongLong& ll) { return ll > l; }
+inline bool WXDLLEXPORT operator!=(long l, const wxLongLong& ll) { return ll > l; }
+
+inline wxLongLong WXDLLEXPORT operator+(long l, const wxLongLong& ll) { return ll + l; }
+inline wxLongLong WXDLLEXPORT operator-(long l, const wxLongLong& ll) { return ll - l; }
+
 #endif // _WX_LONGLONG_H