IByteSwapStreamIO Interface

Provides access to members that support the Byte Swap Helper object.

Members

Name Description
Method Read Perform a read byte swapping to the native format.
Read/write property Stream The stream to perform byte swap reads and writes to.
Method Write Perform a write byte swapping to the windows format.

IByteSwapStreamIO.Read Method

Perform a read byte swapping to the native format.

Public Sub Read ( _
    ByVal dataType As esriByteSwapDataType, _
    ByVal pv As IntPtr, _
    ByVal cb As Integer, _
    ByRef pcbRead As Integer _
)
public void Read (
    esriByteSwapDataType dataType,
    IntPtr pv,
    uint cb,
    ref uint pcbRead
);

Remarks

DataType [in]

User specified type of the data to perform swapping on.

pv [out]

A pointer to the buffer which the stream data is read into.

cb [in]

The number of bytes of data to read from the stream object.

pcbRead [out]

A pointer to a ULONG variable that receives the actual number of bytes

read from the stream object. It could be set to NULL. In this case,

the Read method does not provide the number of bytes read.

The Read method reads requested (in cb variable) number of bytes from the stream object into memory, starting at the current seek pointer, and swaps it into the native format. The actual number of bytes read can be less than it was requested if the end of the stream is reached during the read operation or an error can occur if nothing was read from the stream object.

VC++ example:

// Open the file and set it to be the stream object

IBlobStreamPtr ipBlobStream(CLSID_FileStream);IFilePtr ipFile(ipBlobStream);ipFile->Open(L"C:\\fileIn", esriReadOnly);IStreamPtr ipStream(ipFile);IByteSwapStreamIOPtr ipByteSwapStreamIO (CLSID_ByteSwapStreamIO);ipByteSwapStreamIO->putref_Stream(ipStream);

// Get the size of the stream

unsigned long size;ipBlobStream->get_Size(&size);

// Read and swap streamBYTE pv[14];ULONG pcbRead;ipByteSwapStreamIO->Read(esriBSDTBYTE, &pv, size, &pcbRead);

IByteSwapStreamIO.Stream Property

The stream to perform byte swap reads and writes to.

Public Property Stream As IStream
public IStream Stream {get; set;}

IByteSwapStreamIO.Write Method

Perform a write byte swapping to the windows format.

Public Sub Write ( _
    ByVal dataType As esriByteSwapDataType, _
    ByVal pv As IntPtr, _
    ByVal cb As Integer, _
    ByRef pcbWritten As Integer _
)
public void Write (
    esriByteSwapDataType dataType,
    IntPtr pv,
    uint cb,
    ref uint pcbWritten
);

Remarks

DataType [in]

User specified type of the data to perform swapping on.

pv [in]

A pointer to the buffer which contains the data that is to be written

to the stream object. A valid parameter should be provided.

cb [in]

The number of bytes of data to attempt to write into the stream. The value

can be zero.

pcbRead [out]

A pointer to a ULONG variable that receives the actual number of bytes

written to the stream object. It could be set to NULL. In this case,

the Write method does not provide the number of bytes written.

The Write method writes the specified number of bytes of data to the Stream object and performs a byte swapping on it. The number of bytes actually written to the stream is returned in pcbWritten parameter. If the byte count variable (pv) is zero byte, no data is written to the stream, and the Write operation has no effect.

VC++ example:

// Open the file and set it to be the stream objectIBlobStreamPtr ipBlobStream(CLSID_FileStream);IFilePtr ipFile(ipBlobStream);ipFile->Open(L"C:\\fileIn", esriReadOnly);IStreamPtr ipStream(ipFile);IByteSwapStreamIOPtr ipByteSwapStreamIO (CLSID_ByteSwapStreamIO);ipByteSwapStreamIO->putref_Stream(ipStream);

// Get the size of the stream

unsigned long size;ipBlobStream->get_Size(&size);

// Read and swap stream

BYTE pv[14];ULONG pcbRead;ipByteSwapStreamIO->Read(esriBSDTBYTE, &pv, size, &pcbRead);

// Open a file to write the stream to

DeleteFileW(L"C:\\fileOut");hr = ipFile->Open(L"C:\\fileOut", esriReadWrite);

// Write to the stream

ULONG pcbWritten;ipByteSwapStreamIO->Write(esriBSDTBYTE, c_pv, size, &pcbWritten);

Classes that implement IByteSwapStreamIO

Classes Description
ByteSwapStreamIO Helper object that performs byte swapping of data read and written to stream.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.