Go to the first, previous, next, last section, table of contents.


CNCL -- CNCL Static Members and Functions

SYNOPSIS

#include <CNCL/CNCL.h>

TYPE

None

BASE CLASSES

None

DERIVED CLASSES

CNObject

RELATED CLASSES

None

DESCRIPTION

The CNCL class contains only static members and functions for the class library's parameters and error handling. All classes in the CNCL hierarchy can directly access the static member functions, other code can call them via CNCL::func().

ERROR HANDLING

The class CNCL provides common functionality for error handling. This is used by all classes to issue an error message or warning and terminate the program, if desired. The CNCL library also installs a matherr() handler using CNCL::error() for displaying an appropiate error message.

enum ErrorType 
{ 
    err_fatal, err_abort, err_warning, err_ignore, err_default, err_info
};


The setting of the CNCL error handling:

err_abort
err_fatal
Print error message, then terminate the program. (To do so, CNCL calls the exit handler installed with set_exit_handler().) err_abort is like err_fatal but calls abort() for termination resulting in a core dump.
err_warning
Print error message with "warning" prefix.
err_ignore
No error message.
err_ignore
No error, just the message for info.
err_default
The default setting of the CNCL error handling. The default is err_fatal (may be set with set_error()).

The following member functions of CNCL can be used to manipulate the error handling.

static ErrorType get_error();
Returns the current error handling type.
static ErrorType set_error(ErrorType err);
Sets the error handling type to err and returns the previous value.
static void set_exit_handler(void (*func)());
Installs a function to be called on fatal errors. The default function will print a message and terminate the program by calling exit() (err_fatal) or abort() (err_abort).
static void default_exit_handler()
The CNCL default handler called on fatal errors.

ERROR MESSAGES

The following member function can be used to output error messages and/or terminate the program. Each of the functions accepts up to six const char * arguments, if the first one of these is NIL, then the default string ("CNCL error: ", "CNCL warning: ", "CNCL: " for err_error/err_abort, err_warning, err_info, respectively) is prepended to the output.

static void error(const char *msg1 = NIL, ...)
Output error message, default error handling. Up to 6 different char *msg`s can be added.
void error(ErrorType err, const char *msg1 = NIL, ...)
Output error message, error handling as specified by err.Up to 6 different char *msg`s can be added.
static void fatal(const char *msg1 = NIL, ...)
Output error message, fatal error handling.Up to 6 different char *msg`s can be added.
static void warning(const char *msg1 = NIL, ...)
Output error message, warning error handling.Up to 6 different char *msg`s can be added.
static void info(const char *msg1 = NIL, ...)
Output message.Up to 6 different char *msg`s can be added.
static ostream& msg()
Returns a reference to an output stream. Output to this stream will be appended to the next error(), fatal(), warning(), info() message. This is actually a strstream with a maximum capacity of CNCL::STR_BUF_SIZE.

UTILITIES

Outside the CNCL class the following constants and types are defined:

NIL
The null pointer defined as 0.
TRUE
The boolean value true defined as 1.
FALSE
The boolean value false defined as 0.
bool
A boolean data type, actually typedef int bool.


Go to the first, previous, next, last section, table of contents.