rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWXDRistream Class Reference
[Virtual Streams]

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

#include <rw/xdrstrea.h>

Inheritance diagram for RWXDRistream:
RWvistream RWvios

List of all members.

Public Member Functions

 RWXDRistream (XDR *xp)
 RWXDRistream (std::streambuf *)
 RWXDRistream (std::istream &)
virtual ~RWXDRistream ()
virtual int eof ()
virtual int fail ()
virtual int bad ()
virtual int good ()
virtual int rdstate ()
virtual void clear (int v=0)
virtual int get ()
virtual RWvistreamget (char &c)
virtual RWvistreamget (char *v, size_t N)
virtual RWvistreamget (unsigned char &c)
virtual RWvistreamget (unsigned char *v, size_t N)
virtual RWvistreamget (wchar_t &wc)
virtual RWvistreamget (long double *, size_t)
virtual RWvistreamget (double *v, size_t N)
virtual RWvistreamget (float *v, size_t N)
virtual RWvistreamget (int *v, size_t N)
virtual RWvistreamget (unsigned int *v, size_t N)
virtual RWvistreamget (long *v, size_t N)
virtual RWvistreamget (unsigned long *v, size_t N)
virtual RWvistreamget (short *v, size_t N)
virtual RWvistreamget (unsigned short *v, size_t N)
virtual RWvistreamget (wchar_t *v, size_t N)
virtual RWvistreamget (long long *, size_t)
virtual RWvistreamget (unsigned long long *, size_t)
virtual RWvistreamgetString (char *s, size_t maxlen)
virtual RWvistreamgetSizeT (size_t &)
virtual RWvistreamoperator>> (char &c)
virtual RWvistreamoperator>> (double &d)
virtual RWvistreamoperator>> (float &f)
virtual RWvistreamoperator>> (int &i)
virtual RWvistreamoperator>> (long &l)
virtual RWvistreamoperator>> (short &s)
virtual RWvistreamoperator>> (long double &)
virtual RWvistreamoperator>> (long long &)
virtual RWvistreamoperator>> (unsigned long long &)
virtual RWvistreamoperator>> (wchar_t &wc)
virtual RWvistreamoperator>> (unsigned char &c)
virtual RWvistreamoperator>> (unsigned int &i)
virtual RWvistreamoperator>> (unsigned long &l)
virtual RWvistreamoperator>> (unsigned short &s)

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);

Persistence

None

Examples

 #include <iostream>
 #include <rw/xdrstrea.h>
 
 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::RWXDRistream ( XDR *  xp  ) 

Initializes an RWXDRistream from the XDR structure xp.

RWXDRistream::RWXDRistream ( std::streambuf *   ) 

Initializes an RWXDRistream with a pointer to streambuf. streambuf must be already allocated.

RWXDRistream::RWXDRistream ( std::istream &   ) 

Initializes an RWXDRistream with an input stream.

virtual RWXDRistream::~RWXDRistream (  )  [virtual]

Deallocates previously allocated resources.


Member Function Documentation

virtual int RWXDRistream::bad (  )  [inline, virtual]

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.

virtual void RWXDRistream::clear ( int  v = 0  )  [inline, virtual]

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

Implements RWvistream.

virtual int RWXDRistream::eof (  )  [inline, virtual]

Returns a nonzero integer if an EOF is encountered.

Implements RWvistream.

virtual int RWXDRistream::fail (  )  [inline, virtual]

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.

virtual RWvistream& RWXDRistream::get ( unsigned long long *  v,
size_t  N 
) [inline, virtual]

Gets a vector of N unsigned long 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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

Note:
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( long long *  v,
size_t  N 
) [inline, virtual]

Gets a vector of N long 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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

Note:
This operator function is available only if your compiler supports the long long type.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( wchar_t *  v,
size_t  N 
) [virtual]

Gets a vector of N wide characters from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( unsigned short *  v,
size_t  N 
) [virtual]

Gets a vector of N unsigned short from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( short *  v,
size_t  N 
) [virtual]

