Tools.h++ Manual

21-224 104011 Tandem Computers Incorporated
21
The library that supports XDR routines must be linked in. The name of this
library is not standard.
Public constructors
RWXDRistream(XDR* xp);
Initialize an
RWXDRistream
from the XDR structure xp.
Public member functions
virtual int get();
Redefined from class
RWvistream
. Gets and return the next character from the
XDR input stream. If the operation fails, it sets the failbit and returns EOF.
virtual RWvistream& get(char& c);
Redefined from class
RWvistream
. Gets the next character from the XDR input
stream and stores it in
c
. If the operation fails, it sets the failbit.
virtual RWvistream& get(wchar_t& wc);
Redefined from class
RWvistream
. Gets the next wide character from the XDR
input stream and stores it in
wc
. If the operation fails, it sets the failbit.
#include “rw/xdrstrea.h”
#include “rw/rstream.h”
#include <stdio.h>
main()
{
XDR xdr;
FILE* fp = fopen(“test”,”r+”);
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)
cout << data << endl;
else
cout << “Bad input value” << endl;
}
fclose(fp);
}