]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/stream.cpp
Replaced ostream with FILE* in wxExpr.
[wxWidgets.git] / src / common / stream.cpp
index d5954d71d8c2340fd3383968df78354c960b6793..7d0e543fdb3343ff53edc3dc6ae1c992b2b7ac0e 100644 (file)
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+  #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+  #include "wx/defs.h"
+#endif
+
+#if wxUSE_STREAMS
+
 #include <ctype.h>
 #include <wx/stream.h>
 #include <wx/datstrm.h>
 #include <wx/objstrm.h>
 
-#ifdef __BORLANDC__
-#pragma hdrstop
-#endif
-
 #define BUF_TEMP_SIZE 10000
 
 // ----------------------------------------------------------------------------
@@ -277,6 +284,7 @@ char wxStreamBuffer::GetChar()
   }
 
   GetFromBuffer(&c, 1);
+  
   m_stream->m_lastcount = 1;
   return c;
 }
@@ -596,28 +604,29 @@ wxInputStream& wxInputStream::operator>>(char& c)
   return *this;
 }
 
-wxInputStream& wxInputStream::operator>>(short& i)
+wxInputStream& wxInputStream::operator>>(signed short& i)
 {
-  long l;
+  signed long l;
 
   *this >> l;
-  i = (short)l;
+  i = (signed short)l;
   return *this;
 }
 
-wxInputStream& wxInputStream::operator>>(int& i)
+wxInputStream& wxInputStream::operator>>(signed int& i)
 {
-  long l;
+  signed long l;
 
   *this >> l;
-  i = (short)l;
+  i = (signed int)l;
   return *this;
 }
 
-wxInputStream& wxInputStream::operator>>(long& i)
+wxInputStream& wxInputStream::operator>>(signed long& i)
 {
   /* I only implemented a simple integer parser */
-  int c, sign;
+  int c; 
+  int sign;
 
   while (isspace( c = GetC() ) )
      /* Do nothing */ ;
@@ -631,8 +640,12 @@ wxInputStream& wxInputStream::operator>>(long& i)
   if (c == '-') {
     sign = -1;
     c = GetC();
-  } else
+  } else if (c == '+') {
+    sign = 1;
+    c = GetC();
+  } else {
     sign = 1;
+  }
 
   while (isdigit(c)) {
     i = i*10 + c;
@@ -644,6 +657,46 @@ wxInputStream& wxInputStream::operator>>(long& i)
   return *this;
 }
 
+wxInputStream& wxInputStream::operator>>(unsigned short& i)
+{
+  unsigned long l;
+
+  *this >> l;
+  i = (unsigned short)l;
+  return *this;
+}
+
+wxInputStream& wxInputStream::operator>>(unsigned int& i)
+{
+  unsigned long l;
+
+  *this >> l;
+  i = (unsigned int)l;
+  return *this;
+}
+
+wxInputStream& wxInputStream::operator>>(unsigned long& i)
+{
+  /* I only implemented a simple integer parser */
+  int c;
+
+  while (isspace( c = GetC() ) )
+     /* Do nothing */ ;
+
+  i = 0;
+  if (!isdigit(c)) {
+    InputStreamBuffer()->WriteBack(c);
+    return *this;
+  }
+
+  while (isdigit(c)) {
+    i = i*10 + c;
+    c = GetC();
+  }
+
+  return *this;
+}
+
 wxInputStream& wxInputStream::operator>>(double& f)
 {
   /* I only implemented a simple float parser */
@@ -661,8 +714,12 @@ wxInputStream& wxInputStream::operator>>(double& f)
   if (c == '-') {
     sign = -1;
     c = GetC();
-  } else
+  } else if (c == '+') {
     sign = 1;
+    c = GetC();
+  } else {
+    sign = 1;
+  }
 
   while (isdigit(c)) {
     f = f*10 + (c - '0');
@@ -765,27 +822,41 @@ wxOutputStream& wxOutputStream::operator<<(char c)
   return Write(&c, 1);
 }
 
-wxOutputStream& wxOutputStream::operator<<(short i)
+wxOutputStream& wxOutputStream::operator<<(signed short i)
 {
-  wxString strint;
+  signed long l = (signed long)i;
+  return *this << l;
+}
 
-  strint.Printf(_T("%i"), i);
-  return *this << strint;
+wxOutputStream& wxOutputStream::operator<<(signed int i)
+{
+  signed long l = (signed long)i;
+  return *this << l;
 }
 
-wxOutputStream& wxOutputStream::operator<<(int i)
+wxOutputStream& wxOutputStream::operator<<(signed long i)
 {
-  wxString strint;
+  wxString strlong;
+  strlong.Printf(_T("%ld"), i);
+  return *this << strlong;
+}
 
-  strint.Printf(_T("%i"), i);
-  return *this << strint;
+wxOutputStream& wxOutputStream::operator<<(unsigned short i)
+{
+  unsigned long l = (unsigned long)i;
+  return *this << l;
 }
 
-wxOutputStream& wxOutputStream::operator<<(long i)
+wxOutputStream& wxOutputStream::operator<<(unsigned int i)
 {
-  wxString strlong;
+  unsigned long l = (unsigned long)i;
+  return *this << l;
+}
 
-  strlong.Printf(_T("%i"), i);
+wxOutputStream& wxOutputStream::operator<<(unsigned long i)
+{
+  wxString strlong;
+  strlong.Printf(_T("%lu"), i);
   return *this << strlong;
 }
 
@@ -855,3 +926,6 @@ wxOutputStream& wxEndL(wxOutputStream& stream)
   return stream.Write("\n", 1);
 #endif
 }
+
+#endif
+  // wxUSE_STREAMS