Version: 2.9.4
Public Member Functions
wxDataInputStream Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/datstrm.h>


Detailed Description

このクラスは移植性のある方法でバイナリデータを読み込む機能を提供します。

Data can be read in either big-endian or little-endian format, little-endian being the default on all architectures.

If you want to read data from text files (or streams) use wxTextInputStream instead.

The ">>" operator is overloaded and you can use this class like a standard C++ iostream. Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc and on a typical 32-bit computer, none of these match to the "long" type (wxInt32 is defined as signed int on 32-bit architectures) so that you cannot use long. To avoid problems (here and elsewhere), make use of the wxInt32, wxUint32, etc types.

以下に例を示します:

    wxFileInputStream input( "mytext.dat" );
    wxDataInputStream store( input );
    wxUint8 i1;
    float f2;
    wxString line;

    store >> i1;       // read a 8 bit integer.
    store >> i1 >> f2; // read a 8 bit integer followed by float.
    store >> line;     // read a text line

Library:  wxBase
Category:  Streams
参照:
wxDataOutputStream

Public Member Functions

 wxDataInputStream (wxInputStream &stream, const wxMBConv &conv=wxConvUTF8)
 Constructs a datastream object from an input stream.
 ~wxDataInputStream ()
 Destroys the wxDataInputStream object.
void BigEndianOrdered (bool be_order)
 If be_order is true, all data will be read in big-endian order, such as written by programs on a big endian architecture (e.g.
wxMBConvGetConv () const
 Returns the current text conversion class used for reading strings.
wxUint8 Read8 ()
 Reads a single byte from the stream.
void Read8 (wxUint8 *buffer, size_t size)
 Reads bytes from the stream in a specified buffer.
wxUint16 Read16 ()
 Reads a 16 bit unsigned integer from the stream.
void Read16 (wxUint16 *buffer, size_t size)
 Reads 16 bit unsigned integers from the stream in a specified buffer.
wxUint32 Read32 ()
 Reads a 32 bit unsigned integer from the stream.
void Read32 (wxUint32 *buffer, size_t size)
 Reads 32 bit unsigned integers from the stream in a specified buffer.
wxUint64 Read64 ()
 Reads a 64 bit unsigned integer from the stream.
void Read64 (wxUint64 *buffer, size_t size)
 Reads 64 bit unsigned integers from the stream in a specified buffer.
double ReadDouble ()
 Reads a double (IEEE encoded) from the stream.
void ReadDouble (double *buffer, size_t size)
 Reads double data (IEEE encoded) from the stream in a specified buffer.
wxString ReadString ()
 Reads a string from a stream.
void SetConv (const wxMBConv &conv)
 Sets the text conversion class used for reading strings.

List of all members.


Constructor & Destructor Documentation

wxDataInputStream::wxDataInputStream ( wxInputStream stream,
const wxMBConv conv = wxConvUTF8 
)

Constructs a datastream object from an input stream.

Only read methods will be available.

Note that the conv parameter is only available in Unicode builds of wxWidgets.

Parameters:
streamThe input stream.
convCharset conversion object used to decode strings in Unicode mode (see ReadString() for a detailed description). Note that you must not destroy conv before you destroy this wxDataInputStream instance!
wxDataInputStream::~wxDataInputStream ( )

Destroys the wxDataInputStream object.


Member Function Documentation

void wxDataInputStream::BigEndianOrdered ( bool  be_order)

If be_order is true, all data will be read in big-endian order, such as written by programs on a big endian architecture (e.g.

Sparc) or written by Java-Streams (which always use big-endian order).

wxMBConv* wxDataInputStream::GetConv ( ) const

Returns the current text conversion class used for reading strings.

wxUint16 wxDataInputStream::Read16 ( )

Reads a 16 bit unsigned integer from the stream.

void wxDataInputStream::Read16 ( wxUint16 buffer,
size_t  size 
)

Reads 16 bit unsigned integers from the stream in a specified buffer.

The amount of 16 bit unsigned integers to read is specified by the size variable.

void wxDataInputStream::Read32 ( wxUint32 buffer,
size_t  size 
)

Reads 32 bit unsigned integers from the stream in a specified buffer.

The amount of 32 bit unsigned integers to read is specified by the size variable.

wxUint32 wxDataInputStream::Read32 ( )

Reads a 32 bit unsigned integer from the stream.

wxUint64 wxDataInputStream::Read64 ( )

Reads a 64 bit unsigned integer from the stream.

void wxDataInputStream::Read64 ( wxUint64 buffer,
size_t  size 
)

Reads 64 bit unsigned integers from the stream in a specified buffer.

The amount of 64 bit unsigned integers to read is specified by the size variable.

void wxDataInputStream::Read8 ( wxUint8 buffer,
size_t  size 
)

Reads bytes from the stream in a specified buffer.

The amount of bytes to read is specified by the size variable.

wxUint8 wxDataInputStream::Read8 ( )

Reads a single byte from the stream.

void wxDataInputStream::ReadDouble ( double *  buffer,
size_t  size 
)

Reads double data (IEEE encoded) from the stream in a specified buffer.

The amount of doubles to read is specified by the size variable.

double wxDataInputStream::ReadDouble ( )

Reads a double (IEEE encoded) from the stream.

wxString wxDataInputStream::ReadString ( )

Reads a string from a stream.

Actually, this function first reads a long integer specifying the length of the string (without the last null character) and then reads the string.

In Unicode build of wxWidgets, the fuction first reads multibyte (char*) string from the stream and then converts it to Unicode using the conv object passed to constructor and returns the result as wxString. You are responsible for using the same converter as when writing the stream.

参照:
wxDataOutputStream::WriteString()
void wxDataInputStream::SetConv ( const wxMBConv conv)

Sets the text conversion class used for reading strings.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines