NAME
OTC_TracePattern -
Trace switch enabled through a pattern definition.
SYNOPSIS
#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);
};
CLASS TYPE
Concrete
DESCRIPTION
The class 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;
}
INITIALISATION
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.
QUERY/CHANGE
OTC_Boolean enabled() const;
Returns OTCLIB_TRUE if the switch is
enabled, otherwise returns OTCLIB_FALSE.
inline char const* string() const;
Returns the string associated with this
switch. This string is what is used to
match against the pattern to determine
if the switch is enabled.
static void set(char const* thePattern);
Resets the pattern for matches. This will
result in the status of all switches being
reevaluated.
SEE ALSO
OTC_TraceSwitch, OTC_Regexp
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 TELSTRA CORPORATION LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED