WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_34.html taken on Sat Jun 10 19:13:53 1995

Go to the previous, next section.

OIOostream--Abstract Class for Stream Object Output

SYNOPSIS

#include <nihcl/OIOstream.h>

BASE CLASS

OIOout

DERIVED CLASSES

OIOnihout

RELATED CLASSES

OIOistream

DESCRIPTION

Class OIOostream is the abstract base class for classes implementing object output to ostreams for the storeOn() function. It defines virtual member functions for writing the fundamental data types, arrays of fundamental data types, and C-style (null-terminated) character strings. It also defines virtual member functions for setting and accessing the output format precision and field width.

Since all output functions are virtual, derived classes can easily provide a variety of output formats to an ostream. This is a more flexible form of object I/O than the file descriptor object I/O provided by classes OIOofd and OIOifd, but is less efficient.

CONSTRUCTORS

OIOostream(ostream& s, unsigned capacity =256)
Constructs an OIOostream for the ostream s with an initial object capacity of capacity objects (see class StoreOnTbl).

OUTPUT FUNCTIONS

virtual OIOostream& operator<<(const char*)
Stores the null-terminated character string pointed to by the right operand on the ostream associated with this OIOostream via ostream::operator<<(const char*) and returns a reference to this OIOostream.

virtual OIOostream& operator<<(char)
virtual OIOostream& operator<<(unsigned char)
virtual OIOostream& operator<<(short)
virtual OIOostream& operator<<(unsigned short)
virtual OIOostream& operator<<(int)
virtual OIOostream& operator<<(unsigned int)
virtual OIOostream& operator<<(long)
virtual OIOostream& operator<<(unsigned long)
virtual OIOostream& operator<<(float)
virtual OIOostream& operator<<(double)
Stores the right operand on the ostream associated with this OIOostream via
ostream::operator<<() and returns a reference to this OIOostream.

virtual OIOostream& put(char val)
Stores the single character val on the ostream associated with this OIOostream via ostream::put(char) and returns a reference to this OIOostream.

virtual OIOostream& put(const char* val, unsigned size)
virtual OIOostream& put(const unsigned char* val, unsigned size)
Stores size characters, in hexadecimal, from the array pointed to by val on the ostream associated with this OIOostream via ostream::operator<<(int) and returns a reference to this OIOostream.

virtual OIOostream& put(const short* val, unsigned size)
virtual OIOostream& put(const unsigned short* val, unsigned size)
virtual OIOostream& put(const int* val, unsigned size)
virtual OIOostream& put(const unsigned int* val, unsigned size)
virtual OIOostream& put(const long* val, unsigned size)
virtual OIOostream& put(const unsigned long* val, unsigned size)
virtual OIOostream& put(const float* val, unsigned size)
virtual OIOostream& put(const double* val, unsigned size)
Stores size elements from the array pointed to by val on the ostream associated with this OIOostream via ostream::operator<<() and returns a reference to this OIOostream.

virtual OIOostream& putCString(const char* s)
Stores the C-style (null-terminated) string pointed to by s on the ostream associated with this OIOostream and returns a reference to this OIOostream.

virtual int precision(int n)
Sets the number of significant digits inserted by the floating point inserter to n and returns the previous value.

virtual int precision()
Returns the number of significant digits inserted by the floating point inserter.

virtual int width(int n)
Sets the field width to n and returns the previous value.

virtual int width()
Returns the current field width.

CONVERSION OPERATORS

operator ostream&()
Returns a reference to the ostream associated with this OIOostream.

PROTECTED MEMBERS

Protected Member Variables

ostream* strm;                  // output stream
unsigned col;                   // current column
static const unsigned MAXCOL;   // max columns in output line

Formatting

void putwrap(char c)
void putwrap(unsigned char c)
Increments the output column number col and writes a newline and resets col to 1 if col exceeds MAXCOL. Writes the character c to the ostream* strm.

void putwrap(const char* s, unsigned len)
Adds len to col and writes a newline and resets col to len if col exceeds MAXCOL. Writes the character string s to the ostream* strm.

Object I/O

virtual void storeObject(const Object& ob) = 0
Stores the argument object ob on the ostream associated with this OIOostream. Decides whether to store the object's class description or a reference to a previous class description. Decides whether to store the object itself, or a reference to a previously stored object.

EXCEPTIONS RAISED

None

Go to the previous, next section.