Gets a vector of N short from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( unsigned long *  v,
size_t  N 
) [virtual]

Gets a vector of N unsigned long from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( long *  v,
size_t  N 
) [virtual]

Gets a vector of N long from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( unsigned int *  v,
size_t  N 
) [virtual]

Gets a vector of N unsigned int from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( int *  v,
size_t  N 
) [virtual]

Gets a vector of N int from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( float *  v,
size_t  N 
) [virtual]

Gets a vector of N float from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( double *  v,
size_t  N 
) [virtual]

Gets a vector of N double from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( long double *  v,
size_t  N 
) [inline, virtual]

Gets a vector of N long 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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

Note:
This operator function is available only if your compiler supports the long double type.

Implements RWvistream.

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

Gets the next wide character from the XDR input stream and stores it in wc. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( unsigned char *  v,
size_t  N 
) [virtual]

Gets a vector of N unsigned characters from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

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

Gets the next unsigned character from the XDR input stream and stores it in c. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::get ( char *  v,
size_t  N 
) [virtual]

Gets a vector of N characters from the XDR input stream and stores them in v. If the operation fails, the method sets the failbit.

Implements RWvistream.

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

Gets the next character from the XDR input stream and stores it in c. If the operation fails, the method sets the failbit. Note that this method preserves only US-ASCII numerical codes, not the corresponding character symbol.

Implements RWvistream.

virtual int RWXDRistream::get (  )  [virtual]

Gets and returns the next character from the XDR input stream. If the operation fails, the method sets the failbit and returns EOF.

Implements RWvistream.

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.

virtual RWvistream& RWXDRistream::getString ( char *  s,
size_t  maxlen 
) [virtual]

Restores a character string from the XDR input stream that was stored to the XDR output stream with RWXDRostream::putString() and stores the characters in the array starting at s. The function stops reading at the end of the string or after maxlen -1 characters, whichever comes first. If maxlen -1 characters have been read and the maxlen th character is not the string terminator, then the failbit of the stream will be set. In either case, the string will be terminated with a null byte.

Implements RWvistream.

virtual int RWXDRistream::good (  )  [inline, virtual]

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

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( unsigned short &  s  )  [virtual]

Gets the next unsigned short from the XDR input stream and stores it in s. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( unsigned long &  l  )  [virtual]

Gets the next unsigned long from the XDR input stream and stores it in l. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( unsigned int &  i  )  [virtual]

Gets the next unsigned integer from the XDR input stream and stores it in i. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( unsigned char &  c  )  [virtual]

Gets the next unsigned character from the XDR input stream and stores it in c. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( wchar_t &  wc  )  [virtual]

Gets the next wide character from the XDR input stream and stores it in wc. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( unsigned long long &  i  )  [inline, virtual]

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

Note:
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( long long &  i  )  [inline, virtual]

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

Note:
This operator function is available only if your compiler supports the long long type.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( long double &  d  )  [inline, virtual]

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

Note:
This operator function is available only if your compiler supports the long double type.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( short &  s  )  [virtual]

Gets the next short from the XDR input stream and stores it in s. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( long &  l  )  [virtual]

Gets the next long from the XDR input stream and stores it in l. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( int &  i  )  [virtual]

Gets the next integer from the XDR input stream and stores it in i. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( float &  f  )  [virtual]

Gets the next float from the XDR input stream and stores it in f. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( double &  d  )  [virtual]

Gets the next double from the XDR input stream and stores it in d. If the operation fails, the method sets the failbit.

Implements RWvistream.

virtual RWvistream& RWXDRistream::operator>> ( char &  c  )  [virtual]

Gets the next character from the XDR input stream and stores it in c. If the operation fails, the method sets the failbit. This member attempts to preserve the symbolic characters' values transmitted over the stream.

Implements RWvistream.

virtual int RWXDRistream::rdstate (  )  [inline, virtual]

Returns the current error state.

Implements RWvistream.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.