SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWXDRostream Class Reference

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

#include <rw/xdrstrea.h>

Inheritance diagram for RWXDRostream:
RWvostream RWvios

Public Member Functions

 RWXDRostream (std::ostream &str)
 
 RWXDRostream (std::streambuf *sb)
 
 RWXDRostream (XDR *xp)
 
virtual ~RWXDRostream ()
 
virtual int bad ()
 
virtual void clear (int v=0)
 
virtual int eof ()
 
virtual int fail ()
 
virtual RWvostreamflush ()
 
virtual int good ()
 
virtual RWvostreamput (bool)
 
virtual RWvostreamput (char c)
 
virtual RWvostreamput (const bool *v, size_t n)
 
virtual RWvostreamput (const char *v, size_t n)
 
virtual RWvostreamput (const double *v, size_t n)
 
virtual RWvostreamput (const float *v, size_t n)
 
virtual RWvostreamput (const int *v, size_t n)
 
virtual RWvostreamput (const long *v, size_t n)
 
virtual RWvostreamput (const long double *, size_t)
 
virtual RWvostreamput (const long long *v, size_t n)
 
virtual RWvostreamput (const short *v, size_t n)
 
virtual RWvostreamput (const signed char *v, size_t n)
 
virtual RWvostreamput (const unsigned char *v, size_t n)
 
virtual RWvostreamput (const unsigned int *v, size_t n)
 
virtual RWvostreamput (const unsigned long *v, size_t n)
 
virtual RWvostreamput (const unsigned long long *v, size_t n)
 
virtual RWvostreamput (const unsigned short *v, size_t n)
 
virtual RWvostreamput (const wchar_t *v, size_t n)
 
virtual RWvostreamput (double d)
 
virtual RWvostreamput (float f)
 
virtual RWvostreamput (int i)
 
virtual RWvostreamput (long double)
 
virtual RWvostreamput (long i)
 
virtual RWvostreamput (long long i)
 
virtual RWvostreamput (short i)
 
virtual RWvostreamput (signed char c)
 
virtual RWvostreamput (unsigned char c)
 
virtual RWvostreamput (unsigned int i)
 
virtual RWvostreamput (unsigned long i)
 
virtual RWvostreamput (unsigned long long i)
 
virtual RWvostreamput (unsigned short i)
 
virtual RWvostreamput (wchar_t wc)
 
virtual RWvostreamputChar (char c)
 
virtual RWvostreamputChar (signed char c)
 
virtual RWvostreamputChar (unsigned char c)
 
virtual RWvostreamputChar (wchar_t wc)
 
virtual RWvostreamputChars (const char *s, size_t n)
 
virtual RWvostreamputSizeT (size_t sz)
 
virtual RWvostreamputString (const char *s, size_t n)
 
virtual int rdstate ()
 
- Public Member Functions inherited from RWvostream
virtual ~RWvostream ()
 
unsigned version () const
 
void version (unsigned v)
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Additional Inherited Members

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 outputting 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);
A portable output stream based on XDR routines.
Definition xdrstrea.h:451
Persistence
None
Example
#include <rw/xdrstrea.h>
#include <iostream>
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() [1/3]

RWXDRostream::RWXDRostream ( XDR * xp)

Initializes an RWXDRostream from the XDR structure xp.

◆ RWXDRostream() [2/3]

RWXDRostream::RWXDRostream ( std::streambuf * sb)

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

◆ RWXDRostream() [3/3]

RWXDRostream::RWXDRostream ( std::ostream & str)

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

◆ ~RWXDRostream()

virtual RWXDRostream::~RWXDRostream ( )
virtual

Deallocates previously allocated resources.

Member Function Documentation

◆ bad()

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

◆ clear()

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

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

Implements RWvostream.

◆ eof()

virtual int RWXDRostream::eof ( )
inlinevirtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvostream.

◆ fail()

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

◆ flush()

virtual RWvostream & RWXDRostream::flush ( )
virtual

Sends the contents of the stream buffer to output immediately.

Implements RWvostream.

◆ good()

virtual int RWXDRostream::good ( )
inlinevirtual

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

Implements RWvostream.

◆ put() [1/32]

virtual RWvostream & RWXDRostream::put ( bool b)
virtual

Stores the bool b to the output stream.

Implements RWvostream.

◆ put() [2/32]

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

Stores the char c to the output stream, preserving its value.

Implements RWvostream.

◆ put() [3/32]

virtual RWvostream & RWXDRostream::put ( const bool * v,
size_t n )
virtual

Stores the vector of n bool starting at v to the output stream.

Implements RWvostream.

◆ put() [4/32]

virtual RWvostream & RWXDRostream::put ( const char * v,
size_t n )
virtual

Stores the vector of n char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

◆ put() [5/32]

virtual RWvostream & RWXDRostream::put ( const double * v,
size_t n )
virtual

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

Implements RWvostream.

◆ put() [6/32]

virtual RWvostream & RWXDRostream::put ( const float * v,
size_t n )
virtual

Stores the vector of n float starting at v to the output stream.

Implements RWvostream.

◆ put() [7/32]

virtual RWvostream & RWXDRostream::put ( const int * v,
size_t n )
virtual

Stores the vector of n int starting at v to the output stream.

Implements RWvostream.

◆ put() [8/32]

virtual RWvostream & RWXDRostream::put ( const long * v,
size_t n )
virtual

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

Note
In a 64-bit environment, this method fails if the value of one of the stored elements in v is outside the range of a 32-bit signed integer.

