SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 RWXDRostream RWbostream RWpostream RWvostreamToDataOutputStream 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 (bool b)=0
 
virtual RWvostreamput (char c)=0
 
virtual RWvostreamput (const bool *v, size_t n)=0
 
virtual RWvostreamput (const char *v, size_t n)=0
 
virtual RWvostreamput (const double *v, size_t n)=0
 
virtual RWvostreamput (const float *v, size_t n)=0
 
virtual RWvostreamput (const int *v, size_t n)=0
 
virtual RWvostreamput (const long *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 short *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 unsigned int *v, size_t n)=0
 
virtual RWvostreamput (const unsigned long *v, size_t n)=0
 
virtual RWvostreamput (const unsigned long long *v, size_t n)=0
 
virtual RWvostreamput (const unsigned short *v, size_t n)=0
 
virtual RWvostreamput (const wchar_t *v, size_t n)=0
 
virtual RWvostreamput (double d)=0
 
virtual RWvostreamput (float f)=0
 
virtual RWvostreamput (int i)=0
 
virtual RWvostreamput (long double d)=0
 
virtual RWvostreamput (long i)=0
 
virtual RWvostreamput (long long i)=0
 
virtual RWvostreamput (short i)=0
 
virtual RWvostreamput (signed char c)=0
 
virtual RWvostreamput (unsigned char c)=0
 
virtual RWvostreamput (unsigned int i)=0
 
virtual RWvostreamput (unsigned long i)=0
 
virtual RWvostreamput (unsigned long long i)=0
 
virtual RWvostreamput (unsigned short i)=0
 
virtual RWvostreamput (wchar_t wc)=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
 
unsigned version () const
 
void version (unsigned v)
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Related Symbols

(Note that these are not member symbols.)

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

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 <fstream>
#include <iostream>
#include <rw/bstream.h>
#include <rw/pstream.h>
#include <rw/vstream.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;
}
Stores variables in binary format.
Definition bstream.h:338
Specializes the abstract base class RWvostream to store variables in a portable (printable) US-ASCII ...
Definition pstream.h:398
Abstract base class that provides an interface for format-dependent storage of fundamental types and ...
Definition vstream.h:749
virtual int fail()=0

Constructor & Destructor Documentation

◆ ~RWvostream()

virtual RWvostream::~RWvostream ( )
virtual

Empty destructor.

Member Function Documentation

◆ bad()

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.

◆ clear()

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.

◆ eof()

virtual int RWvostream::eof ( )
pure virtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

◆ fail()

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.

◆ flush()

virtual RWvostream & RWvostream::flush ( )
pure virtual

Sends the contents of the stream buffer to output immediately.

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

◆ good()

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.

◆ put() [1/32]

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

Stores the bool b to the output stream.

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

◆ put() [2/32]

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.

◆ put() [3/32]

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

◆ put() [4/32]

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

◆ put() [5/32]

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.

◆ put() [6/32]

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.

◆ put() [7/32]

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.

◆ put() [8/32]

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.

◆ put() [9/32]

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.

◆ put() [10/32]

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.

◆ put() [11/32]

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.

◆ put() [12/32]

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

◆ put() [13/32]

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

◆ put() [14/32]

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.

◆ put() [15/32]

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.

◆ put() [16/32]

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.

◆ put() [17/32]

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.

◆ put() [18/32]

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

◆ put() [19/32]

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

Stores the double d to the output stream.

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

◆ put() [20/32]

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

Stores the float f to the output stream.

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

◆ put() [21/32]

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

Stores the int i to the output stream.

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

◆ put() [22/32]

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

◆ put() [23/32]

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

Stores the long i to the output stream.

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

◆ put() [24/32]

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

◆ put() [25/32]

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

Stores the short i to the output stream.

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

◆ put() [26/32]

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

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

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

◆ put() [27/32]

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

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

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

◆ put() [28/32]

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

Stores the unsigned int i to the output stream.

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

◆ put() [29/32]

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

Stores the unsigned long i to the output stream.

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

◆ put() [30/32]

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

◆ put() [31/32]

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

Stores the unsigned short i to the output stream.

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

◆ put() [32/32]

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.

◆ putChar() [1/4]

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

◆ putChar() [2/4]

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

◆ putChar() [3/4]

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

◆ putChar() [4/4]

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

◆ putChars()

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

◆ putSizeT()

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.

◆ putString()

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

◆ rdstate()

virtual int RWvostream::rdstate ( )
pure virtual

Returns the current error state.

Implements RWvios.

Implemented in RWbostream, RWpostream, RWvostreamToDataOutputStream, and RWXDRostream.

◆ version() [1/2]

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.

◆ version() [2/2]

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.

Friends And Related Symbol Documentation

◆ operator<<() [1/17]

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

Stores the bool b to the output stream.

◆ operator<<() [2/17]

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

Stores the char c to the output stream.

◆ operator<<() [3/17]

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

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

◆ operator<<() [4/17]

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

Stores the double d to the output stream.

◆ operator<<() [5/17]

RWvostream & operator<< ( RWvostream & os,
float f )
related

Stores the float f to the output stream.

◆ operator<<() [6/17]

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

Stores the int i to the output stream.

◆ operator<<() [7/17]

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.

◆ operator<<() [8/17]

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

Stores the long i to the output stream.

◆ operator<<() [9/17]

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.

◆ operator<<() [10/17]

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

Stores the short i to the output stream.

◆ operator<<() [11/17]

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

Stores the signed char c to the output stream.

◆ operator<<() [12/17]

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

Stores the unsigned char c to the output stream.

◆ operator<<() [13/17]

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

Stores the unsigned int i to the output stream.

◆ operator<<() [14/17]

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

Stores the unsigned long i to the output stream.

◆ operator<<() [15/17]

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.

◆ operator<<() [16/17]

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

Stores the unsigned short i to the output stream.

◆ operator<<() [17/17]

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

Stores the wchar_t wc to the output stream.

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