Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWXDRostream (Unix only)


-->RWvostream-->RWvios RWXDRostream -->RWios

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/xdrstrea.h>

XDR xdr;
xdrstdio_create(&xdr, stdout, XDR_ENCODE) ;
RWXDRostream rw_xdr(&xdr);

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 one to output from a stream and encode an XDR structure from a machine representation. Class RWXDRostream provides the capability 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().

Persistence

None

Example

The example that follows is a "writer" program that encodes an XDR structure onto a file stream. The example for class RWXDRistream is the "reader" program that decodes the XDR structures into a machine representation for a data type. The library that supports XDR routines must be linked in. The name of this library is not standard.

#include <rw/xdrstrea.h>
#include <rw/rstream.h>
#include <stdio.h>

main(){
 XDR xdr;
 FILE* fp = fopen("test","w+");
 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);
}

Public Constructor

RWXDRostream(XDR* xp);
RWXDRostream(streambuf*);
RWXDRostream(ostream&);

Public Destructor

virtual ~RWXDRostream();

Public Member Functions

virtual RWvostream&
operator<<(const char* s); 
virtual RWvostream&
operator<<(char c);
virtual RWvostream&
operator<<(wchar_t wc);
virtual RWvostream&
operator<<(unsigned char c); 
virtual RWvostream&
operator<<(double d);
virtual RWvostream&
operator<<(float f);
virtual RWvostream&
operator<<(int i);
virtual RWvostream&
operator<<(unsigned int i);
virtual RWvostream&
operator<<(long l);
virtual RWvostream&
operator<<(unsigned long l);
virtual RWvostream&
operator<<(short s);
virtual RWvostream&
operator<<(unsigned short );
virtual RWvostream&
put(char c); 
virtual RWvostream&
put(unsigned char c);
virtual RWvostream&
put(wchar_t wc);
virtual RWvostream&
put(const char* p, size_t N);
virtual RWvostream&
put(const wchar_t* p, size_t N);
virtual RWvostream&
put(const short* p, size_t N);
virtual RWvostream&
put(const unsigned short* p, size_t N);
virtual RWvostream&
put(const int* p, size_t N); 
virtual RWvostream&
put(const unsigned int* p, size_t N);
virtual RWvostream&
put(const long* p, size_t N);
virtual RWvostream&
put(const unsigned long* p, size_t N);
virtual RWvostream&
put(const float* p, size_t N);
virtual RWvostream&
put(const double* p, size_t N);
Virtual RWXDRostream&
flush();
Virtual RWXDRostream&
putString(const char*s, size_t N); 


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.