#include <OTC/text/tracepat.hh> class OTC_TracePattern : public OTC_TraceSwitch {
public:
~OTC_TracePattern();
OTC_TracePattern(char const* theString);
OTC_Boolean enabled() const;
inline char const* string() const;
static void set(char const* thePattern);
};
OTC_TracePattern
is a derived version of the class
OTC_TraceSwitch
, where the switch is enabled if the string
associated with the switch matches a regular expression.
The regular expression used to perform the match, can be defined
using the environment variable OTCLIB_TRACEPATTER
, or through
program control. If set under program control, all switches will
be reevaluated at that point and their status reset accordingly.
void Object::function()
{
static OTC_TracePattern FUNCTION("Object::function()");
OTCLIB_TRACER(FUNCTION) << "some text" << endl;
return 0;
}
OTCLIB_TRACEPATTERN="Object::" program
The type of pattern excepted is that of an egrep style
pattern, as implemented by the OTC_Regexp
class.
Macros are also provided for creating and setting the pattern.
Code for these macros will be compiled into your code, only
if the preprocessor symbol OTCLIB_TRACE
is defined. These
macros are OTCLIB_TRACEPATTERN
, OTCLIB_STATIC_TRACEPATTERN
and OTCLIB_SETTRACEPATTERN
. The macro OTCLIB_STATIC_TRACEPATTERN
creates an instance of the class which has static extent.
void Object::function()
{
OTCLIB_STATIC_TRACEPATTERN(FUNCTION,"Object::function()");
OTCLIB_TRACER(FUNCTION) << "some text" << endl;
OTCLIB_SETTRACEPATTERN("Object::");
OTCLIB_TRACER(FUNCTION) << "some text" << endl;
return 0;
}
OTC_TracePattern(char const* theString);
theString
will be used to match
against the pattern to determine if
this switch is enabled. theString
should be a literal string.
OTC_Boolean enabled() const;
OTCLIB_TRUE
if the switch is
enabled, otherwise returns OTCLIB_FALSE
.
inline char const* string() const;
static void set(char const* thePattern);
OTC_TraceSwitch
, OTC_Regexp