Add wxInt64 support to wxText{Input,Output}Stream.
Add explicit Read64[S]() and Write64() methods. Closes #14685. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -146,6 +146,21 @@ bool wxTextInputStream::EatEOL(const wxChar &c)
|
||||
return false;
|
||||
}
|
||||
|
||||
wxUint64 wxTextInputStream::Read64(int base)
|
||||
{
|
||||
wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
|
||||
if(!m_input) return 0;
|
||||
|
||||
wxString word = ReadWord();
|
||||
if(word.empty())
|
||||
return 0;
|
||||
|
||||
wxUint64 res;
|
||||
if(!word.ToULongLong(&res, base))
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
wxUint32 wxTextInputStream::Read32(int base)
|
||||
{
|
||||
wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
|
||||
@@ -167,6 +182,21 @@ wxUint8 wxTextInputStream::Read8(int base)
|
||||
return (wxUint8)Read32(base);
|
||||
}
|
||||
|
||||
wxInt64 wxTextInputStream::Read64S(int base)
|
||||
{
|
||||
wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
|
||||
if(!m_input) return 0;
|
||||
|
||||
wxString word = ReadWord();
|
||||
if(word.empty())
|
||||
return 0;
|
||||
|
||||
wxInt64 res;
|
||||
if(!word.ToLongLong(&res, base))
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
wxInt32 wxTextInputStream::Read32S(int base)
|
||||
{
|
||||
wxASSERT_MSG( !base || (base > 1 && base <= 36), wxT("invalid base") );
|
||||
@@ -287,6 +317,12 @@ wxTextInputStream& wxTextInputStream::operator>>(wxInt32& i)
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxInt64& i)
|
||||
{
|
||||
i = (wxInt64)Read64();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxUint16& i)
|
||||
{
|
||||
i = Read16();
|
||||
@@ -299,6 +335,12 @@ wxTextInputStream& wxTextInputStream::operator>>(wxUint32& i)
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxUint64& i)
|
||||
{
|
||||
i = Read64();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(double& i)
|
||||
{
|
||||
i = ReadDouble();
|
||||
@@ -354,6 +396,14 @@ void wxTextOutputStream::SetMode(wxEOL mode)
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextOutputStream::Write64(wxUint64 i)
|
||||
{
|
||||
wxString str;
|
||||
str.Printf(wxT("%" wxLongLongFmtSpec "u"), (unsigned long long)i);
|
||||
|
||||
WriteString(str);
|
||||
}
|
||||
|
||||
void wxTextOutputStream::Write32(wxUint32 i)
|
||||
{
|
||||
wxString str;
|
||||
@@ -495,6 +545,13 @@ wxTextOutputStream& wxTextOutputStream::operator<<(wxInt32 c)
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxInt64 c)
|
||||
{
|
||||
WriteString(wxString::Format("%" wxLongLongFmtSpec "d", c));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxUint16 c)
|
||||
{
|
||||
wxString str;
|
||||
@@ -513,6 +570,13 @@ wxTextOutputStream& wxTextOutputStream::operator<<(wxUint32 c)
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxUint64 c)
|
||||
{
|
||||
WriteString(wxString::Format("%" wxLongLongFmtSpec "u", c));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream &wxTextOutputStream::operator<<(double f)
|
||||
{
|
||||
WriteDouble(f);
|
||||
|
Reference in New Issue
Block a user