TraceFct Class Reference

#include <TraceFct.h>

List of all members.

Public Member Functions

 TraceFct (string name, bool print_it, int num_fct_to_print)
 Class initializer.
 ~TraceFct ()
 TraceFct (const char *name)
 Function entry constructor.
 TraceFct (string &name)
 Function entry constructor.

Static Public Member Functions

static void dump_stack (void)
 Print the current function stack.
Exit
These functions print an error message to stderr as well as the tracefct output stream (if different from stderr) and then exits the program with the supplied error code. The error message is passed in the same fashion as the arguments to vprintf or sprintf. The message may contain multiple output lines (i.e., multiple newline characters). If a trailing newline character is not specified, it will be appended.

static void exit (int exit_code, const char *format,...)
 Exit a program, dumping the function stack.
static void exit (int exit_code, Exception &ex)
 Exit a program, dumping the function stack.
static void exit (int exit_code, const string &msg)
 Exit a program, dumping the function stack.
static void die (const char *format,...)
 Exit a program with error EXIT_FAILURE, dumping the function stack.
static void die (Exception &ex)
 Exit a program with error EXIT_FAILURE, dumping the function stack.
static void die (const string &msg)
 Exit a program with error EXIT_FAILURE, dumping the function stack.
Messages
The message functions print a user supplied message to the TraceFct output stream, prefixed by the standard TraceFct style prefix string. Unlike TraceFct::exit(), a newline character is not appended to the message.

The println functions are similar, except that they ensure that a newline character is appended to the message.

static void message (const char *format,...)
 Print a formatted message to the tracefct output stream.
static void message (Exception &ex)
 Print a message to the tracefct output stream.
static void message (const string &msg)
 Print a message to the tracefct output stream.
static void vmessage (const char *format, va_list args)
 Print a formatted message to the tracefct output stream using a stdargs argument list.
static void println (Exception &ex)
 Print a message to the tracefct output stream.
static void println (const string &msg)
 Print a message to the tracefct output stream.
static void println (const char *msg)
 Print a message to the tracefct output stream.
Output Stream manipulation


static void open (const string &filename)
 redirect the tracefct output stream
static void close (void)
 reset the tracefct output stream to stderr.


Detailed Description

The TraceFct Class
Examples:

ex1.cc, and ex2.cc.

Definition at line 155 of file TraceFct.h.


Constructor & Destructor Documentation

TraceFct::TraceFct ( const char *  name  ) 

Function entry constructor.

Parameters:
name the name of the function
This constructor is used when entering a function which should be registered.

Definition at line 122 of file TraceFct.cc.

References message().

TraceFct::TraceFct ( string &  name  ) 

Function entry constructor.

Parameters:
name the name of the function
This constructor is used when entering a function which should be registered.

Definition at line 106 of file TraceFct.cc.

References message().

TraceFct::TraceFct ( string  prog_name,
bool  print_it,
int  num_fct_to_print 
)

Class initializer.

This initializer should be used to initialize the class, and should be called once in the program, before any subsequent calls to the per-function initializers

Parameters:
name the name of the program, preferrably argv[0]. path information (if present) is not stripped.
print_it if true, a message will be output upon entry and exit of a function
num_fct_to_print if positive, only the requested number of function names will be printed. if non-positive, all of the function names will be printed.
The calling routine can also set up some output options which determine the depth of the function stack to print and whether a diagnostic should be printed at every entry and return of a function.

Definition at line 80 of file TraceFct.cc.

TraceFct::~TraceFct (  ) 

The destructor.

Definition at line 138 of file TraceFct.cc.

References message().


Member Function Documentation

void TraceFct::exit ( int  exit_code,
const char *  format,
  ... 
) [static]

Exit a program, dumping the function stack.

Parameters:
exit_code the exit code to be returned to the system
format a printf style format string
... additional arguments

Definition at line 361 of file TraceFct.cc.

Referenced by die(), and exit().

void TraceFct::exit ( int  exit_code,
Exception &  ex 
) [static]

Exit a program, dumping the function stack.

Parameters:
exit_code the exit code to be returned to the system
ex The Exception Stack to print
This version of the exit function will print out the passed Exception stack.

Definition at line 398 of file TraceFct.cc.

References dump_stack().

static void TraceFct::exit ( int  exit_code,
const string &  msg 
) [inline, static]

Exit a program, dumping the function stack.

Parameters:
exit_code the exit code to be returned to the system
msg a message to print

Definition at line 166 of file TraceFct.h.

References exit().

void TraceFct::die ( const char *  format,
  ... 
) [static]

Exit a program with error EXIT_FAILURE, dumping the function stack.

Parameters:
format a printf style format string
... additional arguments

Definition at line 446 of file TraceFct.cc.

void TraceFct::die ( Exception &  ex  )  [inline, static]

Exit a program with error EXIT_FAILURE, dumping the function stack.

Parameters:
ex The Exception Stack to print
This version of the exit function will print out the passed Exception stack.

Definition at line 172 of file TraceFct.h.

References exit().

void TraceFct::die ( const string &  msg  )  [inline, static]

Exit a program with error EXIT_FAILURE, dumping the function stack.

Parameters:
msg a message to print

Definition at line 175 of file TraceFct.h.

References exit().

void TraceFct::message ( const char *  format,
  ... 
) [static]

Print a formatted message to the tracefct output stream.

Parameters:
format a printf style format string
... additional arguments
The message is passed in the same fashion as the arguments to printf, allowing formatted output.
Examples:
ex1.cc.

Definition at line 515 of file TraceFct.cc.

Referenced by dump_stack(), message(), TraceFct(), and ~TraceFct().

static void TraceFct::message ( Exception &  ex  )  [inline, static]

Print a message to the tracefct output stream.

Parameters:
ex The exception to print

Definition at line 179 of file TraceFct.h.

static void TraceFct::message ( const string &  msg  )  [inline, static]

Print a message to the tracefct output stream.

Parameters:
msg a message to print

Definition at line 181 of file TraceFct.h.

References message().

void TraceFct::vmessage ( const char *  format,
va_list  args 
) [static]

Print a formatted message to the tracefct output stream using a stdargs argument list.

Parameters:
format a printf style string
args q The error message is passed in the same fashion as the arguments to vprintf. Note that vmessage expects a va_list to be passed, rather than a variable argument list.

Definition at line 543 of file TraceFct.cc.

static void TraceFct::println ( Exception &  ex  )  [inline, static]

Print a message to the tracefct output stream.

Parameters:
ex the exception to print

Definition at line 186 of file TraceFct.h.

static void TraceFct::println ( const string &  msg  )  [inline, static]

Print a message to the tracefct output stream.

Parameters:
msg a message to print

Definition at line 188 of file TraceFct.h.

static void TraceFct::println ( const char *  msg  )  [inline, static]

Print a message to the tracefct output stream.

Parameters:
msg a message to print

Definition at line 190 of file TraceFct.h.

void TraceFct::dump_stack ( void   )  [static]

Print the current function stack.

Parameters:
ostr the output file stream
This prints the current function stack to the TraceFct output stream
Examples:
ex1.cc.

Definition at line 272 of file TraceFct.cc.

References message().

Referenced by exit().

void TraceFct::open ( const string &  file  )  [static]

redirect the tracefct output stream

Parameters:
file the file to which messages are to be written
serves to change the TraceFct output stream to the specified file. Normally TraceFct writes to stderr. TraceFct::exit() always writes to stderr. To reset the output stream, see TraceFct::close(). If the current output stream is not stderr, it is automatically closed.

If the passed filename is the string stderr, open() will use stderr.

Upon error, it writes and exit to stderr and exits.

Definition at line 598 of file TraceFct.cc.

void TraceFct::close ( void   )  [static]

reset the tracefct output stream to stderr.

close() resets the output stream to stderr, closing the file previously opened by TraceFct::open().

Definition at line 646 of file TraceFct.cc.


The documentation for this class was generated from the following files:

Generated on Mon Oct 20 13:55:20 2008 for tracefctxx by  doxygen 1.5.6