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

Go to the previous, next section.

OIOifd--File Descriptor Object Input Formatting

SYNOPSIS

#include <nihcl/OIOfd.h>

BASE CLASS

ReadFromTbl

DERIVED CLASSES

None

RELATED CLASSES

OIOofd

DESCRIPTION

Class OIOifd implements object input for the readFrom() function from UNIX file descriptors via the read() system call. It provides member functions for reading the fundamental data types, arrays of fundamental data types, and C-style (null-terminated) character strings.

This file descriptor object input is more efficient than the stream object input that class OIOin provides because these are non-virtual, inline member functions that call read() directly, and do no parsing--the object format expected is that produced by class OIOofd.

CONSTRUCTORS

OIOifd(int filedesc, unsigned capacity =1024)
Constructs an OIOifd for the UNIX file descriptor filedesc and with an initial object capacity of capacity objects (see class ReadFromTbl).

INPUT FUNCTIONS

OIOifd& operator>>(char&)
OIOifd& operator>>(unsigned char&)
OIOifd& operator>>(short&)
OIOifd& operator>>(unsigned short&)
OIOifd& operator>>(int&)
OIOifd& operator>>(unsigned int&)
OIOifd& operator>>(long&)
OIOifd& operator>>(unsigned long&)
OIOifd& operator>>(float&)
OIOifd& operator>>(double&)
Reads the right operand from the UNIX file descriptor associated with this OIOifd via the UNIX read() system call. The sizeof operator is used to determine the number of bytes to read. Raises an NIHCL_READBINERR exception if the call to read() returns an error. Raises an NIHCL_RDEOF exception if the call to read() returns End Of File (EOF). Raises an NIHCL_READBINUNDFL exception if the call the read() returns fewer bytes than the sizeof the right operand. Returns a reference to this OIOifd if successful.

int get()
Does a get(char&) of a single char from the UNIX file descriptor associated with this OIOifd and returns it as the result.

OIOifd& get(char& c)
OIOifd& get(unsigned char& c)
Reads the next byte (by calling get(char*,unsigned) from the UNIX file descriptor associated with this OIOifd into the argument c and returns a reference to this OIOifd if successful.

OIOifd& get(char* val, unsigned size)
OIOifd& get(unsigned char* val, unsigned size)
OIOifd& get(short* val, unsigned size)
OIOifd& get(unsigned short* val, unsigned size)
OIOifd& get(int* val, unsigned size)
OIOifd& get(unsigned int* val, unsigned size)
OIOifd& get(long* val, unsigned size)
OIOifd& get(unsigned long* val, unsigned size)
OIOifd& get(float* val, unsigned size)
OIOifd& get(double* val, unsigned size)
Reads size elements of the array pointed to by val from the UNIX file descriptor associated with this OIOifd via the UNIX read() system call. The sizeof operator is used to determine the array element size. Raises an NIHCL_READBINERR exception if the call to read() returns an error. Raises an NIHCL_RDEOF exception if the call to read() returns End Of File (EOF). Raises an NIHCL_READBINUNDFL exception if the call to read() returns fewer bytes than the size of the specified array. Returns a reference to this OIOifd if successful.

OIOifd& getCString(char* s, unsigned maxlen)
Reads a C-style (null-terminated) string stored by OIOofd::putCString() into the memory pointed to by s from the UNIX file descriptor associated with this OIOifd. Raises an NIHCL_STROV exception if the string length, including the null terminator, would exceed maxlen. Returns a reference to this OIOifd if successful.

CONVERSION OPERATORS

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

PROTECTED MEMBERS

Object I/O

virtual Object* readObject(const Class& expected)
Reads an object stored by OIOofd::storeObject() from the UNIX file descriptor associated with this OIOifd.

Raises an NIHCL_RDUNKCLASS exception if the class descriptor of the object to be read has not been linked with the program.

Raises an NIHCL_RDWRONGCLASS exception if the class of the object read is not an instance of class expected or an instance of a derived class of expected.

Raises an NIHCL_RDBADSIG exception if the signature of the class of the object read does not match the signature of the class descriptor of the same name that has been linked with the program. This is to detect an attempt to read an object stored by an outdated version of the class.

Raises an NIHCL_RDBADTYP exception if the value of the next byte read from the associated UNIX file descriptor is not a valid record type: an object reference, a class reference and object, or a class name, signature, and object.

Returns a pointer to the object read if successful.

EXCEPTIONS RAISED

NIHCL_RDBADSIG, NIHCL_RDBADTYP, NIHCL_RDEOF, NIHCL_RDUNKCLASS, NIHCL_RDWRONGCLASS, NIHCL_READBINERR, NIHCL_READBINUNDFL, NIHCL_STROV

Go to the previous, next section.