Listing 1: Public interface to Debug class

/******************************************
  Debug, a class for debugging
  Copyright (C) 2000 by Maurice J. Fox
  Permission is granted to use this code without restriction as
  long as this copyright notice appears in all source files.

  This package is inspired by the DBUG package developed
  for C and UNIX by Fred Fish, but does not use any of its code.
*********************************************/

#ifndef DEBUG_CLASS_DEFINED
#define DEBUG_CLASS_DEFINED 1
// A number of # includes omitted for space
#ifdef DEBUG_OFF
class Debug {
public:
// A number of declarations omitted for space
    static void Sync();

private:
    Debug() {}
};

#else

class Debug {
public:
    Debug(const char *);
    Debug(const char *, bool);
    ~Debug();
    void Dbg(const string &, const char *);
    void Dbg(const string &, int);
    void Dbg(const string &, float);
    void Dbg(const string &, const char *, int);
    void Dbg(const string &, const char *, const string &);
    void Dbx(const string &, const char *, unsigned long);
    static void specify( const char * );
    static void TimeStart(const string &, const char *);
    static void TimeEnd(const string &, const char *);
    static void Sync();
private:
    // Constants
    enum {limit = 12};// indentation limit for tracing

    #if defined (DEBUG_1STREAM)
    enum Out_choice {CLOG, COUT, FILE_OUT};
    #endif

    // Static members
    static int level; // Counts the depth of function calling
    static bool Debugging; // Controls printing in Dbg calls
    static bool Tracing;   // Controls printing in ctor 
                           // and dtor calls
    static bool Timing;    // Controls interval timing

    #if defined (DEBUG_1STREAM)
    static enum Out_choice out_usage, next_out;
    #endif

    static char separator;
    static string filename;
    static ofstream out;

    #if defined (DEBUG_1STREAM)
    static streambuf *strm_buf;
    static streambuf *clog_buf;
    #else
    static bool use_cout;
    static bool use_clog;
    #endif

    static vector<string> keywords;
    static vector<string> functions;
    static vector<string> timekeys;
    static vector<pair<string, struct timeb> > timers;
    static char mybuff[200];

    // Internal functions
    bool tracing(const string &); // Tells whether to do 
                                  // tracing or not
    bool debugging(const string &); // Tells whether to do 
                                    // debugging or not.
    // Both of these look at the flag and at the vector.
    static void indent();  // Indents the output line
    void Enter();   // Gets us into a function with proper 
                    // indents, printing function's name.
    void Exit();    // Gets us out of a function with 
                    // proper indents.
    Debug();        // No default ctor
    char *time_stuff();
    Debug(const Debug &);   // No copy ctor
    static void setup_output();
    static bool IntTiming(const string &);  
    // Tells whether to do interval timing

    // object data;
    string function_name;
    bool timing;
    bool raw_time;
    bool going_in;
    struct timeb Start;
};
#endif
#endif
— End of Listing —