X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2f02cb8966964ea7a6f5d875ed9f3434ea05ab59..6e807169c4b63b29b42c36ae15141a31adb29204:/include/wx/longlong.h

diff --git a/include/wx/longlong.h b/include/wx/longlong.h
index c9b582b7a3..1e5ee03100 100644
--- a/include/wx/longlong.h
+++ b/include/wx/longlong.h
@@ -19,6 +19,12 @@
     #pragma interface "longlong.h"
 #endif
 
+#include "wx/defs.h"
+#include "wx/wxchar.h"
+#include "wx/debug.h"
+
+#include <limits.h>     // for LONG_MAX
+
 // ----------------------------------------------------------------------------
 // decide upon which class we will use
 // ----------------------------------------------------------------------------
@@ -124,6 +130,15 @@ public:
         // convert to native long long
     wxLongLong_t GetValue() const { return m_ll; }
 
+        // convert to long with range checking in the debug mode (only!)
+    long ToLong() const
+    {
+        wxASSERT_MSG( (m_ll >= LONG_MIN) && (m_ll <= LONG_MAX),
+                      _T("wxLongLong to long conversion loss of precision") );
+
+        return (long)m_ll;
+    }
+
     // don't provide implicit conversion to wxLongLong_t or we will have an
     // ambiguity for all arithmetic operations
     //operator wxLongLong_t() const { return m_ll; }
@@ -254,8 +269,10 @@ public:
         // conversion to byte array: returns a pointer to static buffer!
     void *asArray() const;
 
+#if wxUSE_STD_IOSTREAM
         // input/output
     friend ostream& operator<<(ostream&, const wxLongLongNative&);
+#endif
 
 private:
     wxLongLong_t  m_ll;
@@ -356,8 +373,10 @@ public:
                 wxLongLongWx& quotient,
                 wxLongLongWx& remainder) const;
 
+#if wxUSE_STD_IOSTREAM
     // input/output
     friend ostream& operator<<(ostream&, const wxLongLongWx&);
+#endif // wxUSE_STD_IOSTREAM
 
 private:
     // long is at least 32 bits, so represent our 64bit number as 2 longs