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

Go to the previous, next section.

NIHCL--Library Static Member Variables and Functions

SYNOPSIS

#include <nihcl/Object.h>

BASE CLASS

None

DERIVED CLASSES

Catch, ExceptionAction, ExceptionTrap, Object, OIOifd, OIOin, OIOofd, OIOout, ReadFromTbl, StoreOnTbl

RELATED CLASSES

None

DESCRIPTION

Class NIHCL is a "module" class--a class containing only static members--which encapsulates member variables and functions which would otherwise be global. This makes it easier to combine the NIH Class Library with other class libraries in the same program since there is less chance of duplicate names.

All NIH Library classes are derived either directly or indirectly from class NIHCL so that they can access its members without the need to use the scope resolution operator.

ACCESSING CONSTANT TABLES

@cindex{tables}

static unsigned char charBitMask(int i)
static unsigned short shortBitMask(int i)
static unsigned int intBitMask(int i)
These member functions return a mask with the ith bit set; for example, charBitMask(0) is 1. The type of the mask is char, short, or int, respectively. The argument must be less than the number of bits in the return type.

static unsigned char bitCount(unsigned i)
The BitCount() member function returns a count of the number of 1 bits in the argument. For example, bitCount(5) is 2. The argument must be in the range 0 to 255.

static unsigned char bitReverse(unsigned i)
The bitReverse() member function returns its argument with its bits reversed left to right. For example, bitReverse(0x80) is 1. The argument must be in the range 0 to 255.

RAISING EXCEPTIONS

@cindex{raising exceptions} @cindex{error handling}

static void setError(int error, int sev, ...)
Raises an NIH Class Library exception. The error argument should be one of the error codes listed in the section nihclerrs.h, and sev should be one of the severity level codes: SUCCESS, INFO, WARNING, ERROR, FATAL, or DEFAULT@refill.

By default, setError() prints the message associated with the specified error on stderr and aborts the program. However, a programmer can arrange to have setError() call a function he supplies before aborting the program (see class ExceptionTrap), or can have the error raised as an exception (see class RaiseException). Using the NIHCL exception mechanism is slow and error prone, and is not recommended.

When used outside the scope of a class derived from class NIHCL, the severity codes must be referenced as: NIHCL::SUCCESS, NIHCL::INFO, NIHCL::WARNING, NIHCL::ERROR, NIHCL::FATAL, or NIHCL::DEFAULT@refill.

Go to the previous, next section.