rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWXDRostream Class Reference
[Virtual Streams]

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

#include <rw/xdrstrea.h>

Inheritance diagram for RWXDRostream:
RWvostream RWvios

List of all members.

Public Member Functions

 RWXDRostream (XDR *xp)
 RWXDRostream (std::streambuf *)
 RWXDRostream (std::ostream &)
virtual ~RWXDRostream ()
virtual int eof ()
virtual int fail ()
virtual int bad ()
virtual int good ()
virtual int rdstate ()
virtual void clear (int v=0)
virtual RWvostreamputString (const char *s, size_t N)
virtual RWvostreamoperator<< (const char *s)
virtual RWvostreamoperator<< (char c)
virtual RWvostreamoperator<< (unsigned char c)
virtual RWvostreamoperator<< (wchar_t wc)
virtual RWvostreamoperator<< (short s)
virtual RWvostreamoperator<< (unsigned short s)
virtual RWvostreamoperator<< (int i)
virtual RWvostreamoperator<< (unsigned int i)
virtual RWvostreamoperator<< (long l)
virtual RWvostreamoperator<< (unsigned long l)
virtual RWvostreamoperator<< (double d)
virtual RWvostreamoperator<< (float f)
virtual RWvostreamoperator<< (long double)
virtual RWvostreamoperator<< (long long)
virtual RWvostreamoperator<< (unsigned long long)
virtual RWvostreamflush ()
virtual RWvostreamput (char c)
virtual RWvostreamput (const char *p, size_t N)
virtual RWvostreamput (unsigned char c)
virtual RWvostreamput (const unsigned char *p, size_t N)
virtual RWvostreamput (wchar_t wc)
virtual RWvostreamput (const wchar_t *p, size_t N)
virtual RWvostreamput (const short *p, size_t N)
virtual RWvostreamput (const unsigned short *p, size_t N)
virtual RWvostreamput (const int *p, size_t N)
virtual RWvostreamput (const unsigned int *p, size_t N)
virtual RWvostreamput (const long *p, size_t N)
virtual RWvostreamput (const unsigned long *p, size_t N)
virtual RWvostreamput (const float *p, size_t N)
virtual RWvostreamput (const double *p, size_t N)
virtual RWvostreamput (const long double *, size_t)
virtual RWvostreamput (const long long *, size_t)
virtual RWvostreamput (const unsigned long long *, size_t)
virtual RWvostreamputSizeT (size_t)

Detailed Description

Class RWXDRostream is a portable output stream based on XDR routines. Class RWXDRostream 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 RWXDRostream enables outputing from a stream and encoding an XDR structure from a machine representation. RWXDRostream provides the ability to encode 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 an argument to the constructor for a RWXDRostream object.

RWXDRostream 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, stdout, XDR_ENCODE) ;
 RWXDRostream rw_xdr(&xdr);

Persistence

None

Examples

 #include <iostream>
 #include <rw/xdrstrea.h>
 
 int main ()
 {
     XDR xdr;
 
     FILE* fp = fopen("test","w+");
     if (fp == 0) {
         std::cerr << "failed to open file.\n";
         return 1;
     }
 
     xdrstdio_create(&xdr, fp, XDR_ENCODE);
 
     RWXDRostream rw_xdr (&xdr);
 
     for(int i = 0; i < 10; ++i)
         rw_xdr << i; // encode integer data
 
     fclose(fp);
 
     return 0;
 }

Constructor & Destructor Documentation

RWXDRostream::RWXDRostream ( XDR *  xp  ) 

Initializes an RWXDRostream from the XDR structure xp.

RWXDRostream::RWXDRostream ( std::streambuf *   ) 

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

RWXDRostream::RWXDRostream ( std::ostream &   ) 

Initializes an RWXDRostream with an output stream.

virtual RWXDRostream::~RWXDRostream (  )  [virtual]

Deallocates previously allocated resources.


Member Function Documentation

virtual int RWXDRostream::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 RWvostream.

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

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

Implements RWvostream.

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

Returns a nonzero integer if an EOF is encountered.

