SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWvostream Class Referenceabstract

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

Public Member Functions

virtual ~RWvostream ()
 
virtual int bad ()=0
 
virtual void clear (int v=0)=0
 
virtual int eof ()=0
 
virtual int fail ()=0
 
virtual RWvostreamflush ()=0
 
virtual int good ()=0
 
virtual RWvostreamput (char c)=0
 
virtual RWvostreamput (signed char c)=0
 
virtual RWvostreamput (unsigned char c)=0
 
virtual RWvostreamput (wchar_t wc)=0
 
virtual RWvostreamput (bool b)=0
 
virtual RWvostreamput (short i)=0
 
virtual RWvostreamput (unsigned short i)=0
 
virtual RWvostreamput (int i)=0
 
virtual RWvostreamput (unsigned int i)=0
 
virtual RWvostreamput (long i)=0
 
virtual RWvostreamput (unsigned long i)=0
 
virtual RWvostreamput (long long i)=0
 
virtual RWvostreamput (unsigned long long i)=0
 
virtual RWvostreamput (float f)=0
 
virtual RWvostreamput (double d)=0
 
virtual RWvostreamput (long double d)=0
 
virtual RWvostreamput (const char *v, size_t n)=0
 
virtual RWvostreamput (const signed char *v, size_t n)=0
 
virtual RWvostreamput (const unsigned char *v, size_t n)=0
 
virtual RWvostreamput (const wchar_t *v, size_t n)=0
 
virtual RWvostreamput (const bool *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 long long *v, size_t n)=0
 
virtual RWvostreamput (const unsigned long 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 RWvostreamput (const long double *v, size_t n)=0
 
virtual RWvostreamputChar (char c)=0
 
virtual RWvostreamputChar (signed char c)=0
 
virtual RWvostreamputChar (unsigned char c)=0
 
virtual RWvostreamputChar (wchar_t wc)=0
 
virtual RWvostreamputChars (const char *s, size_t n)
 
virtual RWvostreamputSizeT (size_t sz)=0
 
virtual RWvostreamputString (const char *s, size_t n)=0
 
virtual int rdstate ()=0
 
void version (unsigned v)
 
unsigned version () const
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Related Functions

(Note that these are not member functions.)

RWvostreamoperator<< (RWvostream &os, const char *s)
 
RWvostreamoperator<< (RWvostream &os, char c)
 
RWvostreamoperator<< (RWvostream &os, signed char c)
 
RWvostreamoperator<< (RWvostream &os, unsigned char c)
 
RWvostreamoperator<< (RWvostream &os, wchar_t wc)
 
RWvostreamoperator<< (RWvostream &os, bool b)
 
RWvostreamoperator<< (RWvostream &os, long long i)
 
RWvostreamoperator<< (RWvostream &os, unsigned long long i)
 
RWvostreamoperator<< (RWvostream &os, float f)
 
RWvostreamoperator<< (RWvostream &os, double d)
 
RWvostreamoperator<< (RWvostream &os, long double d)
 
RWvostreamoperator<< (RWvostream &os, short i)
 
RWvostreamoperator<< (RWvostream &os, unsigned short i)
 
RWvostreamoperator<< (RWvostream &os, int i)
 
RWvostreamoperator<< (RWvostream &os, unsigned int i)
 
RWvostreamoperator<< (RWvostream &os, long i)
 
RWvostreamoperator<< (RWvostream &os, unsigned long i)
 

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
Example
#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(ps);
// storeStuff(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 RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

virtual int RWvostream::eof ( )
pure virtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvios.

Implemented in RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

virtual RWvostream& RWvostream::flush ( )
pure virtual

Sends the contents of the stream buffer to output immediately.

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

virtual int RWvostream::good ( )
pure virtual

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

Implements RWvios.

Implemented in RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

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

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

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

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

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

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

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

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

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

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

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

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

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

Stores the bool b to the output stream.

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

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

Stores the short i to the output stream.

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

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

Stores the unsigned short i to the output stream.

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

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

Stores the int i to the output stream.

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

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

Stores the unsigned int i to the output stream.

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

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

Stores the long i to the output stream.

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

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

Stores the unsigned long i to the output stream.

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

virtual RWvostream& RWvostream::put ( 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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

virtual RWvostream& RWvostream::put ( 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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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

Stores the float f to the output stream.

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

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

Stores the double d to the output stream.

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

virtual RWvostream& RWvostream::put ( 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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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

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

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

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

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

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

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

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

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

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

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

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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 RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

virtual RWvostream& RWvostream::putChar ( char  c)
pure virtual

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

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

virtual RWvostream& RWvostream::putChar ( signed char  c)
pure virtual

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

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

virtual RWvostream& RWvostream::putChar ( unsigned char  c)
pure virtual

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

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

virtual RWvostream& RWvostream::putChar ( wchar_t  wc)
pure virtual

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

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

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

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 in RWXDRostream, RWpostream, RWbostream, RWeostream, and RWvostreamToDataOutputStream.

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

Stores the size_t sz to the output stream.

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

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

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

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

virtual int RWvostream::rdstate ( )
pure virtual

Returns the current error state.

Implements RWvios.

Implemented in RWXDRostream, RWpostream, RWbostream, and RWvostreamToDataOutputStream.

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.
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.

Friends And Related Function Documentation

RWvostream & operator<< ( RWvostream os,
const char *  s 
)
related

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

RWvostream & operator<< ( RWvostream os,
char  c 
)
related

Stores the char c to the output stream.

RWvostream & operator<< ( RWvostream os,
signed char  c 
)
related

Stores the signed char c to the output stream.

RWvostream & operator<< ( RWvostream os,
unsigned char  c 
)
related

Stores the unsigned char c to the output stream.

RWvostream & operator<< ( RWvostream os,
wchar_t  wc 
)
related

Stores the wchar_t wc to the output stream.

RWvostream & operator<< ( RWvostream os,
bool  b 
)
related

Stores the bool b to the output stream.

RWvostream & operator<< ( RWvostream os,
long long  i 
)
related

Stores the long long i to the output stream.

Note
This operator function is available only if your compiler supports the long long type.
RWvostream & operator<< ( RWvostream os,
unsigned long long  i 
)
related

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.
RWvostream & operator<< ( RWvostream os,
float  f 
)
related

Stores the float f to the output stream.

RWvostream & operator<< ( RWvostream os,
double  d 
)
related

Stores the double d to the output stream.

RWvostream & operator<< ( RWvostream os,
long double  d 
)
related

Stores the long double d to the output stream.

Note
This operator function is available only if your compiler supports the long double type.
RWvostream & operator<< ( RWvostream os,
short  i 
)
related

Stores the short i to the output stream.

RWvostream & operator<< ( RWvostream os,
unsigned short  i 
)
related

Stores the unsigned short i to the output stream.

RWvostream & operator<< ( RWvostream os,
int  i 
)
related

Stores the int i to the output stream.

RWvostream & operator<< ( RWvostream os,
unsigned int  i 
)
related

Stores the unsigned int i to the output stream.

RWvostream & operator<< ( RWvostream os,
long  i 
)
related

Stores the long i to the output stream.

RWvostream & operator<< ( RWvostream os,
unsigned long  i 
)
related

Stores the unsigned long i to the output stream.

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