+template <class T>
+static
+void DoWriteI64(const T *buffer, size_t size, wxOutputStream *output, bool be_order)
+{
+ typedef T DataType;
+ if ( be_order )
+ {
+ for ( size_t i = 0; i < size; i++ )
+ {
+ DataType i64 = wxUINT64_SWAP_ON_LE(*buffer);
+ buffer++;
+ output->Write(&i64, 8);
+ }
+ }
+ else // little endian
+ {
+ for ( size_t i=0; i < size; i++ )
+ {
+ DataType i64 = wxUINT64_SWAP_ON_BE(*buffer);
+ buffer++;
+ output->Write(&i64, 8);
+ }
+ }
+}
+
+#endif // wxLongLong_t
+
+
+#if wxHAS_INT64
+void wxDataInputStream::Read64(wxUint64 *buffer, size_t size)
+{
+#ifndef wxLongLong_t
+ DoReadLL(buffer, size, m_input, m_be_order);
+#else
+ DoReadI64(buffer, size, m_input, m_be_order);
+#endif
+}
+
+void wxDataInputStream::Read64(wxInt64 *buffer, size_t size)
+{
+#ifndef wxLongLong_t
+ DoReadLL(buffer, size, m_input, m_be_order);
+#else
+ DoReadI64(buffer, size, m_input, m_be_order);
+#endif
+}
+#endif // wxHAS_INT64
+
+#if defined(wxLongLong_t) && wxUSE_LONGLONG
+void wxDataInputStream::Read64(wxULongLong *buffer, size_t size)
+{
+ DoReadLL(buffer, size, m_input, m_be_order);
+}
+
+void wxDataInputStream::Read64(wxLongLong *buffer, size_t size)
+{
+ DoReadLL(buffer, size, m_input, m_be_order);
+}
+#endif // wxLongLong_t
+
+#if wxUSE_LONGLONG
+void wxDataInputStream::ReadLL(wxULongLong *buffer, size_t size)
+{
+ DoReadLL(buffer, size, m_input, m_be_order);
+}
+
+void wxDataInputStream::ReadLL(wxLongLong *buffer, size_t size)
+{
+ DoReadLL(buffer, size, m_input, m_be_order);
+}
+
+wxLongLong wxDataInputStream::ReadLL(void)
+{
+ wxLongLong ll;
+ DoReadLL(&ll, (size_t)1, m_input, m_be_order);
+ return ll;
+}
+#endif // wxUSE_LONGLONG
+
+void wxDataInputStream::Read32(wxUint32 *buffer, size_t size)
+{
+ m_input->Read(buffer, size * 4);
+
+ if (m_be_order)
+ {
+ for (wxUint32 i=0; i<size; i++)
+ {
+ wxUint32 v = wxUINT32_SWAP_ON_LE(*buffer);
+ *(buffer++) = v;
+ }
+ }
+ else
+ {
+ for (wxUint32 i=0; i<size; i++)
+ {
+ wxUint32 v = wxUINT32_SWAP_ON_BE(*buffer);
+ *(buffer++) = v;
+ }
+ }
+}
+
+void wxDataInputStream::Read16(wxUint16 *buffer, size_t size)
+{
+ m_input->Read(buffer, size * 2);
+
+ if (m_be_order)
+ {
+ for (wxUint32 i=0; i<size; i++)
+ {
+ wxUint16 v = wxUINT16_SWAP_ON_LE(*buffer);
+ *(buffer++) = v;
+ }
+ }
+ else
+ {
+ for (wxUint32 i=0; i<size; i++)
+ {
+ wxUint16 v = wxUINT16_SWAP_ON_BE(*buffer);
+ *(buffer++) = v;
+ }
+ }
+}
+
+void wxDataInputStream::Read8(wxUint8 *buffer, size_t size)
+{
+ m_input->Read(buffer, size);
+}
+
+void wxDataInputStream::ReadDouble(double *buffer, size_t size)
+{
+ for (wxUint32 i=0; i<size; i++)
+ {
+ *(buffer++) = ReadDouble();
+ }
+}
+
+void wxDataInputStream::ReadFloat(float *buffer, size_t size)
+{
+ for (wxUint32 i=0; i<size; i++)
+ {
+ *(buffer++) = ReadFloat();
+ }
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxString& s)
+{
+ s = ReadString();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxInt8& c)
+{
+ c = (wxInt8)Read8();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxInt16& i)
+{
+ i = (wxInt16)Read16();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxInt32& i)
+{
+ i = (wxInt32)Read32();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxUint8& c)
+{
+ c = Read8();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxUint16& i)
+{
+ i = Read16();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxUint32& i)
+{
+ i = Read32();
+ return *this;
+}
+
+#if wxHAS_INT64
+wxDataInputStream& wxDataInputStream::operator>>(wxUint64& i)
+{
+ i = Read64();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxInt64& i)
+{
+ i = Read64();
+ return *this;
+}
+#endif // wxHAS_INT64
+
+#if defined(wxLongLong_t) && wxUSE_LONGLONG
+wxDataInputStream& wxDataInputStream::operator>>(wxULongLong& i)
+{
+ i = ReadLL();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(wxLongLong& i)
+{
+ i = ReadLL();
+ return *this;
+}
+#endif // wxLongLong_t
+
+wxDataInputStream& wxDataInputStream::operator>>(double& d)
+{
+ d = ReadDouble();
+ return *this;
+}
+
+wxDataInputStream& wxDataInputStream::operator>>(float& f)
+{
+ f = ReadFloat();
+ return *this;