SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWXDRistream Class Reference

A portable input stream based on XDR routines. More...

#include <rw/xdrstrea.h>

Inheritance diagram for RWXDRistream:
RWvistream RWvios

Public Member Functions

 RWXDRistream (std::istream &str)
 
 RWXDRistream (std::streambuf *sb)
 
 RWXDRistream (XDR *xp)
 
virtual ~RWXDRistream ()
 
virtual int bad ()
 
virtual void clear (int v=0)
 
virtual int eof ()
 
virtual int fail ()
 
virtual int get ()
 
virtual RWvistreamget (bool &b)
 
virtual RWvistreamget (bool *, size_t n)
 
virtual RWvistreamget (char &c)
 
virtual RWvistreamget (char *v, size_t n)
 
virtual RWvistreamget (double &d)
 
virtual RWvistreamget (double *v, size_t n)
 
virtual RWvistreamget (float &f)
 
virtual RWvistreamget (float *v, size_t n)
 
virtual RWvistreamget (int &i)
 
virtual RWvistreamget (int *v, size_t n)
 
virtual RWvistreamget (long &i)
 
virtual RWvistreamget (long *v, size_t n)
 
virtual RWvistreamget (long double &)
 
virtual RWvistreamget (long double *, size_t)
 
virtual RWvistreamget (long long &i)
 
virtual RWvistreamget (long long *v, size_t n)
 
virtual RWvistreamget (short &i)
 
virtual RWvistreamget (short *v, size_t n)
 
virtual RWvistreamget (signed char &c)
 
virtual RWvistreamget (signed char *v, size_t n)
 
virtual RWvistreamget (unsigned char &c)
 
virtual RWvistreamget (unsigned char *v, size_t n)
 
virtual RWvistreamget (unsigned int &i)
 
virtual RWvistreamget (unsigned int *v, size_t n)
 
virtual RWvistreamget (unsigned long &i)
 
virtual RWvistreamget (unsigned long *v, size_t n)
 
virtual RWvistreamget (unsigned long long &i)
 
virtual RWvistreamget (unsigned long long *v, size_t n)
 
virtual RWvistreamget (unsigned short &i)
 
virtual RWvistreamget (unsigned short *v, size_t n)
 
virtual RWvistreamget (wchar_t &wc)
 
virtual RWvistreamget (wchar_t *, size_t n)
 
virtual RWvistreamgetChar (char &c)
 
virtual RWvistreamgetChar (signed char &c)
 
virtual RWvistreamgetChar (unsigned char &c)
 
virtual RWvistreamgetChar (wchar_t &wc)
 
virtual RWvistreamgetChars (char *s, size_t n)
 
virtual RWvistreamgetSizeT (size_t &sz)
 
virtual RWvistreamgetString (char *s, size_t n)
 
virtual int good ()
 
virtual int rdstate ()
 
- Public Member Functions inherited from RWvistream
virtual ~RWvistream ()
 
unsigned version () const
 
void version (unsigned v)
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Additional Inherited Members

Detailed Description

Class RWXDRistream is a portable input stream based on XDR routines. Class RWXDRistream encapsulates a portion of the XDR library routines that are used for external data representation. XDR routines allow programmers to describe arbitrary data structures in a machine-independent fashion. Data for remote procedure calls (RPC) are transmitted using XDR routines.

Class RWXDRistream enables decoding an XDR structure to a machine representation, providing the ability to decode all the standard data types and vectors of those data types.

An XDR stream must first be created by calling the appropriate creation routine. XDR streams currently exist for encoding/decoding of data to or from standard iostreams and file streams, TCP/IP connections and Unix files, and memory. These creation routines take arguments that are tailored to the specific properties of the stream. After the XDR stream has been created, it can then be used as the argument to the constructor for a RWXDRistream object.

RWXDRistream can be interrogated as to the status of the stream using member functions bad(), clear(), eof(), fail(), good(), and rdstate().

Condition:
This class is not supported on Windows.
Synopsis
#include <rw/xdrstrea.h>
XDR xdr;
xdrstdio_create(&xdr, stdin, XDR_DECODE);
RWXDRistream rw_xdr(&xdr);
A portable input stream based on XDR routines.
Definition xdrstrea.h:121
Persistence
None
Example
#include <rw/xdrstrea.h>
#include <iostream>
int main() {
XDR xdr;
FILE* fp = fopen("test", "r+");
if (fp == 0) {
std::cout << "Run xdrostrm first.\n";
return 1;
}
xdrstdio_create(&xdr, fp, XDR_DECODE);
RWXDRistream rw_xdr(&xdr);
int data;
for (int i = 0; i < 10; ++i) {
rw_xdr >> data; // decode integer data
if (data == i) {
std::cout << data << std::endl;
} else {
std::cout << "Bad input value" << std::endl;
}
}
fclose(fp);
return 0;
}

Constructor & Destructor Documentation

◆ RWXDRistream() [1/3]

