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

Go to the previous, next section.

OIOin--Abstract Class for Object Input

SYNOPSIS

#include <nihcl/OIO.h>

BASE CLASS

ReadFromTbl

DERIVED CLASSES

OIOistream

RELATED CLASSES

OIOout

DESCRIPTION

Class OIOin is the abstract base class for classes implementing various formats of object input for the readFrom() function. It declares pure virtual member functions for reading the fundamental data types, arrays of fundamental data types, and C-style (null-terminated) character strings. It also declares pure virtual member functions for setting and accessing the input format precision and field width.

Since all input functions are virtual, derived classes can easily interpret a variety of formats from a variety of input sources, such as C++ iostreams. 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

OIOin(unsigned capacity =1024)
Constructs an OIOin with an initial object capacity of capacity objects (see class ReadFromTbl).

INPUT FUNCTIONS

virtual OIOin& operator>>(char*) = 0
Reads characters from this OIOin into the array pointed to by the right argument until a whitespace character is read. The whitespace character is also stored. A terminating zero byte is always stored, even if no characters are read. If width() is non-zero, it is interpreted as the size of the array, and a maximum of width()-1 characters will be read, not including the terminating zero byte.

virtual OIOin& operator>>(char&) = 0
virtual OIOin& operator>>(unsigned char&) = 0
virtual OIOin& operator>>(short&) = 0
virtual OIOin& operator>>(unsigned short&) = 0
virtual OIOin& operator>>(int&) = 0
virtual OIOin& operator>>(unsigned int&) = 0
virtual OIOin& operator>>(long&) = 0
virtual OIOin& operator>>(unsigned long&) = 0
virtual OIOin& operator>>(float&) = 0
virtual OIOin& operator>>(double&) = 0
Reads the right operand and returns a reference to this OIOin if successful.

virtual int get()
Reads a single char and returns it as the result.

virtual OIOin& get(char& c) = 0
virtual OIOin& get(unsigned char& c) = 0
Reads the next byte into the argument c and returns a reference to this OIOin if successful.

virtual OIOin& get(char* val, unsigned size) = 0
virtual OIOin& get(unsigned char* val, unsigned size) = 0
virtual OIOin& get(short* val, unsigned size) = 0
virtual OIOin& get(unsigned short* val, unsigned size) = 0
virtual OIOin& get(int* val, unsigned size) = 0
virtual OIOin& get(unsigned int* val, unsigned size) = 0
virtual OIOin& get(long* val, unsigned size) = 0
virtual OIOin& get(unsigned long* val, unsigned size) = 0
virtual OIOin& get(float* val, unsigned size) = 0
virtual OIOin& get(double* val, unsigned size) = 0
Reads size elements into the array pointed to by val and returns a reference to this OIOin if successful.

virtual OIOin& getCString(char* s, unsigned maxlen) = 0
Reads a C-style (null-terminated) string stored by OIOout::putCString() into the memory pointed to by s. Raises an NIHCL_STROV exception if the string length, including the null terminator, would exceed maxlen. Returns a reference to this OIOin if successful.

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

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

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

virtual int width() = 0
Returns the current field width.

PROTECTED MEMBERS

Object I/O

Object* _readObject(const Class& cl)
Reads an object of class cl from this OIOin by applying the function Class::readObject() to cl with this OIOin as the argument.

virtual Object* readObject(const Class& expected) = 0
Reads an object stored by OIOout::storeObject() from this OIOin.

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.

Returns a pointer to the object read if successful.

EXCEPTIONS RAISED

NIHCL_RDBADSIG, NIHCL_RDUNKCLASS, NIHCL_RDWRONGCLASS, NIHCL_STROV

Go to the previous, next section.