libcwd: The C++ Debugging Support Library - Reference Manual
Author: Carlo Wood
Description: C++ debugging support library with ostream debug output
Keywords: libcwd, debug output, debug facility, debug channel, object orientation, OO, C++, nested debug output, ostream, memory allocation, debugging, source file and line number

Main Page Reference Manual Namespace List Compound List Namespace Members Compound Members File Members

# libcwd::debug_ct Class Reference
[The Output Device (Debug Object)]

The Debug Object class, this object represents one output device (`ostream`). More...

`#include <libcwd/debug.h>`

List of all members.

## Public Member Functions
debug_string_ct & | margin (void)
| The margin.
debug_string_ct & | marker (void)
| The marker.
void | set_indent (unsigned short indentation)
| Set number of spaces to indent.
void | inc_indent (unsigned short indentation)
| Increment number of spaces to indent.
void | dec_indent (unsigned short indentation)
| Decrement number of spaces to indent.
unsigned short | get_indent (void) const
| Get the current indentation.
void | push_margin (void)
| Push the current margin on a stack.
void | pop_margin (void)
| Pop margin from the stack.
void | push_marker (void)
| Push the current marker on a stack.
void | pop_marker (void)
| Pop marker from the stack.
std::ostream * | get_ostream (void) const
| Get the `ostream` device as set with set_ostream().
| debug_ct (void)
| Constructor.
void | set_ostream (std::ostream *os)
| Set output device (single threaded applications).Assign a new `ostream` to this debug object (default is `std::cerr`). For use in single threaded applications only.
template<class T >
void | set_ostream (std::ostream *os, T *mutex)
| Set output device and provide external lock.Assign a new `ostream` to this debug object. The `ostream` will only be written to after obtaining the lock that is passed as second argument. Each `ostream` needs to have a unique lock. If the application also writes directly to the same `ostream` then use the same lock.
void | off (void)
| Turn this debug object off.
void | on (void)
| Cancel last call to off().

## Detailed Description

The Debug Object class, this object represents one output device (`ostream`).

See The Output Device (Debug Object).

## Constructor & Destructor Documentation

libcwd::debug_ct::debug_ct | ( | void |  | ) | `[inline]`

Constructor.

A debug object must be global.

See also:
  The Output Device (Debug Object)
  Custom Debug Objects

References libcwd::core_dump().

## Member Function Documentation

void libcwd::debug_ct::on | ( | void |  | ) | `[inline]`

Cancel last call to off().

Calls to off() and on() has to be done in pairs (first off() then on()). These pairs can be nested.

Example:

     int i = 0;
     Debug( libcw_do.off() );
     Dout( dc::notice, "Adding one to " << i++ );
     Debug( libcw_do.on() );
     Dout( dc::notice, "i == " << i );

Outputs:

    NOTICE : i == 0

Note that the statement `i++` was never executed.