RWXDRistream::RWXDRistream ( XDR * xp)

Initializes an RWXDRistream from the XDR structure xp.

◆ RWXDRistream() [2/3]

RWXDRistream::RWXDRistream ( std::streambuf * sb)

Initializes an RWXDRistream from the std::streambuf sb. sb must already be allocated.

◆ RWXDRistream() [3/3]

RWXDRistream::RWXDRistream ( std::istream & str)

Initializes an RWXDRistream from the std::streambuf associated with the std::istream str.

◆ ~RWXDRistream()

virtual RWXDRistream::~RWXDRistream ( )
virtual

Deallocates previously allocated resources.

Member Function Documentation

◆ bad()

virtual int RWXDRistream::bad ( )
inlinevirtual

Returns a nonzero integer if the bad bit has been set. Normally this indicates that a severe error has occurred from which recovery is probably impossible.

Implements RWvistream.

◆ clear()

virtual void RWXDRistream::clear ( int v = 0)
inlinevirtual

Sets the current error state to v. If v is zero, then this clears the error state.

Implements RWvistream.

◆ eof()

virtual int RWXDRistream::eof ( )
inlinevirtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvistream.

◆ fail()

virtual int RWXDRistream::fail ( )
inlinevirtual

Returns a nonzero integer if the failed or bad bit has been set. Normally, this indicates that some storage or retrieval has failed, but that the stream is still in a usable state.

Implements RWvistream.

◆ get() [1/33]

virtual int RWXDRistream::get ( )
virtual

Gets and returns the next byte from the input stream, returning its value. Returns EOF if end of file is encountered.

Implements RWvistream.

◆ get() [2/33]

virtual RWvistream & RWXDRistream::get ( bool & b)
virtual

Gets the next bool from the input stream, returning its value in b.

Implements RWvistream.

◆ get() [3/33]

virtual RWvistream & RWXDRistream::get ( bool * v,
size_t n )
virtual

Gets a vector of n bool and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [4/33]

virtual RWvistream & RWXDRistream::get ( char & c)
virtual

Gets the next char from the input stream, returning its value in c.

Implements RWvistream.

◆ get() [5/33]

virtual RWvistream & RWXDRistream::get ( char * v,
size_t n )
virtual

Gets a vector of n char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Note
This method retrieves raw characters and does not perform any conversions on special characters such as '\n'.

Implements RWvistream.

◆ get() [6/33]

virtual RWvistream & RWXDRistream::get ( double & d)
virtual

Gets the next double from the input stream, returning its value in d.

Implements RWvistream.

◆ get() [7/33]

virtual RWvistream & RWXDRistream::get ( double * v,
size_t n )
virtual

Gets a vector of n double and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [8/33]

virtual RWvistream & RWXDRistream::get ( float & f)
virtual

Gets the next float from the input stream, returning its value in f.

Implements RWvistream.

◆ get() [9/33]

virtual RWvistream & RWXDRistream::get ( float * v,
size_t n )
virtual

Gets a vector of n float and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [10/33]

virtual RWvistream & RWXDRistream::get ( int & i)
virtual

Gets the next int from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [11/33]

virtual RWvistream & RWXDRistream::get ( int * v,
size_t n )
virtual

Gets a vector of n int and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [12/33]

virtual RWvistream & RWXDRistream::get ( long & i)
virtual

Gets the next long from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [13/33]

virtual RWvistream & RWXDRistream::get ( long * v,
size_t n )
virtual

Gets a vector of n long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [14/33]

virtual RWvistream & RWXDRistream::get ( long double & )
inlinevirtual
Exceptions
RWInternalErrThis function is not supported with XDR streams.
Note
This operator function is available only if your compiler supports the long double type.

Implements RWvistream.

◆ get() [15/33]

virtual RWvistream & RWXDRistream::get ( long double * ,
size_t  )
inlinevirtual
Exceptions
RWInternalErrThis function is not supported with XDR streams.
Note
This operator function is available only if your compiler supports the long double type.

Implements RWvistream.

◆ get() [16/33]

virtual RWvistream & RWXDRistream::get ( long long & i)
virtual

Gets the next long long from the input stream and stores it in i.

Exceptions
RWInternalErrThrown if the necessary support for reading a long long from an XDR is not available.
Note
This operator function is available only if your compiler supports the long long type.

Implements RWvistream.

◆ get() [17/33]

virtual RWvistream & RWXDRistream::get ( long long * v,
size_t n )
virtual

Gets a vector of n long long and stores them in the array beginning at v.

Exceptions
RWInternalErrThrown if the necessary support for reading a long long from an XDR is not available.
Note
This operator function is available only if your compiler supports the long long type.

Implements RWvistream.

◆ get() [18/33]

virtual RWvistream & RWXDRistream::get ( short & i)
virtual

Gets the next short from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [19/33]

virtual RWvistream & RWXDRistream::get ( short * v,
size_t n )
virtual