Implements RWvostream.

virtual int RWXDRostream::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 RWvostream.

virtual RWvostream& RWXDRostream::flush (  )  [virtual]

Sends the contents of the stream buffer to output immediately.

Implements RWvostream.

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

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( unsigned long  i  )  [inline, virtual]

Stores the unsigned long long i to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( long  i  )  [inline, virtual]

Stores the long long i to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( long  d  )  [inline, virtual]

Stores the long double d to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( float  f  )  [virtual]

Stores the float f to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( double  d  )  [virtual]

Stores the double d to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( unsigned long  l  )  [virtual]

Stores the unsigned long l to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( long  l  )  [virtual]

Stores the long l to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( unsigned int  i  )  [virtual]

Stores the unsigned integer i to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( int  i  )  [virtual]

Stores the integer i to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( unsigned short  s  )  [virtual]

Stores the unsigned short s to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( short  s  )  [virtual]

Stores the short s to the output stream, using the XDR format.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( wchar_t  wc  )  [virtual]

Stores the wide character wc to the output stream, using the XDR format. Note that wc is treated as a character, not a number.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( unsigned char  c  )  [virtual]

Stores the unsigned character c to the output stream, using the XDR format. Note that c is treated as a character, not a number.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( char  c  )  [virtual]

Stores the character c to the output stream, using the XDR format. Note that c is treated as a character, not a number. This method attempts to preserve the symbolic character values transmitted over the stream.

Implements RWvostream.

virtual RWvostream& RWXDRostream::operator<< ( const char *  s  )  [virtual]

Stores the character string starting at s to the output stream, using the XDR format. The character string is expected to be null terminated.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const unsigned long long *  v,
size_t  N 
) [inline, virtual]

Stores the vector of N unsigned long long starting at v to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const long long *  v,
size_t  N 
) [inline, virtual]

Stores the vector of N long long starting at v to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const long double *  v,
size_t  N 
) [inline, virtual]

Stores the vector of N long double starting at v to the output stream.

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

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const double *  p,
size_t  N 
) [virtual]

Stores the vector of N double starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const float *  p,
size_t  N 
) [virtual]

Stores the vector of N float starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const unsigned long *  p,
size_t  N 
) [virtual]

Stores the vector of N unsigned long starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const long *  p,
size_t  N 
) [virtual]

Stores the vector of N long starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const unsigned int *  p,
size_t  N 
) [virtual]

Stores the vector of N unsigned integer starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const int *  p,
size_t  N 
) [virtual]

Stores the vector of N integer starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const unsigned short *  p,
size_t  N 
) [virtual]

Stores the vector of N unsigned short starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const short *  p,
size_t  N 
) [virtual]

Stores the vector of N short starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const wchar_t *  p,
size_t  N 
) [virtual]

Stores the vector of N wide characters starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( wchar_t  wc  )  [virtual]

Stores the wide character wc to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const unsigned char *  v,
size_t  N 
) [virtual]

Stores the vector of N unsigned char starting at v to the output stream.

Note:
The characters should be treated as literal numbers rather than a character string.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( unsigned char  c  )  [virtual]

Stores the unsigned character c to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( const char *  p,
size_t  N 
) [virtual]

Stores the vector of N characters starting at p to the output stream, using the XDR format. If the operation fails, the method sets the failbit.

Implements RWvostream.

virtual RWvostream& RWXDRostream::put ( char  c  )  [virtual]

Stores the character c to the output stream, using the XDR format. If the operation fails, the method sets the failbit. This method preserves only US-ASCII numerical codes, not the corresponding character symbol.

Implements RWvostream.

virtual RWvostream& RWXDRostream::putSizeT ( size_t  sz  )  [virtual]

Stores the size_t sz to the output stream.

Implements RWvostream.

virtual RWvostream& RWXDRostream::putString ( const char *  s,
size_t  N 
) [virtual]

Stores the first N characters of character string s for retrieval by RWXDRistream::getString().

Implements RWvostream.

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

Returns the current error state.

Implements RWvostream.

 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.