Implements RWvostream.

◆ put() [9/32]

virtual RWvostream & RWXDRostream::put ( const 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 RWvostream.

◆ put() [10/32]

virtual RWvostream & RWXDRostream::put ( const long long * v,
size_t n )
virtual

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

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

Implements RWvostream.

◆ put() [11/32]

virtual RWvostream & RWXDRostream::put ( const short * v,
size_t n )
virtual

Stores the vector of n short starting at v to the output stream.

Implements RWvostream.

◆ put() [12/32]

virtual RWvostream & RWXDRostream::put ( const signed char * v,
size_t n )
virtual

Stores the vector of n signed char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

◆ put() [13/32]

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. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

◆ put() [14/32]

virtual RWvostream & RWXDRostream::put ( const unsigned int * v,
size_t n )
virtual

Stores the vector of n unsigned int starting at v to the output stream.

Implements RWvostream.

◆ put() [15/32]

virtual RWvostream & RWXDRostream::put ( const unsigned long * v,
size_t n )
virtual

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

Note
In a 64-bit environment, this method fails if the value of one of the stored elements in v is outside the range of a 32-bit unsigned integer.

Implements RWvostream.

◆ put() [16/32]

virtual RWvostream & RWXDRostream::put ( const unsigned long long * v,
size_t n )
virtual

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

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

Implements RWvostream.

◆ put() [17/32]

virtual RWvostream & RWXDRostream::put ( const unsigned short * v,
size_t n )
virtual

Stores the vector of n unsigned short starting at v to the output stream.

Implements RWvostream.

◆ put() [18/32]

virtual RWvostream & RWXDRostream::put ( const wchar_t * v,
size_t n )
virtual

Stores the vector of n wchar_t starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

◆ put() [19/32]

virtual RWvostream & RWXDRostream::put ( double d)
virtual

Stores the double d to the output stream.

Implements RWvostream.

◆ put() [20/32]

virtual RWvostream & RWXDRostream::put ( float f)
virtual

Stores the float f to the output stream.

Implements RWvostream.

◆ put() [21/32]

virtual RWvostream & RWXDRostream::put ( int i)
virtual

Stores the int i to the output stream.

Implements RWvostream.

◆ put() [22/32]

virtual RWvostream & RWXDRostream::put ( 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 RWvostream.

◆ put() [23/32]

virtual RWvostream & RWXDRostream::put ( long i)
virtual

Stores the long i to the output stream.

Note
In a 64-bit environment, this method fails if the value of i is outside the range of a 32-bit signed integer.

Implements RWvostream.

◆ put() [24/32]

virtual RWvostream & RWXDRostream::put ( long long i)
virtual

Stores the long long i to the output stream.

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

Implements RWvostream.

◆ put() [25/32]

virtual RWvostream & RWXDRostream::put ( short i)
virtual

Stores the short i to the output stream.

Implements RWvostream.

◆ put() [26/32]

virtual RWvostream & RWXDRostream::put ( signed char c)
virtual

Stores the signed char c to the output stream, preserving its value.

Implements RWvostream.

◆ put() [27/32]

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

Stores the unsigned char c to the output stream, preserving its value.

Implements RWvostream.

◆ put() [28/32]

virtual RWvostream & RWXDRostream::put ( unsigned int i)
virtual

Stores the unsigned int i to the output stream.

Implements RWvostream.

◆ put() [29/32]

virtual RWvostream & RWXDRostream::put ( unsigned long i)
virtual

Stores the unsigned long i to the output stream.

Note
In a 64-bit environment, this method fails if the value of i is outside the range of a 32-bit unsigned integer.

Implements RWvostream.

◆ put() [30/32]

virtual RWvostream & RWXDRostream::put ( unsigned long long i)
virtual

Stores the unsigned long long i to the output stream.

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

Implements RWvostream.

◆ put() [31/32]

virtual RWvostream & RWXDRostream::put ( unsigned short i)
virtual

Stores the unsigned short i to the output stream.

Implements RWvostream.

◆ put() [32/32]

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

Stores the wchar_t wc to the output stream, preserving its value.

Implements RWvostream.

◆ putChar() [1/4]

virtual RWvostream & RWXDRostream::putChar ( char c)
inlinevirtual

Stores the char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

◆ putChar() [2/4]

virtual RWvostream & RWXDRostream::putChar ( signed char c)
inlinevirtual

Stores the signed char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

◆ putChar() [3/4]

virtual RWvostream & RWXDRostream::putChar ( unsigned char c)
inlinevirtual

Stores the unsigned char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

◆ putChar() [4/4]

virtual RWvostream & RWXDRostream::putChar ( wchar_t wc)
inlinevirtual

Stores the wchar_t wc to the output stream, preserving its value. wc is treated as a character.

Implements RWvostream.

◆ putChars()

virtual RWvostream & RWXDRostream::putChars ( const char * s,
size_t n )
virtual

Stores n char starting at s to the output stream. s is treated as a character string.

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

Reimplemented from RWvostream.

◆ putSizeT()

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

Stores the size_t sz to the output stream.

Implements RWvostream.

◆ putString()

virtual RWvostream & RWXDRostream::putString ( const char * s,
size_t n )
virtual

Stores the character string, including embedded nulls, starting at s to the output stream.

Implements RWvostream.

◆ rdstate()

virtual int RWXDRostream::rdstate ( )
inlinevirtual

Returns the current error state.

Implements RWvostream.

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