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

Go to the previous, next section.

OIOofd--File Descriptor Object Output Formatting

SYNOPSIS

#include <nihcl/OIOfd.h>

BASE CLASS

StoreOnTbl

DERIVED CLASSES

None

RELATED CLASSES

OIOifd

DESCRIPTION

Class OIOofd implements object output for the storeOn() function to UNIX file descriptors via the write() system call. It provides member functions for writing the fundamental data types, arrays of fundamental data types, and C-style (null-terminated) character strings.

This file descriptor object output is more efficient than the stream object output that class OIOout provides because these are non-virtual, inline member functions that call write() directly, and do no formatting. Thus, the object output format produced by OIOofd is machine dependent.

CONSTRUCTORS

OIOofd(int filedesc, unsigned capacity =256)
Constructs an OIOofd for the UNIX file descriptor filedesc with an initial object capacity of capacity objects (see class StoreOnTbl).

OUTPUT FUNCTIONS

OIOofd& operator<<(const char*)
Writes the null-terminated character string pointed to by the right operand to the UNIX file descriptor associated with this OIOofd via the UNIX write() function. Raises an NIHCL_STOREBINERR exception if the call to write() fails. Returns a reference to this OIOofd if successful.

OIOofd& operator<<(char)
OIOofd& operator<<(unsigned char)
OIOofd& operator<<(short)
OIOofd& operator<<(unsigned short)
OIOofd& operator<<(int)
OIOofd& operator<<(unsigned int)
OIOofd& operator<<(long)
OIOofd& operator<<(unsigned long)
OIOofd& operator<<(float)
OIOofd& operator<<(double)
Writes the right operand to the UNIX file descriptor associated with this OIOofd via the UNIX write() system call. The sizeof operator is used to determine the number of bytes to write. Raises an NIHCL_STOREBINERR exception if the call to write() fails. Returns a reference to this OIOofd if successful.

OIOofd& put(const char* val, unsigned size)
OIOofd& put(const unsigned char* val, unsigned size)
OIOofd& put(const short* val, unsigned size)
OIOofd& put(const unsigned short* val, unsigned size)
OIOofd& put(const int* val, unsigned size)
OIOofd& put(const unsigned int* val, unsigned size)
OIOofd& put(const long* val, unsigned size)
OIOofd& put(const unsigned long* val, unsigned size)
OIOofd& put(const float* val, unsigned size)
OIOofd& put(const double* val, unsigned size)
Writes size elements of the array pointed to by val to the UNIX file descriptor associated with this OIOofd via the UNIX write() system call. The sizeof operator is used to determine the array element size. Raises an NIHCL_STOREBINERR exception if the call to write() fails. Returns a reference to this OIOofd if successful.

OIOofd& putCString(const char* s)
Writes the C-style (null-terminated) string pointed to by s to the UNIX file descriptor associated with this OIOofd via the UNIX write() function. Raises an
NIHCL_STOREBINERR exception if the call to write() fails. Returns a reference to this OIOofd if successful.

OIOofd& write(const char* buf, unsigned n)
Writes n bytes starting at buf to the UNIX file descriptor associated with this OIOofd via the UNIX write() system call. Raises an NIHCL_STOREBINERR exception if the call to write() fails. Returns a reference to this OIOofd if successful.

CONVERSION OPERATORS

operator int()
Returns the UNIX file descriptor associated with this OIOofd.

PROTECTED MEMBERS

Object I/O

virtual void storeObject(const Object& ob)
Writes a reference to ob if ob has already been written by the current storeOn() operation on this OIOofd. Otherwise, writes a reference to the class of ob if an object of the same class has already been written by the current storeOn() operation on this OIOofd, or writes the class name and signature if it has not been previously written. Writes ob by applying storer().

EXCEPTIONS RAISED

NIHCL_STOREBINERR

Go to the previous, next section.