Main Page | Class Hierarchy | Class List | File List | Class Members

SST::XdrStream Class Reference

XDR encoding/decoding stream. More...

#include <xdr.h>

List of all members.

Public Types

enum  Status { Ok = 0, ReadPastEnd, ReadCorruptData, IOError }

Public Member Functions

 XdrStream ()
 Create a fresh XdrStream with no QIODevice.

 XdrStream (QIODevice *d)
 Create an XdrStream to encode to/decode from a given QIODevice.

 XdrStream (QByteArray *a, QIODevice::OpenMode mode)
 Create an XdrStream and an internal QBuffer device to encode to and/or decode from a specified QByteArray.

 XdrStream (const QByteArray &a)
 Create a read-only XdrStream to decode from a given QByteArray.

QIODevice * device ()
 Return the current QIODevice that this XdrStream refers to.

void setDevice (QIODevice *d)
 Change this XdrStream to encode to/decode from a different device.

Status status () const
 Returns the current encoding/decoding status.

void setStatus (Status st)
 Set the current encode/decode status flag.

void resetStatus ()
 Reset the status to the initial Ok state.

bool atEnd ()
 Returns true if we have read to the end of the underlying device.

void readRawData (void *buf, int len)
 Read raw data from the underlying QIODevice.

void skipRawData (int len)
 Skip over a given number of bytes on the underlying QIODevice.

void writeRawData (const void *buf, int len)
 Write raw data to the underlying QIODevice.

void readPadData (void *buf, int len)
 Read a given number of bytes of raw data, then skip 0-3 bytes to pad the raw block length to a 4-byte boundary as the XDR spec requires.

void skipPadData (int len)
 Skip len bytes, rounded up to the next 4-byte boundary.

void writePadData (const void *buf, int len)
 Write a specified block of raw data, followed by 0-3 zero bytes to pad the data block to a 4-byte boundary as the XDR spec requires.

void readBytes (char *&s, qint32 &len)
 XDR-decode an 'opaque' field.

void writeBytes (const char *s, qint32 len)
 XDR-encode an 'opaque' field.

XdrStreamoperator<< (bool b)
 XDR-encode a boolean.

XdrStreamoperator<< (qint8 i)
 Encode an 8-bit integer (XDR 'char').

XdrStreamoperator<< (qint16 i)
 Encode a 16-bit integer (XDR 'short').

XdrStreamoperator<< (qint32 i)
 Encode a 32-bit integer (XDR 'int').

XdrStreamoperator<< (qint64 i)
 Encode a 64-bit integer (XDR 'hyper').

XdrStreamoperator<< (quint8 i)
 Encode an 8-bit unsigned integer (XDR 'unsigned char').

XdrStreamoperator<< (quint16 i)
 Encode a 16-bit unsigned integer (XDR 'unsigned short').

XdrStreamoperator<< (quint32 i)
 Encode a 32-bit unsigned integer (XDR 'unsigned int').

XdrStreamoperator<< (quint64 i)
 Encode a 64-bit unsigned integer (XDR 'unsigned hyper').

XdrStreamoperator<< (float f)
 Encode a 32-bit IEEE floating-point value (XDR 'float').

XdrStreamoperator<< (double f)
 Encode a 64-bit IEEE floating-point value (XDR 'double').

XdrStreamoperator>> (bool &b)
 XDR-decode a boolean.

XdrStreamoperator>> (qint8 &i)
 Decode an 8-bit integer (XDR 'char').

XdrStreamoperator>> (qint16 &i)
 Decode a 16-bit integer (XDR 'short').

XdrStreamoperator>> (qint32 &i)
 Decode a 32-bit integer (XDR 'int').

XdrStreamoperator>> (qint64 &i)
 Decode a 64-bit integer (XDR 'hyper').

XdrStreamoperator>> (quint8 &i)
 Decode an 8-bit unsigned integer (XDR 'unsigned char').

XdrStreamoperator>> (quint16 &i)
 Decode a 16-bit unsigned integer (XDR 'unsigned short').

XdrStreamoperator>> (quint32 &i)
 Decode a 32-bit unsigned integer (XDR 'unsigned int').

XdrStreamoperator>> (quint64 &i)
 Decode a 64-bit unsigned integer (XDR 'unsigned hyper').

XdrStreamoperator>> (float &f)
 Decode a 32-bit IEEE floating-point value (XDR 'float').

XdrStreamoperator>> (double &f)
 Decode a 64-bit IEEE floating-point value (XDR 'double').

XdrStreamoperator>> (QByteArray &a)
 Encode a QByteArray as a variable-length XDR 'opaque' field.

XdrStreamoperator<< (const QByteArray &a)
 Decode a variable-length XDR 'opaque' field into a QByteArray.

XdrStreamoperator<< (const QString &s)
 Encode a QString as an XDR 'string' using UTF-8 encoding.

XdrStreamoperator>> (QString &s)
 Decode an XDR 'string' into a QString using UTF-8 encoding.

QString errorString ()
 Return a string describing the last encoding or decoding error that occurred, if any.


Detailed Description

XDR encoding/decoding stream.

This class provides an interface modeled on QDataStream, but uses the XDR encoding as specified in RFC 1832.


Constructor & Destructor Documentation

XdrStream::XdrStream  ) 
 

Create a fresh XdrStream with no QIODevice.

A device must be set with setDevice() before using.

XdrStream::XdrStream QIODevice *  d  ) 
 

Create an XdrStream to encode to/decode from a given QIODevice.

The caller is responsible for ensuring that the QIODevice pointer remains valid for the lifetime of this XdrStream.


Member Function Documentation

void XdrStream::readBytes char *&  s,
qint32 &  len
 

XDR-decode an 'opaque' field.

Allocates a new char[] array to hold the opaque data, and returns the pointer and array length in "out" parameters.

Parameters:
s a variable in which this method returns a pointer to the opaque data buffer.
len a variable in which this method returns the length of the opaque data.

void SST::XdrStream::readRawData void *  buf,
int  len
[inline]
 

Read raw data from the underlying QIODevice.

This method does not perform any XDR decoding.

void SST::XdrStream::skipRawData int  len  )  [inline]
 

Skip over a given number of bytes on the underlying QIODevice.

This method does not perform any XDR decoding, and it requires that the underlying device support seeking.

void XdrStream::writeBytes const char *  s,
qint32  len
 

XDR-encode an 'opaque' field.

Parameters:
s a pointer to the opaque data to encode.
len the length of the opaque data in bytes.

void SST::XdrStream::writeRawData const void *  buf,
int  len
[inline]
 

Write raw data to the underlying QIODevice.

This method does not perform any XDR encoding.


The documentation for this class was generated from the following files:
Generated on Wed Mar 28 11:48:05 2007 for SST by doxygen 1.3.4