Gets a vector of n short and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [20/33]

virtual RWvistream & RWXDRistream::get ( signed char & c)
virtual

Gets the next signed char from the input stream, returning its value in c.

Implements RWvistream.

◆ get() [21/33]

virtual RWvistream & RWXDRistream::get ( signed char * v,
size_t n )
virtual

Gets a vector of n signed char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [22/33]

virtual RWvistream & RWXDRistream::get ( unsigned char & c)
virtual

Gets the next unsigned char from the input stream, returning its value in c.

Implements RWvistream.

◆ get() [23/33]

virtual RWvistream & RWXDRistream::get ( unsigned char * v,
size_t n )
virtual

Gets a vector of n unsigned char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [24/33]

virtual RWvistream & RWXDRistream::get ( unsigned int & i)
virtual

Gets the next unsigned int from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [25/33]

virtual RWvistream & RWXDRistream::get ( unsigned int * v,
size_t n )
virtual

Gets a vector of n unsigned int and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [26/33]

virtual RWvistream & RWXDRistream::get ( unsigned long & i)
virtual

Gets the next unsigned long from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [27/33]

virtual RWvistream & RWXDRistream::get ( unsigned long * v,
size_t n )
virtual

Gets a vector of n unsigned long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [28/33]

virtual RWvistream & RWXDRistream::get ( unsigned long long & i)
virtual

Gets the next unsigned long long from the input stream and stores it in i.

Exceptions
RWInternalErrThrown if the necessary support for reading an unsigned long long from an XDR is not available.
Note
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvistream.

◆ get() [29/33]

virtual RWvistream & RWXDRistream::get ( unsigned long long * v,
size_t n )
virtual

Gets a vector of n unsigned long long and stores them in the array beginning at v.

Exceptions
RWInternalErrThrown if the necessary support for reading an unsigned long long from an XDR is not available.
Note
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvistream.

◆ get() [30/33]

virtual RWvistream & RWXDRistream::get ( unsigned short & i)
virtual

Gets the next unsigned short from the input stream, returning its value in i.

Implements RWvistream.

◆ get() [31/33]

virtual RWvistream & RWXDRistream::get ( unsigned short * v,
size_t n )
virtual

Gets a vector of n unsigned short and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Implements RWvistream.

◆ get() [32/33]

virtual RWvistream & RWXDRistream::get ( wchar_t & wc)
virtual

Gets the next wchar_t from the input stream, returning its value in wc.

Implements RWvistream.

◆ get() [33/33]

virtual RWvistream & RWXDRistream::get ( wchar_t * v,
size_t n )
virtual

Gets a vector of n wchar_t and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Note
This method retrieves raw characters and does not perform any conversions on special characters such as L'\n'.

Implements RWvistream.

◆ getChar() [1/4]

virtual RWvistream & RWXDRistream::getChar ( char & c)
inlinevirtual

Gets the next char from the input stream, returning its value in c. c is treated as a character.

Implements RWvistream.

◆ getChar() [2/4]

virtual RWvistream & RWXDRistream::getChar ( signed char & c)
inlinevirtual

Gets the next signed char from the input stream, returning its value in c. c is treated as a character.

Implements RWvistream.

◆ getChar() [3/4]

virtual RWvistream & RWXDRistream::getChar ( unsigned char & c)
inlinevirtual

Gets the next unsigned char from the input stream, returning its value in c. c is treated as a character.

Implements RWvistream.

◆ getChar() [4/4]

virtual RWvistream & RWXDRistream::getChar ( wchar_t & wc)
inlinevirtual

Gets the next wchar_t from the input stream, returning its value in wc. wc is treated as a character.

Implements RWvistream.

◆ getChars()

virtual RWvistream & RWXDRistream::getChars ( char * s,
size_t n )
virtual

Restores n char from the input stream into the array beginning at s. The function stops reading after n char. The resulting buffer is not null terminated. s is treated as a character string.

Note
This function delegates to get(char*, size_t) if not overridden.

Reimplemented from RWvistream.

◆ getSizeT()

virtual RWvistream & RWXDRistream::getSizeT ( size_t & sz)
virtual

Gets the next size_t value from the input stream, returning its value in sz.

Implements RWvistream.

◆ getString()

virtual RWvistream & RWXDRistream::getString ( char * s,
size_t n )
virtual

Restores a character string from the input stream that has been stored to the output stream using RWvostream::putString(), then saves it in the array beginning at s. The function stops reading at the end of the string or after n - 1 characters, whichever comes first. If n - 1 characters have been read and the nth character is not the string terminator, then sets the failbit of the stream. In either case, the string is terminated with a null byte.

Implements RWvistream.

◆ good()

virtual int RWXDRistream::good ( )
inlinevirtual

Returns a nonzero integer if no error bits have been set.

Implements RWvistream.

◆ rdstate()

virtual int RWXDRistream::rdstate ( )
inlinevirtual

Returns the current error state.

Implements RWvistream.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.