trace - // TRACE ('u', "foo = " << foo); //...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#ifndef __TRACE_H__ #define __TRACE_H__ # #include <vector> # using namespace std; u // // traceflags - // static class for maintaining global trace flags, each indicated // by a single character. // setflags - // Takes a string argument, and sets a flag for each char in the // string. As a special case, '@', sets all flags. // getflag - // Used by the TRACE macro to check to see if a flag has been set. // Not to be called by user code. // / class traceflags { private: static vector<char> flags; public: static void setflags (const string &optflags); static bool getflag (char flag); }; } // // TRACE - // Macro which expands into trace code. First argument is a // trace flag char, second argument is output code that can // be sandwiched between <<. Beware of operator precedence. // Example:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // TRACE ('u', "foo = " << foo); // will print two words and a newline if flag 'u' is on. // Traces are preceded by filename, line number, and function. // / #define TRACE(FLAG,CODE) { \ if (traceflags::getflag (FLAG)) { \ cerr << __FILE__ << ":" << __LINE__ << ":" \ << __func__ << ": "; \ cerr << CODE << endl; \ } \ } // // RCSH, RCSC -// Macros which allow RCS Id information to transfer to object // files and executable binaries. // / #define RCSH(NAME,ID) \ static const char __RCS_##NAME = "\0" ID; #define RCSC(NAME,ID) \ static const char __RCS_C_##NAME = "\0" ID \ "\0$Compiled: " __FILE__ " " __DATE__ " " __TIME__ " $"; " RCSH(__TRACE_H__,"$Id: trace.h,v 1.9 2009-01-02 19:10:43-08 - - $") R #endif #...
View Full Document

This note was uploaded on 01/26/2010 for the course CMPS 109 taught by Professor Bailey,d during the Spring '08 term at University of California, Santa Cruz.

Page1 / 2

trace - // TRACE ('u', "foo = " << foo); //...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online