X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/191549ed17cc522034a85bc6f313d47335302e7e..0131687bb53c2d10fec2af13f74ccc458698053a:/src/common/txtstrm.cpp diff --git a/src/common/txtstrm.cpp b/src/common/txtstrm.cpp index 2c628cf3d6..cd0300b42d 100644 --- a/src/common/txtstrm.cpp +++ b/src/common/txtstrm.cpp @@ -61,8 +61,6 @@ wxChar wxTextInputStream::NextNonSeparators() return c; } - // this shouldn't happen - return (wxChar) 0; } inline bool wxTextInputStream::EatEOL(const wxChar &c) @@ -152,7 +150,7 @@ double wxTextInputStream::ReadDouble() if (c==(wxChar)0) return 0; f = 0.0; - if (! (c == wxT('.') || c == wxT('-') || c == wxT('+') || isdigit(c)) ) + if (! (c == wxT('.') || c == wxT(',') || c == wxT('-') || c == wxT('+') || isdigit(c)) ) { m_input.Ungetch(c); return 0.0; @@ -179,7 +177,7 @@ double wxTextInputStream::ReadDouble() c = m_input.GetC(); } - if (c == wxT('.')) + if (c == wxT('.') || c == wxT(',')) { double f_multiplicator = (double) 0.1; @@ -325,15 +323,41 @@ wxTextInputStream& wxTextInputStream::operator>>(float& f) return *this; } -wxTextOutputStream::wxTextOutputStream(wxOutputStream& s) +wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode) : m_output(s) { + m_mode = mode; + if (m_mode == wxEOL_NATIVE) + { +#if defined(__WXMSW__) || defined(__WXPM__) + m_mode = wxEOL_DOS; +#elif defined(__WXMAC__) + m_mode = wxEOL_MAC; +#else + m_mode = wxEOL_UNIX; +#endif + } } wxTextOutputStream::~wxTextOutputStream() { } +void wxTextOutputStream::SetMode(wxEOL mode) +{ + m_mode = mode; + if (m_mode == wxEOL_NATIVE) + { +#if defined(__WXMSW__) || defined(__WXPM__) + m_mode = wxEOL_DOS; +#elif defined(__WXMAC__) + m_mode = wxEOL_MAC; +#else + m_mode = wxEOL_UNIX; +#endif + } +} + void wxTextOutputStream::Write32(wxUint32 i) { wxString str; @@ -373,25 +397,22 @@ void wxTextOutputStream::WriteString(const wxString& string) wxChar c = string[i]; if (c == wxT('\n')) { -#if defined(__WINDOWS__) - c = wxT('\r'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); - c = wxT('\n'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); -#elif defined(__UNIX__) - c = wxT('\n'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); -#elif defined(__WXMAC__) - c = wxT('\r'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); -#elif defined(__OS2__) - c = wxT('\r'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); - c = wxT('\n'); - m_output.Write( (const void*)(&c), sizeof(wxChar) ); -#else - #error "wxTextOutputStream: unsupported platform." -#endif + if (m_mode == wxEOL_DOS) + { + c = wxT('\r'); + m_output.Write( (const void*)(&c), sizeof(wxChar) ); + c = wxT('\n'); + m_output.Write( (const void*)(&c), sizeof(wxChar) ); + } else + if (m_mode == wxEOL_MAC) + { + c = wxT('\r'); + m_output.Write( (const void*)(&c), sizeof(wxChar) ); + } else + { + c = wxT('\n'); + m_output.Write( (const void*)(&c), sizeof(wxChar) ); + } } else { @@ -420,25 +441,37 @@ wxTextOutputStream& wxTextOutputStream::operator<<(wxChar c) wxTextOutputStream& wxTextOutputStream::operator<<(wxInt16 c) { - Write16( (wxUint16)c ); + wxString str; + str.Printf(wxT("%d"), (signed int)c); + WriteString(str); + return *this; } wxTextOutputStream& wxTextOutputStream::operator<<(wxInt32 c) { - Write32( (wxUint32)c ); + wxString str; + str.Printf(wxT("%ld"), (signed long)c); + WriteString(str); + return *this; } wxTextOutputStream& wxTextOutputStream::operator<<(wxUint16 c) { - Write16(c); + wxString str; + str.Printf(wxT("%u"), (unsigned int)c); + WriteString(str); + return *this; } wxTextOutputStream& wxTextOutputStream::operator<<(wxUint32 c) { - Write32(c); + wxString str; + str.Printf(wxT("%lu"), (unsigned long)c); + WriteString(str); + return *this; }