rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWvostream Class Reference
[Virtual Streams]

Abstract base class that provides an interface for format-dependent storage of fundamental types and fundamental-type arrays. More...

#include <rw/vstream.h>

Inheritance diagram for RWvostream:
RWvios RWbostream RWpostream RWvostreamToDataOutputStream RWXDRostream RWeostream

List of all members.

Public Member Functions

virtual ~RWvostream ()
virtual int eof ()=0
virtual int fail ()=0
virtual int bad ()=0
virtual int good ()=0
virtual int rdstate ()=0
virtual void clear (int v=0)=0
virtual RWvostreamputString (const char *s, size_t n)=0
virtual RWvostreamoperator<< (const char *s)=0
virtual RWvostreamoperator<< (char c)=0
virtual RWvostreamoperator<< (wchar_t wc)=0
virtual RWvostreamoperator<< (unsigned char)=0
virtual RWvostreamoperator<< (long double d)=0
virtual RWvostreamoperator<< (long long i)=0
virtual RWvostreamoperator<< (unsigned long long i)=0
virtual RWvostreamoperator<< (double d)=0
virtual RWvostreamoperator<< (float f)=0
virtual RWvostreamoperator<< (int i)=0
virtual RWvostreamoperator<< (unsigned int i)=0
virtual RWvostreamoperator<< (long i)=0
virtual RWvostreamoperator<< (unsigned long i)=0
virtual RWvostreamoperator<< (short i)=0
virtual RWvostreamoperator<< (unsigned short i)=0
virtual RWvostreamflush ()=0
virtual RWvostreamput (char c)=0
virtual RWvostreamput (const char *v, size_t N)=0
virtual RWvostreamput (wchar_t wc)=0
virtual RWvostreamput (const wchar_t *v, size_t N)=0
virtual RWvostreamput (unsigned char c)=0
virtual RWvostreamput (const unsigned char *v, size_t N)=0
virtual RWvostreamput (const long double *v, size_t N)=0
virtual RWvostreamput (const long long *v, size_t N)=0
virtual RWvostreamput (const unsigned long long *v, size_t N)=0
virtual RWvostreamput (const short *v, size_t N)=0
virtual RWvostreamput (const unsigned short *v, size_t N)=0
virtual RWvostreamput (const int *v, size_t N)=0
virtual RWvostreamput (const unsigned int *v, size_t N)=0
virtual RWvostreamput (const long *v, size_t N)=0
virtual RWvostreamput (const unsigned long *v, size_t N)=0
virtual RWvostreamput (const float *v, size_t N)=0
virtual RWvostreamput (const double *v, size_t N)=0
virtual RWvostreamputSizeT (size_t sz)=0
void version (unsigned v)
unsigned version () const

Detailed Description

Class RWvostream is an abstract base class that provides an interface for format-independent storage of fundamental types, and arrays of fundamental types. Its counterpart, RWvistream, provides a complementary interface for the retrieval of variables of the fundamental types.

Because the interface of RWvistream and RWvostream is independent of formatting, your application need not be concerned with how variables are actually stored or restored -- functionality that is the responsibility of whatever derived class you choose. For instance, you could use an operating-system independent US-ASCII format (classes RWpistream and RWpostream), a binary format (classes RWbistream and RWbostream), or define your own format (such as an interface to a network).

Note that, because this is an abstract base class, these design goals cannot be enforced; rather, the description here is merely the model of how a class derived from RWvistream and RWvostream should act.

Note:
There is no need to separate variables with whitespace. It is the responsibility of the derived class to delineate variables with whitespace, packet breaks, or whatever might be appropriate for the final output sink. The intended model is one where variables are inserted into the output stream, either individually or as homogeneous vectors, to be restored in the same order using RWvistream.

About the Storage and Retrieval of Characters Characters can be thought of as either representing some alpha-numeric or control character, or as the literal number. Generally, the overloaded insertion (<<) and extraction (>>) operators seek to store and restore characters while preserving their symbolic meaning. That is, storage of a newline should be restored as a newline, regardless of its representation on the target machine. By contrast, member functions get() and put() should treat the character as a literal number whose value is to be preserved.

See also:
RWpostream.

Synopsis

 #include <rw/vstream.h>

Persistence

None

Examples

 #include <iostream>
 #include <fstream>

 #include <rw/vstream.h>
 #include <rw/bstream.h>
 #include <rw/pstream.h>

 void storeStuff(RWvostream& str)
 {
     int i = 5;
     double d = 22.5;
     char s [] = "A string with \t tabs and a newline\n";

     str << i; // Store an int
     str << d; // Store a double
     str << s; // Store a string

     if (str.fail()) {
         std::cerr << "Storage failed.\n";
     }
 }

 int main ()
 {
     std::ofstream vf ("vfile.dat");

     RWpostream ps(vf);
     RWbostream bs(vf);


     // Uncomment the call to storeStuff that matches your stream type

     storeStuff((RWvostream &) ps);
     // storeStuff((RWvostream &) bs);

     return 0;
 }

Constructor & Destructor Documentation

virtual RWvostream::~RWvostream (  )  [virtual]

Empty destructor.


Member Function Documentation

virtual int RWvostream::bad (  )  [pure 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 RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual void RWvostream::clear ( int  v = 0  )  [pure virtual]

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

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual int RWvostream::eof (  )  [pure virtual]

Returns a nonzero integer if an EOF is encountered.

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual int RWvostream::fail (  )  [pure 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 RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Sends the contents of the stream buffer to output immediately.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual int RWvostream::good (  )  [pure virtual]

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

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( unsigned short  i  )  [pure virtual]

Stores the unsigned short i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( short  i  )  [pure virtual]

Stores the short i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( unsigned long  i  )  [pure virtual]

Stores the unsigned long i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( long  i  )  [pure virtual]

Stores the long i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the unsigned int i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the int i to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the float f to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the double d to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( unsigned long long  i  )  [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( long long  i  )  [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::operator<< ( long double  d  )  [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the unsigned char c to the output stream.

Note:
The parameter c is treated as a character, not a number.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the wchar_t wc to the output stream.

Note:
The parameter wc is treated as a character, not a number.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the char c to the output stream.

Note:
The parameter c is treated as a character, not a number.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the null-terminated character string starting at s to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const float *  v,
size_t  N 
) [pure virtual]

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const int *  v,
size_t  N 
) [pure virtual]

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const short *  v,
size_t  N 
) [pure virtual]

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const unsigned long long *  v,
size_t  N 
) [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const long long *  v,
size_t  N 
) [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const long double *  v,
size_t  N 
) [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const unsigned char *  v,
size_t  N 
) [pure 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.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::put ( const wchar_t *  v,
size_t  N 
) [pure virtual]

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

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

Stores the size_t sz to the output stream.

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual RWvostream& RWvostream::putString ( const char *  s,
size_t  n 
) [pure virtual]

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

Implemented in RWbostream, RWeostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

virtual int RWvostream::rdstate (  )  [pure virtual]

Returns the current error state.

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

unsigned RWvostream::version (  )  const [inline]

Returns the value of the version number.

Note:
The default version number is the maximum supported version that this stream can write.
void RWvostream::version ( unsigned  v  )  [inline]

Changes the value of the version number to v.

Note:
The version number may be used to determine how objects should be serialized to the underlying stream. This can be used to ensure compatibility with existing code or reduce the amount of data put on the underlying output stream.
 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.